generated from mwc/lab_turtle
	I changed the drawing to a sun with sunglasses.
I felt like a kid having fun. Originally, I was going to try creating the dragon that is the logo from the school I just left, but I realized I didn't have a way to fill in the outline I created. I pivoted to drawing a sun, because the star made me think about angles. I realized as I was drawing the dodecagon that I was thinking about the exterior angles of the polygon instead of the interior angles--this, and having to think about the angles with respect to the orientation of the turtle with right and left, made me make quite a few errors, but I found that I enjoyed fixing it and getting closer to the image I wanted. The whole process reminded me of when I was learning how to use NetLogo for the first time in high school! On a side note, after I was finished, I noticed I repeated certain lines a number of times. It wasn't too bad to write, since I could just copy and paste, but it felt like the right moment to learn how to write a for loop--specifically in Python, since I've done it in other languages before--and I ended up googling how to and replacing the repeated lines with them. Although I knew I could have written for loops in the first place as opposed to changing the code once I had something that worked around with this lab, I personally found it helpful to copy and paste a few times so I could make sure the loop body would actually accomplish what I wanted it to without waiting for the whole loop to actually finish drawing.
This commit is contained in:
		
							
								
								
									
										131
									
								
								drawing.py
									
									
									
									
									
								
							
							
						
						
									
										131
									
								
								drawing.py
									
									
									
									
									
								
							@@ -1,21 +1,136 @@
 | 
			
		||||
# drawing.py
 | 
			
		||||
# ----------
 | 
			
		||||
# By ______(you!)________
 | 
			
		||||
# Sun with sunglasses
 | 
			
		||||
# By Cory Chung
 | 
			
		||||
#
 | 
			
		||||
# This is a drawing of ???.
 | 
			
		||||
# This is a drawing of a sun with sunglasses.
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
from turtle import *
 | 
			
		||||
 | 
			
		||||
# ORIGINAL
 | 
			
		||||
 | 
			
		||||
# forward(100)
 | 
			
		||||
# right(360 * 2 / 5)
 | 
			
		||||
# forward(100)
 | 
			
		||||
# right(360 * 2 / 5)
 | 
			
		||||
# forward(100)
 | 
			
		||||
# right(360 * 2 / 5)
 | 
			
		||||
# forward(100)
 | 
			
		||||
# right(360 * 2 / 5)
 | 
			
		||||
# forward(100)
 | 
			
		||||
# right(360 * 2 / 5)
 | 
			
		||||
 | 
			
		||||
# ASSIGNMENT
 | 
			
		||||
 | 
			
		||||
# set initial position higher, but keep original orientation
 | 
			
		||||
penup()
 | 
			
		||||
left(90)
 | 
			
		||||
forward(200)
 | 
			
		||||
left(90)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(180)
 | 
			
		||||
pendown()
 | 
			
		||||
 | 
			
		||||
# begin by drawing a dodecagon
 | 
			
		||||
for i in range(11):
 | 
			
		||||
    forward(100)
 | 
			
		||||
    right(30)
 | 
			
		||||
forward(100)
 | 
			
		||||
right(360 * 2 / 5)
 | 
			
		||||
left(30) # restore original orientation
 | 
			
		||||
 | 
			
		||||
# create equilateral triangles on the edges
 | 
			
		||||
for i in range(11):
 | 
			
		||||
    forward(100)
 | 
			
		||||
    right(120)
 | 
			
		||||
    forward(100)
 | 
			
		||||
    left(90)
 | 
			
		||||
forward(100)
 | 
			
		||||
right(360 * 2 / 5)
 | 
			
		||||
right(120)
 | 
			
		||||
forward(100) # don't go left because we don't need to draw any more triangles
 | 
			
		||||
 | 
			
		||||
# move into a position to draw left half of sunglasses
 | 
			
		||||
 | 
			
		||||
penup()
 | 
			
		||||
right(120)
 | 
			
		||||
forward(100)
 | 
			
		||||
right(360 * 2 / 5)
 | 
			
		||||
left(30)
 | 
			
		||||
forward(50)
 | 
			
		||||
 | 
			
		||||
# draw left half of sunglasses
 | 
			
		||||
 | 
			
		||||
pendown()
 | 
			
		||||
left(60)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(60)
 | 
			
		||||
for i in range(5):
 | 
			
		||||
    forward(100)
 | 
			
		||||
    right(90)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(90)
 | 
			
		||||
forward(67)
 | 
			
		||||
 | 
			
		||||
# get into position to draw right half of sunglasses
 | 
			
		||||
 | 
			
		||||
right(180)
 | 
			
		||||
forward(67)
 | 
			
		||||
right(90)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(90)
 | 
			
		||||
forward(100)
 | 
			
		||||
right(360 * 2 / 5)
 | 
			
		||||
right(60)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(60)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(30)
 | 
			
		||||
for i in range(3):
 | 
			
		||||
    forward(100)
 | 
			
		||||
    right(30)
 | 
			
		||||
forward(50)
 | 
			
		||||
 | 
			
		||||
# draw right half of sunglasses
 | 
			
		||||
 | 
			
		||||
right(60)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(60)
 | 
			
		||||
for i in range(5): 
 | 
			
		||||
    forward(100)
 | 
			
		||||
    left(90)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(90)
 | 
			
		||||
forward(67)
 | 
			
		||||
 | 
			
		||||
# position to make a smile
 | 
			
		||||
 | 
			
		||||
right(180)
 | 
			
		||||
forward(67)
 | 
			
		||||
left(90)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(90)
 | 
			
		||||
forward(100)
 | 
			
		||||
right(360 * 2 / 5)
 | 
			
		||||
left(60)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(60)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(30)
 | 
			
		||||
forward(100)
 | 
			
		||||
left(30)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(90)
 | 
			
		||||
penup() # we don't want to have the pen down while we reposition the turtle
 | 
			
		||||
forward(300)
 | 
			
		||||
 | 
			
		||||
# draw smile
 | 
			
		||||
 | 
			
		||||
pendown()
 | 
			
		||||
left(90)
 | 
			
		||||
forward(50)
 | 
			
		||||
left(30)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(180)
 | 
			
		||||
forward(50)
 | 
			
		||||
right(30)
 | 
			
		||||
forward(100)
 | 
			
		||||
right(30)
 | 
			
		||||
forward(50)
 | 
			
		||||
 | 
			
		||||
input()
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user