Commit Graph
10 Commits
Author SHA1 Message Date
Tirsvad b5483a7373 Add the random-walk and spirograph challenges to the command line
turtle-challenges random-walk and turtle-challenges spirograph, the latter with
--gap for the degrees between two circles.

Task: MIL-004#4
2026-10-07 23:59:15 +08:00
Tirsvad 2328490945 Add draw_spirograph with tests
Draws int(360 / size_of_gap) circles, each in a random RGB color, turning the heading
by the gap after each. A gap that is not positive raises ValueError, and the integer
count avoids the TypeError that range raises for a float.

Task: MIL-004#2
Task: MIL-004#3
2026-10-07 23:59:12 +08:00
Tirsvad 949d2edb63 Add random_walk with tests
200 steps of equal length, each in a random heading of 0, 90, 180 or 270 degrees and
a random RGB color, with a thick line and the fastest speed.

Task: MIL-004#1
2026-10-07 23:59:10 +08:00
Tirsvad c695c47929 Add the shapes challenge to the command line
CI / checks (pull_request) Successful in 1m7s
turtle-challenges shapes draws the polygons. The argument parsing tests already
cover every registered name.

Task: MIL-003#6
2026-10-07 23:59:08 +08:00
Tirsvad 32861fc58f Add draw_shape and draw_shapes with tests
draw_shape turns 360 divided by the number of sides after each side and rejects
fewer than 3 sides. draw_shapes draws a triangle up to a decagon, each in a color
from the palette.

Task: MIL-003#3
Task: MIL-003#4
Task: MIL-003#5
2026-10-07 23:59:05 +08:00
Tirsvad 9318a07fa0 Add random_color and the color palette
random_color returns an immutable (red, green, blue) tuple of integers from 0 to 255
and random_palette_color picks a named color. Both take an optional random.Random
so that tests can seed them.

Task: MIL-003#1
Task: MIL-003#2
2026-10-07 23:59:02 +08:00
Tirsvad b3153b9dc1 Add the command line entry point
CI / checks (pull_request) Successful in 1m13s
python -m turtle_challenges <challenge> and the turtle-challenges command open a
window, run the named challenge and wait for a click. square and dashed-line are
registered; a missing Tk is reported with a hint instead of a traceback.

Task: MIL-002#6
2026-10-07 23:58:56 +08:00
Tirsvad a34bf6bbc2 Add draw_square and draw_dashed_line with tests
Challenge 1 draws four sides and turns right 90 degrees after each. Challenge 2 puts
the pen down for a dash and up for a gap and leaves it down at the end. Lengths and
counts come from constants.py; invalid values raise ValueError.

Task: MIL-002#3
Task: MIL-002#4
Task: MIL-002#5
2026-10-07 23:58:52 +08:00
Tirsvad e2249de46e Add the Pen protocol, window helpers and a recording fake turtle
The drawing functions take a Pen, the part of turtle.Turtle they use, so a test can
pass a fake that records every call. window.py is the only module that imports
turtle, and it does so inside the functions so that importing the package needs no Tk.

Task: MIL-002#1
Task: MIL-002#2
2026-10-07 23:58:50 +08:00
Tirsvad 2cd19dfd03 Add project configuration, .gitignore and the package skeleton
pyproject.toml declares Python 3.13 or later, an empty runtime dependency list and
pytest, ruff and mypy as development tools. The package has constants.py, the one
place for constants, and a smoke test keeps the test run green.

Task: MIL-001#1
Task: MIL-001#2
Task: MIL-001#3
2026-10-07 23:58:37 +08:00