diff options
author | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-01-08 05:30:31 +0300 |
---|---|---|
committer | Yaroslav de la Peña Smirnov <yps@yaroslavps.com> | 2022-01-08 05:30:31 +0300 |
commit | bdf7cd5ba853f93cedfb25f68fcbea4df15c5413 (patch) | |
tree | 36bfaf8f6772f93440a7971665efa676cabb08db /starfield | |
parent | 8171f14d658af4b237589ab1354b8bdcc684f80d (diff) | |
download | canvas-antics-ibah.tar.gz canvas-antics-ibah.zip |
DJ IBAH 2022ibah
Wow so much blur!
З.Ы. заебал не давать спатб
Diffstat (limited to 'starfield')
-rw-r--r-- | starfield/stars.js | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/starfield/stars.js b/starfield/stars.js index 6d649f8..f9e8a12 100644 --- a/starfield/stars.js +++ b/starfield/stars.js @@ -53,6 +53,8 @@ function Particle(ix, iy, posz, rgb){ function warpLaunch(options={}){ /* >>> Some parameters <<< */ + var blur = 1.0; + var IBAH = 0; var max_particles = options.hasOwnProperty('max_particles') ? options['max_particles'] : 500; var speed = @@ -175,7 +177,21 @@ function warpLaunch(options={}){ requestedFrame = window.requestAnimationFrame(nextFrame); return; } - ctx.clearRect(0, 0, canvas.width, canvas.height); + //ctx.clearRect(0, 0, canvas.width, canvas.height); + if (IBAH === 1) { + blur -= 0.02; + if (blur <= 0.0) { + IBAH = 2; + } + } else if (IBAH === 2) { + blur += 0.03; + if (blur >= 1.0) { + IBAH = 0; + blur = 1.0; + } + } + ctx.fillStyle = "rgba(0, 0, 0," + blur + ")"; + ctx.fillRect(0, 0, canvas.width, canvas.height); // Decrease the distance from the screen of the star based // based on the speed for(let i = 0; i < max_particles; i++){ @@ -214,6 +230,16 @@ function warpLaunch(options={}){ if (interactive){ console.log("Interactivity is on, move the mouse wheel to control speed"); canvas.addEventListener("wheel", updateSpeed); + window.addEventListener('keypress', function(e){ + if (e.code == 'KeyQ') + blur += 0.1; + if (e.code == 'KeyE') + blur -= 0.1; + if (e.code == 'KeyW') { + IBAH = 1; + blur = 0.95; + } + }); } window.addEventListener("resize", resize); |