var EHDI = EHDI || Object.create(null); EHDI.displays = EHDI.displays || Object.create(null); EHDI.displays.FillRectangle = function(color, x, y, width, height) { var alpha = arguments.length <= 4 || typeof arguments[5] == "undefined" ? 1 : arguments[5]; var graphics = new PIXI.Graphics(); graphics._sprite = null; graphics._width = width; graphics._height = height; graphics._color = color; var draw = function(width, height, fillStyle) { graphics.clear(); graphics.beginFill(fillStyle); graphics.drawRect(0,0,width, height); graphics.endFill(); }; draw(graphics._width, graphics._height, graphics._color); var texture = graphics.generateCanvasTexture(1); var sprite = new EHDI.aka.Sprite(texture); sprite.position.set(x,y); sprite.alpha = alpha; graphics.sprite = sprite; return sprite; }; EHDI.displays.changeRectangleColor = function(color, width, height) { var alpha = arguments.length <= 4 || typeof arguments[5] == "undefined" ? 1 : arguments[5]; var graphics = new PIXI.Graphics(); graphics._sprite = null; graphics._width = width; graphics._height = height; graphics._color = color; var draw = function(width, height, fillStyle) { graphics.clear(); graphics.beginFill(fillStyle); graphics.drawRect(0,0,width, height); graphics.endFill(); graphics.destroy(); }; draw(graphics._width, graphics._height, graphics._color); var texture = graphics.generateCanvasTexture(1); return texture; }