Created
April 30, 2016 02:30
-
-
Save takahashilabo/8c7cb35b31532459665812bfd704111f to your computer and use it in GitHub Desktop.
drawOutlineText method for Processing
This file contains hidden or 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
| 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