Skip to content

Instantly share code, notes, and snippets.

@sampottinger
Last active February 25, 2025 19:55
Show Gist options
  • Save sampottinger/c991bfe174275c89112e466cc0cfa137 to your computer and use it in GitHub Desktop.
Save sampottinger/c991bfe174275c89112e466cc0cfa137 to your computer and use it in GitHub Desktop.
# 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