From af6def37c29d662be9b6f56e8c2c8c818b35068d Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Wed, 21 Feb 2018 13:55:53 +0100 Subject: undergraduate level --- client/draw.js | 1 - client/index.js | 11 +++++++++-- client/lib/util.js | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) (limited to 'client') diff --git a/client/draw.js b/client/draw.js index 3ff6620..0a86d4a 100644 --- a/client/draw.js +++ b/client/draw.js @@ -18,7 +18,6 @@ function resize(){ document.body.addEventListener('resize', resize) resize() - function clear(n){ ctx.fillStyle = 'rgba(255,255,255,' + (n || 0.5) + ')' ctx.fillRect(0,0,w,h) diff --git a/client/index.js b/client/index.js index 024c2d4..fbe0491 100644 --- a/client/index.js +++ b/client/index.js @@ -34,16 +34,23 @@ keys.listen(index => { if (last_index !== index) { samplers['smash'].play(randrange(90, 150) + index, 0) last_index = index + draw.clear() + draw.triangle(window.innerWidth/2, window.innerHeight/2, 500) } else if (Math.random() < 0.09) { last_index = -1 } - for (var i = 0; i < count; i++) { + let when, i + for (i = 0; i < count; i++) { // kalimba.play(freq * (i+1)/4, now + Math.random()/(i+1)) + when = Math.random()/2000 + (i + Math.random()/10)/randrange(2,5) samplers['glass'].play( 100 + index*(Math.random() * 10), - now + (Math.random()/2000 + i/10) + now + when ) + setTimeout( () => { + draw.triangle(randint(window.innerWidth), randint(window.innerHeight), randrange(10, 100)) + }, when * 1000) } }) diff --git a/client/lib/util.js b/client/lib/util.js index 6d8577a..48145e0 100644 --- a/client/lib/util.js +++ b/client/lib/util.js @@ -14,7 +14,7 @@ const browser = { isIphone, isIpad, isMobile, isDesktop } function clamp(n,a,b){ return n= 0.5 ? -1 : 1 } -- cgit v1.2.3-70-g09d2