function Canvas(input){

		this.id = (input && typeof input.id=="string") ? input.id : "LensToy";
		this.src = (input && typeof input.src=="string") ? input.src : "";
		this.width = (input && typeof input.width=="number") ? input.width : parseInt(getStyle(this.id, 'width'), 10);
		this.height = (input && typeof input.height=="number") ? input.height : parseInt(getStyle(this.id, 'height'), 10);
		this.events = { load:"", click:"", mousemove:"" };	// Let's define some events
		this.clipboard = {};
		this.clipboardData = {};

		// Now we want to build the <canvas> element that will hold our image
		var el = document.getElementById(this.id);
		//if(console && typeof console.log=="function") console.log('setup',el,id)
		if(el!=null){
			// Look for a <canvas> with the specified ID or fall back on a <div>
			if(typeof el=="object" && el.tagName != "CANVAS"){
				// Looks like the element is a container for our <canvas>
				el.setAttribute('id',this.id+'holder');
				var canvas = document.createElement('canvas');
				canvas.style.display='block';
				canvas.setAttribute('width',this.width);
				canvas.setAttribute('height',this.height);
				canvas.setAttribute('id',this.id);
				el.appendChild(canvas);
				// For excanvas we need to initialise the newly created <canvas>
				if(/*@cc_on!@*/false) el = G_vmlCanvasManager.initElement(this.canvas);
			}else{
				// Define the size of the canvas
				// Excanvas doesn't seem to attach itself to the existing
				// <canvas> so we make a new one and replace it.
				if(/*@cc_on!@*/false){
					var canvas = document.createElement('canvas');
					canvas.style.display='block';
					canvas.setAttribute('width',this.width);
					canvas.setAttribute('height',this.height);
					canvas.setAttribute('id',this.id);
					el.parentNode.replaceChild(canvas,el);
					if(/*@cc_on!@*/false) el = G_vmlCanvasManager.initElement(elcanvas);
				}else{
					el.setAttribute('width',this.width);
					el.setAttribute('height',this.height);
				}   
			}
			this.canvas = document.getElementById(this.id);
		}else this.canvas = el;
		this.ctx = (this.canvas) ? this.canvas.getContext("2d") : null;
	
		// The object didn't exist before so we add event listeners to it
		var _obj = this;
		addEvent(this.canvas,"click",function(e){
			_obj.getCursor(e);
			_obj.trigger("click",{x:_obj.cursor.x,y:_obj.cursor.y});
		});
		addEvent(this.canvas,"mousemove",function(e){
			_obj.getCursor(e);
			_obj.trigger("mousemove",{x:_obj.cursor.x,y:_obj.cursor.y})
		});
		addEvent(this.canvas,"mouseout",function(e){
			_obj.trigger("mouseout")
		});
		addEvent(this.canvas,"mouseover",function(e){
			_obj.trigger("mouseover")
		});
		return this;
	}
// Make sure you have set the width/height of the canvas element
Make sure you have set the width/height of the canvas element
Make sure you have set the width / height of the canvas element
function Canvas(input){
		this.id = (input && typeof input.id=="string") ? input.id : "LensToy";
		this.src = (input && typeof input.src=="string") ? input.src : "";
		this.width = (input && typeof input.width=="number") ? input.width : parseInt(getStyle(this.id, 'width'), 10);
		this.height = (input && typeof input.height=="number") ? input.height : parseInt(getStyle(this.id, 'height'), 10);
		this.events = { load:"", click:"", mousemove:"" };	
		this.clipboard = {};
		this.clipboardData = {};
		var el = document.getElementById(this.id);
		if(el!=null){
			if(typeof el=="object" && el.tagName != "CANVAS"){
				el.setAttribute('id',this.id+'holder');
				var canvas = document.createElement('canvas');
				canvas.style.display='block';
				canvas.setAttribute('width',this.width);
				canvas.setAttribute('height',this.height);
				canvas.setAttribute('id',this.id);
				el.appendChild(canvas);
				if(false) el = G_vmlCanvasManager.initElement(this.canvas);
			}else{
				if(false){
					var canvas = document.createElement('canvas');
					canvas.style.display='block';
					canvas.setAttribute('width',this.width);
					canvas.setAttribute('height',this.height);
					canvas.setAttribute('id',this.id);
					el.parentNode.replaceChild(canvas,el);
					if(false) el = G_vmlCanvasManager.initElement(elcanvas);
				}else{
					el.setAttribute('width',this.width);
					el.setAttribute('height',this.height);
				}   
			}
			this.canvas = document.getElementById(this.id);
		}else this.canvas = el;
		this.ctx = (this.canvas) ? this.canvas.getContext("2d") : null;
		var _obj = this;
		addEvent(this.canvas,"click",function(e){
			_obj.getCursor(e);
			_obj.trigger("click",{x:_obj.cursor.x,y:_obj.cursor.y});
		});
		addEvent(this.canvas,"mousemove",function(e){
			_obj.getCursor(e);
			_obj.trigger("mousemove",{x:_obj.cursor.x,y:_obj.cursor.y})
		});
		addEvent(this.canvas,"mouseout",function(e){
			_obj.trigger("mouseout")
		});
		addEvent(this.canvas,"mouseover",function(e){
			_obj.trigger("mouseover")
		});
		return this;
	}
