-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
44 lines (40 loc) · 1.23 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
var last;
var colorz = 0;
const l = 15;
const r = 20;
function setup() {
createCanvas(windowWidth, windowHeight);
strokeWeight(l / 7.5)
strokeCap(SQUARE);
textSize(28);
textFont('Verdana');
var b = random();
var c = random();
var d = random();
var e = random();
last = new Array(Math.floor(width / r) + 1);
for (let i = 0; i < (width / r) + 1; i++) {
last[i] = new Array(Math.floor(height / r) + 1);
for (let j = 0; j < (height / r) + 1; j++) {
last[i][j] = (((cos(i * b) * c + cos(j * d) * e) / 4) + 0.5) * 360
}
}
}
function draw() {
background(0);
var mod, ra;
colorMode(HSL);
mouseIsPressed ? colorz += 5 : null;
for (let i = 0; i < (width / r) + 1; i++) {
stroke((colorz + (i * 10)) % 360, 58, 63);
for (let j = 0; j < (height / r) + 1; j++) {
mouseIsPressed ? ra = ((last[i][j] += 5) / 180) * Math.PI : ra = ((last[i][j]) / 180) * Math.PI;
mod = [cos(ra) * l, sin(ra) * l];
line((i * r) + 5, (j * r) + 5, (i * r) + 5 + mod[0], (j * r) + 5 + mod[1])
}
}
stroke(0);
fill(255);
text('Reload for a different pattern', 15, 35);
text('Click?', width - 150, height - 35);
}