/*
	canvas wrapper

	author:nakagawa[]ville.jp
	license:NYSL
*/
function VilleCanvas(elem, width, height){
	this.elem = elem;
	this.ctx = null;
	this.width = elem.width = width;
	this.height = elem.height = height;

	if(!this.elem || !this.elem.getContext) return null;
	this.ctx = this.elem.getContext('2d');
}
VilleCanvas.prototype = {
	plot : function(point, color){
		this.ctx.fillStyle = color;
		this.ctx.globalAlpha = 1;
		this.ctx.fillRect(point.x, point.y, 4, 4);
	},
	drawTriangle : function(triangle){
		this.ctx.globalAlpha = 0.3;
		this.ctx.beginPath();
		this.ctx.moveTo(triangle[0].x, triangle[0].y);
		this.ctx.lineTo(triangle[1].x, triangle[1].y);
		this.ctx.lineTo(triangle[2].x, triangle[2].y);
		this.ctx.closePath();
		this.ctx.stroke();
	},
	clear : function(){
		this.ctx.clearRect(0, 0, this.width, this.height);
	}
}