function MyCanvas(width, height) {
// create it
var canvas = document.createElement('canvas')
canvas.height = height;
canvas.width = width;
// add it to the document
document.body.appendChild(canvas);
// save some infor as local values
this.width = width;
this.height = height;
this.ctx = canvas.getContext("2d");
return this;
}
MyCanvas.prototype.Redraw = function() {
var i;
var x,y;
var r,g,b;
var color;
this.ctx.fillStyle="#000000";
this.ctx.fillRect(0,0,this.width,this.height);
for(i=0;i<100;i++) {
r = Math.floor(Math.random()*255);
g = Math.floor(Math.random()*255);
b = Math.floor(Math.random()*255);
color = "rgb("+r+","+g+","+b+")";
this.ctx.fillStyle = color;
x = Math.random()*this.width;
y = Math.random()*this.height;
this.ctx.fillRect(x, y, 2, 2);
}
}