chiark / gitweb /
draw_thick_line: Bound thickness by 1.0 below
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Thu, 28 Sep 2017 23:20:49 +0000 (00:20 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 29 Sep 2017 12:50:38 +0000 (13:50 +0100)
A line less than 1 pixel wide may not be visible.  So if a backend
wants to draw a line whose width scaled by the window size, that line
thickness ought to be at least 1.0.

That way if the scale is small, but still big enough that there is a
straightforward interpretation of the drawing primitives which is
legible, we implement that interpretation.

If a frontend draws a narrower line, making it wider might cause
drawing anomalies, due to the line now having a bigger bounding box.
These anomalies should occur only at small scales where currently the
display is not legible, and we should fix them as we notice them.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
devel.but
drawing.c

index 6a74ed99fc6b24aa94564c68a8041aa4178fa6f2..e59b2a265ce8c8cd3c04f680b883bc8ef5c9c621 100644 (file)
--- a/devel.but
+++ b/devel.but
@@ -1928,6 +1928,9 @@ Indeed, even horizontal or vertical lines may be anti-aliased.
 
 This function may be used for both drawing and printing.
 
+If the xpecified thickness is less than 1.0, 1.0 is used.
+This ensures that thin lines are visible even at small scales.
+
 \S{drawing-draw-text} \cw{draw_text()}
 
 \c void draw_text(drawing *dr, int x, int y, int fonttype,
index 7f4a6cf6746eabdea9fba7a63f6d9b9900ef35d0..a10a7f06d68553c827347c7e249c704cc8fea272 100644 (file)
--- a/drawing.c
+++ b/drawing.c
@@ -90,6 +90,8 @@ void draw_line(drawing *dr, int x1, int y1, int x2, int y2, int colour)
 void draw_thick_line(drawing *dr, float thickness,
                     float x1, float y1, float x2, float y2, int colour)
 {
+    if (thickness < 1.0)
+        thickness = 1.0;
     if (dr->api->draw_thick_line) {
        dr->api->draw_thick_line(dr->handle, thickness,
                                 x1, y1, x2, y2, colour);