-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
57 lines (41 loc) · 1.17 KB
/
sketch.js
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
55
56
57
let randomTexts = ["the", "grid", "is", "alive", "typography", "creating", "experience"];
let rows, cols;
let size = 50;
let grid = [];
let xoff = 0;
function setup() {
createCanvas(windowWidth, windowHeight);
cols = floor(width / size) + 1;
rows = floor(height / size) + 1;
for (let i = 0; i < rows; i++) {
for (let j = 0; j < cols; j++) {
grid.push(createVector(j * size, i * size));
}
}
}
function draw() {
background("blue");
textFont("Maax Mono");
textAlign(CENTER, CENTER);
textSize(24);
let step = 4;
for (let i = 0; i < rows; i += step) {
for (let j = 0; j < cols; j += step) {
let x = j * size;
let y = i * size;
let textNoise = noise(x * 0.01, y * 0.01, xoff);
let index = floor(textNoise * randomTexts.length);
let ix = ceil(map(mouseX, 0, width, 0, randomTexts[index].length));
if (ix == randomTexts[index].length) {
fill(255);
text(randomTexts[index], dist(mouseX, mouseY, x, y), y);
} else {
noFill()
stroke(255)
strokeWeight(0.5)
text(randomTexts[index].substring(0, ix), dist(mouseX, mouseY, x, y), y);
}
}
}
xoff += 0.02;
}