Esempio n. 1
0
    def nearest_point(self, x, y, exclude=[]):
        """ Return the point in vector closest to position """
        min = None
        min_dist = 1000000  ## not a great soultion but the simplest
        for point in self.points:
            if not point in exclude:
                dist = util.point_dist(point.pos, (x, y))
                if dist < min_dist:
                    min = point
                    min_dist = dist

        return min, min_dist
Esempio n. 2
0
    def nearest_point(self, x, y, exclude=[]):
        """ Return the point in vector closest to position """
        min = None
        min_dist = 1000000  ## not a great soultion but the simplest
        for point in self.points:
            if not point in exclude:
                dist = util.point_dist(point.pos, (x, y))
                if dist < min_dist:
                    min = point
                    min_dist = dist

        return min, min_dist
Esempio n. 3
0
    def _mouse_moved(self, event):
        pos = event.pos
        if self._mouse_left_is_down:
            if self.mouse_dragging:
                EventManager.post(self.mouse_drag_update, pos=pos)
            elif InputManager.MOUSE_DRAG_THRESHOLD < \
                    util.point_dist(self._mouse_left_down_pos, pos):
                self._mouse_drag_start = pos
                self.mouse_dragging = True
                EventManager.post(self.mouse_drag_start, pos=pos)

        current_active_hotareas = set()
        for hotarea_id in self._hot_area_ids:
            if self._hot_area_rects[hotarea_id].collidepoint(pos):
                current_active_hotareas.add(hotarea_id)

        entered_hotareas = current_active_hotareas - self._active_hotareas
        #left_hotareas = self._active_hotareas - current_active_hotareas

        for hotarea_id in entered_hotareas:
            callback, args = self._hot_area_actions[hotarea_id]
            callback(**args)