var Class = require('../../../utils/Class'); var GeomRectangle = require('../../../geom/rectangle/Rectangle'); var Shape = require('../Shape'); var RectangleRender = require('./RectangleRender'); var Rectangle = new Class({ Extends: Shape, Mixins: [RectangleRender] , initialize: function Rectangle(scene, x, y, width, height, fillColor, fillAlpha){ if (x === undefined) { x = 0; } if (y === undefined) { y = 0; } if (width === undefined) { width = 128; } if (height === undefined) { height = 128; } Shape.call(this, scene, 'Rectangle', new GeomRectangle(0, 0, width, height)); this.setPosition(x, y); this.setSize(width, height); if (fillColor !== undefined) { this.setFillStyle(fillColor, fillAlpha); } this.updateDisplayOrigin(); this.updateData(); } , setSize: function (width, height){ this.width = width; this.height = height; this.geom.setSize(width, height); this.updateData(); return this; } , updateData: function (){ var path = [] ; var rect = this.geom; var line = this._tempLine; rect.getLineA(line); path.push(line.x1, line.y1, line.x2, line.y2); rect.getLineB(line); path.push(line.x2, line.y2); rect.getLineC(line); path.push(line.x2, line.y2); rect.getLineD(line); path.push(line.x2, line.y2); this.pathData = path; return this; } } ); module.exports = Rectangle;