diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-02-25 19:19:29 +0100 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-02-25 19:19:29 +0100 |
| commit | 7050f54518a6d78b6f8dec43d465ff0643ea9ff1 (patch) | |
| tree | a79ac12fec47a281c34e2c6d3b8521da17bc355f /client/index.js | |
| parent | 5e4a56bdfed89fa547bbcd520372f67cab18dac5 (diff) | |
build
Diffstat (limited to 'client/index.js')
| -rw-r--r-- | client/index.js | 59 |
1 files changed, 55 insertions, 4 deletions
diff --git a/client/index.js b/client/index.js index 0b917ac..03e36a3 100644 --- a/client/index.js +++ b/client/index.js @@ -120,9 +120,18 @@ function stripey(odd){ return y % 2 ? odd : !odd }) } -function noise(){ +function checker(odd, n){ + odd = !! odd + n = n || 1 forEach((x,y,state) => { - return Math.random() < 0.5 + return ((Math.floor(x/n)%2) ^ (Math.floor(y/n)%2)) ? odd : !odd + }) +} +function noise(n){ + n = n || 0.5 + n = n * n + forEach((x,y,state) => { + return Math.random() < n }) } @@ -218,7 +227,7 @@ function swap_instrument(){ let life_bpm = 50 window.addEventListener("keydown", keydown, true) function keydown(e){ - // console.log(e.keyCode) + console.log(e.keyCode) if (e.altKey || e.ctrlKey || e.metaKey) return switch (e.keyCode){ case 32: // space @@ -246,7 +255,7 @@ function keydown(e){ white() break case 78: // n - noise() + noise(0.5) break case 69: // e stripex(Math.random() < 0.5) @@ -254,6 +263,48 @@ function keydown(e){ case 82: // r stripey(Math.random() < 0.5) break + case 84: // t + checker(Math.random() < 0.5, 1) + break + case 89: // y + checker(Math.random() < 0.5, 2) + break + case 85: // u + checker(Math.random() < 0.5, 3) + break + case 73: // i + checker(Math.random() < 0.5, 4) + break + case 49: // 1 + noise(0.1) + break + case 50: // 2 + noise(0.2) + break + case 51: // 3 + noise(0.3) + break + case 52: // 4 + noise(0.4) + break + case 53: // 5 + noise(0.5) + break + case 54: // 6 + noise(0.6) + break + case 55: // 7 + noise(0.7) + break + case 56: // 8 + noise(0.8) + break + case 57: // 9 + noise(0.9) + break + case 48: // 0 + noise(1) + break } } keys.listen(function(index){ |
