Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python plugin: point in selection?
#2
From one of my scripts:

Code:
def isSelectedPoint(point,image):
   x,y=point.pixelX,point.pixelY
   return 0<=x<image.width and 0<=y<image.height and image.selection.get_pixel(x,y)[0] > 0

Instead of testing >0 you may want to try >127.

In my Point class, pixelX and pixelY are pseudo attributes:
Code:
    @property
    def pixelX(self):
        return int(math.floor(self.x))

    @property
    def pixelY(self):
        return int(math.floor(self.y))
Reply


Messages In This Thread
RE: Python plugin: point in selection? - by Ofnuts - 01-23-2021, 12:36 PM

Forum Jump: