diff --git a/bubbles.py b/bubbles.py new file mode 100644 index 0000000..a9f2dbb --- /dev/null +++ b/bubbles.py @@ -0,0 +1,34 @@ +from turtle import * +from superturtle.animation import animate +from random import random, seed + +HOW_FAR_BUBBLES_GO = 400 + +def random_bubble_x(): + return -200 + 400 * random() + +def random_bubble_y(): + return -200 + 400 * random() + +def random_bubble_size(): + return 10 + 40 * random() + +def generate_bubble_positions(n): + bubble_positions = [] + for i in range(n): + x = random_bubble_x() + y = random_bubble_y() + r = random_bubble_size() + bubble_positions.append([x, y, r]) + return bubble_positions + +def draw_bubbles(bubble_positions, frame): + for x, y, r in bubble_positions: + with frame.translate([x, y], [x, y + HOW_FAR_BUBBLES_GO]): + circle(r) + +number_of_bubbles = 25 +bubble_positions = generate_bubble_positions(number_of_bubbles) +for frame in animate(100): + draw_bubbles(bubble_positions, frame) + diff --git a/turtle.py b/turtle.py new file mode 100644 index 0000000..14ddfb6 --- /dev/null +++ b/turtle.py @@ -0,0 +1,7 @@ +def draw_turtle(frame): + # ... + + +for frame in animate(100): + draw_turtle(frame) + draw_bubbles(frame)