Last active
June 6, 2016 12:44
-
-
Save brendandawes/996fbcb709e8986613ae2662565e528c to your computer and use it in GitHub Desktop.
Processing:typeToImage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PGraphics typeToImage(String txt,PFont theFont, int fontSize){ | |
PImage img; | |
ArrayList<PVector> vectors = new ArrayList(); | |
PGraphics pg; | |
textFont(theFont); | |
textSize(fontSize); | |
textAlign(LEFT,TOP); | |
float w = textWidth(txt); | |
float h = fontSize; | |
pg = createGraphics(int(w),int(h),JAVA2D); | |
pg.beginDraw(); | |
pg.smooth(); | |
pg.noStroke(); | |
pg.textFont(theFont); | |
pg.background(255); | |
pg.fill(0); | |
pg.textSize(fontSize); | |
pg.textAlign(LEFT,TOP); | |
pg.text(txt, 0, 0); | |
pg.endDraw(); | |
return pg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment