graphical strange results with blend() function, EXCLUSION mode
in
Programming Questions
•
3 years ago
Hi all,
I guess my first problem is in relation with following previous discussions (unfortunately I am not abble to understand them totally) :
While using EXCLUSION mode of the blend() function, with only black and white, I got quickly greys with the code bellow :
PGraphics img1;
int nb = 2;
int x, y, a;
boolean bStop;
int nb = 2;
int x, y, a;
boolean bStop;
void setup() {
size(400, 400, P2D);
background(0);
img1 = createGraphics(400, 400, P2D);
img1.ellipseMode(CENTER);
img1.fill(255);
img1.noStroke();
smooth();
}
size(400, 400, P2D);
background(0);
img1 = createGraphics(400, 400, P2D);
img1.ellipseMode(CENTER);
img1.fill(255);
img1.noStroke();
smooth();
}
void draw() {
img1.beginDraw();
img1.background(0);
x = width/nb * int (random(nb+1));
y = int (width/nb * int (random(nb+1)));
a = width/nb*2;
img1.ellipse(x,y,a,a);
img1.endDraw();
blend(img1, 0, 0, width, height, 0, 0, width, height, EXCLUSION);
}
img1.beginDraw();
img1.background(0);
x = width/nb * int (random(nb+1));
y = int (width/nb * int (random(nb+1)));
a = width/nb*2;
img1.ellipse(x,y,a,a);
img1.endDraw();
blend(img1, 0, 0, width, height, 0, 0, width, height, EXCLUSION);
}
void keyPressed(){
bStop = !bStop;
if (bStop)
noLoop();
else
loop();
}
bStop = !bStop;
if (bStop)
noLoop();
else
loop();
}
Another trouble is that it creates outlines around identical superimposed forms as positions and sizes are strictly the same between scrImg and the display window.
And it curiously seems to work better with :
blend(img1, 0, 0, width, height, 0, 0, width
-1,
height-1, EXCLUSION);
??
Thank you for your help!
1
