-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path05 Draw Circle In Glyph With Direction.py
50 lines (42 loc) · 1.31 KB
/
05 Draw Circle In Glyph With Direction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#MenuTitle: 05 Draw Circle In Glyph With Direction
from mojo.roboFont import CurrentGlyph
def draw_circle(pen, pt, diameter=50, clockwise=False, roundness=0.552):
x, y = pt
radius = 0.5 * diameter
ctrl = 0.5 * diameter * roundness
factor = -1 if clockwise else 1
points = [
(
(x + factor * ctrl, y - radius),
(x + factor * radius, y - ctrl),
(x + factor * radius, y)
),
(
(x + factor * radius, y + ctrl),
(x + factor * ctrl, y + radius),
(x, y + radius)
),
(
(x - factor * ctrl, y + radius),
(x - factor * radius, y + ctrl),
(x - factor * radius, y)
),
(
(x - factor * radius, y - ctrl),
(x - factor * ctrl, y - radius),
(x, y - radius)
),
]
pen.moveTo((x, y - radius))
for ctrl1, ctrl2, pt in points:
pen.curveTo(ctrl1, ctrl2, pt)
pen.closePath()
if __name__ == "__main__":
g = CurrentGlyph()
g.clear()
p = g.getPen()
rd = 0.7
draw_circle(p, (275, 216), 400, False, rd)
draw_circle(p, (275, 216), 300, True, rd)
draw_circle(p, (275, 216), 200, False, rd)
draw_circle(p, (275, 216), 100, True, rd)