programmering:cirkel3-js-code
<script> function render() { for (var j=0; j<2; j++) { i=i+0.02; var x=w/2+Math.floor(w/2*Math.cos(cos_mul*i)); var y=h/2+Math.floor(h/2*Math.sin(sin_mul*i)); ctx.moveTo(last_x,last_y); ctx.lineTo(x,y); ctx.stroke(); last_x=x; last_y=y; h=h*0.9996; w=w*0.9996; } if (h>75 && w>75) { requestAnimationFrame(render,ctx); } } var c=document.getElementById("canvas2"); var ctx=c.getContext("2d"); var h=window.innerHeight*0.9; var w=window.innerWidth*0.9; document.getElementById("canvas2").width=w; document.getElementById("canvas2").height=h; var i=2; var cos_mul=5; var sin_mul=15; var last_x=w/2+Math.floor(w/2*Math.cos(cos_mul*i)); var last_y=h/2+Math.floor(h/2*Math.sin(sin_mul*i)); render(); </script>
programmering/cirkel3-js-code.txt · Last modified: 2023/10/21 19:19 by 127.0.0.1