Initial commit

This commit is contained in:
2026-01-26 01:34:09 +00:00
commit be4345104f
8 changed files with 265 additions and 0 deletions

10
.commit_template Normal file
View File

@@ -0,0 +1,10 @@
# -----------------------------------------------------------------
# Write your commit message above this line.
#
# The first line should be a quick description of what you changed.
# Then leave a blank line.
# Then write a few sentences reflecting on one moment from your last
# work session. What were you feeling? If you solved a problem,
# what strategy helped you?

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
__pycache__/*

17
grid.py Normal file
View File

@@ -0,0 +1,17 @@
from turtle import *
GRID_ROWS = 8
def draw_square(unit):
for i in range(4):
forward(unit)
left(90)
def draw_grid(unit):
"Draws a grid, with `unit` as the spacing."
for cycle in range(2):
for i in range(GRID_ROWS + 1):
draw_square(i * unit)
for side in range(2):
forward(GRID_ROWS * unit)
left(90)

66
proof.py Normal file
View File

@@ -0,0 +1,66 @@
# proof.py
# By Chris Proctor
#
# Draws a proof sheet, showing each letter in `typeface`
# at two different sizes.
# ---------------------------------------------------------
# ⚠️ You don't need to read or understand this code.
# Some of the code uses techniques you haven't learned yet.
# That said, feel free to poke around and don't hesistate to
# ask if you're curious.
from turtle import *
from grid import draw_grid, GRID_ROWS
from superturtle.movement import no_delay
import typeface
GRID_COLOR = "lightgrey"
GRID_SIZE = 1
LETTER_COLOR = "black"
LETTER_SIZE = 3
LETTERS_PER_ROW = 7
ALPHABET = "abcdefghijklmnopqrstuvwxyz"
def fly(distance):
penup()
forward(distance)
pendown()
def flyto(x, y):
penup()
goto(x, y)
pendown()
def go_to_next_line(unit):
right(180)
fly((GRID_ROWS + 1) * LETTERS_PER_ROW * unit)
left(90)
fly((GRID_ROWS + 1) * unit)
left(90)
def draw_proof_sheet(unit):
rows = ((len(ALPHABET) - 1) // LETTERS_PER_ROW) + 1
left(90)
fly((GRID_ROWS + 1) * (rows - 1) * unit)
right(90)
for i, letter in enumerate(ALPHABET):
if i > 0 and i % LETTERS_PER_ROW == 0:
go_to_next_line(unit)
color(GRID_COLOR)
pensize(GRID_SIZE)
draw_grid(unit)
color(LETTER_COLOR)
pensize(LETTER_SIZE)
letter_function = getattr(typeface, f"draw_letter_{letter}")
letter_function(unit)
fly((GRID_ROWS + 1) * unit)
fly((GRID_ROWS + 1) * (len(ALPHABET) % LETTERS_PER_ROW) * -unit)
with no_delay():
flyto(-310, -60)
draw_proof_sheet(10)
flyto(-310, -260)
draw_proof_sheet(5)
input()

16
pyproject.toml Normal file
View File

@@ -0,0 +1,16 @@
[project]
name = "problemset-typeface"
version = "5.0.0"
description = ""
authors = [{ name = "Chris Proctor", email = "chris@chrisproctor.net" }]
requires-python = ">=3.10,<4.0"
readme = "README.md"
license = { text = "MIT" }
dependencies = ["superturtle (>=0.2.0,<0.3.0)"]
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.uv]
package = false

42
test.py Normal file
View File

@@ -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()

91
typeface.py Normal file
View File

@@ -0,0 +1,91 @@
# 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):
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

22
uv.lock generated Normal file
View File

@@ -0,0 +1,22 @@
version = 1
requires-python = ">=3.10, <4.0"
[[package]]
name = "problemset-typeface"
version = "5.0.0"
source = { virtual = "." }
dependencies = [
{ name = "superturtle" },
]
[package.metadata]
requires-dist = [{ name = "superturtle", specifier = ">=0.2.0,<0.3.0" }]
[[package]]
name = "superturtle"
version = "0.2.0"
source = { registry = "https://pypi.org/simple" }
sdist = { url = "https://files.pythonhosted.org/packages/6a/92/126ebdb094cce3d058746c99148acb2fb3a132998d69f2945f344e837d04/superturtle-0.2.0.tar.gz", hash = "sha256:807fb419c1dba9cb809a22a68e72c0193bdeed4a9326eb36ad940b2a7ff6ac04", size = 9611 }
wheels = [
{ url = "https://files.pythonhosted.org/packages/bf/a6/221c4dab508d0f2c9c80fe89cc16b4b1df8be98a7458d48cf298f1d993ba/superturtle-0.2.0-py3-none-any.whl", hash = "sha256:ca3a31be3259387b4490846adbf64502acc9d23472912cc43497ab170e89f506", size = 11177 },
]