cr.line_to(v[0], v[1])
cr.close_path()
- def draw_polygon(self, verts, fill_color=None, stroke_color=[0, 0, 0]):
+ def draw_polygon_by_verts(self, verts, fill_color=None, stroke_color=[0, 0, 0]):
cr = self.cr
if fill_color:
cr.set_source_rgba(r, g, b, a)
cr.stroke()
- def draw_star(self, cx, cy, verts, stroke_color=[0, 0, 0]):
+ def draw_polygon(self, cx, cy, sides, r, theta=0.0, fill_color=None, stroke_color=[0, 0, 0]):
+ verts = self.get_regular_polygon(cx, cy, sides, r, theta)
+ self.draw_polygon_by_verts(verts, fill_color, stroke_color)
+
+ def draw_star_by_verts(self, cx, cy, verts, stroke_color=[0, 0, 0]):
cr = self.cr
for v in verts:
cr.set_source_rgba(r, g, b, a)
cr.stroke()
+ def draw_star(self, cx, cy, sides, r, theta=0.0, stroke_color=[0, 0, 0]):
+ apothem = r * cos(pi / sides)
+ apothem_angle = theta + pi / sides
+
+ verts = self.get_regular_polygon(cx, cy, sides, apothem, apothem_angle)
+ self.draw_star_by_verts(cx, cy, verts, stroke_color)
+
def draw_circle(self, cx, cy, size=10.0, fill_color=[0, 0, 0, 0.5],
stroke_color=None):
cr = self.cr
def draw_centered_text(self, cx, cy, text, theta=0,
color=[0, 0, 0],
align_baseline=False,
- bb_fill=True, bb_fill_color=[1, 1, 1, 0.8],
- bb_stroke=False, bb_stroke_color=[0, 0, 0, 0.5]):
+ bb_fill_color=[1, 1, 1, 0.8],
+ bb_stroke_color=None):
cr = self.cr
x_bearing, y_bearing, width, height, x_advance = cr.text_extents(text)[:5]
theta = 0
- advance = diagram.draw_centered_text(x_offset, y, "Ciao", theta, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "Ciao", theta, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "____", theta + pi / 4, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "____", theta + pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "jxpqdlf", theta + pi / 2, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "jxpqdlf", theta + pi / 2, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "pppp", theta + 3 * pi / 4, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "pppp", theta + 3 * pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "dddd", theta + pi, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "dddd", theta + pi, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "Jjjj", theta + 5 * pi / 4, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "Jjjj", theta + 5 * pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "1369", theta + 3 * pi / 2, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "1369", theta + 3 * pi / 2, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
- advance = diagram.draw_centered_text(x_offset, y, "qqqq", theta + 7 * pi / 4, align_baseline=True, bb_stroke=True)
+ advance = diagram.draw_centered_text(x_offset, y, "qqqq", theta + 7 * pi / 4, align_baseline=True, bb_stroke_color=[0, 0, 0, 0.5])
x_offset += advance
diagram.draw_line(0, y, 400, y, [0, 0, 1, 0.2])