If hovering over? pic paste, rotate friendly (detects if over transparent parts of img)

Hi, i’ve been wondering how to detect if mouse (or just X and Y cords) is hovering over an image, and if the image is transparent at x y it isnt hovering over. So if you r hovering over transparent part of img it returns false. That would be a lot, but i’d ask if you could help with some rotate stuff, so same, but img can rotate? Well by that point it would be easier if you would just input img, and a function would: paste img, rotate canvas, by point x and y, so you wouldnt need to find all the other stuff.

Thanks!

Detecting transparent pixels depends on what you consider “transparent”.
Do you mean pixels with an alpha value of 0 (i.e. full transparency) or just less than 255 (no transparency at all)?

well… maby below value? maby int transparentValue = 100; if < 100 than its considered transparent

You can use get()

When the result color is simply similar background color, it’s transparent

If the image being drawn on a PGraphics then you can check for the alpha value of the pixel under the mouse directly with alpha(): https://processing.org/reference/alpha_.html

Note that the main canvas doesn’t support alpha, so you cannot measure alpha directly after a transparent image has been composited onto it – only the background color to the extent that it shows through. If you only have an image that never uses the same color as your canvas background – and only has pixels that are either 100% transparent or 100% opaque – then checking for the background works well. If you have partial transparency or can’t guarantee that image colors won’t match the background then the PGraphics method is more flexible and reliable.