We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › PGraphics problem.
Page Index Toggle Pages: 1
PGraphics problem. (Read 1113 times)
PGraphics problem.
Jan 15th, 2010, 10:11pm
 
I'm working on this Processing example on PGraphics:
I've changed only two things: specifying the Processing renderer to be P2D, commenting the background for the PGraphics. What happened was unexpected. The PGraphics fades into a black background. Just run the program and see it for yourself. It's weird like the alpha channel is messed up gradually. If I change P2D to JAVA2D or leave it blank (default?), the problem is gone. Any idea? Thanks.

PGraphics pg;

void setup() {
 size(100, 100, P2D);
 pg = createGraphics(80, 80, P3D);
}

void draw() {
 pg.beginDraw();
//  pg.background(102);
 pg.stroke(255);
 pg.line(40, 40, mouseX, mouseY);
 pg.endDraw();
 image(pg, 10, 10);
}
Re: PGraphics problem.
Reply #1 - Jan 16th, 2010, 1:46am
 
Maybe the issue is that you're using P2D. Looking a the createGraphics reference I notice:

Quote:
renderer      Either P2D (not yet implemented), P3D, JAVA2D, PDF, DXF


Also:

Quote:
Note that transparency levels are binary: pixels are either complete opaque or transparent.


which might have some bearing...
Re: PGraphics problem.
Reply #2 - Jan 16th, 2010, 4:38am
 
Yes, it is a well known restriction, that transparency works only in JAVA2D mode.

The "not yet implemented" notice on P2D mentioned by blindfish is probably an overlook of the authors, AFAIK it have been implemented for quite some time now.
Re: PGraphics problem.
Reply #3 - Jan 16th, 2010, 7:49pm
 
Thanks guys. I thought P2D for PGraphics is not supported but it looks like P2D for the entire windows is also not well supported. I tried to use JAVA2D for both size() and PGraphics but my program (too long to post) freezes my machine. I probably drew too many lines on the PGraphics.
Re: PGraphics problem.
Reply #4 - Jan 16th, 2010, 8:57pm
 
Don't mean to hijack your thread but two PGraphics threads on the same page seemed redundant.

I'm also having problems with PGraphics and transparency. I am making a simple animation program: you draw on the screen, then save the frame (to an Arraylist) and start drawing a new one. It is supposed to onion skin the last frame underneath yours (but I have to keep it from saving with the frame) so I implemented multiple PGraphics objects that act as layers.

It works perfectly for some times; I can draw on the middle layer, and it appears below the top one and above the bottom one (which would be the onion skin). But, when I save the draw layer as a PImage using the .get() function for PGraphics, it is solid black. It is supposed to be a transparent background with line drawings. My method worked before I added layers...and transparency with them. Any ideas/experience? I may make another thread on this, and if anyone wants me to send them the code so they can take a look I would GREATLY appreciate it.
Page Index Toggle Pages: 1