// Canvas オブジェクト

function Canvas(id,width,height,mode){
	if(id){
		cv=document.getElementById(id);
	}else{
		cv=document.createElement('canvas');
	}
	cv.setAttribute("width",width);
	cv.setAttribute("height",height);
	if(!cv || !cv.getContext){
		cvctx=null;
	}else{
		cvctx=cv.getContext(mode);
	}
	this.canvas=cv;	// キャンバス
	this.context=cvctx;	// キャンバスのコンテキスト
	this.width=width;	// キャンバスの幅
	this.height=height;	// キャンバスの高さ
	
	// メソッド
	this.initCanvas=function(fillmode){
		// mode=0:背景透明
		// mode=1:背景白
		// mode=2:背景黒
		this.context.beginPath();
		this.context.fillStyle='#000000';
		this.context.strokeStyle='#000000';
		if((fillmode == 1)||(fillmode == 2)){
			if(fillmode == 1){
				this.context.fillStyle='#ffffff';
			}
			this.context.fillRect(0,0,this.width,this.height);
			this.context.fillStyle='#000000';
		}
		return true;
	}
	
	return this.context;
}

