I began outlining the program to create the

drawing with functions I think I might need,
and I created a separate file where those functions
will be. This is my first commit of 3.

Somewhere I got stuck was trying to create three
balls in a circular arrangement such that two
had the same y-coordinate and the third had an
x-coordinate between those of the other two. I
knew I needed the turtle to stop and draw a ball
every 120 degrees, but I'd forgotten I needed to
change the heading. After I changed the heading
I realized that the radius had to be adjusted
since the center of the circle is to the turtle's
left. Overall, the math was what I needed to
remind myself of to implement the ideas I had,
but it wasn't always clear to me what math I
would need to think about as I adjusted the
program.

For my next commit, I'll draw out the upper body
of the juggler and then position the turtle so
the juggled balls are in a location that makes
sense relative to the juggler. For my last commit,
my goal is to animate the balls moving in a circle.
I've already started thinking about how I might
do it, so I have an offset to determine where in
the (imaginary) circle the turtle should draw the
first ball.
This commit is contained in:
Cory Dean Chung 2023-08-01 08:29:43 -04:00
parent 7e14ca8de6
commit 4561b95cc9
5 changed files with 71 additions and 15 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

View File

@ -1,7 +1,21 @@
# drawing.py
# ----------
# By ____(you)___________
# By Cory
#
# (Briefly describe what this program does.)
# This program draws the upper body of a juggler juggling balls.
from turtle import *
from helper_functions import *
HALF = 300 # Max x- and y-coordinate the turtle will go to.
# Sets up a square region with max x-coordinate HALF and min -HALF
startingPosition(HALF)
# Draw a person, appropriately scaled
drawPerson(HALF)
# Draw juggling balls, arranged in a circle and appropriately scaled
drawJugglingCircle(HALF,0)
# Do not close immediately
input()

42
helper_functions.py Normal file
View File

@ -0,0 +1,42 @@
from math import *
from turtle import *
from superturtle import *
def startingPosition(HALF):
# Sets up a square region with max x-coordinate HALF and min -HALF
penup()
setup(HALF * 2 + 40, HALF * 2 + 40)
bgcolor("aquamarine")
left(180)
forward(HALF)
left(90)
forward(HALF)
left(90)
pendown()
def drawPerson(HALF):
pass
def drawBall(HALF):
# draw a filled circle
fillcolor("blue")
begin_fill()
circle(HALF / 10.0)
end_fill()
def drawJugglingCircle(HALF,OFFSET):
# Draw 3 balls in a circle. The 3 balls are evenly spaced apart and the first ball starts at OFFSET degrees CCW from the starting position.
right(60)
penup()
circle(2/3 * HALF,OFFSET)
for i in range(2):
pendown()
drawBall(HALF)
penup()
circle(2/3 * HALF,120)
input()
pendown()
drawBall(HALF)
penup()
circle(2/3 * HALF,120-OFFSET)

24
poetry.lock generated
View File

@ -42,13 +42,13 @@ lxml = ["lxml"]
[[package]]
name = "certifi"
version = "2023.5.7"
version = "2023.7.22"
description = "Python package for providing Mozilla's CA Bundle."
optional = false
python-versions = ">=3.6"
files = [
{file = "certifi-2023.5.7-py3-none-any.whl", hash = "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716"},
{file = "certifi-2023.5.7.tar.gz", hash = "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7"},
{file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"},
{file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"},
]
[[package]]
@ -159,13 +159,13 @@ files = [
[[package]]
name = "furo"
version = "2023.5.20"
version = "2023.7.26"
description = "A clean customisable Sphinx documentation theme."
optional = false
python-versions = ">=3.7"
files = [
{file = "furo-2023.5.20-py3-none-any.whl", hash = "sha256:594a8436ddfe0c071f3a9e9a209c314a219d8341f3f1af33fdf7c69544fab9e6"},
{file = "furo-2023.5.20.tar.gz", hash = "sha256:40e09fa17c6f4b22419d122e933089226dcdb59747b5b6c79363089827dea16f"},
{file = "furo-2023.7.26-py3-none-any.whl", hash = "sha256:1c7936929ec57c5ddecc7c85f07fa8b2ce536b5c89137764cca508be90e11efd"},
{file = "furo-2023.7.26.tar.gz", hash = "sha256:257f63bab97aa85213a1fa24303837a3c3f30be92901ec732fea74290800f59e"},
]
[package.dependencies]
@ -342,13 +342,13 @@ files = [
[[package]]
name = "sphinx"
version = "7.0.1"
version = "7.1.1"
description = "Python documentation generator"
optional = false
python-versions = ">=3.8"
files = [
{file = "Sphinx-7.0.1.tar.gz", hash = "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d"},
{file = "sphinx-7.0.1-py3-none-any.whl", hash = "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616"},
{file = "sphinx-7.1.1-py3-none-any.whl", hash = "sha256:4e6c5ea477afa0fb90815210fd1312012e1d7542589ab251ac9b53b7c0751bce"},
{file = "sphinx-7.1.1.tar.gz", hash = "sha256:59b8e391f0768a96cd233e8300fe7f0a8dc2f64f83dc2a54336a9a84f428ff4e"},
]
[package.dependencies]
@ -497,13 +497,13 @@ sphinx = ">=7.0.1,<8.0.0"
[[package]]
name = "urllib3"
version = "2.0.3"
version = "2.0.4"
description = "HTTP library with thread-safe connection pooling, file post, and more."
optional = false
python-versions = ">=3.7"
files = [
{file = "urllib3-2.0.3-py3-none-any.whl", hash = "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1"},
{file = "urllib3-2.0.3.tar.gz", hash = "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825"},
{file = "urllib3-2.0.4-py3-none-any.whl", hash = "sha256:de7df1803967d2c2a98e4b11bb7d6bd9210474c46e8a0401514e3a42a75ebde4"},
{file = "urllib3-2.0.4.tar.gz", hash = "sha256:8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11"},
]
[package.extras]