Diagram.py: support drawing a rectangle rotated on its bottom-left corner
[experiments/RadialSymmetry.git] / Diagram.py
index 8d958f9..ff5a500 100755 (executable)
@@ -186,12 +186,13 @@ class Diagram(object):
 
         cr.restore()
 
-    def draw_rect(self, x, y, width, height, fill=True, fill_color=[1, 1, 1, 0.8],
+    def draw_rect(self, x, y, width, height, theta=0, fill=True, fill_color=[1, 1, 1, 0.8],
                   stroke=False, stroke_color=[0, 0, 0, 0.5]):
         cr = self.cr
 
         cr.save()
         cr.translate(x, y)
+        cr.rotate(theta)
 
         if fill:
             cr.rectangle(0, 0, width, height)
@@ -244,7 +245,7 @@ class Diagram(object):
         cr.rotate(theta)
 
         if bb_fill or bb_stroke:
-            self.draw_rect(bb[0], bb[1], bb[2], bb[3], bb_fill, bb_fill_color, bb_stroke, bb_stroke_color)
+            self.draw_rect(bb[0], bb[1], bb[2], bb[3], 0, bb_fill, bb_fill_color, bb_stroke, bb_stroke_color)
 
         r, g, b, a = self.color_to_rgba(color)
         cr.set_source_rgba(r, g, b, a)