(self, x, y)
return xpos, ypos
Convert physical to logical coordinates within screen bounds.
Convert physical to logical coordinates within screen bounds.
Convert physical to logical coordinates within screen bounds .
def normalise_pos(self, x, y):
        """Convert physical to logical coordinates within screen bounds."""
        if not self._canvas_logical or not self._window_size:
            # window not initialised
            return 0, 0
        border_shift = self._border_shift_logical
        letterbox_shift = self.letterbox_shift
        scale = self._scale
        xpos = min(self._canvas_logical[0] - 1, max(
            0, int((x-letterbox_shift[0]) // scale[0] - border_shift[0])
        ))
        ypos = min(self._canvas_logical[1] - 1, max(
            0, int((y-letterbox_shift[1]) // scale[1] - border_shift[1])
        ))
        return xpos, ypos
def normalise_pos ( self , x , y ) : if not self . _canvas_logical or not self . _window_size : # window not initialised return 0 , 0 border_shift = self . _border_shift_logical letterbox_shift = self . letterbox_shift scale = self . _scale xpos = min ( self . _canvas_logical [ 0 ] - 1 , max ( 0 , int ( ( x - letterbox_shift [ 0 ] ) // scale [ 0 ] - border_shift [ 0 ] ) ) ) ypos = min ( self . _canvas_logical [ 1 ] - 1 , max ( 0 , int ( ( y - letterbox_shift [ 1 ] ) // scale [ 1 ] - border_shift [ 1 ] ) ) ) return xpos , ypos