projects
/
experiments
/
RadialSymmetry.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
6f91eff
)
Diagram.py: add a draw_star() wrapper, don't open-code apothem calculation
author
Antonio Ospite <ao2@ao2.it>
Thu, 18 Jun 2015 10:34:16 +0000
(12:34 +0200)
committer
Antonio Ospite <ao2@ao2.it>
Thu, 18 Jun 2015 10:34:16 +0000
(12:34 +0200)
Diagram.py
patch
|
blob
|
history
RadialSymmetryDiagram.py
patch
|
blob
|
history
diff --git
a/Diagram.py
b/Diagram.py
index
cb4bde1
..
e2d85d5
100755
(executable)
--- a/
Diagram.py
+++ b/
Diagram.py
@@
-125,7
+125,7
@@
class Diagram(object):
verts = self.get_regular_polygon(cx, cy, sides, r, theta)
self.draw_polygon_by_verts(verts, fill_color, stroke_color)
verts = self.get_regular_polygon(cx, cy, sides, r, theta)
self.draw_polygon_by_verts(verts, fill_color, stroke_color)
- def draw_star(self, cx, cy, verts, stroke_color=[0, 0, 0]):
+ def draw_star
_by_verts
(self, cx, cy, verts, stroke_color=[0, 0, 0]):
cr = self.cr
for v in verts:
cr = self.cr
for v in verts:
@@
-136,6
+136,13
@@
class Diagram(object):
cr.set_source_rgba(r, g, b, a)
cr.stroke()
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_circle(self, cx, cy, size=10.0, fill_color=[0, 0, 0, 0.5],
stroke_color=None):
cr = self.cr
diff --git
a/RadialSymmetryDiagram.py
b/RadialSymmetryDiagram.py
index
09a3638
..
ba0a716
100755
(executable)
--- a/
RadialSymmetryDiagram.py
+++ b/
RadialSymmetryDiagram.py
@@
-99,12
+99,8
@@
class RadialSymmetryDiagram(Diagram.Diagram):
theta, None, color)
if model.show_stars:
theta, None, color)
if model.show_stars:
- apothem = model.element_radius * cos(pi / model.element_sides)
- apothem_angle = theta + pi / model.element_sides
-
- sverts = self.get_regular_polygon(x, y, model.element_sides, apothem,
- apothem_angle)
- self.draw_star(x, y, sverts, color)
+ self.draw_star(x, y, model.element_sides, model.element_radius,
+ theta, color)
if __name__ == '__main__':
if __name__ == '__main__':