Hi @bplus
Nice graphics! I like it! :)
I modified your a code a little and I have used _MEM instead of POINT for getting color (_MEM is faster than POINT )
_Title "XOR Magic ^2" ' b+ revisit 2021-04-09 'MEM mod by Ashish
'c~& = Point(x, y)
'cAnalysis c~&, r, g, b, a
If you’re looking for speed, move as much math as possible outside your loop.
For y = 0 To (_Height -1) * 4 * _WIDTH STEP 4 * _WIDTH
For x = 0 To (_Width - 1) * 4 STEP 4
t = y + x
b = _MemGet(m, m.OFFSET + t, _Unsigned _Byte)
g = _MemGet(m, m.OFFSET + t + 1, _Unsigned _Byte)
r = _MemGet(m, m.OFFSET + t + 2, _Unsigned _Byte)
a = _MemGet(m, m.OFFSET + t + 3, _Unsigned _Byte)
'c~& = Point(x, y)
'cAnalysis c~&, r, g, b, a
PSet (x, y), _RGB32(r Xor red, g Xor green, b Xor blue, a)
Next
Next
The fewer math calculations you do inside your loop, the faster it can process — which can really affect performance with _MEM.
Personally, since this checks the whole screen, I’d just make it a simple DO...LOOP
t = 0
DO UNTIL t >= m.size
b = _MemGet(m, m.OFFSET + t, _Unsigned _Byte)
g = _MemGet(m, m.OFFSET + t + 1, _Unsigned _Byte)
r = _MemGet(m, m.OFFSET + t + 2, _Unsigned _Byte)
_MEMPUT m, m.OFFSET + t, _RGB32(r Xor red, g Xor green, b Xor blue) AS STRING * 3
t = t + 4
LOOP
Once it’s right, $CHECKING:OFF before it and $CHECKING:ON after it, and you’re not going to get it any faster. (And since you’re not changing alpha levels at all, I don’t think you’re going to need to read or write them either, unless I’m missing something.)