diff --git a/src/doodles/examples/balls.py b/src/doodles/examples/balls.py index 1dccb0e..35b1000 100644 --- a/src/doodles/examples/balls.py +++ b/src/doodles/examples/balls.py @@ -24,7 +24,6 @@ class Ball(Circle): if self.y > world.HEIGHT + 20: self.move(0, -world.HEIGHT-20) -balls = [Ball().pos(40*i, 0).radius(10).color(Color.BLUE) for i in range(21)] class GravityBall(Circle): @@ -40,5 +39,6 @@ class GravityBall(Circle): self.speed *= -0.98 # dampening self.pos(self.x, world.HEIGHT - 10.01) - -grav = [GravityBall().pos(20+40*i, 0).radius(10).color(Color.PURPLE) for i in range(21)] +def create(): + balls = [Ball().pos(40*i, 0).radius(10).color(Color.BLUE) for i in range(21)] + grav = [GravityBall().pos(20+40*i, 0).radius(10).color(Color.PURPLE) for i in range(21)] diff --git a/src/doodles/examples/circles.py b/src/doodles/examples/circles.py index b81f443..0c059ba 100644 --- a/src/doodles/examples/circles.py +++ b/src/doodles/examples/circles.py @@ -1,10 +1,9 @@ from doodles.doodles import Group, Circle, Color from doodles.world import world -c = Circle() - -g = Group().pos(400, 300) -for r in range(20, 50, 5): - Circle(g).radius(r).color(Color.random()).z_index(-r) -for r in range(60, 150, 10): - Circle(g).radius(r).color(Color.random()).z_index(-r) +def create(): + g = Group().pos(400, 300) + for r in range(20, 50, 5): + Circle(g).radius(r).color(Color.random()).z_index(-r) + for r in range(60, 150, 10): + Circle(g).radius(r).color(Color.random()).z_index(-r) diff --git a/src/doodles/examples/copies.py b/src/doodles/examples/copies.py index b11aecd..28a8b46 100644 --- a/src/doodles/examples/copies.py +++ b/src/doodles/examples/copies.py @@ -7,10 +7,7 @@ def original(): c = c.copy().move(45, 45) return g -r = original() -r.copy().move(200, 0).color(Color.GREEN) -r.copy().move(400, 0).color(Color.BLUE) - -# from doodles.world import world -# for d in world._drawables: -# print(" >", d) +def create(): + r = original() + r.copy().move(200, 0).color(Color.GREEN) + r.copy().move(400, 0).color(Color.BLUE) diff --git a/src/doodles/examples/grid.py b/src/doodles/examples/grid.py index f9fda6f..6f7cd10 100644 --- a/src/doodles/examples/grid.py +++ b/src/doodles/examples/grid.py @@ -9,5 +9,6 @@ def same_spiral(): Line(g).vec(d, 200 - d) yield g -# Make copies, moving each one and modifying the color -make_grid(same_spiral(), 3, 4, 250, 140, x_offset=70, y_offset=20) +def create(): + # Make copies, moving each one and modifying the color + make_grid(same_spiral(), 3, 4, 250, 140, x_offset=70, y_offset=20) diff --git a/src/doodles/examples/rects.py b/src/doodles/examples/rects.py index 992c8b4..eb9c169 100644 --- a/src/doodles/examples/rects.py +++ b/src/doodles/examples/rects.py @@ -1,5 +1,5 @@ from doodles.doodles import Group, Rectangle, Color -for _ in range(100): - r = Rectangle().random(250) - +def create(): + for _ in range(100): + r = Rectangle().random(250) diff --git a/src/doodles/main.py b/src/doodles/main.py index 00d235e..69cde13 100644 --- a/src/doodles/main.py +++ b/src/doodles/main.py @@ -30,7 +30,7 @@ def load_module(modname): raise ImportError( f"Tried to import {modname} and doodles.examples.{modname}" ) - return mod + return mod.create() def main(modname: str = None):