-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdarkStar.js
54 lines (40 loc) · 1.17 KB
/
darkStar.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
//https://editor.p5js.org/Shiraserilevi/sketches/P5ZsJYW_P
//Code used and adapted from the above link.
function Dark_Star() {
this.name = "3. dark star";
var symmetry = 16;
var angle = 360 / symmetry;
this.draw = function(){
push();
var spectrum = fft.analyze();
angleMode(DEGREES);
//background(0);
var pos = translate(width / 2, height / 2);
for (var i = 0; i < spectrum.length; i++) {
push();
rotate(i*angle);
//mirroring
if (i % 2 == 1) {
scale(-1, 1);
}
//animation:
var musicBox = frameCount * 5;
rotate(musicBox/ 8.0);
//drawing shapes
blendMode(ADD);
noStroke();
push();
var x = map(i, 0, spectrum.length, 0, 300);
var y = map(spectrum[i], 0, spectrum.length, 0, height);
//add color selector
fill(colorPalette[0]);
translate(100,100);
rotate(r*20);
triangle(x*2, y*2, 58, 20, 86, 75);
//triangle(50, 30, 58, 20, 86, 75);
pop();
var r=+
pop();
}
};
}