function Canvas ( input ) { this . id = ( input && typeof input . id == "string" ) ? input . id : "LensToy" ; this . src = ( input && typeof input . src == "string" ) ? input . src : "" ; this . width = ( input && typeof input . width == "number" ) ? input . width : parseInt ( getStyle ( this . id , 'width' ) , 10 ) ; this . height = ( input && typeof input . height == "number" ) ? input . height : parseInt ( getStyle ( this . id , 'height' ) , 10 ) ; this . events = { load : "" , click : "" , mousemove : "" } ; this . clipboard = { } ; this . clipboardData = { } ; var el = document . getElementById ( this . id ) ; if ( el != null ) { if ( typeof el == "object" && el . tagName != "CANVAS" ) { el . setAttribute ( 'id' , this . id + 'holder' ) ; var canvas = document . createElement ( 'canvas' ) ; canvas . style . display = 'block' ; canvas . setAttribute ( 'width' , this . width ) ; canvas . setAttribute ( 'height' , this . height ) ; canvas . setAttribute ( 'id' , this . id ) ; el . appendChild ( canvas ) ; if ( false ) el = G_vmlCanvasManager . initElement ( this . canvas ) ; } else { if ( false ) { var canvas = document . createElement ( 'canvas' ) ; canvas . style . display = 'block' ; canvas . setAttribute ( 'width' , this . width ) ; canvas . setAttribute ( 'height' , this . height ) ; canvas . setAttribute ( 'id' , this . id ) ; el . parentNode . replaceChild ( canvas , el ) ; if ( false ) el = G_vmlCanvasManager . initElement ( elcanvas ) ; } else { el . setAttribute ( 'width' , this . width ) ; el . setAttribute ( 'height' , this . height ) ; } } this . canvas = document . getElementById ( this . id ) ; } else this . canvas = el ; this . ctx = ( this . canvas ) ? this . canvas . getContext ( "2d" ) : null ; var _obj = this ; addEvent ( this . canvas , "click" , function ( e ) { _obj . getCursor ( e ) ; _obj . trigger ( "click" , { x : _obj . cursor . x , y : _obj . cursor . y } ) ; } ) ; addEvent ( this . canvas , "mousemove" , function ( e ) { _obj . getCursor ( e ) ; _obj . trigger ( "mousemove" , { x : _obj . cursor . x , y : _obj . cursor . y } ) } ) ; addEvent ( this . canvas , "mouseout" , function ( e ) { _obj . trigger ( "mouseout" ) } ) ; addEvent ( this . canvas , "mouseover" , function ( e ) { _obj . trigger ( "mouseover" ) } ) ; return this ; }
Make sure you have set the width/height of the canvas element
Make sure you have set the width / height of the canvas element
// Let's define some events // Now we want to build the <canvas> element that will hold our image //if(console && typeof console.log=="function") console.log('setup',el,id) // Look for a <canvas> with the specified ID or fall back on a <div> // Looks like the element is a container for our <canvas> // For excanvas we need to initialise the newly created <canvas> /*@cc_on!@*/ // Define the size of the canvas // Excanvas doesn't seem to attach itself to the existing // <canvas> so we make a new one and replace it. /*@cc_on!@*/ /*@cc_on!@*/ // The object didn't exist before so we add event listeners to it