-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathtextOffsetCurves.pde
54 lines (46 loc) · 1.59 KB
/
textOffsetCurves.pde
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import processing.javafx.*;
import micycle.pgs.*;
import java.util.List;
PShape pgs;
PFont font;
void setup() {
size(1000, 1000, FX2D);
smooth();
colorMode(HSB, 1, 1, 1, 1);
font = createFont(PFont.list()[(int) random(PFont.list().length)], 300, true);
}
void draw() {
background(0, 0, 0.1);
prepareText();
PShape offsetCurves = PGS_Contour.offsetCurvesOutward(pgs, PGS_Contour.OffsetStyle.BEVEL, 15 + sin(frameCount*0.02f)*8, 25);
float hue = 0;
final float inc = 1f / offsetCurves.getChildCount();
for (PShape offsetCurve : offsetCurves.getChildren()) {
offsetCurve.setStroke(color((hue+frameCount*0.01f) % 1, 0.8f, 1, 1));
offsetCurve.setStrokeWeight(3);
hue += inc;
}
shape(offsetCurves);
shape(pgs);
}
void prepareText() {
PShape p = font.getShape('P');
PShape g = font.getShape('G');
PShape s = font.getShape('S');
double pWidth = PGS_ShapePredicates.width(p);
double gWidth = PGS_ShapePredicates.width(g);
p = PGS_Morphology.fieldWarp(p, 50, 0.6, frameCount*0.01, false, 81);
g = PGS_Transformation.translate(g, pWidth + 30, 0);
g = PGS_Morphology.fieldWarp(g, 60, 0.75, frameCount*0.01, false, 1337);
s = PGS_Transformation.translate(s, pWidth + gWidth + 60, 0);
s = PGS_Morphology.fieldWarp(s, 30, 0.5, frameCount*0.01, false, 123081);
pgs = createShape(GROUP);
pgs.addChild(p);
pgs.addChild(g);
pgs.addChild(s);
pgs = PGS_Transformation.translateEnvelopeTo(pgs, width/2f, height/2f);
PGS_Conversion.setAllFillColor(pgs, color(0.5f, 0, 1));
}
void keyPressed() {
font = createFont(PFont.list()[(int) random(PFont.list().length)], 300, true);
}