Files
project_drawing/drawing.py
jwberent cc91047769 I added the grass and the house to the background of my picture.
Milestone 3:
-When creating the house I had to figure out where to put the door.  I wanted the door to be close to the center of the house.  I knew that the house was 100 units in width so I did math to figure out if I moved 40 units in and made a door that was 20 units wide, there would be 40 units on the other side between the door and the edge of the house.  This means that the door would be in the center.  I visualized this by drawing it on a separate paper.
-This project has made me really think about where the turtle is facing and what it is doing.  A way I was able to visualize that is by actaally drawing what it will be doing on a separate piece of paper.
2025-09-28 21:09:06 -04:00

151 lines
2.5 KiB
Python

# drawing.py
# ----------
# By James Berent
#
# (This will make a person and the person will stand next to a house)
from turtle import *
def fly(forw):
penup()
forward(forw)
pendown()
def rectangle(height,width,col):
dimensions = [width, height, width, height]
fillcolor(col)
begin_fill()
for dim in dimensions:
forward(dim)
left(90)
end_fill()
def triangle_facing_right(height,col):
top_of_tri = (height**2+height**2)**(1/2)
fillcolor(col)
begin_fill()
forward(height)
left(180)
fly(height)
right(90)
forward(height)
right(135)
forward(top_of_tri)
right(135)
fly(height)
left(180)
end_fill()
def triangle_facing_left(height,col):
top_of_tri = (height**2+height**2)**(1/2)
fillcolor(col)
begin_fill()
forward(height)
left(90)
forward(height)
left(135)
forward(top_of_tri)
left(135)
end_fill()
def circ(radius):
circle(radius,360) #found in section 1 link of Typeface Problem set instructions
speed(100)
rectangle(250,150,"red") #this is the torso
right(90)
fly(150)
left(90)
rectangle(150,50,"blue") #this is the left leg
fly(100)
rectangle(150,50,"blue") #this is the right leg
fly(50)
left(90)
fly(350)
right(180)
rectangle(150,50,"red") #this is right arm
right(90)
fly(300)
left(90)
rectangle(150,50,"red") #this is left arm
right(180)
fly(50)
right(90)
fly(230)
left(90)
rectangle(10,30,"white") #this is the neck
left(90)
fly(5)
right(90)
fly(30)
right(90)
circ(35) #this is the head
left(90)
fly(40)
left(90)
fly(12)
right(180)
circ(5) #this is the left eye
fly(25)
circ(5) #this is the right eye
right(90)
fly(25)
right(90)
fly(12)
right(180)
triangle_facing_right(15,"black") #this is the mouth
left(180)
fly(15)
right(180)
triangle_facing_left(15,"black") #this is the mouth
fly(45)
left(90)
fly(60)
left(90)
for num in [55,60,65,85]: #this is the hat
rectangle(10,num,"brown")
left(90)
fly(5)
right(90)
fly(400)
right(180)
dot(200,"royalblue") #this is the moon
fly(200)
right(90)
fly(475)
right(90)
fly(300)
left(90)
rectangle(800,300,"green") #this is the grass
left(90)
fly(100)
rectangle(150,100,"dodgerblue") #this is the house
fly(40)
rectangle(40,20,"white") #this is the door
left(180)
fly(10)
right(90)
fly(100)
right(90)
for r in [10,10]: #this is the windows to the house
circ(r)
fly(40)
left(180)
fly(135)
right(90)
fly(50)
right(90)
triangle_facing_left(75,"gray") #this is the roof
fly(75)
triangle_facing_right(75,"gray") #this is the roof
input()