generated from mwc/problemset_typeface
254 lines
4.7 KiB
Python
254 lines
4.7 KiB
Python
# typeface.py
|
|
# By Chris Proctor and Stacy S
|
|
|
|
# Contains one function for each letter in the English alphabet.
|
|
# Each function should draw its letter at a scale of `unit`, and then
|
|
# return back to the same position and heading where it started.
|
|
|
|
# Note: The `sqrt` function from math may be helpful--if you want to
|
|
# move the turtle along the diagonal of a square with side length x,
|
|
# the turtle should move a distance of sqrt(x)
|
|
|
|
from turtle import *
|
|
from math import sqrt
|
|
|
|
def draw_eye(unit):
|
|
right(45)
|
|
pendown()
|
|
fillcolor('black')
|
|
begin_fill()
|
|
circle(unit/2, 90)
|
|
circle(unit/12, 90)
|
|
circle(unit/2, 90)
|
|
circle(unit/12, 90)
|
|
end_fill()
|
|
penup()
|
|
left(45)
|
|
|
|
def draw_master_ghostyskirt(unit, length):
|
|
for width in range(length):
|
|
circle(-unit/4, 180)
|
|
circle(unit/4, 180)
|
|
circle(-unit/4, 180)
|
|
|
|
def draw_letter_a(unit):
|
|
width(1)
|
|
penup() #(0,0)
|
|
forward(unit) #(1,0)
|
|
left(90)
|
|
forward(unit/4) #(1,1/4)
|
|
pendown()
|
|
forward(19*unit/4) #(1,5)
|
|
circle(-3*unit, 180) #(7,5)
|
|
forward(19*unit/4) #(7,1/4)
|
|
draw_master_ghostyskirt(unit,2) #(9/2,1/4)
|
|
forward(2*unit) #(9/2,9/4)
|
|
circle(unit/2, 180) #(7/2,9/4)
|
|
forward(2*unit) #(7/2,1/4)
|
|
draw_master_ghostyskirt(unit,2) #(1,1/4)
|
|
penup()
|
|
forward(15*unit/4) #(1,4)
|
|
right(90)
|
|
forward(3*unit) #(4,4)
|
|
pendown()
|
|
circle(unit) #(4,4)
|
|
penup()
|
|
circle(unit, 90) #(5,5)
|
|
forward(5*unit/4) #(5,25/4)
|
|
draw_eye(unit)
|
|
left(90)
|
|
forward(2*unit) #(3,25/4)
|
|
draw_eye(-unit)
|
|
penup()
|
|
forward(3*unit)
|
|
left(90)
|
|
forward(25*unit/4)
|
|
left(90)
|
|
|
|
def draw_letter_b(unit):
|
|
width(1)
|
|
penup() #(0,0)
|
|
forward(unit) #(1,0)
|
|
left(90)
|
|
forward(3*unit/4) #(1,1/4)
|
|
pendown()
|
|
forward(21*unit/4) #(1,6)
|
|
circle(-2*unit, 90) #(3,8)
|
|
forward(2*unit) #(5,8)
|
|
circle(-2*unit, 180) #(5,4)
|
|
right(180)
|
|
circle(-2*unit, 150) #(6,2-sqrt3)
|
|
left(60)
|
|
forward((((7-4*sqrt(3)))/4)*unit) #(6,1/4)
|
|
draw_master_ghostyskirt(unit,4) #(3/2,1/4)
|
|
circle(unit/4, 90)
|
|
circle(-unit/4, 90) #(1,3/4)
|
|
penup()
|
|
forward(17*unit/4) #(1,5)
|
|
right(90)
|
|
forward(3*unit) #(4,5)
|
|
pendown()
|
|
circle(unit) #(4,5)
|
|
right(90)
|
|
penup()
|
|
forward(3.5*unit) #(4,3/2)
|
|
left(90)
|
|
pendown()
|
|
circle(unit) #(4,3/2)
|
|
penup()
|
|
left(90)
|
|
forward(11*unit/2) #(4,7)
|
|
right(90)
|
|
forward(unit) #(5,7)
|
|
left(90)
|
|
draw_eye(unit) #(5,7)
|
|
left(90)
|
|
forward(2*unit) #(3,7)
|
|
draw_eye(-unit) #(3,7)
|
|
forward(3*unit)
|
|
left(90)
|
|
forward(7*unit)
|
|
left(90)
|
|
|
|
def draw_letter_c(unit):
|
|
width(1)
|
|
penup() #(0,0)
|
|
forward(unit) #(1,0)
|
|
left(90)
|
|
forward(1*unit) #(1,1)
|
|
pendown()
|
|
forward(4*unit) #(1,5)
|
|
circle(-3*unit, 90)
|
|
forward(2*unit)
|
|
circle(-unit, 180)
|
|
forward(2*unit)
|
|
circle(unit,90)
|
|
forward(7*unit/4)
|
|
circle(unit, 90)
|
|
forward(2*unit)
|
|
circle(-unit, 180)
|
|
left(90)
|
|
draw_master_ghostyskirt(unit,4)
|
|
circle(unit/4, 90)
|
|
circle(-unit/4, 90)
|
|
forward(unit/4) #(1,1)
|
|
penup()
|
|
forward(5.5*unit)
|
|
right(90)
|
|
forward(3*unit)
|
|
left(90)
|
|
draw_eye(unit)
|
|
left(90)
|
|
forward(4*unit)
|
|
left(90)
|
|
forward(6.5*unit)
|
|
left(90)
|
|
|
|
def draw_letter_d(unit):
|
|
width(1)
|
|
penup()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit)
|
|
pendown()
|
|
forward(6*unit)
|
|
circle(-unit, 90)
|
|
forward(3*unit)
|
|
circle(-2*unit, 90)
|
|
forward(3.75*unit)
|
|
circle(-2*unit, 90)
|
|
left(90)
|
|
draw_master_ghostyskirt(unit, 3)
|
|
circle(unit/4, 90)
|
|
circle(-unit/4, 90)
|
|
forward(unit/4)
|
|
penup()
|
|
forward(2.5*unit)
|
|
right(90)
|
|
forward(2*unit)
|
|
right(90)
|
|
pendown()
|
|
circle(unit, 180)
|
|
forward(unit)
|
|
circle(unit, 180)
|
|
forward(unit)
|
|
penup()
|
|
right(180)
|
|
forward(2*unit)
|
|
draw_eye(unit)
|
|
right(90)
|
|
forward(2*unit)
|
|
left(90)
|
|
draw_eye(unit)
|
|
left(90)
|
|
forward(5*unit)
|
|
left(90)
|
|
forward(5.5*unit)
|
|
left(90)
|
|
|
|
def draw_letter_e(unit):
|
|
pass
|
|
|
|
def draw_letter_f(unit):
|
|
pass
|
|
|
|
def draw_letter_g(unit):
|
|
pass
|
|
|
|
def draw_letter_h(unit):
|
|
pass
|
|
|
|
def draw_letter_i(unit):
|
|
pass
|
|
|
|
def draw_letter_j(unit):
|
|
pass
|
|
|
|
def draw_letter_k(unit):
|
|
pass
|
|
|
|
def draw_letter_l(unit):
|
|
pass
|
|
|
|
def draw_letter_m(unit):
|
|
pass
|
|
|
|
def draw_letter_n(unit):
|
|
pass
|
|
|
|
def draw_letter_o(unit):
|
|
pass
|
|
|
|
def draw_letter_p(unit):
|
|
pass
|
|
|
|
def draw_letter_q(unit):
|
|
pass
|
|
|
|
def draw_letter_r(unit):
|
|
pass
|
|
|
|
def draw_letter_s(unit):
|
|
pass
|
|
|
|
def draw_letter_t(unit):
|
|
pass
|
|
|
|
def draw_letter_u(unit):
|
|
pass
|
|
|
|
def draw_letter_v(unit):
|
|
pass
|
|
|
|
def draw_letter_w(unit):
|
|
pass
|
|
|
|
def draw_letter_x(unit):
|
|
pass
|
|
|
|
def draw_letter_y(unit):
|
|
pass
|
|
|
|
def draw_letter_z(unit):
|
|
pass
|