Skip to content

Commit 9c3d7c2

Browse files
committed
Cleanup
1 parent b7711fc commit 9c3d7c2

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

App.hx

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ enum abstract NoiseType(String) from String to String {
1515
var brown;
1616
}
1717

18-
var colorBg = "#000";
19-
var colorFg = "#fff";
18+
var color = { bg: "#000", fg: "#fff" };
2019

2120
var audio : AudioContext;
2221
var gain : GainNode;
@@ -38,16 +37,14 @@ function update( time : Float ) {
3837
analyser.getByteFrequencyData( freqs );
3938
analyser.getByteTimeDomainData( times );
4039

41-
var v : Float, x : Float, y : Float;
40+
var v : Float;
4241
var hw = canvas.width/2, hh = canvas.height/2;
4342
ctx.clearRect( 0, 0, canvas.width, canvas.height );
4443
ctx.strokeStyle = noise;
4544
ctx.beginPath();
4645
for( i in 0...analyser.fftSize ) {
4746
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]) );
5148
}
5249
ctx.stroke();
5350
}
@@ -89,11 +86,7 @@ function initAudio() : Promise<Map<NoiseType,Dynamic>> {
8986
addWorklet('pink-noise-processor'),
9087
addWorklet('brown-noise-processor'),
9188
]).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]];
9790
});
9891

9992
/*
@@ -121,13 +114,11 @@ function main() {
121114
window.onload = () -> {
122115

123116
canvas = cast document.getElementById( 'spectrum' );
124-
//canvas.style.backgroundColor = '#000';
125117
canvas.width = window.innerWidth;
126118
canvas.height = window.innerHeight;
127-
128119
ctx = canvas.getContext2d();
129-
ctx.fillStyle = colorBg;
130-
ctx.strokeStyle = colorFg;
120+
ctx.fillStyle = color.bg;
121+
ctx.strokeStyle = color.fg;
131122

132123
var noiseTypes = [white, brown, pink];
133124
for( type in noiseTypes ) {

web/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
66
<meta http-equiv="Content-Language" content="en">
77
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
8-
<meta name="keywords" content="noise,generator,white,pink,brown">
8+
<meta name="keywords" content="noise,generator,white,pink,brown,webaudio">
99
<title>NOISEGEN</title>
1010
<link rel="stylesheet" href="app.css">
1111
<script src="app.js" defer></script>

0 commit comments

Comments
 (0)