Diagram.py: set color right before drawing the stroke in draw_line()
[experiments/RadialSymmetry.git] / Diagram.py
index 28cb064..74c3bb2 100755 (executable)
@@ -132,14 +132,23 @@ class Diagram(object):
         cr.set_source_rgba(r, g, b, a)
         cr.stroke()
 
-    def draw_dot(self, cx, cy, size=10.0, fill_color=[0, 0, 0, 0.5]):
+    def draw_circle(self, cx, cy, size=10.0, fill_color=[0, 0, 0, 0.5],
+                    stroke_color=None):
         cr = self.cr
 
         cr.save()
-        r, g, b, a = self.color_to_rgba(fill_color)
-        cr.set_source_rgba(r, g, b, a)
         cr.arc(cx, cy, size, 0, 2 * pi)
-        cr.fill()
+
+        if fill_color:
+            r, g, b, a = self.color_to_rgba(fill_color)
+            cr.set_source_rgba(r, g, b, a)
+            cr.fill()
+
+        if stroke_color:
+            r, g, b, a = self.color_to_rgba(stroke_color)
+            cr.set_source_rgba(r, g, b, a)
+            cr.stroke()
+
         cr.restore()
 
     def normalized_angle_01(self, theta):
@@ -147,10 +156,10 @@ class Diagram(object):
 
     def draw_line(self, x1, y1, x2, y2, stroke_color=[0, 0, 0, 1]):
         cr = self.cr
-        r, g, b, a = self.color_to_rgba(stroke_color)
-        cr.set_source_rgba(r, g, b, a)
         cr.move_to(x1, y1)
         cr.line_to(x2, y2)
+        r, g, b, a = self.color_to_rgba(stroke_color)
+        cr.set_source_rgba(r, g, b, a)
         cr.stroke()
 
     def draw_rect_from_center(self, cx, cy, width, height, theta=0,
@@ -189,7 +198,6 @@ class Diagram(object):
             r, g, b, a = self.color_to_rgba(stroke_color)
             cr.set_source_rgba(r, g, b, a)
             cr.stroke()
-            self.draw_dot(0, 0, 3.0, stroke_color)
 
         cr.restore()