diff --git a/src/gui.py b/src/gui.py --- a/src/gui.py +++ b/src/gui.py @@ -2,18 +2,7 @@ from PIL import ImageTk import PIL import math - - -class EPoint: - def __init__(self,x,y): - self.x=x - self.y=y - - def dist(self,a): - return math.sqrt((self.x-a.x)**2+(self.y-a.y)**2) - - def __str__(self): return "({0},{1})".format(self.x,self.y) - def __repr__(self): return "EPoint({0},{1})".format(self.x,self.y) +from epoint import * class Application(tk.Frame): @@ -39,7 +28,8 @@ class Application(tk.Frame): # board with detected stones self.boardView=BoardView(self) self.boardView.grid(column=1,row=0) - + + ## Stores a grid corner located at x,y coordinates. def addCorner(self,x,y): a=EPoint(x,y) for i,c in enumerate(self.corners): # move an improperly placed point @@ -66,6 +56,7 @@ class Application(tk.Frame): self.redrawImgView() + ## Redraws the current image and its overlay. def redrawImgView(self): self.imgView.create_image(2,2,anchor="nw",image=self.img) for corner in self.corners: @@ -73,6 +64,7 @@ class Application(tk.Frame): self.imgView.grid() + ## Marks a point at the image with a green cross. Used for corners. def markPoint(self,x,y): self.imgView.create_line(x-3,y-3,x+4,y+4,fill="#00ff00") self.imgView.create_line(x-3,y+3,x+4,y-4,fill="#00ff00") @@ -80,6 +72,7 @@ class Application(tk.Frame): self.imgView.grid() +## Handles and presents the game state as detected by the program. class BoardView(tk.Canvas): def __init__(self, master=None): tk.Canvas.__init__(self, master)