generated from mwc/project_drawing
Did some trig, made a cow, fixed it to be a dog
Turns out I did end up needing the chord length for some of the proportioning if I wanted symmetry. Did need to add math, but was easy enough to plug and chug. Looking back, I could have done the trig once right after I assigned the faceLength variable and then stored that value to use later on, rather than copy/pasting the equation over and over again and then tweaking it with a constant... Because of the design I chose, iteration didn't take a primary role in my program, but I did use it for the ellipses and the triangle to save myself a lot of variable updating/redundant lines of code since all of the non-circle shapes were regular shapes anyway. That did make things a lot easier, especially since by design the turtle ended up with a consistent in/out position which maybe wouldn't have happened if I wrote the whole thing line by line. If I were going to continue with this project, which I still might, I would add the lower half of the dog and a nice animation might be to make the tail wag.
This commit is contained in:
parent
7fb8f7d11e
commit
88b6a7798f
39
drawing.py
39
drawing.py
|
@ -5,16 +5,19 @@
|
|||
# This program will (hopefully) draw a dog
|
||||
|
||||
from turtle import *
|
||||
import superturtle as st
|
||||
import math
|
||||
|
||||
# for the dog's ears
|
||||
def ear(rad):
|
||||
def ear(rad,color):
|
||||
pendown()
|
||||
fillcolor(color)
|
||||
begin_fill()
|
||||
# draw an ellipse, rad is the "radius" of the ellipse
|
||||
for i in range(2):
|
||||
# two arcs, each one half of the ellipse
|
||||
circle(rad,90) # long side
|
||||
circle(rad//25,90) # short side
|
||||
end_fill()
|
||||
penup()
|
||||
|
||||
# main part of the dog's face
|
||||
|
@ -65,21 +68,45 @@ def nose(rad):
|
|||
circle(-rad,150)
|
||||
penup()
|
||||
|
||||
def eye(rad):
|
||||
def eye(rad,color):
|
||||
pendown()
|
||||
color = 'black'
|
||||
fillcolor(color)
|
||||
begin_fill()
|
||||
circle(rad)
|
||||
end_fill()
|
||||
penup()
|
||||
|
||||
speed(0)
|
||||
penup()
|
||||
pencolor('black')
|
||||
pensize(4)
|
||||
hideturtle()
|
||||
|
||||
faceLength = 200
|
||||
|
||||
right(20)
|
||||
goto(2*(faceLength/2)*math.sin(math.pi/4)*0.5,0)
|
||||
ear(-faceLength,'sienna')
|
||||
goto(-2*(faceLength/2)*math.sin(math.pi/4)*0.5,0)
|
||||
right(140)
|
||||
ear(faceLength,'sienna')
|
||||
|
||||
goto(-2*(faceLength/2)*math.sin(math.pi/4)*0.5,0)
|
||||
setheading(-135)
|
||||
face(200,'white')
|
||||
face(faceLength,'white')
|
||||
|
||||
goto(-2*(faceLength/2)*math.sin(math.pi/4),-2*(faceLength)*math.sin(math.pi/4)*1.25)
|
||||
setheading(-45)
|
||||
face(200,'saddle brown')
|
||||
face(faceLength,'sienna')
|
||||
|
||||
setheading(0)
|
||||
goto(-2*(faceLength/2)*math.sin(math.pi/4)*0.4,-faceLength/2)
|
||||
eye(faceLength/12,'black')
|
||||
goto(2*(faceLength/2)*math.sin(math.pi/4)*0.4,-faceLength/2)
|
||||
eye(faceLength/12,'black')
|
||||
|
||||
goto(faceLength/12,-2*(faceLength/2)*math.sin(math.pi/4)*1.25)
|
||||
nose(faceLength/6)
|
||||
|
||||
done()
|
||||
|
||||
|
|
Loading…
Reference in New Issue