Skip to content

Instantly share code, notes, and snippets.

@atduskgreg
Created October 28, 2011 22:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atduskgreg/1323716 to your computer and use it in GitHub Desktop.
Save atduskgreg/1323716 to your computer and use it in GitHub Desktop.
example of a function to turn string into pgraphics
String t = "start";
PGraphics pg;
void setup() {
size(500, 500);
}
void draw() {
background(0);
text(t, 20, 20);
if (mousePressed) {
pg = turnStringIntoImage(t);
image(pg, mouseX, mouseY);
}
}
void keyPressed() {
t = t + key;
}
PGraphics turnStringIntoImage(String myString) {
PGraphics p = createGraphics(500, 500, P2D);
p.beginDraw();
p.text(myString, 10, 10);
p.endDraw();
return p;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment