Corrected a long-standing error in which ending text with a literal
[xcircuit.git] / examples / test.py
blob771a3b43aa3191a271ac0e5c4237db8ce919f6de
1 #-----------------------------------------------------------
2 # Test of the python interpreter and use of animation in
3 # xcircuit. Execute this script using menu option
4 # "File/Execute Script", if Python has been compiled in.
5 #-----------------------------------------------------------
7 from math import pi,sin,cos
9 def move(h1, x, y):
10 d = {"position": (x, y)}
11 setattr(h1, d)
13 def newarc(x, y, r):
14 h1=newelement("Arc")
15 d = {"radius": r, "minor axis": r, "position": (x, y)}
16 setattr(h1, d)
17 return h1
19 x = y = 0
20 x2 = y2 = 0
21 bigrx = 400
22 bigry = 200
23 nsteps = 200
24 step = 2 * pi / (nsteps - 1)
26 set("grid","off")
27 set("axis","off")
28 set("snap","off")
30 h1 = newarc(x, y, 100)
31 h2 = newarc(x2, y2, 85)
33 pause(0.5)
34 for i in range(0,nsteps):
35 x2 = x
36 y2 = y
37 x = int(round(bigrx * sin(i * step)))
38 y = int(round(bigry * cos(i * step)))
39 move(h1, x, y)
40 move(h2, x2, y2)
41 # pause(0.01)
42 refresh();
44 set("grid","on")
45 set("axis","on")
46 set("snap","on")
48 #-----------------------------------------------------------