Created
October 23, 2012 19:06
-
-
Save xav76/3940896 to your computer and use it in GitHub Desktop.
A CodePen by mareis. Spiralillusjon
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 characters
| <canvas id="canvas"></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 characters
| var canvas = document.getElementById("canvas"); | |
| var ctx = canvas.getContext('2d'); | |
| canvas.width = window.innerWidth; | |
| canvas.height = window.innerHeight; | |
| var b = canvas.width; | |
| var h = canvas.height; | |
| var teller = 0; | |
| var offset = 0; | |
| var xPos, fontS, farge1, farge2; | |
| function spiral(){ | |
| ctx.fillStyle = "#000"; | |
| ctx.fillRect(0,0,b,h); | |
| for(var yPos = 0; yPos<=h; yPos+=15){ | |
| xPos = (b/6) * Math.sin(teller + offset) + (b/2); | |
| fontS = 50 * Math.cos(teller + offset)+60; | |
| farge1 = Math.floor(125*(Math.sin(teller+offset+Math.PI)+1)); | |
| farge2 = Math.floor(125*(Math.cos(teller+offset+Math.PI)+1)); | |
| ctx.fillStyle = "rgba("+farge2+","+farge1+","+farge1+",0.7)" | |
| ctx.fillText("0", xPos, yPos); | |
| ctx.font = fontS + "px Arial"; | |
| offset = offset + 0.2; | |
| } | |
| offset = 0; | |
| teller=teller + 0.05; | |
| } | |
| setInterval(spiral,20); |
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 characters
| body{ | |
| margin:0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment