Initial commit

This commit is contained in:
nate 2025-05-20 00:21:16 +00:00
commit 5eaca4c122
8 changed files with 266 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)

18
poetry.lock generated Normal file
View File

@ -0,0 +1,18 @@
# This file is automatically @generated by Poetry 2.0.0 and should not be changed by hand.
[[package]]
name = "superturtle"
version = "0.2.0"
description = "Extensions to Python's turtle"
optional = false
python-versions = "<4.0,>=3.9"
groups = ["main"]
files = [
{file = "superturtle-0.2.0-py3-none-any.whl", hash = "sha256:ca3a31be3259387b4490846adbf64502acc9d23472912cc43497ab170e89f506"},
{file = "superturtle-0.2.0.tar.gz", hash = "sha256:807fb419c1dba9cb809a22a68e72c0193bdeed4a9326eb36ad940b2a7ff6ac04"},
]
[metadata]
lock-version = "2.1"
python-versions = ">=3.10,<4.0"
content-hash = "6aad436bbbf760fa856344262eab22d62a167cac4e5dfefbf4be77d5a37428c9"

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

21
pyproject.toml Normal file
View File

@ -0,0 +1,21 @@
[project]
name = "problemset-typeface"
version = "0.1.0"
description = ""
authors = [
{name = "Chris Proctor",email = "chris@chrisproctor.net"}
]
license = {text = "MIT"}
readme = "README.md"
requires-python = ">=3.10,<4.0"
dependencies = [
"superturtle (>=0.2.0,<0.3.0)"
]
[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.poetry]
package-mode = 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