commit 969c5454b4a264f9d553f5e6171e759db41f436d Author: test100 Date: Tue Jan 27 20:07:30 2026 +0000 Initial commit diff --git a/.commit_template b/.commit_template new file mode 100644 index 0000000..37d0849 --- /dev/null +++ b/.commit_template @@ -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? diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..96403d3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +__pycache__/* diff --git a/grid.py b/grid.py new file mode 100644 index 0000000..71b054f --- /dev/null +++ b/grid.py @@ -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) diff --git a/proof.py b/proof.py new file mode 100644 index 0000000..4ff6d10 --- /dev/null +++ b/proof.py @@ -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() + diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9a4f3db --- /dev/null +++ b/pyproject.toml @@ -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 diff --git a/test.py b/test.py new file mode 100644 index 0000000..3703e2d --- /dev/null +++ b/test.py @@ -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() diff --git a/typeface.py b/typeface.py new file mode 100644 index 0000000..b966bef --- /dev/null +++ b/typeface.py @@ -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 diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..defec67 --- /dev/null +++ b/uv.lock @@ -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 }, +]