PGraphics buf;
void setup(){
size(30,30);
buf = createGraphics(30,30);
buf.beginDraw();
buf.stroke(255);
buf.strokeWeight(2);
buf.strokeCap(ROUND);
buf.line(5,15,25,15);
buf.line(5,15,10,10);
buf.line(5,15,10,20);
buf.line(25,15,20,10);
buf.line(25,15,20,20);
buf.endDraw();
buf.save("switch.png");
}
void draw(){
image(buf,0,0);
}
By using an offscreen graphics buffer, I could create an image with a transparent background, and then by doing most of the work in setup and saving then, I stopped myself from creating the image file over and over again. (But then I blasted the image to draw, so I can see it each time I changed and ran it.)
No comments:
Post a Comment