generated from mwc/problemset_typeface
I really sturggled figuring out the angles needed to make diagonal lines in letters, i also struggle A LOT with the whol getting back to where we started, i thought they meant where the writing started and i picked my pen up so my letters were centered on the grids, so the next letter was always in the wrong orintation but once i talked to dr proctor i saw that it needed to end at the bottom left corner where my pen start AND it needed to pointing to thr right. once i got all those things, i was able to get it perfect.
214 lines
3.3 KiB
Python
214 lines
3.3 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):
|
|
pass
|
|
|
|
def draw_letter_l(unit):
|
|
print(position(),heading())
|
|
penup()
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit)
|
|
right(90)
|
|
pendown()
|
|
forward(unit*4)
|
|
left(90)
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit*3)
|
|
right(90)
|
|
forward(unit*5)
|
|
left(90)
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit*6)
|
|
penup()
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit*2)
|
|
right(180)
|
|
pendown()
|
|
print(position(),heading())
|
|
|
|
def draw_letter_m(unit):
|
|
penup()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit)
|
|
right(90)
|
|
pendown()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit*3)
|
|
right(144)
|
|
forward(unit*2.5)
|
|
left(54)
|
|
forward(unit)
|
|
left(54)
|
|
forward(unit*2.5)
|
|
right(144)
|
|
forward(unit*3)
|
|
left(90)
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit*6)
|
|
left(90)
|
|
forward(unit)
|
|
left(57)
|
|
forward(unit*3.625)
|
|
right(114)
|
|
forward(unit*3.625)
|
|
left(57)
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit*6)
|
|
penup()
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit)
|
|
right(180)
|
|
pendown()
|
|
|
|
|
|
def draw_letter_n(unit):
|
|
pass
|
|
|
|
def draw_letter_o(unit):
|
|
penup()
|
|
forward(unit)
|
|
left(90)
|
|
forward(unit)
|
|
right(90)
|
|
pendown()
|
|
forward(unit*6)
|
|
left(90)
|
|
forward(unit*6)
|
|
left(90)
|
|
forward(unit*6)
|
|
left(90)
|
|
forward(unit*6)
|
|
left(90)
|
|
penup()
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit*2)
|
|
pendown()
|
|
right(90)
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit*2)
|
|
penup()
|
|
forward(unit*3)
|
|
right(90)
|
|
forward(unit*3)
|
|
right(180)
|
|
pendown()
|
|
|
|
|
|
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):
|
|
penup()
|
|
forward(unit*3)
|
|
left(90)
|
|
forward(unit)
|
|
right(90)
|
|
pendown()
|
|
forward(unit*2)
|
|
left(90)
|
|
forward(unit*3)
|
|
right(34)
|
|
forward(unit*3.625)
|
|
left(124)
|
|
forward(unit*2)
|
|
left(62)
|
|
forward(unit*2.3)
|
|
right(126)
|
|
forward(unit*2.3)
|
|
left(64)
|
|
forward(unit*2)
|
|
left(124)
|
|
forward(unit*3.625)
|
|
right(34)
|
|
forward(unit*3)
|
|
penup()
|
|
forward(unit)
|
|
right(90)
|
|
forward(unit*3)
|
|
right(180)
|
|
|
|
def draw_letter_z(unit):
|
|
pass
|