-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathsvg_lissajous.pyde
39 lines (32 loc) · 931 Bytes
/
svg_lissajous.pyde
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
# For Processing v.3.5.4 ONLY.
#
# Generate a Lissajous curve, and export it as an SVG file.
# For more information on the Processing SVG library, see:
# https://processing.org/reference/libraries/svg/index.html
#
# Known to work with Python Mode for Processing 3.5.4.
# Does NOT work with Python Mode for Processing 4+,
# owing to problems loading the SVG library.
add_library('svg')
def setup():
# Letter: 11"x8.5" at 96 DPI.
size(1056, 816)
# Only run once:
noLoop()
def draw():
background(255)
beginRecord(SVG, "lissajous-from-processing-py.svg");
stroke(0)
noFill()
nPoints = 100
cx = width/2
cy = height/2
radius = width/4
beginShape()
for i in range (nPoints):
theta = map(i, 0, nPoints, 0, TWO_PI)
px = cx + radius * sin(2.0 * theta)
py = cy + radius * cos(3.0 * theta)
vertex(px, py)
endShape(CLOSE)
endRecord()