generated from mwc/project_drawing
87 lines
1.6 KiB
Python
87 lines
1.6 KiB
Python
# drawing.py
|
|
# ----------
|
|
# By Patrick Wick
|
|
#
|
|
# This program will (hopefully) draw a dog
|
|
|
|
from turtle import *
|
|
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,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()
|
|
|
|
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()
|
|
|
|
|