-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
54 lines (43 loc) · 1.02 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
let font;
let vehicles = [];
let gradColors = [];
function preload() {
font = loadFont('AvenirNextLTPro-Demi.otf');
}
function setup() {
createCanvas(windowWidth, windowHeight);
background('#222222');
gradColors = [
color(255, 165, 0),
color(228, 137, 35),
color(216, 124, 50),
color(197, 104, 73),
color(98, 15, 163),
color(113, 27, 153),
color(128, 39, 142),
color(146, 55, 127),
];
var points = font.textToPoints('Run The Mouse Through Me!', 100, 350, 100, {
sampleFactor: .21
});
rangeForGradient = Math.ceil(points.length / gradColors.length) + 10;
index = 0;
for (var i = 0, i_2 = 0; i < points.length; i++, i_2++) {
var pt = points[i];
if (rangeForGradient == i_2) {
index++;
i_2 = 0;
}
var vehicle = new Vehicle(pt.x, pt.y, gradColors[index]);
vehicles.push(vehicle);
}
}
function draw() {
background('#222222');
for (var i = 0; i < vehicles.length; i++) {
var v = vehicles[i];
v.behaviors();
v.update();
v.show();
}
}