-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathpath_effects.py
executable file
·39 lines (32 loc) · 1021 Bytes
/
path_effects.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
####################################################
# Demonstrate the application of live path effects #
# to a curve using Simple Inkscape Scripting. #
####################################################
# Define some program parameters.
steps = 7 # Must be odd.
delta = canvas.width/steps
# Establish a left-to-right zigzag.
pts = []
for i in range(steps + 1):
x = i*delta
if i % 2 == 0:
y = 0
else:
y = delta
pts.append((x, y))
# Continue with a right-to-left zigzag.
for i in range(steps + 1):
x = (steps - i)*delta
if i % 2 == 0:
y = 0
else:
y = delta
pts.append((x, y))
# Draw a polygon then convert this immediately to a path.
zigzag = polygon(pts, stroke='green', stroke_width=6*pt).to_path(True)
# Instantiate the BSpline live path effect,
bspline = path_effect('bspline', weight=25)
# Instantiate the Knot live path effect.
knot = path_effect('knot')
# Apply both path effects to the path.
zigzag.apply_path_effect([bspline, knot])