+def draw_rounded_block (expr bottom_left, top_right, roundness) =
+ save round;
+ round = floor min(roundness,xpart (top_right-bottom_left),
+ ypart (top_right-bottom_left));
+
+
+ pickup pencircle scaled round;
+
+ begingroup;
+ save x,y;
+ z2+(round/2,round/2) = top_right;
+ z4-(round/2,round/2) = bottom_left;
+ y3 = y2;
+ y4 = y1;
+ x2 = x1;
+ x4 = x3;
+ fill bot z1 .. rt z1 --- rt z2 .. top z2 ---
+ top z3 .. lft z3 --- lft z4 .. bot z4 --- 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;
+