This project aims at learning to draw images using turtle program in python computer language. It begins with drawing very simple diagrams like triangle. Then the we learn to draw more complex diagrams by composing two known diagrams and zooming the diagram using different multitudes.
The first image I draw is a star. Compare to triangle, the star image is more complex due to the fact that it is harder to calculate the angle within the star. To calculate the angle for each arrow, it is necessary to calculate the angle within the pentagon which is 108 degree. Then it is possible to calculate the arrow which is 36 degree and the turtle need to turn 144 degree to complete another arrow in the diagram.
The second image I draw is a pentagon, since I already got the angle in a right pentagon which is 108 degree, it becomes not hard to calculate the degree that turtle need to turn which is 72 degree.
The third image i design to put the star into the pentagon. Since the codes are made already, it is not hard to put them together into one file. However, it is hard to calculate the exact distance of the pentagon so that each angle of pentagon fits with star’s angles. Such calculation requires trigonometry and the result turn out to be around 61.8.
The fourth image, as shown below, is a composition of the first image which is a star. By defining the parameter, it become possible to compose the same image with different sizes using fewer lines of code as shown below.
def shapeA (distance):
Extension 1: I learned that to have a set of instruction repeat in numbers of time, it is necessary to introduce another algorithm:
for i in range(n):
Extension 2: By using the algorithm above, it is possible to create an n-gon as written below:
for i in range(n):
The image on the right shows a right octagon
Extension3: Combing both the new algorithm and what I learned in homework which is to draw a triangle, I can make a Colby logo which is based on twenty four congruent triangles and a icosagon, a right polygon with twenty sides.
what I learned: i learned to draw simple images using python code. Base on given code, I learned to control the parameters and create complicated images that are composed out of simple image.
I learned the algorithm of repeating command on Prof. Maxwell’s computer science class.