Processing 2, PGraphics, and P2D
in
Programming Questions
•
1 month ago
In the past when using PGraphics I have always used JAVA2D. I am now using Processing 2 and decided to give P2D a try but encountered a problem. I created the following code as a simple test to explain the problem.
If you take the following program and run it:..
Now change JAVA2D to P2D on the createGraphics() statement.
Note that the program will not run as OpenGL needs the size() statement in order to execute.
So uncomment the size() statement and run the program. The program will run BUT...
while the background statement does execute and create the requested background color, none of the ellipses are written to the PGraphics object. Can someone else give this a try and confirm my findings.
Best Regards, Jim
If you take the following program and run it:..
- PGraphics png;
- String outDir="C:/a_PDE_Output/";
- String filenam;
- float x,y;
- int limitF=100;
- void setup() {
- //size(100,100,P2D);
- png = createGraphics(1024, 768, JAVA2D);
- png.beginDraw();
- png.background(255,210,210);
- }
- void draw() {
- x = random(png.width-1);
- y = random(png.height-1);
- png.fill(random(255),random(255),random(255));
- png.ellipse(x,y,10,10);
- if(frameCount >= limitF) drawEnd();
- }
- void drawEnd() {
- bldFname();
- png.endDraw();
- png.save(filenam);
- println("Saved "+filenam);
- exit();
- }
- void bldFname() {
- String pr = "testing";
- String sx = ".png";
- filenam=outDir+pr+sx;
- }
Now change JAVA2D to P2D on the createGraphics() statement.
Note that the program will not run as OpenGL needs the size() statement in order to execute.
So uncomment the size() statement and run the program. The program will run BUT...
while the background statement does execute and create the requested background color, none of the ellipses are written to the PGraphics object. Can someone else give this a try and confirm my findings.
Best Regards, Jim
1