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
|
class mouse_state:
""" store mouse clicks so we know where to draw and what to create """
button1 = 0
button2 = 0
button3 = 0
cordinates = []
x = y = 0
def append(self, x, y, button=1):
""" store a new mouse click """
self.x = x
self.y = y
self.cordinates.append((x, y,))
def get_click_position(self):
""" return the position of the last click """
return self.x, self.y
def get_points(self):
""" return all stored points we may want to store lots of points when drawing a line for example"""
if len(self.cordinates) != 2:
return None
result = self.cordinates
self.cordinates = []
return result
def count(self):
"""return number of stored points """
return len(self.cordinates)
def clear(self):
self.x = self.y = 0
self.cordinates = []
|