1 goog.provide('lime.fill.Fill'); 2 3 goog.require('goog.events.EventTarget'); 4 5 /** 6 * Abstract class for adding textures to sprites 7 * @constructor 8 * extends goog.events.EventTarget 9 */ 10 lime.fill.Fill = function() { 11 goog.base(this); 12 13 }; 14 goog.inherits(lime.fill.Fill, goog.events.EventTarget); 15 16 /** 17 * Initialize connection between fill and a sprite. 18 * No drawing is performed here but common setup is done. 19 * @param {lime.Sprite} sprite Sprite. 20 */ 21 lime.fill.Fill.prototype.initForSprite = goog.nullFunction; 22 23 24 /** 25 * Parse fill object out of mixed inputs. 26 * Accepts: RGB(A) values, color strings, urls to images 27 * @param {*} inp Mixed inputs. 28 * @return {lime.fill.Fill} Fill object. 29 */ 30 lime.fill.parse = function(inp) { 31 if (inp[0] instanceof lime.fill.Fill) return inp[0]; 32 33 if(!goog.isArray(inp)) inp = goog.array.toArray(arguments); 34 if (inp.length > 2) { 35 return new lime.fill.Color(inp); 36 } 37 else if (goog.isString(inp[0]) && (inp[0].substring(0, 4) == 'rgb(' || 38 inp[0].substring(0, 5) == 'rgba(' || inp[0].substring(0, 1) == '#')) { 39 return new lime.fill.Color(inp[0]); 40 } 41 42 return new lime.fill.Image(inp[0]); 43 44 }; 45 46 /** 47 * Set color as a DOM style for dom element. 48 * @param {Element} domEl DOM Element. 49 * @param {lime.Node=} shape The shape to draw in. 50 */ 51 lime.fill.Fill.prototype.setDOMStyle = goog.nullFunction; 52 53 54 /** 55 * Set color as Canvas fillStyle. 56 * @param {CanvasRenderingContext2D} context Canvas context. 57 * @param {lime.Node=} shape The shape to draw in. 58 */ 59 lime.fill.Fill.prototype.setCanvasStyle = goog.nullFunction; 60 61