diff --git a/setup.py b/setup.py index f05c2ce..f98ab44 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ setuptools.setup( name="spyrograph", - version="0.25.0", + version="0.25.1", author="Chris Greening", author_email="chris@christophergreening.com", description="Library for drawing spirographs in Python", diff --git a/spyrograph/core/_cycloid.py b/spyrograph/core/_cycloid.py index 0f2d2bd..babad0e 100644 --- a/spyrograph/core/_cycloid.py +++ b/spyrograph/core/_cycloid.py @@ -59,7 +59,7 @@ def animate( thetas: List[Number] = None, theta_start: Number = None, theta_stop: Number = None, theta_step: Number = None, origin: Tuple[Number, Number] = (0, 0), - screen_size: Tuple[Number, Number] = (1000, 1000), + screen_size: Tuple[Number, Number] = None, screen_color: str = "white", exit_on_click: bool = False, color: str = "black", width: Number = 1, frame_pause: Number = 0.1, screen: "turtle.Screen" = None, @@ -137,6 +137,14 @@ def animate( R, r, thetas, theta_start, theta_stop, theta_step, origin ) + min_x = min(shapes_arr, key=lambda x: x.min_x).min_x + max_x = max(shapes_arr, key=lambda x: x.max_x).max_x + min_y = min(shapes_arr, key=lambda x: x.min_y).min_y + max_y = max(shapes_arr, key=lambda x: x.max_y).max_y + screen_size = ( + max_x - min_x + padding, + max_y - min_y + padding + ) _draw_animation( shapes_arr=shapes_arr, screen_size=screen_size, screen_color=screen_color, exit_on_click=exit_on_click, color=color, diff --git a/spyrograph/core/_trochoid.py b/spyrograph/core/_trochoid.py index 3053a15..7004b84 100644 --- a/spyrograph/core/_trochoid.py +++ b/spyrograph/core/_trochoid.py @@ -447,6 +447,14 @@ def animate( R, r, d, thetas, theta_start, theta_stop, theta_step, origin ) + min_x = min(shapes_arr, key=lambda x: x.min_x).min_x + max_x = max(shapes_arr, key=lambda x: x.max_x).max_x + min_y = min(shapes_arr, key=lambda x: x.min_y).min_y + max_y = max(shapes_arr, key=lambda x: x.max_y).max_y + screen_size = ( + max_x - min_x + padding, + max_y - min_y + padding + ) _draw_animation( shapes_arr=shapes_arr, screen_size=screen_size, screen_color=screen_color, exit_on_click=exit_on_click, color=color,