generated from mwc/project_drawing
Added nose and eye functions, final layout testing
The nose function got me stuck for a while, mostly because I tried to relearn how to measure chord length of a circle so I could trig my way into an exact position of the turtle to make the swoops for the septum/upper lip of the dog at the base of the nose, but after much math, I found myself estimating anyway, so the only real known that I *needed* was the x-dir midpoint, which I knew and from there I chose some reasonable numbers that make the bottom of the nose look as intended. I'm finding myself not stuck, but challenged, with the final layout of all of the parts of the face. I think I'm going to be in the same boat as before where exact values aren't really needed and I have enough info to estimate a "close enough" position for how all of the parts come together. Order of operations is also going to be important here because some of the shapes need to go on top of others to get a layering effect.
This commit is contained in:
parent
8cc5090b5f
commit
7fb8f7d11e
63
drawing.py
63
drawing.py
|
@ -9,23 +9,78 @@ import superturtle as st
|
|||
|
||||
# for the dog's ears
|
||||
def ear(rad):
|
||||
|
||||
pendown()
|
||||
# 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
|
||||
penup()
|
||||
|
||||
# main part of the dog's face
|
||||
def face(rad):
|
||||
|
||||
def face(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//2,90) # short side
|
||||
end_fill()
|
||||
penup()
|
||||
|
||||
face(100)
|
||||
def nose(rad):
|
||||
# circles are drawn CCW so if the turtle is facing right, the nose is upside down
|
||||
setheading(180)
|
||||
pendown()
|
||||
color = 'black'
|
||||
fillcolor(color)
|
||||
begin_fill()
|
||||
|
||||
# initial position will need to be shifted +X by rad/2 to be centered
|
||||
for i in range(3):
|
||||
forward(rad)
|
||||
circle(rad,120)
|
||||
|
||||
end_fill()
|
||||
penup()
|
||||
|
||||
# reset position and do the dogs septum/upper lip
|
||||
forward(rad/2)
|
||||
left(90)
|
||||
forward(2*rad)
|
||||
x = xcor()
|
||||
y = ycor()
|
||||
pendown()
|
||||
# swoop right
|
||||
forward(2*rad)
|
||||
circle(rad,150)
|
||||
penup()
|
||||
goto(x,y)
|
||||
setheading(270)
|
||||
pendown()
|
||||
# swoop left
|
||||
forward(2*rad)
|
||||
circle(-rad,150)
|
||||
penup()
|
||||
|
||||
def eye(rad):
|
||||
pendown()
|
||||
color = 'black'
|
||||
fillcolor(color)
|
||||
begin_fill()
|
||||
circle(rad)
|
||||
penup()
|
||||
|
||||
pencolor('black')
|
||||
pensize(4)
|
||||
|
||||
setheading(-135)
|
||||
face(200,'white')
|
||||
setheading(-45)
|
||||
face(200,'saddle brown')
|
||||
|
||||
done()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue