generated from mwc/problemset_typeface
154 lines
2.6 KiB
Python
154 lines
2.6 KiB
Python
# typeface.py
|
|
# By Chris Proctor and _____Grace____
|
|
|
|
# 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):
|
|
initial_position = pos()
|
|
initial_heading = heading()
|
|
left(60)
|
|
forward(8 * unit)
|
|
|
|
right(120)
|
|
forward(8 * unit)
|
|
|
|
backward(4 * unit)
|
|
right(120)
|
|
forward(4 * unit)
|
|
|
|
penup()
|
|
setpos(initial_position) # Return to original position
|
|
setheading(initial_heading) # Return to original heading
|
|
pendown()
|
|
|
|
def draw_letter_b(unit):
|
|
initial_position = pos()
|
|
initial_heading = heading()
|
|
speed(0)
|
|
circle(2 * unit, 180)
|
|
left(180)
|
|
circle(2 * unit, 180)
|
|
left(90)
|
|
forward(8 * unit)
|
|
|
|
penup()
|
|
setpos(initial_position) # Return to original position
|
|
setheading(initial_heading) # Return to original heading
|
|
pendown()
|
|
|
|
def draw_letter_c(unit):
|
|
initial_position = pos()
|
|
initial_heading = heading()
|
|
speed(0)
|
|
penup()
|
|
forward(4 * unit)
|
|
left(90)
|
|
forward(8 * unit)
|
|
pendown()
|
|
left(90)
|
|
circle(4 * unit, 180)
|
|
|
|
penup()
|
|
right(90)
|
|
forward(2 * unit)
|
|
pendown()
|
|
|
|
penup()
|
|
setpos(initial_position)
|
|
setheading(initial_heading)
|
|
pendown()
|
|
|
|
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):
|
|
initial_position = pos()
|
|
initial_heading = heading()
|
|
penup()
|
|
forward(4 * unit)
|
|
left(90)
|
|
pendown()
|
|
forward(5 * unit)
|
|
penup()
|
|
forward(1 * unit)
|
|
pendown()
|
|
forward(1 * unit)
|
|
|
|
penup()
|
|
setpos(initial_position)
|
|
setheading(initial_heading)
|
|
pendown()
|
|
|
|
|
|
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
|