Hi everyone,
I've written a brush class which simulates a brushstroke (in a basic way). I need to be able to make these brushstrokes in a PGraphics buffer, but I can't seem to get it to work....
code here:
http://pastebin.ca/1840461I wrote the program below as a simple model - just drawing a rectangle instead of something more complicated....and this does work......what is the difference
Code:PGraphics pg;
rectangle r;
void setup()
{
size(300,300);
pg=createGraphics(width,height,P2D);
r = new rectangle(100, 100, 50, 60, PI/8, color(100, 200, 100));
pg.beginDraw();
r.render();
pg.endDraw();
image(pg, 0, 0);
}
void draw()
{
}
class rectangle
{
float x,y,w,h;
float angle;
color c;
rectangle(float x, float y, float w, float h, float angle, color c)
{
this.x=x;
this.y=y;
this.w=w;
this.h=h;
this.angle=angle;
this.c=c;
}
void render()
{
pg.rectMode(CENTER);
pg.fill(c);
pg.pushMatrix();
pg.translate(x, y);
pg.rotate(angle);
pg.rect(x,y,w,h);
pg.popMatrix();
}
}