Hey guys,
i am trying to draw a pgraphics image on top of the rest of the sketch here.
It seems to behave weirdly though. In this example i am drawing a line pattern, at z = -50, an ellipse at 0 and the pgraphics image on z = 50
The pgraphics interacts with the circle as expected, it has a transparent background.
With the lines however, it draws a white background on top of the lines. I want the pgraphics image to consistently draw with its transparent background.
What is going on here?
PGraphics pg;
void setup() {
size(1000, 700, P3D);
pg = createGraphics(200, 200, P2D);
}
void draw() {
background(255);
translate(0, 0, -50);
//FOR LOOP LINE PATTERN
for (int i = 0; i <= width; i+=width/50) {
stroke(0, 0, 200);
strokeWeight(3);
if (i <= width-1)line(i, 0, i, height);
}
translate(0, 0, 50);
//SIMPLE BLACK ELLIPSE
fill(0);
ellipse(width/2, height/2, height, height);
translate(0, 0, 50);
//DRAW PGRAPHICS WITH TRANSPARENT BACKGROUND
pg.beginDraw();
//pg.clear();
//pg.background(255, 0);
pg.fill(255, 0, 0);
pg.noStroke();
pg.ellipse(pg.width/2, pg.height/2, pg.width, pg.width);
pg.endDraw();
translate(0, 0, 50);
imageMode(CENTER);
image(pg, mouseX, mouseY);
translate(0, 0, -50);
println(pg.format);
}