Logo Search packages:      
Sourcecode: uligo version File versions  Download package

def board1::Board::getBoardCoord (   self,
  pos,
  sloppy = 1 
)

transform pixel coordinates on canvas into go board coord. in [1,..,boardSize]x[1,..,boardSize]
    sloppy refers to how far the pixel may be from the intersection in order to
    be accepted 

Definition at line 403 of file board1.py.

00403                                           :
        """ transform pixel coordinates on canvas into go board coord. in [1,..,boardSize]x[1,..,boardSize]
            sloppy refers to how far the pixel may be from the intersection in order to
            be accepted """

        if sloppy: a, b = self.canvasSize[0]-self.canvasSize[1]/2, self.canvasSize[1]-1
        else:      a, b = self.canvasSize[0]-self.canvasSize[1]/4, self.canvasSize[1]/2

        if (pos[0]-a)%self.canvasSize[1] <= b: x = (pos[0]-a)/self.canvasSize[1] + 1
        else:                                  x = 0
        
        if (pos[1]-a)%self.canvasSize[1] <= b: y = (pos[1]-a)/self.canvasSize[1] + 1
        else:                  y = 0

        if x<0 or y<0 or x>self.boardSize or y>self.boardSize: x = y = 0

        return (x,y)    

    def placeMark(self, pos, color):


Generated by  Doxygen 1.6.0   Back to index