Inverted cursor coloring?

Would it be possible to use something like masking to make a custom cursor sprite the inverted color of what’s behind it, if so, how?

Hi ResinTheFuriousMage, ooh interesting idea. I don’t think you’d need masking. If I was trying this, I’d make my custom cursor object with a small transparent “hole” in the centre. Then I’d get the ReadPixels extension and use that to read the color at the point where the hole is. And then change the color of the cursor to that color.

Oops, I forgot you want the opposite of the color. That makes it more complicated but should still be possible, maybe with an effect? If not, you’d have to find out how to mathematically maybe? find a color’s opposite.

Well, I love this kind of thing so I made it!

I used two extensions, ReadPixels and CursorObject.

Make a custom point on your cursor object. I called my custom point “Sensor”. This would be in the transparent hole. Or you could just have no hole and have the point somewhere outside the cursor, maybe at the tip.

My custom cursor has three number variables - red, green and blue.
The ReadPixels extension reads the pixels at the “Sensor” custom point in the cursor and saves them to the variables. But not the actual value, but instead 255 - the value. This inverts each rgb color.

Then these three number variables get saved to a scene string variable “RGBColor”.

The cursor object has the ColorReplace effect with the Original color parameter set to white (the color of my custom cursor).

The ColorReplace effect changes the NewColor parameter to the "RGBColor variable.

Cursor


Hi!

Good work.

Xierra

I’m sorry, this wasn’t exactly what I wanted.
I have a crosshair sprite in my game, the crosshair consists of one solid color and it’s hard to see sometimes.
Games use this strategy to make the cursor visible.
The desired result is to change every pixel of the cursor to the opposite of the color behind it.
I don’t think it’d be possible to simply change the single color of the cursor to get this result, but rather do something a bit more complicated.
I do still appreciate the effort.

No worries, it was fun. But I don’t get your explanation though. If my cursor was a crosshair and didn’t have a black outline, wouldn’t it achieve this:

I think they are referring to subtractive blending, which is unfortunately not supported by the Pixi WebGL renderer:

Various blend modes supported by PIXI.
 *
 * IMPORTANT - The WebGL renderer only supports the NORMAL, ADD, MULTIPLY and SCREEN blend modes.
 * Anything else will silently act like NORMAL.

A Minecraft crosshair for example:


@magicsofa, yes I believe that’s correct.
Would it be possible to achieve this in any way?
Or is it impossible?

Maybe we can make each pixel of the crosshair separately
Each P is a pixel blocks that are arranged to form a crosshair. And there should be white so we can tint it.
[PP]
[PP]
[PP]
[PP][PP][PP][PP][PP]
[PP]
[PP]
[PP]

Then we check for each of 22 Ps to see color behind them and then invert the BG and tint the P to the inverted color. We can run this every frame if its cheap or every 0.2s and after mouse move.

I was considering that when I made the game I was talking about. I think that would definitely work. It wasn’t what I had in mind, though. It seems like it’d be a very unoptimized method of doing it but likely the only way to do it.

ReadPixels is not cheap… you might be able to get away with it as long as the crosshair doesn’t have too many pixels

@magicsofa was right it ain’t cheap? I just got the custom pixel working and I am hitting a 9-17 FPS range. Maybe a repeat every 0.2 s would fix this.