Created
September 27, 2022 14:45
-
-
Save tom-ricci/4fc01ce19bdcf8fdf34f55c3698e8416 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
| from cmu_graphics import * | |
| class Settings: | |
| color = "" | |
| x = [] | |
| y = [] | |
| points = [] | |
| def createSettings(): | |
| color = input("What color do you want the shape to be? ") | |
| Settings.color = color | |
| createSettings() | |
| def onMouseRelease(mouseX, mouseY): | |
| Settings.x.append(mouseX) | |
| Settings.y.append(mouseY) | |
| drawPoint(mouseX, mouseY) | |
| def onKeyRelease(key): | |
| if key == "enter" and len(Settings.x) > 0 and len(Settings.y) > 0: | |
| drawShape() | |
| def drawShape(): | |
| p = Polygon(Settings.x[0], Settings.y[0], fill=Settings.color, border=None, borderWidth=2, opacity=100, rotateAngle=0, dashes=False, visible=True) | |
| for i in range(len(Settings.x)): | |
| p.addPoint(Settings.x[i], Settings.y[i]) | |
| p.addPoint(Settings.x[0], Settings.y[0]) | |
| Settings.x = [] | |
| Settings.y = [] | |
| for point in Settings.points: | |
| point.opacity = 0 | |
| Settings.points = [] | |
| def drawPoint(x, y): | |
| c = Circle(x, y, 2, fill=Settings.color, border=None, borderWidth=2, opacity=100, rotateAngle=0, dashes=False, align='center', visible=True) | |
| Settings.points.append(c) | |
| cmu_graphics.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment