Skip to content

Instantly share code, notes, and snippets.

@krizajb
krizajb / PGraphicsJava2DJustify.java
Last active March 6, 2018 13:23
Adds option to Justify text aligenment in processing.
import processing.core.*;
public class PGraphicsJava2DJustify extends PGraphicsJava2D {
public static int JUSTIFY = 4;
static protected void showTextFontException(String method) {
throw new RuntimeException("Use textFont() before " + method + "()");
}
@krizajb
krizajb / measureString.as
Last active July 19, 2019 13:35
Messure text/string in textfield
public static function measureString(str:String, format:TextFormat) : Number {
var textField:TextField = new TextField();
textField.autoSize = TextFieldAutoSize.LEFT; // adjust appropriately
textField.defaultTextFormat = format;
textField.text = str;
return textField.textWidth;
}