File: test.py

package info (click to toggle)
xcircuit 2.5.3rev0-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 3,292 kB
  • ctags: 3,497
  • sloc: ansic: 41,848; sh: 2,741; python: 473; makefile: 165
file content (48 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (8)
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
#-----------------------------------------------------------
# Test of the python interpreter and use of animation in
# xcircuit. Execute this script using menu option
# "File/Execute Script", if Python has been compiled in.
#-----------------------------------------------------------

from math import pi,sin,cos

def move(h1, x, y):
   d = {"position": (x, y)}
   setattr(h1, d) 

def newarc(x, y, r):
   h1=newelement("Arc")
   d = {"radius": r, "minor axis": r, "position": (x, y)}
   setattr(h1, d)
   return h1

x = y = 0
x2 = y2 = 0
bigrx = 400
bigry = 200
nsteps = 200
step = 2 * pi / (nsteps - 1) 

set("grid","off")
set("axis","off")
set("snap","off")

h1 = newarc(x, y, 100)
h2 = newarc(x2, y2, 85)

pause(0.5)
for i in range(0,nsteps):
   x2 = x
   y2 = y
   x = int(round(bigrx * sin(i * step)))
   y = int(round(bigry * cos(i * step)))
   move(h1, x, y)
   move(h2, x2, y2)
#  pause(0.01)
   refresh();

set("grid","on")
set("axis","on")
set("snap","on")

#-----------------------------------------------------------