generated from mwc/project_drawing
34 lines
814 B
Python
34 lines
814 B
Python
from turtle import *
|
|
from superturtle.movement import fly
|
|
from superturtle.animation import animate
|
|
from superturtle.easing import easeOutBounce
|
|
|
|
def nopen(distance):
|
|
"Move with the pen up"
|
|
penup()
|
|
forward(distance)
|
|
pendown()
|
|
|
|
def beachball(radius, n_seams=6):
|
|
"""Draws a beach ball centered at the turtle's current position.
|
|
When finished, leaves the turtle at the original position.
|
|
"""
|
|
left(90)
|
|
nopen(radius)
|
|
right(90)
|
|
circle(radius)
|
|
left(90)
|
|
nopen(radius)
|
|
right(90)
|
|
|
|
for seam in range(n_seams):
|
|
circle(radius/2, 180)
|
|
circle(radius/2, -180)
|
|
right(360/n_seams)
|
|
|
|
for frame in animate(256, loop=True):
|
|
x = frame.interpolate(-100, 100)
|
|
y = frame.interpolate(200, -100, easing=easeOutBounce)
|
|
fly(x, y)
|
|
beachball(40)
|