[Japanese][Menu][Home]

Lissajous' curves



I use DrawingCanvas.js and prototype.js.
JavaScript source
  var canvas = new DrawingCanvas($('fld'), 200, 200);
  canvas.setBgColor("#f0f0f0");
  canvas.setLineColor("#ff0000");
  var i=4;
  var n=50;
  var y0=100;
  var x0=100;
  canvas.startLine(x0,y0);
  for(j=0;j<=2*Math.PI;j+=Math.PI/n/i){
    x=70*Math.sin(i*j);
    y=70*Math.sin((i+1)*j);
    canvas.lineTo(x0+x,y0-y);
  }
  canvas.endLine();