1 /** 2 * Hilo 3 * Copyright 2015 alibaba.com 4 * Licensed under the MIT License 5 */ 6 7 /** 8 * @language=en 9 * @class Renderer Renderer is the base class of renderer. 10 * @param {Object} properties The properties to create a renderer, contains all writeable props of this class. 11 * @module hilo/renderer/Renderer 12 * @requires hilo/core/Hilo 13 * @requires hilo/core/Class 14 * @property {Object} canvas The canvas of renderer. It can be a dom element, such as a div element, or a canvas element. readonly. 15 * @property {Object} stage The stage of renderer, readonly. 16 * @property {String} renderType The render type of renderer, readonly. 17 */ 18 var Renderer = Class.create(/** @lends Renderer.prototype */{ 19 constructor: function(properties){ 20 properties = properties || {}; 21 Hilo.copy(this, properties, true); 22 }, 23 24 renderType:null, 25 canvas: null, 26 stage: null, 27 28 /** 29 * @language=en 30 * Prepare for draw visual object. The subclass need to implement it. 31 * @param {View} target The visual target to draw. 32 */ 33 startDraw: function(target){ }, 34 35 /** 36 * @language=en 37 * Draw the visual object. The subclass need to implement it. 38 * @param {View} target The visual target to draw. 39 */ 40 draw: function(target){ }, 41 42 /** 43 * @language=en 44 * The handling method after draw the visual object. The subclass need to implement it. 45 * @param {View} target The visual target to draw. 46 */ 47 endDraw: function(target){ }, 48 49 /** 50 * @language=en 51 * Transfrom the visual object. The subclass need to implement it. 52 */ 53 transform: function(){ }, 54 55 /** 56 * @language=en 57 * Hide the visual object. The subclass need to implement it. 58 */ 59 hide: function(){ }, 60 61 /** 62 * @language=en 63 * Remove the visual object from canvas. Notice that it dosen't remove the object from stage. The subclass need to implement it. 64 * @param {View} target The visual target to remove. 65 */ 66 remove: function(target){ }, 67 68 /** 69 * @language=en 70 * Clear the given region of canvas. The subclass need to implement it. 71 * @param {Number} x The position on the x axis of the given region. 72 * @param {Number} y The position on the y axis of the given region. 73 * @param {Number} width The width of the given region. 74 * @param {Number} height The height of the given region. 75 */ 76 clear: function(x, y, width, height){ }, 77 78 /** 79 * @language=en 80 * Resize the renderer's canvas. 81 * @param {Number} width The width of renderer's canvas. 82 * @param {Number} height The height of the renderer's canvas. 83 */ 84 resize: function(width, height){ } 85 86 });