Created
July 11, 2018 12:32
-
-
Save Dezzign/4759dd3063064db467795b3c10411ae2 to your computer and use it in GitHub Desktop.
Revisions
-
Dezzign created this gist
Jul 11, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <canvas id="canvas"> Can I have</canvas> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,57 @@ var canvas = document.getElementById('canvas'), ctx = canvas.getContext('2d'), perlin = new ClassicalNoise(), variation = .003, amp = 200, variators = [], max_lines = (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) ? 25 : 30, canvasWidth, canvasHeight, start_y; for (var i = 0, u = 0; i < max_lines; i++, u+=.02) { variators[i] = u; } function draw(){ ctx.shadowColor = "rgba(43, 205, 255, 1)"; ctx.shadowBlur = 0; for (var i = 0; i <= max_lines; i++){ ctx.beginPath(); ctx.moveTo(0, start_y); for (var x = 0; x <= canvasWidth; x++) { var y = perlin.noise(x*variation+variators[i], x*variation, 0); ctx.lineTo(x, start_y + amp*y); } var color = Math.floor(150*Math.abs(y)); var alpha = Math.min(Math.abs(y), .8)+.1; ctx.strokeStyle = "rgba(80,210,240,"+alpha+")"; ctx.stroke(); ctx.closePath(); variators[i] += .005; } } (function init() { resizeCanvas(); animate(); window.addEventListener('resize', resizeCanvas); })(); function animate() { ctx.clearRect(0, 0, canvasWidth, canvasHeight); draw(); requestAnimationFrame(animate); } function resizeCanvas(){ canvasWidth = document.documentElement.clientWidth, canvasHeight = document.documentElement.clientHeight; canvas.setAttribute("width", canvasWidth); canvas.setAttribute("height", canvasHeight); start_y = canvasHeight/2; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <script src="https://codepen.io/Thibka/pen/LWGOWR"></script> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ html, body { margin: 0; background-color: black; overflow: hidden; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,7 @@ Waves ----- A [Pen](https://codepen.io/Dezzign/pen/NBPjQQ) by [Richard Brus](https://codepen.io/Dezzign) on [CodePen](https://codepen.io). [License](https://codepen.io/Dezzign/pen/NBPjQQ/license).