# By changing the angle each time for the loops, this will create different shape, e.g. 90˚ angle will create a square and 70˚ angle will create a pentagon shape.
import axi
A4_PORT = (0, 0, 8.25, 11.75) # A4 Portrait bounds
A4_LAND = (0, 0, 11.75, 8.25) # A4 Landscape bounds
BOUNDS = A4_LAND
def draw_square(turtle, x, y):
turtle.pu() # pen up
turtle.goto(x,y) # go to point (0,0)
turtle.pd() # pen down
angle = 91 # I add 1 to make the square (90') rotate slightly bigger to diferent angle for each loop
for i in range(100):
turtle.forward(i)
turtle.left(angle)
def draw_circle(turtle, x, y):
turtle.pu() # pen up
turtle.goto(x,y) # go to point (0,0)
turtle.pd() # pen down
angle = 51 # I add 1 to make the circle rotate slightly bigger to diferent angle for each loop
for i in range(70):
turtle.circle(i)
turtle.right(angle)
def draw_pentagon(turtle, x, y):
turtle.pu() # pen up
turtle.goto(x,y) # go to point (0,0)
turtle.pd() # pen down
angle = 71 # I add 1 to make the pentagon (70') rotate slightly bigger to diferent angle for each loop
for i in range(150):
turtle.forward(i)
turtle.right(angle)
def save_img(turtle, name = 'out'):
drawing = turtle.drawing.rotate_and_scale_to_fit(BOUNDS[2], BOUNDS[3], step=90, padding=0.5) # scale letter to fit A4-sized paper
im = drawing.render(bounds=BOUNDS) # render drawing
im.write_to_png(name + '.png') # save a image of your drawing in a file called name.png
def draw_img(turtle):
drawing = turtle.drawing.rotate_and_scale_to_fit(BOUNDS[2], BOUNDS[3], step=90, padding=0.5) # scale letter to fit A4-sized paper
axi.draw(drawing)
def main():
turtle = axi.Turtle()
draw_circle(turtle, 150, 300)
draw_pentagon(turtle, 350, 300)
draw_square(turtle, 350, 600)
output_img = 'Task4_Art'
save_img(turtle, output_img)
# draw_img(turtle) # Uncomment to draw your image
if __name__ == '__main__':
main()