1 /** 2 * @author Gillis Haasnoot <gillis.haasnoot@gmail.com> 3 * @package Banana.Controls 4 * @summary Html canvas element 5 */ 6 goog.provide('Banana.Controls.Canvas'); 7 goog.require('Banana.UiControl'); 8 9 /** @namespace Banana.Controls.Canvas */ 10 namespace('Banana.Controls').Canvas = Banana.UiControl.extend( 11 /** @lends Banana.Controls.Canvas.prototype */ 12 { 13 /** 14 * Creates a Html Canvas element 15 * 16 * @param {String} type of the canvas. 17 * @constructs 18 * @extends Banana.UiControl 19 */ 20 init : function(type) 21 { 22 this._super(); 23 this.type = type; 24 } 25 }); 26 27 /** 28 * Return the context of the canvas 29 * 30 * @returns {Object} 31 */ 32 Banana.Controls.Canvas.prototype.getContext = function() 33 { 34 if (!this.context) { 35 console.log(this.type) 36 this.context = document.getElementById(this.getClientId()).getContext(this.type || "2d"); 37 } 38 return this.context; 39 }; 40 41 /** 42 * Clear the Canvas 43 * 44 * @returns void 45 */ 46 Banana.Controls.Canvas.prototype.clear = function() 47 { 48 var dem = this.getParent().getDemensions(); 49 var c =this.getContext(); 50 c.clearRect(0, 0, dem.width, dem.height); 51 c.beginPath(); 52 }; 53 54 /** 55 * @returns String The Tag Name of Canvas 56 */ 57 Banana.Controls.Canvas.prototype.getTagName = function() 58 { 59 return 'canvas'; 60 }; 61