Rename XOR tool; Create a true XOR tool
An award-winning drawing program for children of all ages
Brought to you by:
wkendrick
The existing "Exclusive OR" (xor.c) Magic tool doesn't seem to actually have anything to do with the Exclusive OR bitwise operation. It is described in the comments at the top as:
Draws pixels which color depends on previous hue value
(in HSV model) and coordinates
The code takes the HSV of the image, adjusts the existing hue based on the pixel coordinates within the canvas, and draws the results with 100% saturation and value:
SDL_GetRGB(api->getpixel(canvas, x, y), canvas->format, &r, &g, &b);
api->rgbtohsv(r, g, b, &hue, &sat, &val);
if (sat == 0)
xor = (2 * (int)hue + (x ^ y)) % 360;
else
xor = ((int)hue + (x ^ y)) % 360;
api->hsvtorgb(xor, 1, 1, &r, &g, &b);
pixel = SDL_MapRGB(canvas->format, r, g, b);
api->putpixel(canvas, x, y, pixel);
This tool should be renamed.
A tool that actually does an XOR operation could be created. (It could, for example, XOR the R, G and B values on the canvas with those of the currently-chosen color.)
h/t @drypaphmrbro@transfem.social for asking what the current tool does, which made me think about this.
And here I am! Hello from Bluesky, William!