I need to be able to create a frieze pattern of six shapes. The link provides a visual of the shape and the size it needs to be.
from turtle import *
number_of_shapes = 6
# Draw six basic elements
for shape in range (number_of_shapes):
# Draw a basic element
for section in range(8):
forward(30)
right(110)
forward(30)
left(20)
forward(30)
right(110)
forward(30)
left(20)
forward(30)
right(110)
forward(30)
left(20)
forward(20)
right(110)
forward(30)
this code creates a different shape to the pattern I need which I found quite funny.
You have just used the angles specified in the diagram, without wondering how turtle
will interpret them.
The key is to think of 180
minus the stated angle.
Plus one run through the turns and forwards creates one star all on its own.
Your code should have been more like this:
from turtle import *
number_of_shapes = 6
LEFT=180-110
RIGHT=180-20
# Draw six basic elements
penup()
left(180)
forward(100*number_of_shapes // 2)
right(180)
for shape in range (number_of_shapes):
# Draw a basic element
left(10)
pendown()
forward(30)
left(LEFT)
forward(30)
right(RIGHT)
forward(30)
left(LEFT)
forward(30)
right(RIGHT)
forward(30)
left(LEFT)
forward(30)
right(RIGHT)
forward(30)
left(LEFT)
forward(30)
right(RIGHT)
right(10)
penup()
forward(100)