-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoint.py
More file actions
29 lines (22 loc) · 1013 Bytes
/
Copy pathPoint.py
File metadata and controls
29 lines (22 loc) · 1013 Bytes
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
#############################################################
## IMPORTS
from Vector import Vector
#############################################################
## POINT
class Point():
def __init__(self, canvas, pos = (400,250), mass = 1e8, radius = 4, color="#CF333A", tag="Point"):
self.canvas = canvas
self.pos = Vector(pos[0], pos[1])
self.mass = mass
self.radius = radius
self.color = color
self.tag = tag
self.create_body()
def create_body(self):
self.item = self.canvas.create_oval(self.pos.x - self.radius, self.pos.y-self.radius, self.pos.x+self.radius, self.pos.y + self.radius, fill = self.color, outline = "black", tags=self.tag)
def set_radius(self, new_radius):
self.radius = new_radius
self.create_body()
def move(self,x ,y):
self.pos = Vector(x + self.radius, y + self.radius)
self.canvas.moveto(self.item, int(x)-self.radius-1, int(y)-self.radius-1)