package com.indindi.Raster
{
	import flash.display.MovieClip;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.text.TextFormat;
	import flash.display.BitmapData;
	
	import com.indindi.Raster.FrameRate;


	public class FrameRateRenderer
	{
		private var format:TextFormat=new TextFormat();
		private var messageText:String;
		private var messageBitmapData:BitmapData;
		private var messageTextField:TextField = new TextField();
		public var canvasBD:BitmapData;
		public var messagePoint:Point;
		public var messageRect:Rectangle;
		private var _frameRate:FrameRate;
						
		
		public function FrameRateRenderer(xval:int,yval:int,canvasval:BitmapData, framerate:FrameRate):void {
			canvasBD=canvasval;
			format.size=10;
			format.font="Arial";
			format.color="0xffffff";
			format.bold=true;
			messageText="0";
			messageTextField.text=messageText;
			messageTextField.setTextFormat(format);
			//messageTextField.width=(messageText.length+2)*int(format.size);
			messageTextField.width=25;
			//messageTextField.height=int(format.size)*2;
			messageTextField.height=15;
			messageBitmapData=new BitmapData(messageTextField.width,messageTextField.height,true,0xffff0000);
			messagePoint=new Point(xval,yval);
			messageRect=new Rectangle(0,0,messageTextField.width,messageTextField.height);
			_frameRate = framerate;
		}
		
		public function render():void {
			format.size=10;
			format.font="Arial";
			format.color="0xffffff";
			format.bold=true;
			format.align="center";
			messageTextField.text=_frameRate.GetFrameRate().toString();
			messageTextField.setTextFormat(format);
			messageBitmapData.fillRect(messageRect,0x55ff0000);
			messageBitmapData.draw(messageTextField);
			canvasBD.copyPixels(messageBitmapData,messageRect, messagePoint);
		}
	}
}