warn for text as path being impossible without a font
[PyX.git] / design / dtk / springs.py
blob7500f614a2ba215dbc96880b05869539ee84d49c
1 from pyx import *
3 n = 3 # number of masses
4 r = 3.0 # system radius
5 rcyc = 0.3 # radius of cycloid
6 nl = 13 # number of cycloid half-loops
7 rc = 0.5 # radius of masses
8 eps = 0.03 # extra spacing for surrounding circles
10 c = canvas.canvas()
11 springcircle = path.circle(0, 0, r)
12 masspositions = [i*springcircle.arclen()/n
13 for i in range(n)]
14 for springsegment in springcircle.split(masspositions):
15 c.stroke(springsegment,
16 [deformer.cycloid(rcyc, nl),
17 deformer.smoothed(radius=0.1)])
18 for x, y in springcircle.at(masspositions):
19 c.fill(path.circle(x, y, rc))
20 c.stroke(path.circle(0, 0, r - rc - eps))
21 c.stroke(path.circle(0, 0, r + rc + eps))
22 c.writeEPSfile("springs")