| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
- var Shape = require('../shape');
- var bbox = require('../util/bbox');
- var Polygon =
- /*#__PURE__*/
- function (_Shape) {
- _inheritsLoose(Polygon, _Shape);
- function Polygon() {
- return _Shape.apply(this, arguments) || this;
- }
- var _proto = Polygon.prototype;
- _proto._initProperties = function _initProperties() {
- _Shape.prototype._initProperties.call(this);
- this._attrs.canFill = true;
- this._attrs.canStroke = true;
- this._attrs.type = 'polygon';
- };
- _proto.getDefaultAttrs = function getDefaultAttrs() {
- return {
- points: null,
- lineWidth: 0
- };
- };
- _proto.createPath = function createPath(context) {
- var self = this;
- var attrs = self.get('attrs');
- var points = attrs.points;
- context.beginPath();
- for (var i = 0, len = points.length; i < len; i++) {
- var point = points[i];
- if (i === 0) {
- context.moveTo(point.x, point.y);
- } else {
- context.lineTo(point.x, point.y);
- }
- }
- context.closePath();
- };
- _proto.calculateBox = function calculateBox() {
- var attrs = this.get('attrs');
- var points = attrs.points;
- return bbox.getBBoxFromPoints(points);
- };
- return Polygon;
- }(Shape);
- Shape.Polygon = Polygon;
- module.exports = Polygon;
|