generated from mwc/problemset_typeface
228 lines
3.8 KiB
Python
228 lines
3.8 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
|
|
|
|
|
|
def draw_letter_a(unit):
|
|
pass
|
|
|
|
def draw_letter_b(unit):
|
|
pass
|
|
|
|
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):
|
|
|
|
diagonal_45 = sqrt((unit*unit)+(unit*unit))
|
|
|
|
penup()
|
|
forward(unit*2)
|
|
left(90)
|
|
pendown()
|
|
forward(unit*8)
|
|
right(90)
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit*3)
|
|
left(135)
|
|
forward(diagonal_45*3)
|
|
right(45)
|
|
forward(unit)
|
|
right(135)
|
|
forward(diagonal_45*4)
|
|
left(90)
|
|
forward(diagonal_45*4)
|
|
right(135)
|
|
forward(unit)
|
|
right(45)
|
|
forward(diagonal_45*3)
|
|
left(135)
|
|
forward(unit*3)
|
|
right(90)
|
|
forward(unit)
|
|
penup()
|
|
forward(unit*2)
|
|
right(180)
|
|
pendown()
|
|
|
|
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):
|
|
|
|
diagonal_26 = (unit * sqrt(5/4))
|
|
diagonal_45 = sqrt((unit*unit)+(unit*unit))
|
|
|
|
def corner_left():
|
|
left(26.565)
|
|
forward(diagonal_26)
|
|
left(45-26.565)
|
|
forward(diagonal_45/2)
|
|
left(45-26.565)
|
|
forward(diagonal_26)
|
|
|
|
penup()
|
|
forward(unit*3)
|
|
pendown()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit*3)
|
|
right(90)
|
|
forward(unit)
|
|
corner_left()
|
|
left(26.565)
|
|
forward(unit)
|
|
corner_left()
|
|
left(26.565)
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit*8)
|
|
|
|
penup()
|
|
#placing the interior hole
|
|
left(90)
|
|
#how far to the right do you want the interior hole of the P?
|
|
forward(unit*1.5)
|
|
left(90)
|
|
#how far up do we want the interior hole?
|
|
forward(unit*4.5)
|
|
|
|
pendown()
|
|
#Draw the interior hole
|
|
forward(unit*2)
|
|
right(90)
|
|
forward(unit*1)
|
|
right(45)
|
|
forward(diagonal_45/2)
|
|
right(45)
|
|
forward(unit)
|
|
right(45)
|
|
forward(diagonal_45/2)
|
|
right(45)
|
|
forward(unit*1)
|
|
penup()
|
|
forward(unit*4.5)
|
|
left(90)
|
|
forward(unit*4.5)
|
|
left(90)
|
|
pendown()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def draw_letter_q(unit):
|
|
pass
|
|
|
|
def draw_letter_r(unit):
|
|
pass
|
|
|
|
def draw_letter_s(unit):
|
|
|
|
diagonal_26 = (unit * sqrt(5/4))
|
|
diagonal_45 = sqrt((unit*unit)+(unit*unit))
|
|
|
|
def corner_left():
|
|
left(26.565)
|
|
forward(diagonal_26)
|
|
left(45-26.565)
|
|
forward(diagonal_45/2)
|
|
left(45-26.565)
|
|
forward(diagonal_26)
|
|
|
|
def corner_right():
|
|
right(26.565)
|
|
forward(diagonal_26)
|
|
right(45-26.565)
|
|
forward(diagonal_45/2)
|
|
right(45-26.565)
|
|
forward(diagonal_26)
|
|
|
|
def s_side():
|
|
corner_left()
|
|
left(26.565)
|
|
corner_left()
|
|
left(26.565)
|
|
corner_right()
|
|
right(26.565)
|
|
corner_right()
|
|
right(26.565)
|
|
|
|
penup()
|
|
forward(unit*3)
|
|
pendown()
|
|
s_side()
|
|
forward(unit)
|
|
right(180)
|
|
s_side()
|
|
forward(unit)
|
|
penup()
|
|
forward(unit*3)
|
|
right(180)
|
|
pendown()
|
|
|
|
|
|
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
|