Skip to content

Instantly share code, notes, and snippets.

@xav76
Created October 23, 2012 19:06
Show Gist options
  • Select an option

  • Save xav76/3940896 to your computer and use it in GitHub Desktop.

Select an option

Save xav76/3940896 to your computer and use it in GitHub Desktop.
A CodePen by mareis. Spiralillusjon
<canvas id="canvas"></canvas>
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);
body{
margin:0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment