Last active
February 25, 2025 19:55
-
-
Save sampottinger/f04ec269d0678fa86d397a82e3b7c0f6 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 from the center of a drawing to the user's cursor. | |
# Author: A Samuel Pottinger | |
# License: BSD-3-Clause | |
import sketchingpy | |
import time | |
sketch = sketchingpy.Sketch2D(500, 400) | |
center_x = 500 / 2 | |
center_y = 400 / 2 | |
end_x = 100 | |
end_y = 50 | |
sketch.draw_line(center_x, center_y, end_x, end_y) | |
def draw_moving_line(self): | |
mouse = sketch.get_mouse() | |
sketch.draw_line(250, 200, mouse.get_pointer_x(), mouse.get_pointer_y()) | |
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