summaryrefslogtreecommitdiff
path: root/meme/marker.c
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-02-14 19:09:52 (GMT)
committerWerner Almesberger <werner@almesberger.net>2016-02-14 19:09:52 (GMT)
commit929702e4c0dbacdd0874a789b632044cc80dfd81 (patch)
treec9c66797c791193d4ed0441aa14667bb45d49ec0 /meme/marker.c
parentb7b65dd8f929afc5db505f76d954b8822221c58b (diff)
downloadmisc-929702e4c0dbacdd0874a789b632044cc80dfd81.zip
misc-929702e4c0dbacdd0874a789b632044cc80dfd81.tar.gz
misc-929702e4c0dbacdd0874a789b632044cc80dfd81.tar.bz2
meme/marker.c (marker_draw): make normal never point to X-
This way, text won't end up on the measurement line.
Diffstat (limited to 'meme/marker.c')
-rw-r--r--meme/marker.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/meme/marker.c b/meme/marker.c
index 31d679a..98c68aa 100644
--- a/meme/marker.c
+++ b/meme/marker.c
@@ -42,11 +42,20 @@ void marker_draw(const struct marker *marker,
text(user, mark->xa, mark->ya, 0, 0, mark->s);
continue;
}
+
dx = mark->xb - mark->xa;
dy = mark->yb - mark->ya;
d = hypotf(dx, dy);
+
+ /* dy < 0 this means nx < 0 */
+ if (dy < 0) {
+ dx = -dx;
+ dy = -dy;
+ }
+
x = (mark->xa + mark->xb) / 2.0;
y = (mark->ya + mark->yb) / 2.0;
+
line(user, mark->xa, mark->ya, mark->xb, mark->yb,
dy / d, -dx / d);
text(user, x, y, dy / d, -dx / d, mark->s);