def getIdAtCoordinate(self, x, y): if not self._selection_image: return None px = (0.5 + x / 2.0) * self._viewport_width py = (0.5 + y / 2.0) * self._viewport_height if px < 0 or px > (self._selection_image.width() - 1) or py < 0 or py > (self._selection_image.height() - 1): return None pixel = self._selection_image.pixel(px, py) return self._selection_map.get(Color.fromARGB(pixel), None)
def getIdAtPosition(self, x, y): output = self.getOutput() window_size = self._renderer.getWindowSize() px = (0.5 + x / 2.0) * window_size[0] py = (0.5 + y / 2.0) * window_size[1] if px < 0 or px > (output.width() - 1) or py < 0 or py > (output.height() - 1): return None pixel = output.pixel(px, py) return self._selection_map.get(Color.fromARGB(pixel), None)
def getIdAtPosition(self, x, y): """Get the object id at a certain pixel coordinate.""" output = self.getOutput() window_size = self._renderer.getWindowSize() px = round((0.5 + x / 2.0) * window_size[0]) py = round((0.5 + y / 2.0) * window_size[1]) if px < 0 or px > (output.width() - 1) or py < 0 or py > (output.height() - 1): return None pixel = output.pixel(px, py) return self._selection_map.get(Color.fromARGB(pixel), None)
def getSelectionColorAtCoorindateRadius(self,x,y,radius): if not self._selection_image: return None px = (0.5 + x / 2.0) * self._viewport_width py = (0.5 + y / 2.0) * self._viewport_height squared_radius = radius * radius samples = [] for sx in range(-radius, radius): squared_sx = sx*sx if px + sx < 0 or px + sx > (self._selection_image.width() - 1): continue for sy in range(-radius, radius): squared_sy = sy * sy if py + sy < 0 or py + sy > (self._selection_image.height() - 1): continue if squared_sx + squared_sy < squared_radius: pixel = self._selection_image.pixel(px + sx, py + sy) samples.append(Color.fromARGB(pixel)) return samples
def getSelectionColorAtCoordinate(self,x,y): if not self._selection_image: return None px = (0.5 + x / 2.0) * self._viewport_width py = (0.5 + y / 2.0) * self._viewport_height return Color.fromARGB(self._selection_image.pixel(px,py))