Issues with transparency in an offscreen graphic
in
Programming Questions
•
6 months ago
Hey, I'm trying to make a paint program, but for some reason when I try to use the transparency it shows up as a darker shade of what I want. The code I attached shows the issue. the commented out section is the desired effect, and I need to have multiple PGraphics. Each PGraphic is a different layer, so the actual program with display them on top of each other. Any suggestions or things I didn't explain well?
- void setup(){
- size(400,400);
- img=createGraphics(width,height,P2D);
- noStroke();
- }
- PGraphics img;
- void draw(){
- if(mousePressed){
- img.beginDraw();
- img.noStroke();
- img.fill(255,0,0,40);
- img.ellipse(mouseX,mouseY,30,30);
- img.endDraw();
- }
- image(img,0,0);
- }
- /*
- void draw(){
- if(mousePressed){
- fill(255,0,0,40);
- ellipse(mouseX,mouseY,30,30);
- }
- }
- */
1

However, the goal is to be able to see the layers through each other. It's a good way to get the layers to change order, but you can't see through each of them. What about this: each layer remains off-screen, but I load all of the bottom layer's pixels onto the screen as points, then the next layers pixels, and so on. You don't see any of the images, just the points that are the same color and location are being put together on screen (if this makes sense).