-
Notifications
You must be signed in to change notification settings - Fork 0
/
paint.py
118 lines (85 loc) · 1.87 KB
/
paint.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
from turtle import *
v = 100
step = 17
t = Turtle()
t.width(5)
t.color('black')
t.shape('circle')
t.pendown()
t.speed(v)
def draw(x, y):
t.goto(x, y)
def move(x, y):
t.penup()
t.goto(x, y)
t.pendown()
def circler():
t.circle(50)
def erase():
t.clear()
def default():
t.color('black')
def setRed():
t.color('red')
def setGreen():
t.color('green')
def setBlue():
t.color('blue')
def setYellow():
t.color('yellow')
def setOrange():
t.color('orange')
def setPurple():
t.color('purple')
def setLime():
t.color('lime')
def setCyan():
t.color('cyan')
def setSilver():
t.color('silver')
def setWhite():
t.color('white')
def stepUp():
t.goto(t.xcor(), t.ycor() + step)
def stepDown():
t.goto(t.xcor(), t.ycor() - step)
def stepLeft():
t.goto(t.xcor() - step, t.ycor())
def stepRight():
t.goto(t.xcor() + step, t.ycor())
def beginFill():
t.begin_fill()
def endFill():
t.end_fill()
def blackening():
scr.bgcolor('black')
def whitening():
scr.bgcolor('white')
t.ondrag(draw)
scr = t.getscreen()
scr.onscreenclick(move)
scr.onkey(default, 'D')
scr.onkey(setRed, 'r')
scr.onkey(setBlue, 'b')
scr.onkey(setGreen, 'g')
scr.onkey(setYellow, 'y')
scr.onkey(setOrange, 'o')
scr.onkey(setPurple, 'p')
scr.onkey(setLime, 'l')
scr.onkey(setCyan, 'c')
scr.onkey(setSilver, 's')
scr.onkey(setWhite, 'w')
scr.onkeypress(beginFill, 'f')
scr.onkeyrelease(endFill, 'f')
scr.onkey(stepUp, 'Up')
scr.onkey(stepDown, 'Down')
scr.onkey(stepLeft, 'Left')
scr.onkey(stepRight, 'Right')
scr.onkey(circler, 'C')
scr.onkey(erase, 'Delete')
scr.onkeypress(blackening, 'space')
scr.onkeyrelease(whitening, 'space')
scr.onkeypress(NInk, 'Tab')
scr.onkeyrelease(Ink, 'Tab')
scr.listen()
done()