[Japanese][Menu][Home]

pentagon and star


I use DrawingCanvas.js and prototype.js.

JavaScript source

  var canvas = new DrawingCanvas($('fld'), 400, 190);
  canvas.setBgColor("#e0e0e0");
  canvas.setLineColor("#ff0000");
  canvas.startLine(100,10);
  for(var i=1;i<=5; ++i){
    th=i * 2 * Math.PI/5;
    x=100+90*Math.sin(th);
    y=100-90*Math.cos(th);
    canvas.lineTo(x,y);
  }
  canvas.endLine();
  canvas.setLineColor("#0000ff");
  canvas.startLine(300,10);
  for(var i=1;i<=5; ++i){
    th=i * 4 * Math.PI/5;
    x=300+90*Math.sin(th);
    y=100-90*Math.cos(th);
    canvas.lineTo(x,y);
  }
  canvas.endLine();