-
Notifications
You must be signed in to change notification settings - Fork 2k
/
Copy pathdraw.py
35 lines (31 loc) · 1.02 KB
/
draw.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
import mouse
import math
import time
def draw_square(size):
# click and hold the left mouse button
mouse.press()
mouse.move(size, 0, absolute=False, duration=0.2)
mouse.move(0, size, absolute=False, duration=0.2)
mouse.move(-size, 0, absolute=False, duration=0.2)
mouse.move(0, -size, absolute=False, duration=0.2)
# release the left mouse button
mouse.release()
def draw_circle(radius):
# click and hold the left mouse button
mouse.press()
# move the mouse in a circle
for i in range(0, 360, 5):
# convert degrees to radians
angle = math.radians(i)
# calculate the x and y coordinates
x = radius * math.cos(angle)
y = radius * math.sin(angle)
# move the mouse to the calculated position
mouse.move(x, y, absolute=False, duration=0.01)
# release the left mouse button
mouse.release()
if __name__ == "__main__":
# Place the mouse at the starting point and then call
draw_square(200)
time.sleep(1)
draw_circle(10)