Help with bitwise operators
in
Programming Questions
•
8 months ago
- PImage P1, P2;
int bg = 0x00;
int fg = 0xFF;
int len1, len2;
void setup()
{
size(512, 512, P3D);
noLoop();
noStroke();
len1 = (8 * width / 13);
}
void draw()
{
//Layer 1
background(bg);
fill(fg);
ellipse(width / 3, height / 2, len1, len1);
P1 = get();
//Layer 2
background(bg);
fill(fg);
ellipse(2 * width / 3, height / 2, len1, len1);
P2 = get();
imageXOR(P1, P2);
image(P1,0,0);
}
void imageXOR(PImage I1, PImage I2)
{
for (int i = 0; i < min(I1.width, I2.width); i++)
for (int j = 0; j < min(I1.height, I2.height); j++)
I1.set(i, j, I1.get(i, j) ^ I2.get(i, j));
}
But the actual output is:
I have copied everything correctly, as far as I can tell. Processing 2.0b7. I can include the other examples' (namely AND and OR) images if things aren't clear enough. Thanks in advance.
1