-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathday_17.js
65 lines (45 loc) · 1.31 KB
/
day_17.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
58
59
60
61
62
63
64
// (c) 2021 Joseph HENRY
// This code is licensed under MIT license (see LICENSE for details)
let yellow, orange, pink;
let offset = 0;
function lines(x, y, size, nLines, offset, fromColor, toColor) {
const slice = TWO_PI / nLines;
const radius = size / 2;
push();
translate(x, y);
for (let i = 0; i < nLines; i++) {
randomSeed(i * 500);
const angle = i * slice;
const rotMultiplier = sin(angle / 2) + 1;
const rotation = angle * rotMultiplier + offset;
const color = lerpColor(fromColor, toColor, random(1));
stroke(color);
strokeWeight(map(sin(rotation * 2), -1, 1, size / 20, size / 5));
push();
translate(cos(angle) * radius, sin(angle) * radius);
rotate(rotation);
line(0, 0, size / 4, 0);
pop();
}
pop();
}
function setup() {
createCanvas(500, 500);
yellow = color("#ff9900");
orange = color("#ff5500");
pink = color("#ff7c67");
}
function draw() {
background("#003344");
translate(width / 2, height / 2);
noStroke();
fill(pink);
circle(0, 0, 120 + sin(offset) * 20);
fill(orange);
circle(0, 0, 100 + sin(offset + QUARTER_PI) * 10);
fill(yellow);
circle(0, 0, 50 + sin(offset) * 20);
lines(0, 0, 250, 50, offset, yellow, orange);
lines(0, 0, 150, 25, offset, orange, pink);
offset += 0.03;
}