Hi, I’m trying to draw green pixel from a layer to a PImage.
But I’ve got this result unexpected :
The code seems ok, there is something I don’t understand.
PImage result;
PGraphics msk;
void setup() {
size(360, 200);
msk = createGraphics(width, height);
result = createImage(width, height, ARGB);
noLoop();
}
void draw() {
msk.beginDraw();
msk.background(0, 255);
msk.stroke(0, 255, 0);
msk.noFill();
msk.strokeWeight(6);
msk.circle(260, 60, 32);
msk.loadPixels();
for (int i=0; i<width; i++) {
for (int j=0; j<height; j++) {
if (msk.pixels[i*height+j]==#FF00FF00) {
result.set(i, j, #FFFFFFFF);// this line is not correct
}
}
}
msk.updatePixels();
msk.endDraw();
image(msk, 0, 0);
image(result, 0, 0);
}
Thanks for help !