from drawing import *
from math import sin, cos, pi
# Set up a list of points around a circle.
size = 600 # width & height of drawing in pixels
x_center = size // 2 # circle center and radius
y_center = size // 2
radius = size * 0.4
n_points = 37 # number of points around the circle
n_skip = [18, 16, 12, 7] # string art layers
colors = ['blue', 'green', 'yellow', 'orange']
points = []
for i in range(n_points):
angle = i * 2.0 * pi / n_points
x = x_center + radius * cos(angle)
y = y_center + radius * sin(angle)
points = points + [Point(x,y)]
art = Drawing(size, size)
# Create line segments connecting the points
# with a different skip number and color for each layer
for layer in range(len(colors)):
i = 0
for iteration in range(n_points):
j = (i + n_skip[layer]) % n_points # j is next point past i
art.add( Line(points[i], # add a line from point i to point j
points[j],
color=colors[layer],
line_width=1
)
)
i = j # forward to the next point
art.render()
art.display()