User Tools

Site Tools


programmering:lissajous1-js-code
<script>

  function draw() {
	  var c=document.getElementById("canvas");
	  var ctx=c.getContext("2d");
	  while (count<100) {	
		  i=i+0.25;
		  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;
		  count++;
		  ctx.beginPath();
		  if (h<window.innerHeight*0.2) { going_up=1; }
		  if (h>window.innerHeight*0.9) { going_up=0; }
		  if (going_up==1) {
			h=h*1.002;
			w=w*1.002;
		  }
		  else {
		    h=h*0.9995;
		    w=w*0.9995;
		  }
		}
  }
  var h=window.innerHeight*0.9;
  var w=window.innerWidth*0.9;
  var count=0;
  var going_up=0;
  document.getElementById("canvas").width=w;
  document.getElementById("canvas").height=h;
  var i=0;
  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));
  draw();
</script>
programmering/lissajous1-js-code.txt · Last modified: 2023/10/21 19:19 by 127.0.0.1

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki