TOP   Sample1

Sample1 Code

var cvs, td, cw, ch;
onload = function() {
  cvs = document.getElementById("Canvas");
  td = cvs.getContext("2d");
  cw = cvs.width; ch = cvs.height;
  cvs.onclick = main;
}
function main(e) {
  var x1, y1, cx, cy;
  cx = cvs.offsetLeft; cy = cvs.offsetTop;
  x1 = e.pageX; y1 = e.pageY;
  td.beginPath();
  td.fillStyle = "rgb(" + rnd() + "," + rnd() + "," + rnd() + ")";
  td.arc(x1 - cx, y1 - cy, 25, 0, Math.PI * 2);
  td.fill();
}
function rnd() {
  return String(Math.floor(Math.random()*256));
}
function cvsClear() {
  td.clearRect(0, 0, cw, ch);
}

inserted by FC2 system