Skip to content

Instantly share code, notes, and snippets.

@takahashilabo
Created April 30, 2016 02:30
Show Gist options
  • Save takahashilabo/8c7cb35b31532459665812bfd704111f to your computer and use it in GitHub Desktop.
Save takahashilabo/8c7cb35b31532459665812bfd704111f to your computer and use it in GitHub Desktop.
drawOutlineText method for Processing
void setup() {
size(800,400);
}
void draw() {
background(0, 255, 255);
float y = 0;
for (int i = 1; i <= 5; i++) {
y += 24 * (i - 1);
drawOutlineText("Hello, Processing World!", 0, y, 24 * i, color(255), color(0));
}
}
void drawOutlineText(String text, float x, float y, int size, int fgColor, int bgColor) {
float outlineWidth = (float)(size / 24.0);
textSize(size);
fill(bgColor);
text(text, x - outlineWidth, y + size - outlineWidth);
text(text, x + outlineWidth, y + size - outlineWidth);
text(text, x - outlineWidth, y + size + outlineWidth);
text(text, x + outlineWidth, y + size + outlineWidth);
fill(fgColor);
text(text, x, y + size);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment