generated from mwc/problemset_typeface
189 lines
3.2 KiB
Python
189 lines
3.2 KiB
Python
# typeface.py
|
|
# By Chris Proctor and _________
|
|
|
|
# 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
|
|
from math import asin
|
|
from math import pi
|
|
|
|
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_ghostyskirt_type_a(unit):
|
|
circle(-unit/4, 180)
|
|
circle(unit/4, 180)
|
|
circle(-unit/4, 180)
|
|
circle(unit/4, 180)
|
|
circle(-unit/4, 180)
|
|
|
|
def draw_ghostyskirt_type_b(unit):
|
|
circle(-unit/4, 180)
|
|
circle(unit/4, 180)
|
|
circle(-unit/4, 180)
|
|
circle(unit/4, 180)
|
|
circle(-unit/4, 180)
|
|
circle(unit/4, 180)
|
|
circle(-unit/4, 180)
|
|
|
|
def draw_letter_a(unit):
|
|
penup()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit/4)
|
|
pendown()
|
|
forward(19*unit/4)
|
|
circle(-3*unit, 180)
|
|
forward(19*unit/4)
|
|
draw_ghostyskirt_type_a(unit)
|
|
forward(2*unit)
|
|
circle(unit/2, 180)
|
|
forward(2*unit)
|
|
draw_ghostyskirt_type_a(unit)
|
|
penup()
|
|
forward(15*unit/4)
|
|
right(90)
|
|
forward(3*unit)
|
|
pendown()
|
|
circle(unit)
|
|
penup()
|
|
circle(unit, 90)
|
|
forward(5*unit/4)
|
|
draw_eye(unit)
|
|
left(90)
|
|
forward(2*unit)
|
|
draw_eye(-unit)
|
|
|
|
|
|
def draw_letter_b(unit):
|
|
penup()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit/4)
|
|
pendown()
|
|
forward(23*unit/4)
|
|
circle(-2*unit, 90)
|
|
forward(2*unit)
|
|
circle(-2*unit, 180)
|
|
right(180)
|
|
circle(-2*unit, 135)
|
|
left(45)
|
|
forward(2*sqrt(2)*unit/8)
|
|
draw_ghostyskirt_type_b(unit)
|
|
circle(.95*unit/4, 180)
|
|
circle(-.95*unit/4, 180)
|
|
circle(.95*unit/4, 180)
|
|
circle(-.95*unit/4, 180)
|
|
penup()
|
|
forward(4.5*unit)
|
|
right(90)
|
|
forward(3*unit)
|
|
pendown()
|
|
circle(unit)
|
|
right(90)
|
|
penup()
|
|
forward(3.5*unit)
|
|
left(90)
|
|
pendown()
|
|
circle(unit)
|
|
penup()
|
|
left(90)
|
|
forward(5.5*unit)
|
|
right(90)
|
|
forward(unit)
|
|
left(90)
|
|
draw_eye(unit)
|
|
left(90)
|
|
forward(2*unit)
|
|
draw_eye(-unit)
|
|
|
|
|
|
def draw_letter_c(unit):
|
|
pass
|
|
|
|
def draw_letter_d(unit):
|
|
pass
|
|
|
|
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
|