-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwormhole.js
92 lines (55 loc) · 1.97 KB
/
wormhole.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
//https://editor.p5js.org/Shiraserilevi/sketches/P5ZsJYW_P
//Code used and adapted from the above link.
function Wormhole() {
this.name = "2. wormhole";
var symmetry = 32;
var angle = 360 / symmetry;
this.draw = function(){
push();
var spectrum = fft.analyze();
var t = fft.getEnergy("treble");
//increase speed of kaleidoscope effect
var musicBox = frameCount * 3;
angleMode(DEGREES);
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:
//control rotation speed of triangles
rotate(musicBox/8);
//drawing shapes
//blends the pixels in the display window
//Screen - opposite multiply, uses inverse values of the colors
blendMode(SCREEN);
//pink rect
noStroke();
fill(colorPalette[1]);
//fill(255, 72, 176);
// rect(100, 100, height, t);
push();
var x = map(i, 0, spectrum.length, 0, 300);
var y = map(i, 0, spectrum.length, 0, height);
//fill(map(i, spectrum.length, 255, 72, 176));
translate(100,100);
//x*t gives interesting inverted effect
triangle(x, y, 58, 20, 86, 75);
pop();
blueSquare();
rect(100, 100, height, t*0.2);
pop();
}
}
function blueSquare(){
var m = fft.getEnergy("mid");
var musicBox = frameCount * 3;
rotate(musicBox/4);
//fill(colorPalette[0]);
fill(0, 121, 191);
rect(m, m, 55, 55);
}
}