hi,
how can i please implement a function into a createGraphics layer?
i want to have the drawCircl function (bottom) run within the PGraphics, as the ellipse sample i put in is working..
thank you!
how can i please implement a function into a createGraphics layer?
i want to have the drawCircl function (bottom) run within the PGraphics, as the ellipse sample i put in is working..
thank you!
- PGraphics pg;
PGraphics pgAux;
float Rad;
void setup(){
size (800,600);
pg = createGraphics (width, height, P2D);
pgAux = createGraphics (width, height, P2D);
background(0);
}
void draw() {
pg.beginDraw();
pg.smooth();
pg.background(0);
pg.image(pgAux, 0,0, width, height);
pg.stroke(255,5);
pg.fill(random(255),222);
Rad = random(15)+width*noise(frameCount)/11;
pg.ellipse(random(width), random(height), Rad,Rad); // this works
pg.drawCircl(random(width), random(height), random(0.5,1)); // this works not:( ..how to implement a function into createGraphics ???
pg.endDraw();
image (pg, 0, 0);
pgAux.beginDraw();
//pgAux.background(0,5);
pgAux.image (pg,-1, -1, width+2, height+2);
pgAux.endDraw();
}
void drawCircl(float x,float y,float scal) {
//pg.beginDraw();
translate(x,y);
scal=random(0.1,10.3);
int num=(int)random(10,101);
for(float i=0; i<num; i++) {
for(int j = 0; j < 22; j += 4) {
strokeWeight (random (0.6,1.3));
ellipse (0,j,i,i);
rotate(radians(360/num));
}
}
//pg.endDraw();
}
1