Last active
February 25, 2025 19:55
-
-
Save sampottinger/c991bfe174275c89112e466cc0cfa137 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example for interactivedatascience.courses | |
# Draws a line that responds to time. | |
# Author: A Samuel Pottinger | |
# License: BSD-3-Clause | |
import sketchingpy | |
import time | |
sketch = sketchingpy.Sketch2D(500, 400) | |
start_time = time.time() | |
def draw_moving_line(self): | |
seconds = time.time() - start_time | |
pixels_per_second = 5 | |
offset = seconds * pixels_per_second | |
sketch.draw_line(250, 200, 100, 50 + offset) | |
sketch.on_step(draw_moving_line) | |
sketch.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment