Files
problemset_typeface/test.py
erbrown ee29bbde78 I created blocks of code for letters a, b, c, d by using the forward, right, left, penup, pendown commands
I am sorry for submitting all my code at once. I was working on the letters and got to the bottom of the submission page and read that I should submit after I got each letter. Honestly I am feeling great at first I was a little confused on what I had to do but then once I got the first letter it was not that bad. I enjoyed doing this code and it is fun to create the letters.
2025-09-22 20:27:54 -04:00

83 lines
1.6 KiB
Python

# test.py
# ----------
# By MWC Contributors
#
# Tests one letter in `typeface`. This testing script will be very useful
# as you work on one letter at a time. This program requires one argument,
# the letter you want to test. For example:
#
# python test.py q
from turtle import *
from grid import draw_grid
from argparse import ArgumentParser
from superturtle.movement import no_delay
import typeface
UNIT = 40
GRID_COLOR = "lightgrey"
GRID_SIZE = 1
LETTER_COLOR = "black"
LETTER_SIZE = 3
parser = ArgumentParser("Test a letter in your typeface.")
parser.add_argument("letter")
arguments = parser.parse_args()
letter_function_name = "draw_letter_" + arguments.letter
letter_function = getattr(typeface, letter_function_name)
penup()
goto(-160, -160)
pendown()
with no_delay():
color(GRID_COLOR)
pensize(GRID_SIZE)
draw_grid(UNIT)
color(LETTER_COLOR)
pensize(LETTER_SIZE)
letter_function(UNIT)
def draw_letter_d(unit):
penup()
forward(unit)
pendown()
forward(unit*4)
left(45)
forward(unit * sqrt(2) *2)
left(45)
forward(unit *4)
left(45)
forward(unit * sqrt(2) *2)
left(45)
forward(unit *4)
left(90)
forward(unit *8)
penup()
left(90)
forward(unit *2)
left(90)
forward(unit *2)
right(90)
pendown()
forward(unit)
left(45)
forward(unit * sqrt(2))
left(45)
forward(unit *2)
left(45)
forward(unit * sqrt(2))
left(45)
forward(unit)
left(90)
forward(unit *4)
penup()
forward(unit *2)
right(90)
forward(unit *3)
right(180)
input()