Invert colors


(NL) #1

Hello.

Is it possible to make a rectangle that inverts pixels colors Inside itself ?
If yes, have you an example ?


(Matt) #2

It is possible using xor. I don’t know of any library or draw function that does it today. I added it to my own drawBitmap function and use it in my games:

Look for wherever it says drawMode == DrawMode.Xor. But unfortunately this function is an absolute beast and I’m not sure how easily you can grab anything from it.

An example, the bats are drawn with xor

xor


(Matt) #3

Thinking more, it’d be a bit different with what you want to do, but still similar. You could go to the screen buffer and wherever the buffer is inside the rectangle, flip the bytes. You’d have to deal with the fact that one byte is 8 pixels though, making it a bit more challenging.