@@ -15,8 +15,7 @@ enum abstract NoiseType(String) from String to String {
15
15
var brown ;
16
16
}
17
17
18
- var colorBg = " #000" ;
19
- var colorFg = " #fff" ;
18
+ var color = { bg : " #000" , fg : " #fff" };
20
19
21
20
var audio : AudioContext ;
22
21
var gain : GainNode ;
@@ -38,16 +37,14 @@ function update( time : Float ) {
38
37
analyser .getByteFrequencyData ( freqs );
39
38
analyser .getByteTimeDomainData ( times );
40
39
41
- var v : Float , x : Float , y : Float ;
40
+ var v : Float ;
42
41
var hw = canvas .width / 2 , hh = canvas .height / 2 ;
43
42
ctx .clearRect ( 0 , 0 , canvas .width , canvas .height );
44
43
ctx .strokeStyle = noise ;
45
44
ctx .beginPath ();
46
45
for ( i in 0 ... analyser .fftSize ) {
47
46
v = i * (Math .PI / 2 )/ 180 ;
48
- x = Math .cos (v ) * ( 100 + times [i ] );
49
- y = Math .sin (v ) * ( 100 + times [i ] );
50
- ctx .lineTo ( hw + x , hh + y );
47
+ ctx .lineTo (hw + Math .cos (v ) * ( 100 + times [i ] ), hh + Math .sin (v ) * ( 100 + times [i ]) );
51
48
}
52
49
ctx .stroke ();
53
50
}
@@ -89,11 +86,7 @@ function initAudio() : Promise<Map<NoiseType,Dynamic>> {
89
86
addWorklet (' pink-noise-processor' ),
90
87
addWorklet (' brown-noise-processor' ),
91
88
]).then ( r -> {
92
- return noises = [
93
- white => r [0 ],
94
- pink => r [1 ],
95
- brown => r [2 ]
96
- ];
89
+ return noises = [white => r [0 ], pink => r [1 ], brown => r [2 ]];
97
90
});
98
91
99
92
/*
@@ -121,13 +114,11 @@ function main() {
121
114
window .onload = () -> {
122
115
123
116
canvas = cast document .getElementById ( ' spectrum' );
124
- // canvas.style.backgroundColor = '#000';
125
117
canvas .width = window .innerWidth ;
126
118
canvas .height = window .innerHeight ;
127
-
128
119
ctx = canvas .getContext2d ();
129
- ctx .fillStyle = colorBg ;
130
- ctx .strokeStyle = colorFg ;
120
+ ctx .fillStyle = color . bg ;
121
+ ctx .strokeStyle = color . fg ;
131
122
132
123
var noiseTypes = [white , brown , pink ];
133
124
for ( type in noiseTypes ) {
0 commit comments