def test():
diagram = CairoDiagram(400, 400)
- diagram.clear()
-
- x = 40
- y = 200
-
- x_offset = x
-
- theta = 0
-
- diagram.draw_line(0, y, 400, y, (1, 0, 0, 1))
-
- advance = diagram.draw_centered_text(x_offset, y, "Ciao", theta,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "____", theta + pi / 4,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "jxpqdlf", theta + pi / 2,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "pppp", theta + 3 * pi / 4,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "dddd", theta + pi,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "Jjjj", theta + 5 * pi / 4,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "1369", theta + 3 * pi / 2,
- color=(0, 1, 0),
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- advance = diagram.draw_centered_text(x_offset, y, "qqqq", theta + 7 * pi / 4,
- align_baseline=True,
- bb_stroke_color=(0, 0, 0, 0.5),
- bb_fill_color=(1, 1, 1, 0.8))
- x_offset += advance
-
- diagram.draw_rect(40, 40, 300, 100, stroke_color=(0, 0, 0, 0.8))
- diagram.draw_rect(40, 40, 300, 100, pi / 30, stroke_color=(0, 0, 0, 0.8))
-
- verts = diagram.draw_regular_polygon(190, 90, 3, 20)
-
- diagram.draw_rect(40, 250, 300, 100, stroke_color=(0, 0, 0, 0.8))
- diagram.draw_rect_from_center(40 + 150, 250 + 50, 300, 100, theta=(pi / 40),
- stroke_color=(1, 0, 0),
- fill_color=None)
-
- verts = diagram.draw_regular_polygon(190, 300, 6, 20, pi / 3., (0, 0, 1, 0.5), (0, 1, 0.5))
- diagram.draw_apothem_star(190, 300, 6, 20, 0, (1, 0, 1))
-
- diagram.draw_star_by_verts(190, 300, verts, (1, 0, 0, 0.5))
- diagram.draw_star(190, 300, 6, 25, 0, (1, 0, 1, 0.2))
-
- diagram.draw_circle(190, 300, 30, (0, 1, 0, 0.5), None)
- diagram.draw_circle(100, 300, 30, (1, 0, 0, 0.5), (0, 1, 1, 0.5))
+ Diagram.test(diagram)
diagram.show()
raise NotImplementedError
@staticmethod
+ def test(diagram):
+ diagram.clear()
+
+ x = 40
+ y = 200
+
+ x_offset = x
+
+ theta = 0
+
+ diagram.draw_line(0, y, 400, y, (1, 0, 0, 1))
+
+ advance = diagram.draw_centered_text(x_offset, y, "Ciao", theta,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "____", theta + pi / 4,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "jxpqdlf", theta + pi / 2,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "pppp", theta + 3 * pi / 4,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "dddd", theta + pi,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "Jjjj", theta + 5 * pi / 4,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "1369", theta + 3 * pi / 2,
+ color=(0, 1, 0),
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ advance = diagram.draw_centered_text(x_offset, y, "qqqq", theta + 7 * pi / 4,
+ align_baseline=True,
+ bb_stroke_color=(0, 0, 0, 0.5),
+ bb_fill_color=(1, 1, 1, 0.8))
+ x_offset += advance
+
+ diagram.draw_rect(40, 40, 300, 100, stroke_color=(0, 0, 0, 0.8))
+ diagram.draw_rect(40, 40, 300, 100, pi / 30, stroke_color=(0, 0, 0, 0.8))
+
+ verts = diagram.draw_regular_polygon(190, 90, 3, 20)
+
+ diagram.draw_rect(40, 250, 300, 100, stroke_color=(0, 0, 0, 0.8))
+ diagram.draw_rect_from_center(40 + 150, 250 + 50, 300, 100, theta=(pi / 40),
+ stroke_color=(1, 0, 0),
+ fill_color=None)
+
+ verts = diagram.draw_regular_polygon(190, 300, 6, 20, pi / 3., (0, 0, 1, 0.5), (0, 1, 0.5))
+ diagram.draw_apothem_star(190, 300, 6, 20, 0, (1, 0, 1))
+
+ diagram.draw_star_by_verts(190, 300, verts, (1, 0, 0, 0.5))
+ diagram.draw_star(190, 300, 6, 25, 0, (1, 0, 1, 0.2))
+
+ diagram.draw_circle(190, 300, 30, (0, 1, 0, 0.5), None)
+ diagram.draw_circle(100, 300, 30, (1, 0, 0, 0.5), (0, 1, 1, 0.5))
+
+ @staticmethod
def color_to_rgba(color):
assert len(color) >= 3