Hi all, i've made a simple program to test some "glow effect"; but on my mac g4 i got really poor performance, about 6 fps for just 3 circles...
here's the code:
Code:
PGraphics[] circles;
void setup() {
size(500, 500);
frameRate(30);
circles = new PGraphics[3];
circles[0] = makeCircle(color(255, 0, 0));
circles[1] = makeCircle(color(0, 255, 0));
circles[2] = makeCircle(color(0, 0, 255));
}
void draw() {
background(0);
/* uncomment this to get slow
circles[0] = makeCircle(color(255, 0, 0));
circles[1] = makeCircle(color(0, 255, 0));
circles[2] = makeCircle(color(0, 0, 255));
*/
print("frame rate: " + frameRate + "\n");
image(circles[0], random(0,500), random(0,500));
image(circles[1], random(0,500), random(0,500));
image(circles[2], random(0,500), random(0,500));
}
PGraphics makeCircle (color c) {
PGraphics pg = createGraphics(100, 100, JAVA2D);
pg.beginDraw();
pg.noFill();
pg.stroke(c);
pg.strokeWeight(10);
pg.ellipse(50,50,50,50);
pg.loadPixels();
pg.filter(BLUR,4);
pg.strokeWeight(1);
pg.smooth();
pg.ellipse(50,50,50,50);
pg.endDraw();
return pg;
}
i've also tried to remove the blur filter, but the problem seems to be also creating the PGraphics in the draw loop ...
in this example i don't need it, so i can create the circles only in the setup function, but if (for example) i need to canhge the colors dinamically?
of course i can draw directly without using PGraphics, but then i dunno how to obtain the glow effect with an efficient method ...