diff CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/turtledemo/paint.py @ 68:5028fdace37b

planemo upload commit 2e9511a184a1ca667c7be0c6321a36dc4e3d116d
author jpayne
date Tue, 18 Mar 2025 16:23:26 -0400
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CSP2/CSP2_env/env-d9b9114564458d9d-741b3de822f2aaca6c6caa4325c4afce/lib/python3.8/turtledemo/paint.py	Tue Mar 18 16:23:26 2025 -0400
@@ -0,0 +1,54 @@
+#!/usr/bin/env python3
+"""       turtle-example-suite:
+
+            tdemo_paint.py
+
+A simple  event-driven paint program
+
+- left mouse button moves turtle
+- middle mouse button changes color
+- right mouse button toggles between pen up
+(no line drawn when the turtle moves) and
+pen down (line is drawn). If pen up follows
+at least two pen-down moves, the polygon that
+includes the starting point is filled.
+ -------------------------------------------
+ Play around by clicking into the canvas
+ using all three mouse buttons.
+ -------------------------------------------
+          To exit press STOP button
+ -------------------------------------------
+"""
+from turtle import *
+
+def switchupdown(x=0, y=0):
+    if pen()["pendown"]:
+        end_fill()
+        up()
+    else:
+        down()
+        begin_fill()
+
+def changecolor(x=0, y=0):
+    global colors
+    colors = colors[1:]+colors[:1]
+    color(colors[0])
+
+def main():
+    global colors
+    shape("circle")
+    resizemode("user")
+    shapesize(.5)
+    width(3)
+    colors=["red", "green", "blue", "yellow"]
+    color(colors[0])
+    switchupdown()
+    onscreenclick(goto,1)
+    onscreenclick(changecolor,2)
+    onscreenclick(switchupdown,3)
+    return "EVENTLOOP"
+
+if __name__ == "__main__":
+    msg = main()
+    print(msg)
+    mainloop()