projects
/
experiments
/
RadialSymmetry.git
/ blobdiff
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Diagram.py: simplify draw_star()
[experiments/RadialSymmetry.git]
/
Diagram.py
diff --git
a/Diagram.py
b/Diagram.py
index
fa35d32
..
3a03949
100755
(executable)
--- a/
Diagram.py
+++ b/
Diagram.py
@@
-23,7
+23,7
@@
from math import *
class Diagram(object):
class Diagram(object):
- def __init__(self, width, height, background=[1, 1, 1]):
+ def __init__(self, width, height, background=[1, 1, 1]
, font_size=20
):
self.width = width
self.height = height
self.background = background
self.width = width
self.height = height
self.background = background
@@
-38,7
+38,7
@@
class Diagram(object):
cr.select_font_face("Georgia", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
cr.select_font_face("Georgia", cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_NORMAL)
- cr.set_font_size(
20
)
+ cr.set_font_size(
font_size
)
# Adjust the font matrix to left-bottom origin
M = cr.get_font_matrix()
# Adjust the font matrix to left-bottom origin
M = cr.get_font_matrix()
@@
-125,11
+125,9
@@
class Diagram(object):
def draw_star(self, cx, cy, verts, stroke_color=[0, 0, 0]):
cr = self.cr
def draw_star(self, cx, cy, verts, stroke_color=[0, 0, 0]):
cr = self.cr
- v = verts[0]
- cr.move_to(cx, cy)
for v in verts:
for v in verts:
- cr.line_to(v[0], v[1])
cr.move_to(cx, cy)
cr.move_to(cx, cy)
+ cr.line_to(v[0], v[1])
r, g, b, a = self.color_to_rgba(stroke_color)
cr.set_source_rgba(r, g, b, a)
r, g, b, a = self.color_to_rgba(stroke_color)
cr.set_source_rgba(r, g, b, a)