Update test function to take an argument
This commit is contained in:
parent
5434eafd5c
commit
936bf2c1d7
|
@ -0,0 +1,42 @@
|
|||
# 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)
|
||||
|
||||
input()
|
33
testing.py
33
testing.py
|
@ -1,33 +0,0 @@
|
|||
# testing.py
|
||||
# By Chris Proctor
|
||||
#
|
||||
# Tests one letter in `typeface`. This testing script will be very useful
|
||||
# as you work on one letter at a time. If you want to change which letter
|
||||
# is tested, edit line 31 below.
|
||||
#
|
||||
|
||||
from turtle import *
|
||||
from grid import draw_grid
|
||||
from superturtle.movement import no_delay
|
||||
import typeface
|
||||
|
||||
UNIT = 40
|
||||
GRID_COLOR = "lightgrey"
|
||||
GRID_SIZE = 1
|
||||
LETTER_COLOR = "black"
|
||||
LETTER_SIZE = 3
|
||||
|
||||
penup()
|
||||
goto(-160, -160)
|
||||
pendown()
|
||||
|
||||
with no_delay():
|
||||
color(GRID_COLOR)
|
||||
pensize(GRID_SIZE)
|
||||
draw_grid(UNIT)
|
||||
|
||||
color(LETTER_COLOR)
|
||||
pensize(LETTER_SIZE)
|
||||
typeface.draw_letter_a(UNIT)
|
||||
|
||||
input()
|
Loading…
Reference in New Issue