generated from mwc/project_drawing
Commit 2. I made a juggler and arranged the balls.
This took far too much time to do. What I realized about my own work habits is not having strict due dates makes it easy for me to procrastinate... (In good news, I'm finished with my summer job, so I should be able to get back on track quickly.) I also don't consider myself a creative or artistic person, so it took a while to build any sort of momentum. Something I hadn't anticipated was having degrees() from math not work. I had imported the functions in the same way we had imported those from turtle, and I had previously used degrees() in another assignment, so I was surprised degrees() didn't behave as I thought it would. I'm not sure what the difference between from math import * and import math is, or what it means to say something like math.degrees, but I ended up doing the latter and got it to work. It's interesting to me to have all this documentation and information online while at the same time not knowing what's immediately useful or important to focus on, or even what I'm ready to understand and know yet.
This commit is contained in:
parent
4561b95cc9
commit
da2ba3566d
Binary file not shown.
|
@ -2,11 +2,11 @@
|
|||
# ----------
|
||||
# By Cory
|
||||
#
|
||||
# This program draws the upper body of a juggler juggling balls.
|
||||
# This program draws the juggling upper body of a bald juggler.
|
||||
|
||||
from helper_functions import *
|
||||
|
||||
HALF = 300 # Max x- and y-coordinate the turtle will go to.
|
||||
HALF = 200 # 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)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from math import *
|
||||
import math # degrees() from math wasn't working so I have this to do math.degrees() instead...
|
||||
from turtle import *
|
||||
from superturtle import *
|
||||
|
||||
|
@ -12,31 +12,139 @@ def startingPosition(HALF):
|
|||
left(90)
|
||||
forward(HALF)
|
||||
left(90)
|
||||
pendown()
|
||||
|
||||
def drawPerson(HALF):
|
||||
pass
|
||||
# Turtle starts and ends at starting position
|
||||
drawBody(HALF)
|
||||
drawHead(HALF)
|
||||
drawFace(HALF)
|
||||
|
||||
def drawBody(HALF):
|
||||
# Turtle starts at starting position
|
||||
fillcolor("green")
|
||||
begin_fill()
|
||||
forward(HALF * 4 / 5.0)
|
||||
pendown()
|
||||
forward(HALF * 2 / 5.0)
|
||||
left(90)
|
||||
forward(HALF / 2.0)
|
||||
right(180)
|
||||
forward(HALF / 5.0)
|
||||
left(90)
|
||||
forward(HALF / 10.0)
|
||||
left(45)
|
||||
forward(HALF * math.sqrt(2) / 5.0)
|
||||
left(135)
|
||||
forward(HALF / 10.0)
|
||||
left(45)
|
||||
forward(HALF * math.sqrt(2) / 10.0)
|
||||
right(135)
|
||||
forward(HALF / 5.0)
|
||||
left(90)
|
||||
forward(HALF / 5.0)
|
||||
left(45)
|
||||
forward(HALF * math.sqrt(2) / 10.0)
|
||||
right(90)
|
||||
forward(HALF * math.sqrt(2) / 10.0)
|
||||
left(45)
|
||||
forward(HALF / 5.0)
|
||||
left(90)
|
||||
forward(HALF / 5.0)
|
||||
right(135)
|
||||
forward(HALF * math.sqrt(2) / 10.0)
|
||||
left(45)
|
||||
forward(HALF / 10.0)
|
||||
left(135)
|
||||
forward(HALF * math.sqrt(2) / 5.0)
|
||||
left(45)
|
||||
forward(HALF / 10.0)
|
||||
left(90)
|
||||
forward(HALF / 5.0)
|
||||
left(180)
|
||||
forward(HALF / 2.0)
|
||||
penup()
|
||||
end_fill()
|
||||
|
||||
|
||||
def drawHead(HALF):
|
||||
# Turtle starts from where drawBody ended
|
||||
neckHeadAngle = math.degrees(math.acos(.35))
|
||||
fillcolor("bisque")
|
||||
right(180)
|
||||
forward(.6 * HALF)
|
||||
right(90)
|
||||
forward(.1 * HALF)
|
||||
begin_fill()
|
||||
pendown()
|
||||
right(45)
|
||||
forward(.1 * math.sqrt(2) * HALF)
|
||||
left(90)
|
||||
forward(.1 * math.sqrt(2) * HALF)
|
||||
left(135)
|
||||
forward(.05 * HALF)
|
||||
right(90)
|
||||
forward(.1 * HALF)
|
||||
right(neckHeadAngle)
|
||||
circle(HALF / 7.0, 180 + 2 * neckHeadAngle)
|
||||
right(neckHeadAngle)
|
||||
forward(.1 * HALF)
|
||||
right(90)
|
||||
forward(.05 * HALF)
|
||||
penup()
|
||||
end_fill()
|
||||
|
||||
def drawFace(HALF):
|
||||
# Turtle starts from where drawHead ended and returns to starting position
|
||||
right(90)
|
||||
forward(1.7 * HALF / 7.0)
|
||||
right(90)
|
||||
forward(.025 * HALF)
|
||||
left(90)
|
||||
pendown()
|
||||
forward(.025 * HALF)
|
||||
penup()
|
||||
right(90)
|
||||
forward(.15 * HALF)
|
||||
right(90)
|
||||
pendown()
|
||||
forward(.025 * HALF)
|
||||
penup()
|
||||
forward(.05 * HALF)
|
||||
pendown()
|
||||
circle(-0.075 * HALF,180)
|
||||
penup()
|
||||
right(180)
|
||||
forward(27 * HALF / 140.0)
|
||||
right(90)
|
||||
forward(37 * HALF / 40.0)
|
||||
left(90)
|
||||
forward(3 * HALF / 5.0)
|
||||
print("C")
|
||||
print(position())
|
||||
left(90)
|
||||
|
||||
def drawJugglingCircle(HALF,OFFSET):
|
||||
# Turtle starts and ends from starting position
|
||||
# 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.
|
||||
forward(.5 * HALF)
|
||||
left(90)
|
||||
forward(.5 * HALF)
|
||||
right(150)
|
||||
penup()
|
||||
circle(math.sqrt(3) /3 * HALF,OFFSET)
|
||||
for i in range(2):
|
||||
pendown()
|
||||
drawBall(HALF)
|
||||
penup()
|
||||
circle(math.sqrt(3) /3 * HALF,120)
|
||||
pendown()
|
||||
drawBall(HALF)
|
||||
penup()
|
||||
circle(math.sqrt(3) /3 * HALF,120-OFFSET)
|
||||
|
||||
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)
|
||||
|
||||
end_fill()
|
|
@ -285,13 +285,13 @@ files = [
|
|||
|
||||
[[package]]
|
||||
name = "pygments"
|
||||
version = "2.15.1"
|
||||
version = "2.16.1"
|
||||
description = "Pygments is a syntax highlighting package written in Python."
|
||||
optional = false
|
||||
python-versions = ">=3.7"
|
||||
files = [
|
||||
{file = "Pygments-2.15.1-py3-none-any.whl", hash = "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1"},
|
||||
{file = "Pygments-2.15.1.tar.gz", hash = "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c"},
|
||||
{file = "Pygments-2.16.1-py3-none-any.whl", hash = "sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692"},
|
||||
{file = "Pygments-2.16.1.tar.gz", hash = "sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
|
@ -342,13 +342,13 @@ files = [
|
|||
|
||||
[[package]]
|
||||
name = "sphinx"
|
||||
version = "7.1.1"
|
||||
version = "7.1.2"
|
||||
description = "Python documentation generator"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "sphinx-7.1.1-py3-none-any.whl", hash = "sha256:4e6c5ea477afa0fb90815210fd1312012e1d7542589ab251ac9b53b7c0751bce"},
|
||||
{file = "sphinx-7.1.1.tar.gz", hash = "sha256:59b8e391f0768a96cd233e8300fe7f0a8dc2f64f83dc2a54336a9a84f428ff4e"},
|
||||
{file = "sphinx-7.1.2-py3-none-any.whl", hash = "sha256:d170a81825b2fcacb6dfd5a0d7f578a053e45d3f2b153fecc948c37344eb4cbe"},
|
||||
{file = "sphinx-7.1.2.tar.gz", hash = "sha256:780f4d32f1d7d1126576e0e5ecc19dc32ab76cd24e950228dcf7b1f6d3d9e22f"},
|
||||
]
|
||||
|
||||
[package.dependencies]
|
||||
|
|
Loading…
Reference in New Issue