made a abstract shape using tiles.py, was fun

This commit is contained in:
jfer
2026-02-12 11:11:01 -05:00
parent 69a9553023
commit f7f97c3b6d
6 changed files with 48 additions and 33 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
source .venv/bin/activate

18
poetry.lock generated Normal file
View File

@@ -0,0 +1,18 @@
# This file is automatically @generated by Poetry 2.3.1 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"

View File

@@ -8,16 +8,16 @@ def print_all_numbers(maximum):
print(number) print(number)
def print_even_numbers(maximum): def print_even_numbers(maximum):
"Prints all even integers from 0 to maximum." for number in range(0, maximum, 2):
pass print(number)
def print_odd_numbers(maximum): def print_odd_numbers(maximum):
"Prints all odd integers from 0 to maximum." for number in range(1, maximum, 2):
pass print(number)
def print_multiples_of_five(maximum): def print_multiples_of_five(maximum):
"Prints all integers which are multiples of five from 0 to maximum." for number in range(0, maximum, 5):
pass print(number)
chosen_maximum = int(input("Choose a number: ")) chosen_maximum = int(input("Choose a number: "))
print(f"All numbers from 0 to {chosen_maximum}") print(f"All numbers from 0 to {chosen_maximum}")

View File

@@ -1,17 +1,13 @@
from turtle import * from turtle import *
def square(side_length): def square(side_length):
forward(side_length) for i in range (4):
right(90)
forward(side_length)
right(90)
forward(side_length)
right(90)
forward(side_length) forward(side_length)
right(90) right(90)
sizes = [20, 40, 60, 80, 100] sizes = [20, 40, 60, 80, 100]
for size in sizes: for size in sizes:
square(size) square(size)
input() input()

36
tile.py
View File

@@ -10,18 +10,18 @@ def draw_tile_outline(size):
square(size) square(size)
def draw_squiggle(size): def draw_squiggle(size):
forward(size/4) forward(size/25)
pencolor("black") pencolor("pink")
left(90) left(135)
quarter_arc_right(size/4) half_arc_right(size * 2)
quarter_arc_left(size/4) half_arc_left(size * 2)
quarter_arc_left(size/4) half_arc_left(size * 2)
quarter_arc_right(size/4) half_arc_right(size * 2)
left(90) left(135)
fly(size/4) fly(size/2)
left(90) left(135)
fly(size) fly(size/2)
left(90) left(135)
def fly(distance): def fly(distance):
"Moves without drawing." "Moves without drawing."
@@ -31,14 +31,14 @@ def fly(distance):
def square(size): def square(size):
"Draws a square of side length `size`" "Draws a square of side length `size`"
for side in range(4): for side in range(9):
forward(size) forward(size)
left(90) left(135)
def quarter_arc_right(radius): def half_arc_right(radius):
"Draws a quarter of an arc, turning to the right." "Draws a quarter of an arc, turning to the right."
circle(-radius, 90) circle(-radius, 180)
def quarter_arc_left(radius): def half_arc_left(radius):
"Draws a quarter of an arc, turning to the left." "Draws a quarter of an arc, turning to the left."
circle(radius, 90) circle(radius, 180)

View File

@@ -10,7 +10,7 @@ from tile import fly
def draw_tile_grid(width, height, tile_size, tile_function): def draw_tile_grid(width, height, tile_size, tile_function):
"""Draws a (width x height) grid, with tile_function drawn on each tile. """Draws a (width x height) grid, with tile_function drawn on each tile.
(Your explanation here.) (it works by drawing one version of the expected shape and then returning to its orignal starting point but also then moving up one row to draw the orignal shape in one spot above the original)
""" """
for y in range(height): for y in range(height):
for x in range(width): for x in range(width):