-def draw_brush(expr a,w,b,v) =
- save x,y;
- z1=a; z2=b;
- penpos3(w,angle(z2-z1)+90);
- penpos4(w,angle(z2-z1));
- penpos5(v,angle(z1-z2)+90);
- penpos6(v,angle(z1-z2));
+ if cycle path_.l:
+ cyclestroke_;
+ else:
+ fill path_.l
+ ..tension1.5.. reverse path_.r
+ -- cycle;
+ fi;
+enddef;
+
+
+%
+% Make a round path segment going from P to Q. 2*A is the angle that the
+% path should take.
+%
+
+def simple_serif (expr p, q, a) =
+ p{dir (angle (q - p) - a)}
+ .. q{-dir (angle (p - q) + a)}
+enddef;
+
+
+%
+% Draw an axis aligned block making sure that edges are on pixels.
+%
+
+def draw_rounded_block (expr bottom_left, top_right, roundness) =
+begingroup;
+ save size;
+ save x, y;
+
+ % Originally, there was `floor' instead of `round', but this is
+ % not correct because pens use `round' also.
+ size = round min (roundness,
+ xpart (top_right - bottom_left),
+ ypart (top_right - bottom_left));
+
+ z2 + (size / 2, size / 2) = top_right;
+ z4 - (size / 2, size / 2) = bottom_left;
+ y3 = y2;
+ y4 = y1;
+ x2 = x1;
+ x4 = x3;
+
+ pickup pencircle scaled size;
+
+ fill bot z1{right}
+ .. rt z1{up}
+ -- rt z2{up}
+ .. top z2{left}
+ -- top z3{left}
+ .. lft z3{down}
+ -- lft z4{down}
+ .. bot z4{right}
+ -- cycle;
+endgroup;
+enddef;
+
+
+def draw_block (expr bottom_left, top_right) =
+ draw_rounded_block (bottom_left, top_right, blot_diameter);
+enddef;
+
+
+def draw_square_block (expr bottom_left, top_right) =
+ save x, y;
+
+ x1 = xpart bottom_left;
+ y1 = ypart bottom_left;
+ x2 = xpart top_right;
+ y2 = ypart top_right;
+
+ fill (x1, y1)
+ -- (x2, y1)
+ -- (x2, y2)
+ -- (x1, y2)
+ -- cycle;
+enddef;
+
+
+def draw_gridline (expr bottom_left, top_right, thickness) =
+ draw_rounded_block (bottom_left - (thickness / 2, thickness / 2),
+ top_right + (thickness / 2, thickness / 2),
+ thickness);
+enddef;
+
+
+def draw_brush (expr a, w, b, v) =
+ save x, y;
+
+ z1 = a;
+ z2 = b;