generated from mwc/problemset_typeface
It was fun making the fonts, i was having some trouple at first on how to start it but i just looked back at my old labs to help me get started
181 lines
2.6 KiB
Python
181 lines
2.6 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 IE(unit):
|
|
right(90)
|
|
forward(unit * 2)
|
|
right(90)
|
|
forward(unit * 3)
|
|
left(90)
|
|
forward(unit)
|
|
left(90)
|
|
|
|
|
|
def fly(unit):
|
|
penup()
|
|
forward(unit)
|
|
pendown()
|
|
|
|
|
|
|
|
|
|
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):
|
|
left(90)
|
|
forward(unit * 8)
|
|
right(90)
|
|
forward(unit * 4)
|
|
IE(unit)
|
|
forward(unit * 3)
|
|
IE(unit)
|
|
forward(unit * 3)
|
|
right(90)
|
|
forward(unit * 2)
|
|
right(90)
|
|
forward(unit * 4)
|
|
right(180)
|
|
|
|
|
|
|
|
|
|
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):
|
|
left(90)
|
|
forward(unit * 8)
|
|
right(90)
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit * 7)
|
|
left(90)
|
|
forward(unit * 3)
|
|
right(90)
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit * 4)
|
|
right(180)
|
|
|
|
|
|
|
|
def draw_letter_m(unit):
|
|
pass
|
|
|
|
def draw_letter_n(unit):
|
|
pass
|
|
|
|
def draw_letter_o(unit):
|
|
penup()
|
|
pendown()
|
|
fly(unit * 4)
|
|
circle(unit * 4)
|
|
left(90)
|
|
fly(unit)
|
|
right(90)
|
|
circle(unit * 3)
|
|
right(90)
|
|
fly(unit)
|
|
left(90)
|
|
fly(unit * -4)
|
|
|
|
|
|
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):
|
|
penup()
|
|
pendown()
|
|
left(90)
|
|
forward(unit)
|
|
fly(unit * 6)
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit * 8)
|
|
right(90)
|
|
forward(unit)
|
|
right(45)
|
|
forward(unit * sqrt(72))
|
|
left(135)
|
|
forward(unit * 6)
|
|
right(90)
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit * 8)
|
|
right(90)
|
|
fly(unit)
|
|
right(45)
|
|
forward(unit * sqrt(72))
|
|
left(135)
|
|
forward(unit * 6)
|
|
left(90)
|
|
fly(unit * 7)
|
|
left(90)
|
|
|
|
|
|
|