generated from mwc/problemset_typeface
195 lines
3.2 KiB
Python
195 lines
3.2 KiB
Python
# typeface.py
|
|
# By Chris Proctor and Nelson Mason
|
|
# Due by 9-29-2025
|
|
|
|
# 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):
|
|
penup()
|
|
left(90)
|
|
forward(unit*8)
|
|
right(90)
|
|
forward(unit*1.5)
|
|
pendown()
|
|
pensize(10)
|
|
color(1, 1, 0)
|
|
forward(unit*5)
|
|
penup()
|
|
right(180)
|
|
forward(unit*2.5)
|
|
left(90)
|
|
pendown()
|
|
forward(unit*7)
|
|
right(45)
|
|
forward(unit*sqrt(2))
|
|
right(45)
|
|
forward(unit)
|
|
right(45)
|
|
forward(unit*sqrt(2))
|
|
penup()
|
|
left(135)
|
|
forward(unit)
|
|
left(90)
|
|
pendown()
|
|
pensize(1)
|
|
color(0, 0, 0)
|
|
|
|
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):
|
|
penup()
|
|
left(90)
|
|
forward(unit*8)
|
|
right(90)
|
|
forward(unit*2.5)
|
|
pendown()
|
|
pensize(10)
|
|
color(1, 0.647, 0)
|
|
forward(unit*3)
|
|
right(45)
|
|
forward(unit*1.5*sqrt(2))
|
|
right(45)
|
|
forward(unit*5)
|
|
right(45)
|
|
forward(unit*1.5*sqrt(2))
|
|
right(45)
|
|
forward(unit*3)
|
|
right(45)
|
|
forward(unit*1.5*sqrt(2))
|
|
right(45)
|
|
forward(unit*5)
|
|
right(45)
|
|
forward(unit*1.5*sqrt(2))
|
|
penup()
|
|
left(135)
|
|
forward(unit*2.5)
|
|
left(90)
|
|
forward(unit*8)
|
|
left(90)
|
|
pendown()
|
|
pensize(1)
|
|
color(0, 0, 0)
|
|
|
|
def draw_letter_p(unit):
|
|
pass
|
|
|
|
def draw_letter_q(unit):
|
|
pass
|
|
|
|
def draw_letter_r(unit):
|
|
pensize(10)
|
|
color(1, 0, 0)
|
|
left(90)
|
|
forward(unit*8)
|
|
right(90)
|
|
forward(unit*6)
|
|
right(45)
|
|
forward(unit*sqrt(2))
|
|
right(45)
|
|
forward(unit*2)
|
|
right(45)
|
|
forward(unit*sqrt(2))
|
|
right(45)
|
|
forward(unit*6)
|
|
penup()
|
|
right(180)
|
|
forward(unit*5)
|
|
pendown()
|
|
right(63.43) # derived from an online SOH-CAH-TOA app
|
|
forward(unit*sqrt((4**2)+(2**2)))
|
|
penup()
|
|
right(116.57) # derived from an online SOH-CAH-TOA app
|
|
forward(unit*7)
|
|
right(180)
|
|
pendown()
|
|
pensize(1)
|
|
color(0, 0, 0)
|
|
|
|
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()
|
|
left(90)
|
|
forward(unit*8)
|
|
right(90)
|
|
pendown()
|
|
pensize(10)
|
|
color(0, 1, 1)
|
|
forward(unit*8)
|
|
right(135)
|
|
forward(unit*8*sqrt(2))
|
|
left(135)
|
|
forward(unit*8)
|
|
penup()
|
|
left(180)
|
|
forward(unit*8)
|
|
left(180)
|
|
pendown()
|
|
pensize(1)
|
|
color(0, 0, 0)
|