generated from mwc/project_drawing
I removed the easing from the bubbles because I
didn't realize how the function worked before and now realized that the function will not animate the bubbles the way that I had envisioned. I may try to use the easing for my turtles swim. I drew the bubbles and have coded the drawing of the top two flippers. I need to complete the changes to the flipper function for the bottom two quadrants. Next step is animating the flippers and then the turtle. I'm a little aprehensive about nesting the animations, but we'll see how it goes.
This commit is contained in:
parent
6bc9ef9f0b
commit
0b609de21e
|
@ -9,9 +9,7 @@ which allows basic formatting.
|
|||
|
||||
## Description
|
||||
|
||||
(I would like to create an animated swimming sea turtle with some bubbles.
|
||||
If you want to link to an
|
||||
)
|
||||
(I would like to create an animated swimming sea turtle with some bubbles.)
|
||||
|
||||
## Planning
|
||||
|
||||
|
|
82
drawing.py
82
drawing.py
|
@ -15,7 +15,7 @@ import random
|
|||
|
||||
def draw_turtle(size):
|
||||
|
||||
|
||||
pencolor("green")
|
||||
#draw an oval for the shell
|
||||
height = size*2
|
||||
width = size*1.5
|
||||
|
@ -54,8 +54,78 @@ def draw_turtle(size):
|
|||
forward(size*1.5)
|
||||
pendown()
|
||||
|
||||
def draw_flipper(size):
|
||||
left(90)
|
||||
draw_flipper(size, 1)
|
||||
draw_flipper(size, 4)
|
||||
|
||||
def draw_flipper(size, quad):
|
||||
|
||||
width = 2.5 * size
|
||||
height = 1.5 * size
|
||||
steps = 100 # Number of points to smooth the curve
|
||||
|
||||
penup()
|
||||
if quad == 1:
|
||||
angle_range = range(0, steps + 1) # Top half
|
||||
|
||||
for i in angle_range:
|
||||
angle = math.pi * i / steps # Only go from 0 to π radians
|
||||
x = ((width / 2) * math.cos(angle))+(size*2)
|
||||
y = ((height / 2) * math.sin(angle))+size
|
||||
if i == angle_range[0]:
|
||||
goto(x , y )
|
||||
pendown()
|
||||
else:
|
||||
goto(x, y)
|
||||
forward (size*2.5)
|
||||
|
||||
|
||||
elif quad == 4:
|
||||
angle_range = range(0, steps + 1) # Top half
|
||||
|
||||
for i in angle_range:
|
||||
angle = math.pi * i / steps # Only go from 0 to π radians
|
||||
x = ((width / 2) * math.cos(angle))-(size*2)
|
||||
y = ((height / 2) * math.sin(angle))+size
|
||||
if i == angle_range[0]:
|
||||
goto(x , y )
|
||||
pendown()
|
||||
else:
|
||||
goto(x, y)
|
||||
|
||||
forward (size*2.5)
|
||||
|
||||
|
||||
elif quad == 3:
|
||||
angle_range = range(0, steps + 1) # Top half
|
||||
|
||||
for i in angle_range:
|
||||
angle = math.pi * i / steps # Only go from 0 to π radians
|
||||
x = ((width / 2) * math.cos(angle))-(size*2)
|
||||
y = ((height / 2) * math.sin(angle))+size
|
||||
if i == angle_range[0]:
|
||||
goto(x , y )
|
||||
pendown()
|
||||
else:
|
||||
goto(x, y)
|
||||
forward (size*2.5)
|
||||
|
||||
|
||||
else:
|
||||
angle_range = range(0, steps + 1) # Top half
|
||||
|
||||
for i in angle_range:
|
||||
angle = math.pi * i / steps # Only go from 0 to π radians
|
||||
x = ((width / 2) * math.cos(angle))-(size*2)
|
||||
y = ((height / 2) * math.sin(angle))+size
|
||||
if i == angle_range[0]:
|
||||
goto(x , y )
|
||||
pendown()
|
||||
else:
|
||||
goto(x, y)
|
||||
forward (size*2.5)
|
||||
|
||||
|
||||
|
||||
|
||||
def draw_bubble(b_size):
|
||||
pencolor("blue")
|
||||
|
@ -89,13 +159,15 @@ def place_bubbles(number):
|
|||
draw_bubble(b_size)
|
||||
fly(0,0)
|
||||
|
||||
|
||||
"""
|
||||
#pass the number of bubbles you want in each quadrant (so it will be 4 X what you pass)
|
||||
for frame in animate(50, loop=True):
|
||||
for frame in animate(50, loop=False):
|
||||
x = frame.interpolate(-10, 10)
|
||||
y = frame.interpolate(20, -10, easing=easeInQuad)
|
||||
fly(x, y)
|
||||
place_bubbles(1)
|
||||
"""
|
||||
place_bubbles(5)
|
||||
|
||||
draw_turtle(20)
|
||||
|
||||
|
|
Loading…
Reference in New Issue