From 514af40b47248a05f9952c37a0c55ac35d7e8d3c Mon Sep 17 00:00:00 2001 From: Chris Proctor Date: Sun, 25 May 2025 22:06:38 -0400 Subject: [PATCH] Add demo with bouncing beach ball --- demo.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 demo.py diff --git a/demo.py b/demo.py new file mode 100644 index 0000000..84acb46 --- /dev/null +++ b/demo.py @@ -0,0 +1,33 @@ +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)