Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWade Brainerd <wadetb@gmail.com>2009-04-05 22:51:45 (GMT)
committer Wade Brainerd <wadetb@gmail.com>2009-04-05 22:51:45 (GMT)
commit699689eee3a6cbb8d183534f95ef7365cb90ef80 (patch)
tree043214ff10462c92e7dec4509cfd240e475c9b84
parent260669b6aece4f6f5992b6283d6d42dcd720311b (diff)
Simplify ThreeDObject drawing a bit.
-rw-r--r--threedobject.py31
1 files changed, 11 insertions, 20 deletions
diff --git a/threedobject.py b/threedobject.py
index c7e8cac..7fb32fc 100644
--- a/threedobject.py
+++ b/threedobject.py
@@ -54,7 +54,13 @@ class ThreeDObject(MovableObject):
return False
return True
- def draw_poly(self, cr):
+ def draw_poly(self, cr, points):
+ # Generate the shape.
+ cr.move_to(points[0].x, points[0].y)
+ for p in points:
+ cr.line_to(p.x, p.y)
+ cr.close_path()
+
# Draw the fill.
if self.selected:
cr.set_source_rgb(self.color[0]*1.6, self.color[1]*1.6, self.color[2]*1.6)
@@ -83,28 +89,13 @@ class ThreeDObject(MovableObject):
back_points = [p + Vector(50, -50) for p in front_points]
- # Generate the shape.
- cr.move_to(front_points[0].x, front_points[0].y)
- for p in front_points:
- cr.line_to(p.x, p.y)
- cr.close_path()
- self.draw_poly(cr)
-
+ self.draw_poly(cr, front_points)
+
# Draw the top trapezoid.
- cr.move_to(front_points[0].x, front_points[0].y)
- cr.line_to(back_points[0].x, back_points[0].y)
- cr.line_to(back_points[1].x, back_points[1].y)
- cr.line_to(front_points[1].x, front_points[1].y)
- cr.close_path()
- self.draw_poly(cr)
+ self.draw_poly(cr, [ front_points[0], back_points[0], back_points[1], front_points[1] ])
# Draw the side trapezoid.
- cr.move_to(front_points[1].x, front_points[1].y)
- cr.line_to(back_points[1].x, back_points[1].y)
- cr.line_to(back_points[2].x, back_points[2].y)
- cr.line_to(front_points[2].x, front_points[2].y)
- cr.close_path()
- self.draw_poly(cr)
+ self.draw_poly(cr, [ front_points[1], back_points[1], back_points[2], front_points[2] ])
# Draw the symbol (capital letter representing the shapes's area).
if self.symbol_visible: