UNPKG

1.02 MBJavaScriptView Raw
1(function webpackUniversalModuleDefinition(root, factory) {
2 if(typeof exports === 'object' && typeof module === 'object')
3 module.exports = factory();
4 else if(typeof define === 'function' && define.amd)
5 define([], factory);
6 else if(typeof exports === 'object')
7 exports["interaction"] = factory();
8 else
9 root["interaction"] = factory();
10})(typeof self !== 'undefined' ? self : this, function() {
11return /******/ (function(modules) { // webpackBootstrap
12/******/ // The module cache
13/******/ var installedModules = {};
14/******/
15/******/ // The require function
16/******/ function __webpack_require__(moduleId) {
17/******/
18/******/ // Check if module is in cache
19/******/ if(installedModules[moduleId]) {
20/******/ return installedModules[moduleId].exports;
21/******/ }
22/******/ // Create a new module (and put it into the cache)
23/******/ var module = installedModules[moduleId] = {
24/******/ i: moduleId,
25/******/ l: false,
26/******/ exports: {}
27/******/ };
28/******/
29/******/ // Execute the module function
30/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
31/******/
32/******/ // Flag the module as loaded
33/******/ module.l = true;
34/******/
35/******/ // Return the exports of the module
36/******/ return module.exports;
37/******/ }
38/******/
39/******/
40/******/ // expose the modules object (__webpack_modules__)
41/******/ __webpack_require__.m = modules;
42/******/
43/******/ // expose the module cache
44/******/ __webpack_require__.c = installedModules;
45/******/
46/******/ // define getter function for harmony exports
47/******/ __webpack_require__.d = function(exports, name, getter) {
48/******/ if(!__webpack_require__.o(exports, name)) {
49/******/ Object.defineProperty(exports, name, {
50/******/ configurable: false,
51/******/ enumerable: true,
52/******/ get: getter
53/******/ });
54/******/ }
55/******/ };
56/******/
57/******/ // getDefaultExport function for compatibility with non-harmony modules
58/******/ __webpack_require__.n = function(module) {
59/******/ var getter = module && module.__esModule ?
60/******/ function getDefault() { return module['default']; } :
61/******/ function getModuleExports() { return module; };
62/******/ __webpack_require__.d(getter, 'a', getter);
63/******/ return getter;
64/******/ };
65/******/
66/******/ // Object.prototype.hasOwnProperty.call
67/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
68/******/
69/******/ // __webpack_public_path__
70/******/ __webpack_require__.p = "";
71/******/
72/******/ // Load entry module and return exports
73/******/ return __webpack_require__(__webpack_require__.s = 68);
74/******/ })
75/************************************************************************/
76/******/ ([
77/* 0 */
78/***/ (function(module, exports, __webpack_require__) {
79
80var CommonUtil = __webpack_require__(7);
81var DomUtil = __webpack_require__(29);
82
83var Util = {};
84
85CommonUtil.merge(Util, CommonUtil, DomUtil, {
86 mixin: function mixin(c, mixins) {
87 var Param = c.CFG ? 'CFG' : 'ATTRS';
88 if (c && mixins) {
89 c._mixins = mixins;
90 c[Param] = c[Param] || {};
91 var temp = {};
92 Util.each(mixins, function (mixin) {
93 Util.augment(c, mixin);
94 var attrs = mixin[Param];
95 if (attrs) {
96 Util.merge(temp, attrs);
97 }
98 });
99 c[Param] = Util.merge(temp, c[Param]);
100 }
101 }
102});
103
104module.exports = Util;
105
106/***/ }),
107/* 1 */
108/***/ (function(module, exports, __webpack_require__) {
109
110var Util = __webpack_require__(0);
111var Element = __webpack_require__(55);
112var Inside = __webpack_require__(3);
113
114var Shape = function Shape(cfg) {
115 Shape.superclass.constructor.call(this, cfg);
116};
117
118Shape.ATTRS = {};
119
120Util.extend(Shape, Element);
121
122Util.augment(Shape, {
123 isShape: true,
124 createPath: function createPath() {},
125 afterPath: function afterPath() {},
126 drawInner: function drawInner(context) {
127 var self = this;
128 var attrs = self.__attrs;
129 self.createPath(context);
130 var originOpacity = context.globalAlpha;
131 if (self.hasFill()) {
132 var fillOpacity = attrs.fillOpacity;
133 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
134 context.globalAlpha = fillOpacity;
135 context.fill();
136 context.globalAlpha = originOpacity;
137 } else {
138 context.fill();
139 }
140 }
141 if (self.hasStroke()) {
142 var lineWidth = self.__attrs.lineWidth;
143 if (lineWidth > 0) {
144 var strokeOpacity = attrs.strokeOpacity;
145 if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
146 context.globalAlpha = strokeOpacity;
147 }
148 context.stroke();
149 }
150 }
151 self.afterPath(context);
152 },
153
154 /**
155 * 节点是否在图形中
156 * @param {Number} x x 坐标
157 * @param {Number} y y 坐标
158 * @return {Boolean} 是否在图形中
159 */
160 isPointInPath: function isPointInPath() {
161 return false;
162 },
163
164 /**
165 * 击中图形时是否进行包围盒判断
166 * @return {Boolean} [description]
167 */
168 isHitBox: function isHitBox() {
169 return true;
170 },
171
172 /**
173 * 节点是否能够被击中
174 * @param {Number} x x坐标
175 * @param {Number} y y坐标
176 * @return {Boolean} 是否在图形中
177 */
178 isHit: function isHit(x, y) {
179 var self = this;
180 var v = [x, y, 1];
181 self.invert(v); // canvas
182
183 if (self.isHitBox()) {
184 var box = self.getBBox();
185 if (box && !Inside.box(box.minX, box.maxX, box.minY, box.maxY, v[0], v[1])) {
186 return false;
187 }
188 }
189 var clip = self.__attrs.clip;
190 if (clip) {
191 if (clip.inside(x, y)) {
192 return self.isPointInPath(v[0], v[1]);
193 }
194 } else {
195 return self.isPointInPath(v[0], v[1]);
196 }
197 return false;
198 },
199
200 /**
201 * @protected
202 * 计算包围盒
203 * @return {Object} 包围盒
204 */
205 calculateBox: function calculateBox() {
206 return null;
207 },
208
209 // 获取拾取时线的宽度,需要考虑附加的线的宽度
210 getHitLineWidth: function getHitLineWidth() {
211 var attrs = this.__attrs;
212 // if (!attrs.stroke) {
213 // return 0;
214 // }
215 var lineAppendWidth = attrs.lineAppendWidth || 0;
216 var lineWidth = attrs.lineWidth || 0;
217 return lineWidth + lineAppendWidth;
218 },
219
220 // 清除当前的矩阵
221 clearTotalMatrix: function clearTotalMatrix() {
222 this.__cfg.totalMatrix = null;
223 this.__cfg.region = null;
224 },
225 clearBBox: function clearBBox() {
226 this.__cfg.box = null;
227 this.__cfg.region = null;
228 },
229 getBBox: function getBBox() {
230 var box = this.__cfg.box;
231 // 延迟计算
232 if (!box) {
233 box = this.calculateBox();
234 if (box) {
235 box.x = box.minX;
236 box.y = box.minY;
237 box.width = box.maxX - box.minX;
238 box.height = box.maxY - box.minY;
239 }
240 this.__cfg.box = box;
241 }
242 return box;
243 }
244});
245
246module.exports = Shape;
247
248/***/ }),
249/* 2 */
250/***/ (function(module, exports, __webpack_require__) {
251
252var CommonUtil = __webpack_require__(7);
253var mat3 = __webpack_require__(74);
254var vec3 = __webpack_require__(75);
255var vec2 = __webpack_require__(76);
256
257vec2.angle = function (v1, v2) {
258 var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
259 return Math.acos(CommonUtil.clamp(theta, -1, 1));
260};
261/**
262 * 向量 v1 到 向量 v2 夹角的方向
263 * @param {Array} v1 向量
264 * @param {Array} v2 向量
265 * @return {Boolean} >= 0 顺时针 < 0 逆时针
266 */
267vec2.direction = function (v1, v2) {
268 return v1[0] * v2[1] - v2[0] * v1[1];
269};
270vec2.angleTo = function (v1, v2, direct) {
271 var angle = vec2.angle(v1, v2);
272 var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
273 if (direct) {
274 if (angleLargeThanPI) {
275 return Math.PI * 2 - angle;
276 }
277
278 return angle;
279 }
280
281 if (angleLargeThanPI) {
282 return angle;
283 }
284 return Math.PI * 2 - angle;
285};
286vec2.vertical = function (out, v, flag) {
287 if (flag) {
288 out[0] = v[1];
289 out[1] = -1 * v[0];
290 } else {
291 out[0] = -1 * v[1];
292 out[1] = v[0];
293 }
294
295 return out;
296};
297
298mat3.translate = function (out, a, v) {
299 var transMat = new Array(9);
300 mat3.fromTranslation(transMat, v);
301 return mat3.multiply(out, transMat, a);
302};
303
304mat3.rotate = function (out, a, rad) {
305 var rotateMat = new Array(9);
306 mat3.fromRotation(rotateMat, rad);
307 return mat3.multiply(out, rotateMat, a);
308};
309
310mat3.scale = function (out, a, v) {
311 var scaleMat = new Array(9);
312 mat3.fromScaling(scaleMat, v);
313 return mat3.multiply(out, scaleMat, a);
314};
315
316module.exports = {
317 mat3: mat3,
318 vec2: vec2,
319 vec3: vec3,
320 transform: function transform(m, ts) {
321 m = CommonUtil.clone(m);
322 CommonUtil.each(ts, function (t) {
323 switch (t[0]) {
324 case 't':
325 mat3.translate(m, m, [t[1], t[2]]);
326 break;
327 case 's':
328 mat3.scale(m, m, [t[1], t[2]]);
329 break;
330 case 'r':
331 mat3.rotate(m, m, t[1]);
332 break;
333 case 'm':
334 mat3.multiply(m, m, t[1]);
335 break;
336 default:
337 return false;
338 }
339 });
340 return m;
341 }
342};
343
344/***/ }),
345/* 3 */
346/***/ (function(module, exports, __webpack_require__) {
347
348var Line = __webpack_require__(22);
349var Quadratic = __webpack_require__(23);
350var Cubic = __webpack_require__(12);
351var Arc = __webpack_require__(24);
352
353module.exports = {
354 line: function line(x1, y1, x2, y2, lineWidth, x, y) {
355 var box = Line.box(x1, y1, x2, y2, lineWidth);
356
357 if (!this.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
358 return false;
359 }
360
361 var d = Line.pointDistance(x1, y1, x2, y2, x, y);
362 if (isNaN(d)) {
363 return false;
364 }
365 return d <= lineWidth / 2;
366 },
367 polyline: function polyline(points, lineWidth, x, y) {
368 var l = points.length - 1;
369 if (l < 1) {
370 return false;
371 }
372 for (var i = 0; i < l; i++) {
373 var x1 = points[i][0];
374 var y1 = points[i][1];
375 var x2 = points[i + 1][0];
376 var y2 = points[i + 1][1];
377
378 if (this.line(x1, y1, x2, y2, lineWidth, x, y)) {
379 return true;
380 }
381 }
382
383 return false;
384 },
385 cubicline: function cubicline(x1, y1, x2, y2, x3, y3, x4, y4, lineWidth, x, y) {
386 return Cubic.pointDistance(x1, y1, x2, y2, x3, y3, x4, y4, x, y) <= lineWidth / 2;
387 },
388 quadraticline: function quadraticline(x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
389 return Quadratic.pointDistance(x1, y1, x2, y2, x3, y3, x, y) <= lineWidth / 2;
390 },
391 arcline: function arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y) {
392 return Arc.pointDistance(cx, cy, r, startAngle, endAngle, clockwise, x, y) <= lineWidth / 2;
393 },
394 rect: function rect(rx, ry, width, height, x, y) {
395 return rx <= x && x <= rx + width && ry <= y && y <= ry + height;
396 },
397 circle: function circle(cx, cy, r, x, y) {
398 return Math.pow(x - cx, 2) + Math.pow(y - cy, 2) <= Math.pow(r, 2);
399 },
400 box: function box(minX, maxX, minY, maxY, x, y) {
401 return minX <= x && x <= maxX && minY <= y && y <= maxY;
402 }
403};
404
405/***/ }),
406/* 4 */
407/***/ (function(module, exports, __webpack_require__) {
408
409var Util = __webpack_require__(0);
410var Element = __webpack_require__(13);
411
412var SHAPES = {
413 rect: 'rect',
414 circle: 'circle',
415 line: 'line',
416 path: 'path',
417 marker: 'marker',
418 text: 'text',
419 polygon: 'polygon',
420 image: 'image',
421 ellipse: 'ellipse',
422 dom: 'foreignObject',
423 fan: 'path'
424};
425
426var Shape = function Shape(cfg) {
427 Shape.superclass.constructor.call(this, cfg);
428};
429
430Shape.ATTRS = {};
431
432Util.extend(Shape, Element);
433
434Util.augment(Shape, {
435 isShape: true,
436 createPath: function createPath() {},
437 init: function init(id) {
438 Shape.superclass.init.call(this);
439 var type = SHAPES[this.type];
440 if (type) {
441 var shape = document.createElementNS('http://www.w3.org/2000/svg', type);
442 id = id || Util.uniqueId(this.type + '_');
443 shape.setAttribute('id', id);
444 this.setSilent('el', shape);
445 this.setSilent('id', id);
446 }
447 },
448
449 /**
450 * 节点是否在图形中
451 * @param {Number} x x 坐标
452 * @param {Number} y y 坐标
453 * @return {Boolean} 是否在图形中
454 */
455 isPointInPath: function isPointInPath() {
456 return false;
457 },
458
459 /**
460 * 击中图形时是否进行包围盒判断
461 * @return {Boolean} [description]
462 */
463 isHitBox: function isHitBox() {
464 return true;
465 },
466
467 /**
468 * 节点是否能够被击中
469 * @return {Boolean} 是否在图形中
470 */
471 isHit: function isHit() {
472 return false;
473 },
474
475 /**
476 * @protected
477 * @protected
478 * 计算包围盒
479 * @return {Object} 包围盒
480 */
481 calculateBox: function calculateBox() {
482 return null;
483 },
484
485 // 获取拾取时线的宽度,需要考虑附加的线的宽度
486 getHitLineWidth: function getHitLineWidth() {
487 var attrs = this.__attrs;
488 // if (!attrs.stroke) {
489 // return 0;
490 // }
491 var lineAppendWidth = attrs.lineAppendWidth || 0;
492 var lineWidth = attrs.lineWidth || 0;
493 return lineWidth + lineAppendWidth;
494 },
495
496 // 清除当前的矩阵
497 clearTotalMatrix: function clearTotalMatrix() {
498 this.__cfg.totalMatrix = null;
499 this.__cfg.region = null;
500 },
501 clearBBox: function clearBBox() {
502 this.__cfg.box = null;
503 this.__cfg.region = null;
504 }
505});
506
507module.exports = Shape;
508
509/***/ }),
510/* 5 */
511/***/ (function(module, __webpack_exports__, __webpack_require__) {
512
513"use strict";
514/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_color__ = __webpack_require__(18);
515/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["e"]; });
516/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["g"]; });
517/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["f"]; });
518/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_lab__ = __webpack_require__(92);
519/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["a"]; });
520/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["b"]; });
521/* unused harmony reexport lch */
522/* unused harmony reexport gray */
523/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__ = __webpack_require__(93);
524/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__["a"]; });
525
526
527
528
529/***/ }),
530/* 6 */
531/***/ (function(module, exports, __webpack_require__) {
532
533var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
534
535var Marker = __webpack_require__(27);
536var Util = __webpack_require__(0);
537
538var PI = Math.PI;
539var sin = Math.sin;
540var cos = Math.cos;
541var atan2 = Math.atan2;
542var DEFAULT_LENGTH = 10;
543var DEFAULT_ANGLE = PI / 3;
544
545function _addArrow(ctx, attrs, x1, y1, x2, y2) {
546 var leftX = void 0;
547 var leftY = void 0;
548 var rightX = void 0;
549 var rightY = void 0;
550 var offsetX = void 0;
551 var offsetY = void 0;
552 var angle = void 0;
553
554 if (!attrs.fill) {
555 // 闭合的不绘制箭头
556 var arrowLength = attrs.arrowLength || DEFAULT_LENGTH;
557 var arrowAngle = attrs.arrowAngle ? attrs.arrowAngle * PI / 180 : DEFAULT_ANGLE; // 转换为弧
558 // Calculate angle
559 angle = atan2(y2 - y1, x2 - x1);
560 // Adjust angle correctly
561 angle -= PI;
562 // Calculate offset to place arrow at edge of path
563 offsetX = attrs.lineWidth * cos(angle);
564 offsetY = attrs.lineWidth * sin(angle);
565
566 // Calculate coordinates for left half of arrow
567 leftX = x2 + arrowLength * cos(angle + arrowAngle / 2);
568 leftY = y2 + arrowLength * sin(angle + arrowAngle / 2);
569 // Calculate coordinates for right half of arrow
570 rightX = x2 + arrowLength * cos(angle - arrowAngle / 2);
571 rightY = y2 + arrowLength * sin(angle - arrowAngle / 2);
572 ctx.beginPath();
573 // Draw left half of arrow
574 ctx.moveTo(leftX - offsetX, leftY - offsetY);
575 ctx.lineTo(x2 - offsetX, y2 - offsetY);
576 // Draw right half of arrow
577 ctx.lineTo(rightX - offsetX, rightY - offsetY);
578
579 // Visually connect arrow to path
580 ctx.moveTo(x2 - offsetX, y2 - offsetY);
581 ctx.lineTo(x2 + offsetX, y2 + offsetY);
582 // Move back to end of path
583 ctx.moveTo(x2, y2);
584 ctx.stroke();
585 }
586}
587
588function _addMarker(ctx, attrs, x1, y1, x2, y2, shape) {
589 var marker = shape.__attrs;
590 var method = marker.symbol;
591 var markerX = marker.x || x2;
592 var markerY = marker.y || y2;
593 var markerR = marker.r || attrs.lineWidth;
594 if (!Util.isFunction(method)) {
595 method = Marker.Symbols[method || 'triangle'];
596 }
597 var deg = 0;
598 var x = x1 - x2;
599 var y = y1 - y2;
600 if (y === 0) {
601 if (x < 0) {
602 deg = Math.PI / 2;
603 } else {
604 deg = 270 * Math.PI / 180;
605 }
606 } else if (x >= 0 && y > 0) {
607 deg = -Math.atan(x / y);
608 } else if (x <= 0 && y < 0) {
609 deg = Math.PI - Math.atan(x / y);
610 } else if (x > 0 && y < 0) {
611 deg = Math.PI + Math.atan(-x / y);
612 } else if (x < 0 && y > 0) {
613 deg = Math.atan(x / -y);
614 }
615 ctx.save();
616 ctx.beginPath();
617 ctx.translate(markerX, markerY);
618 ctx.rotate(deg);
619 ctx.translate(-markerX, -markerY);
620 method(markerX, markerY, markerR, ctx, shape);
621 ctx.setTransform(1, 0, 0, 1, 0, 0);
622 ctx.fillStyle = shape.attr('fill') || ctx.strokeStyle;
623 ctx.fill();
624 ctx.restore();
625}
626
627module.exports = {
628 addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) {
629 if (_typeof(attrs.startArrow) === 'object') {
630 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.startArrow);
631 } else if (attrs.startArrow) {
632 _addArrow(ctx, attrs, x1, y1, x2, y2);
633 }
634 },
635 addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) {
636 if (_typeof(attrs.endArrow) === 'object') {
637 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.endArrow);
638 } else if (attrs.endArrow) {
639 _addArrow(ctx, attrs, x1, y1, x2, y2);
640 }
641 }
642};
643
644/***/ }),
645/* 7 */
646/***/ (function(module, exports, __webpack_require__) {
647
648var Util = __webpack_require__(10);
649
650module.exports = {
651 isFunction: Util.isFunction,
652 isObject: Util.isObject,
653 isBoolean: Util.isBoolean,
654 isNil: Util.isNil,
655 isString: Util.isString,
656 isArray: Util.isArray,
657 isNumber: Util.isNumber,
658 isEmpty: Util.isEmpty, // isBlank
659 uniqueId: Util.uniqueId,
660 clone: Util.clone,
661 assign: Util.mix, // simpleMix
662 merge: Util.deepMix, // mix
663 upperFirst: Util.upperFirst, // ucfirst
664 each: Util.each,
665 isEqual: Util.isEqual,
666 toArray: Util.toArray,
667 extend: Util.extend,
668 augment: Util.augment,
669 remove: Util.arrayUtil.pull,
670 isNumberEqual: Util.isNumberEqual,
671 toRadian: Util.toRadian,
672 toDegree: Util.toDegree,
673 mod: Util.mod,
674 clamp: Util.clamp
675};
676
677/***/ }),
678/* 8 */
679/***/ (function(module, __webpack_exports__, __webpack_require__) {
680
681"use strict";
682/* harmony export (immutable) */ __webpack_exports__["c"] = hue;
683/* harmony export (immutable) */ __webpack_exports__["b"] = gamma;
684/* harmony export (immutable) */ __webpack_exports__["a"] = nogamma;
685/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(36);
686
687
688function linear(a, d) {
689 return function (t) {
690 return a + t * d;
691 };
692}
693
694function exponential(a, b, y) {
695 return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function (t) {
696 return Math.pow(a + t * b, y);
697 };
698}
699
700function hue(a, b) {
701 var d = b - a;
702 return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
703}
704
705function gamma(y) {
706 return (y = +y) === 1 ? nogamma : function (a, b) {
707 return b - a ? exponential(a, b, y) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
708 };
709}
710
711function nogamma(a, b) {
712 var d = b - a;
713 return d ? linear(a, d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
714}
715
716/***/ }),
717/* 9 */
718/***/ (function(module, exports, __webpack_require__) {
719
720function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
721
722// const Global = require('../global');
723var G = __webpack_require__(69);
724var EventUtil = __webpack_require__(116);
725var DomUtil = G.DomUtil;
726var CommonUtil = G.CommonUtil;
727// const View = require('../chart/view');
728// const G2 = require('../core.js');
729
730var assign = CommonUtil.assign;
731
732var EVENT_TYPES = ['start', 'process', 'end', 'reset'];
733
734var Interaction = function () {
735 Interaction.prototype.getDefaultCfg = function getDefaultCfg() {
736 return {
737 startEvent: 'mousedown',
738 processEvent: 'mousemove',
739 endEvent: 'mouseup',
740 resetEvent: 'dblclick'
741 };
742 };
743
744 Interaction.prototype._start = function _start(ev) {
745 var me = this;
746 me.preStart && me.preStart(ev);
747 me.start(ev);
748 me.onStart && me.onStart(ev);
749 };
750
751 Interaction.prototype._process = function _process(ev) {
752 var me = this;
753 me.preProcess && me.preProcess(ev);
754 me.process(ev);
755 me.onProcess && me.onProcess(ev);
756 };
757
758 Interaction.prototype._end = function _end(ev) {
759 var me = this;
760 me.preEnd && me.preEnd(ev);
761 me.end(ev);
762 me.onEnd && me.onEnd(ev);
763 };
764
765 Interaction.prototype._reset = function _reset(ev) {
766 var me = this;
767 me.preReset && me.preReset(ev);
768 me.reset(ev);
769 me.onReset && me.onReset(ev);
770 };
771
772 Interaction.prototype.start = function start() {
773 // TODO override
774 };
775
776 Interaction.prototype.process = function process() {
777 // TODO override
778 };
779
780 Interaction.prototype.end = function end() {
781 // TODO override
782 };
783
784 Interaction.prototype.reset = function reset() {
785 // TODO override
786 };
787
788 function Interaction(cfg, view) {
789 _classCallCheck(this, Interaction);
790
791 var me = this;
792 var defaultCfg = me.getDefaultCfg();
793 assign(me, defaultCfg, cfg);
794 me.view = view;
795 me.canvas = view.get('canvas');
796 me._bindEvents();
797 }
798
799 Interaction.prototype._bindEvents = function _bindEvents() {
800 var me = this;
801 var canvas = me.canvas;
802 var canvasDOM = canvas.get('canvasDOM');
803 me._clearEvents();
804 CommonUtil.each(EVENT_TYPES, function (type) {
805 var ucType = CommonUtil.upperFirst(type);
806 me['_on' + ucType + 'Listener'] = DomUtil.addEventListener(canvasDOM, me[type + 'Event'], EventUtil.wrapBehavior(me, '_' + type));
807 });
808 };
809
810 Interaction.prototype._clearEvents = function _clearEvents() {
811 var me = this;
812 CommonUtil.each(EVENT_TYPES, function (type) {
813 var listenerName = '_on' + CommonUtil.upperFirst(type) + 'Listener';
814 me[listenerName] && me[listenerName].remove();
815 });
816 };
817
818 Interaction.prototype.destroy = function destroy() {
819 this._clearEvents();
820 };
821
822 return Interaction;
823}();
824
825module.exports = Interaction;
826
827/***/ }),
828/* 10 */
829/***/ (function(module, exports, __webpack_require__) {
830
831/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
832
833(function webpackUniversalModuleDefinition(root, factory) {
834 if (( false ? 'undefined' : _typeof2(exports)) === 'object' && ( false ? 'undefined' : _typeof2(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
835 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
836 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
837 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else if ((typeof exports === 'undefined' ? 'undefined' : _typeof2(exports)) === 'object') exports["Util"] = factory();else root["Util"] = factory();
838})(this, function () {
839 return (/******/function (modules) {
840 // webpackBootstrap
841 /******/ // The module cache
842 /******/var installedModules = {};
843 /******/
844 /******/ // The require function
845 /******/function __webpack_require__(moduleId) {
846 /******/
847 /******/ // Check if module is in cache
848 /******/if (installedModules[moduleId]) {
849 /******/return installedModules[moduleId].exports;
850 /******/
851 }
852 /******/ // Create a new module (and put it into the cache)
853 /******/var module = installedModules[moduleId] = {
854 /******/i: moduleId,
855 /******/l: false,
856 /******/exports: {}
857 /******/ };
858 /******/
859 /******/ // Execute the module function
860 /******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
861 /******/
862 /******/ // Flag the module as loaded
863 /******/module.l = true;
864 /******/
865 /******/ // Return the exports of the module
866 /******/return module.exports;
867 /******/
868 }
869 /******/
870 /******/
871 /******/ // expose the modules object (__webpack_modules__)
872 /******/__webpack_require__.m = modules;
873 /******/
874 /******/ // expose the module cache
875 /******/__webpack_require__.c = installedModules;
876 /******/
877 /******/ // define getter function for harmony exports
878 /******/__webpack_require__.d = function (exports, name, getter) {
879 /******/if (!__webpack_require__.o(exports, name)) {
880 /******/Object.defineProperty(exports, name, {
881 /******/configurable: false,
882 /******/enumerable: true,
883 /******/get: getter
884 /******/ });
885 /******/
886 }
887 /******/
888 };
889 /******/
890 /******/ // getDefaultExport function for compatibility with non-harmony modules
891 /******/__webpack_require__.n = function (module) {
892 /******/var getter = module && module.__esModule ?
893 /******/function getDefault() {
894 return module['default'];
895 } :
896 /******/function getModuleExports() {
897 return module;
898 };
899 /******/__webpack_require__.d(getter, 'a', getter);
900 /******/return getter;
901 /******/
902 };
903 /******/
904 /******/ // Object.prototype.hasOwnProperty.call
905 /******/__webpack_require__.o = function (object, property) {
906 return Object.prototype.hasOwnProperty.call(object, property);
907 };
908 /******/
909 /******/ // __webpack_public_path__
910 /******/__webpack_require__.p = "";
911 /******/
912 /******/ // Load entry module and return exports
913 /******/return __webpack_require__(__webpack_require__.s = 22);
914 /******/
915 }(
916 /************************************************************************/
917 /******/[
918 /* 0 */
919 /***/function (module, exports, __webpack_require__) {
920
921 var isType = __webpack_require__(3);
922
923 var isArray = Array.isArray ? Array.isArray : function (value) {
924 return isType(value, 'Array');
925 };
926
927 module.exports = isArray;
928
929 /***/
930 },
931 /* 1 */
932 /***/function (module, exports, __webpack_require__) {
933
934 var isObject = __webpack_require__(12);
935 var isArray = __webpack_require__(0);
936
937 var each = function each(elements, func) {
938 if (!elements) {
939 return;
940 }
941 var rst = void 0;
942 if (isArray(elements)) {
943 for (var i = 0, len = elements.length; i < len; i++) {
944 rst = func(elements[i], i);
945 if (rst === false) {
946 break;
947 }
948 }
949 } else if (isObject(elements)) {
950 for (var k in elements) {
951 if (elements.hasOwnProperty(k)) {
952 rst = func(elements[k], k);
953 if (rst === false) {
954 break;
955 }
956 }
957 }
958 }
959 };
960
961 module.exports = each;
962
963 /***/
964 },
965 /* 2 */
966 /***/function (module, exports) {
967
968 var isArrayLike = function isArrayLike(value) {
969 /**
970 * isArrayLike([1, 2, 3]) => true
971 * isArrayLike(document.body.children) => true
972 * isArrayLike('abc') => true
973 * isArrayLike(Function) => false
974 */
975 return value !== null && typeof value !== 'function' && isFinite(value.length);
976 };
977
978 module.exports = isArrayLike;
979
980 /***/
981 },
982 /* 3 */
983 /***/function (module, exports) {
984
985 var toString = {}.toString;
986 var isType = function isType(value, type) {
987 return toString.call(value) === '[object ' + type + ']';
988 };
989
990 module.exports = isType;
991
992 /***/
993 },
994 /* 4 */
995 /***/function (module, exports, __webpack_require__) {
996
997 /**
998 * 判断是否数字
999 * @return {Boolean} 是否数字
1000 */
1001 var isType = __webpack_require__(3);
1002
1003 var isNumber = function isNumber(value) {
1004 return isType(value, 'Number');
1005 };
1006 module.exports = isNumber;
1007
1008 /***/
1009 },
1010 /* 5 */
1011 /***/function (module, exports, __webpack_require__) {
1012
1013 /**
1014 * 是否为函数
1015 * @param {*} fn 对象
1016 * @return {Boolean} 是否函数
1017 */
1018 var isType = __webpack_require__(3);
1019
1020 var isFunction = function isFunction(value) {
1021 return isType(value, 'Function');
1022 };
1023
1024 module.exports = isFunction;
1025
1026 /***/
1027 },
1028 /* 6 */
1029 /***/function (module, exports) {
1030
1031 // isFinite,
1032 var isNil = function isNil(value) {
1033 /**
1034 * isNil(null) => true
1035 * isNil() => true
1036 */
1037 return value === null || value === undefined;
1038 };
1039
1040 module.exports = isNil;
1041
1042 /***/
1043 },
1044 /* 7 */
1045 /***/function (module, exports, __webpack_require__) {
1046
1047 var isObjectLike = __webpack_require__(8);
1048 var isType = __webpack_require__(3);
1049
1050 var isPlainObject = function isPlainObject(value) {
1051 /**
1052 * isObjectLike(new Foo) => false
1053 * isObjectLike([1, 2, 3]) => false
1054 * isObjectLike({ x: 0, y: 0 }) => true
1055 * isObjectLike(Object.create(null)) => true
1056 */
1057 if (!isObjectLike(value) || !isType(value, 'Object')) {
1058 return false;
1059 }
1060 if (Object.getPrototypeOf(value) === null) {
1061 return true;
1062 }
1063 var proto = value;
1064 while (Object.getPrototypeOf(proto) !== null) {
1065 proto = Object.getPrototypeOf(proto);
1066 }
1067 return Object.getPrototypeOf(value) === proto;
1068 };
1069
1070 module.exports = isPlainObject;
1071
1072 /***/
1073 },
1074 /* 8 */
1075 /***/function (module, exports) {
1076
1077 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
1078 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1079 } : function (obj) {
1080 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1081 };
1082
1083 var isObjectLike = function isObjectLike(value) {
1084 /**
1085 * isObjectLike({}) => true
1086 * isObjectLike([1, 2, 3]) => true
1087 * isObjectLike(Function) => false
1088 * isObjectLike(null) => false
1089 */
1090 return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
1091 };
1092
1093 module.exports = isObjectLike;
1094
1095 /***/
1096 },
1097 /* 9 */
1098 /***/function (module, exports, __webpack_require__) {
1099
1100 var isArrayLike = __webpack_require__(2);
1101
1102 function toArray(value) {
1103 return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
1104 }
1105
1106 module.exports = toArray;
1107
1108 /***/
1109 },
1110 /* 10 */
1111 /***/function (module, exports) {
1112
1113 function _mix(dist, obj) {
1114 for (var key in obj) {
1115 if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
1116 dist[key] = obj[key];
1117 }
1118 }
1119 }
1120
1121 var mix = function mix(dist, src1, src2, src3) {
1122 if (src1) _mix(dist, src1);
1123 if (src2) _mix(dist, src2);
1124 if (src3) _mix(dist, src3);
1125 return dist;
1126 };
1127
1128 module.exports = mix;
1129
1130 /***/
1131 },
1132 /* 11 */
1133 /***/function (module, exports, __webpack_require__) {
1134
1135 var isArrayLike = __webpack_require__(2);
1136
1137 var indexOf = Array.prototype.indexOf;
1138
1139 var contains = function contains(arr, value) {
1140 if (!isArrayLike(arr)) {
1141 return false;
1142 }
1143 return indexOf.call(arr, value) > -1;
1144 };
1145
1146 module.exports = contains;
1147
1148 /***/
1149 },
1150 /* 12 */
1151 /***/function (module, exports) {
1152
1153 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
1154 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1155 } : function (obj) {
1156 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1157 };
1158
1159 var isObject = function isObject(value) {
1160 /**
1161 * isObject({}) => true
1162 * isObject([1, 2, 3]) => true
1163 * isObject(Function) => true
1164 * isObject(null) => false
1165 */
1166 var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
1167 return value !== null && type === 'object' || type === 'function';
1168 };
1169
1170 module.exports = isObject;
1171
1172 /***/
1173 },
1174 /* 13 */
1175 /***/function (module, exports, __webpack_require__) {
1176
1177 var each = __webpack_require__(1);
1178 var isArrayLike = __webpack_require__(2);
1179
1180 var filter = function filter(arr, func) {
1181 if (!isArrayLike(arr)) {
1182 return arr;
1183 }
1184 var result = [];
1185 each(arr, function (value, index) {
1186 if (func(value, index)) {
1187 result.push(value);
1188 }
1189 });
1190 return result;
1191 };
1192
1193 module.exports = filter;
1194
1195 /***/
1196 },
1197 /* 14 */
1198 /***/function (module, exports, __webpack_require__) {
1199
1200 var isArrayLike = __webpack_require__(2);
1201
1202 var splice = Array.prototype.splice;
1203
1204 var pullAt = function pullAt(arr, indexes) {
1205 if (!isArrayLike(arr)) {
1206 return [];
1207 }
1208 var length = arr ? indexes.length : 0;
1209 var last = length - 1;
1210
1211 while (length--) {
1212 var previous = void 0;
1213 var index = indexes[length];
1214 if (length === last || index !== previous) {
1215 previous = index;
1216 splice.call(arr, index, 1);
1217 }
1218 }
1219 return arr;
1220 };
1221
1222 module.exports = pullAt;
1223
1224 /***/
1225 },
1226 /* 15 */
1227 /***/function (module, exports) {
1228
1229 module.exports = parseInt;
1230
1231 /***/
1232 },
1233 /* 16 */
1234 /***/function (module, exports) {
1235
1236 var toString = {}.toString;
1237
1238 var getType = function getType(value) {
1239 return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
1240 };
1241
1242 module.exports = getType;
1243
1244 /***/
1245 },
1246 /* 17 */
1247 /***/function (module, exports) {
1248
1249 var objectProto = Object.prototype;
1250 var isPrototype = function isPrototype(value) {
1251 var Ctor = value && value.constructor;
1252 var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
1253 return value === proto;
1254 };
1255
1256 module.exports = isPrototype;
1257
1258 /***/
1259 },
1260 /* 18 */
1261 /***/function (module, exports, __webpack_require__) {
1262
1263 var isType = __webpack_require__(3);
1264
1265 var isString = function isString(str) {
1266 return isType(str, 'String');
1267 };
1268
1269 module.exports = isString;
1270
1271 /***/
1272 },
1273 /* 19 */
1274 /***/function (module, exports, __webpack_require__) {
1275
1276 var isFunction = __webpack_require__(5);
1277 var isArray = __webpack_require__(0);
1278 var groupBy = __webpack_require__(20);
1279
1280 var groupToMap = function groupToMap(data, condition) {
1281 if (!condition) {
1282 return {
1283 0: data
1284 };
1285 }
1286 if (!isFunction(condition)) {
1287 var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
1288 condition = function condition(row) {
1289 var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
1290 for (var i = 0, l = paramsCondition.length; i < l; i++) {
1291 unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();
1292 }
1293 return unique;
1294 };
1295 }
1296 var groups = groupBy(data, condition);
1297 return groups;
1298 };
1299
1300 module.exports = groupToMap;
1301
1302 /***/
1303 },
1304 /* 20 */
1305 /***/function (module, exports, __webpack_require__) {
1306
1307 var each = __webpack_require__(1);
1308 var isArray = __webpack_require__(0);
1309 var hasOwnProperty = Object.prototype.hasOwnProperty;
1310 var groupBy = function groupBy(data, condition) {
1311 if (!condition || !isArray(data)) {
1312 return data;
1313 }
1314 var result = {};
1315 var key = null;
1316 each(data, function (item) {
1317 key = condition(item);
1318 if (hasOwnProperty.call(result, key)) {
1319 result[key].push(item);
1320 } else {
1321 result[key] = [item];
1322 }
1323 });
1324 return result;
1325 };
1326
1327 module.exports = groupBy;
1328
1329 /***/
1330 },
1331 /* 21 */
1332 /***/function (module, exports, __webpack_require__) {
1333
1334 var isObjectLike = __webpack_require__(8);
1335 var isArrayLike = __webpack_require__(2);
1336 var isString = __webpack_require__(18);
1337
1338 var isEqual = function isEqual(value, other) {
1339 if (value === other) {
1340 return true;
1341 }
1342 if (!value || !other) {
1343 return false;
1344 }
1345 if (isString(value) || isString(other)) {
1346 return false;
1347 }
1348 if (isArrayLike(value) || isArrayLike(other)) {
1349 if (value.length !== other.length) {
1350 return false;
1351 }
1352 var rst = true;
1353 for (var i = 0; i < value.length; i++) {
1354 rst = isEqual(value[i], other[i]);
1355 if (!rst) {
1356 break;
1357 }
1358 }
1359 return rst;
1360 }
1361 if (isObjectLike(value) || isObjectLike(other)) {
1362 var valueKeys = Object.keys(value);
1363 var otherKeys = Object.keys(other);
1364 if (valueKeys.length !== otherKeys.length) {
1365 return false;
1366 }
1367 var _rst = true;
1368 for (var _i = 0; _i < valueKeys.length; _i++) {
1369 _rst = isEqual(value[valueKeys[_i]], other[valueKeys[_i]]);
1370 if (!_rst) {
1371 break;
1372 }
1373 }
1374 return _rst;
1375 }
1376 return false;
1377 };
1378
1379 module.exports = isEqual;
1380
1381 /***/
1382 },
1383 /* 22 */
1384 /***/function (module, exports, __webpack_require__) {
1385
1386 var arrayUtil = __webpack_require__(23);
1387 var eventUtil = __webpack_require__(34);
1388 var mathUtil = __webpack_require__(37);
1389 var stringUtil = __webpack_require__(52);
1390 var typeUtil = __webpack_require__(53);
1391 var each = __webpack_require__(1);
1392 var mix = __webpack_require__(10);
1393
1394 var util = {
1395 // collections
1396 arrayUtil: arrayUtil,
1397 eventUtil: eventUtil,
1398 mathUtil: mathUtil,
1399 stringUtil: stringUtil,
1400 typeUtil: typeUtil,
1401 // others
1402 augment: __webpack_require__(58),
1403 clone: __webpack_require__(59),
1404 deepMix: __webpack_require__(60),
1405 each: each,
1406 extend: __webpack_require__(61),
1407 filter: __webpack_require__(13),
1408 group: __webpack_require__(62),
1409 groupBy: __webpack_require__(20),
1410 groupToMap: __webpack_require__(19),
1411 indexOf: __webpack_require__(63),
1412 isEmpty: __webpack_require__(64),
1413 isEqual: __webpack_require__(21),
1414 isEqualWith: __webpack_require__(65),
1415 map: __webpack_require__(66),
1416 mix: mix,
1417 pick: __webpack_require__(67),
1418 toArray: __webpack_require__(9),
1419 uniqueId: __webpack_require__(68)
1420 };
1421
1422 each([arrayUtil, eventUtil, mathUtil, stringUtil, typeUtil], function (collection) {
1423 mix(util, collection);
1424 });
1425
1426 module.exports = util;
1427
1428 /***/
1429 },
1430 /* 23 */
1431 /***/function (module, exports, __webpack_require__) {
1432
1433 module.exports = {
1434 contains: __webpack_require__(11),
1435 firstValue: __webpack_require__(24),
1436 flatten: __webpack_require__(25),
1437 getRange: __webpack_require__(26),
1438 merge: __webpack_require__(27),
1439 pull: __webpack_require__(28),
1440 pullAt: __webpack_require__(14),
1441 reduce: __webpack_require__(29),
1442 remove: __webpack_require__(30),
1443 union: __webpack_require__(31),
1444 uniq: __webpack_require__(32),
1445 values: __webpack_require__(33)
1446 };
1447
1448 /***/
1449 },
1450 /* 24 */
1451 /***/function (module, exports, __webpack_require__) {
1452
1453 var isNil = __webpack_require__(6);
1454 var isArray = __webpack_require__(0);
1455
1456 var firstValue = function firstValue(data, name) {
1457 var rst = null;
1458 for (var i = 0; i < data.length; i++) {
1459 var obj = data[i];
1460 var value = obj[name];
1461 if (!isNil(value)) {
1462 if (isArray(value)) {
1463 rst = value[0];
1464 } else {
1465 rst = value;
1466 }
1467 break;
1468 }
1469 }
1470 return rst;
1471 };
1472
1473 module.exports = firstValue;
1474
1475 /***/
1476 },
1477 /* 25 */
1478 /***/function (module, exports, __webpack_require__) {
1479
1480 var isArray = __webpack_require__(0);
1481 var each = __webpack_require__(1);
1482
1483 /**
1484 * Flattens `array` a single level deep.
1485 *
1486 * @param {Array} arr The array to flatten.
1487 * @return {Array} Returns the new flattened array.
1488 * @example
1489 *
1490 * _.flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
1491 */
1492 var flatten = function flatten(arr) {
1493 if (!isArray(arr)) {
1494 return arr;
1495 }
1496 var result = [];
1497 each(arr, function (item) {
1498 if (isArray(item)) {
1499 each(item, function (subItem) {
1500 result.push(subItem);
1501 });
1502 } else {
1503 result.push(item);
1504 }
1505 });
1506 return result;
1507 };
1508
1509 module.exports = flatten;
1510
1511 /***/
1512 },
1513 /* 26 */
1514 /***/function (module, exports, __webpack_require__) {
1515
1516 var filter = __webpack_require__(13);
1517 var isArray = __webpack_require__(0);
1518
1519 var getRange = function getRange(values) {
1520 // 存在 NaN 时,min,max 判定会出问题
1521 values = filter(values, function (v) {
1522 return !isNaN(v);
1523 });
1524 if (!values.length) {
1525 // 如果没有数值则直接返回0
1526 return {
1527 min: 0,
1528 max: 0
1529 };
1530 }
1531 if (isArray(values[0])) {
1532 var tmp = [];
1533 for (var i = 0; i < values.length; i++) {
1534 tmp = tmp.concat(values[i]);
1535 }
1536 values = tmp;
1537 }
1538 var max = Math.max.apply(null, values);
1539 var min = Math.min.apply(null, values);
1540 return {
1541 min: min,
1542 max: max
1543 };
1544 };
1545
1546 module.exports = getRange;
1547
1548 /***/
1549 },
1550 /* 27 */
1551 /***/function (module, exports) {
1552
1553 var merge = function merge(dataArray) {
1554 var rst = [];
1555 for (var i = 0; i < dataArray.length; i++) {
1556 rst = rst.concat(dataArray[i]);
1557 }
1558 return rst;
1559 };
1560
1561 module.exports = merge;
1562
1563 /***/
1564 },
1565 /* 28 */
1566 /***/function (module, exports) {
1567
1568 var arrPrototype = Array.prototype;
1569 var splice = arrPrototype.splice;
1570 var indexOf = arrPrototype.indexOf;
1571 var slice = arrPrototype.slice;
1572
1573 var pull = function pull(arr) {
1574 var values = slice.call(arguments, 1);
1575 for (var i = 0; i < values.length; i++) {
1576 var value = values[i];
1577 var fromIndex = -1;
1578 while ((fromIndex = indexOf.call(arr, value)) > -1) {
1579 splice.call(arr, fromIndex, 1);
1580 }
1581 }
1582 return arr;
1583 };
1584
1585 module.exports = pull;
1586
1587 /***/
1588 },
1589 /* 29 */
1590 /***/function (module, exports, __webpack_require__) {
1591
1592 var isArray = __webpack_require__(0);
1593 var isPlainObject = __webpack_require__(7);
1594 var each = __webpack_require__(1);
1595
1596 var reduce = function reduce(arr, fn, init) {
1597 if (!isArray(arr) && !isPlainObject(arr)) {
1598 return arr;
1599 }
1600 var result = init;
1601 each(arr, function (data, i) {
1602 result = fn(result, data, i);
1603 });
1604 return result;
1605 };
1606
1607 module.exports = reduce;
1608
1609 /***/
1610 },
1611 /* 30 */
1612 /***/function (module, exports, __webpack_require__) {
1613
1614 var isArrayLike = __webpack_require__(2);
1615 var pullAt = __webpack_require__(14);
1616
1617 var remove = function remove(arr, predicate) {
1618 /**
1619 * const arr = [1, 2, 3, 4]
1620 * const evens = remove(arr, n => n % 2 == 0)
1621 * console.log(arr) // => [1, 3]
1622 * console.log(evens) // => [2, 4]
1623 */
1624 var result = [];
1625 if (!isArrayLike(arr)) {
1626 return result;
1627 }
1628 var i = -1;
1629 var indexes = [];
1630 var length = arr.length;
1631
1632 while (++i < length) {
1633 var value = arr[i];
1634 if (predicate(value, i, arr)) {
1635 result.push(value);
1636 indexes.push(i);
1637 }
1638 }
1639 pullAt(arr, indexes);
1640 return result;
1641 };
1642
1643 module.exports = remove;
1644
1645 /***/
1646 },
1647 /* 31 */
1648 /***/function (module, exports, __webpack_require__) {
1649
1650 var each = __webpack_require__(1);
1651 var toArray = __webpack_require__(9);
1652
1653 var union = function union() {
1654 var result = new Set();
1655 var values = [];
1656 each(arguments, function (arg) {
1657 values = toArray(arg);
1658 each(values, function (val) {
1659 result.add(val);
1660 });
1661 });
1662 return Array.from(result);
1663 };
1664
1665 module.exports = union;
1666
1667 /***/
1668 },
1669 /* 32 */
1670 /***/function (module, exports, __webpack_require__) {
1671
1672 var contains = __webpack_require__(11);
1673
1674 var uniq = function uniq(arr) {
1675 var resultArr = [];
1676 arr.forEach(function (item) {
1677 if (!contains(resultArr, item)) {
1678 resultArr.push(item);
1679 }
1680 });
1681 return resultArr;
1682 };
1683
1684 module.exports = uniq;
1685
1686 /***/
1687 },
1688 /* 33 */
1689 /***/function (module, exports, __webpack_require__) {
1690
1691 var each = __webpack_require__(1);
1692 var isNil = __webpack_require__(6);
1693 var isArray = __webpack_require__(0);
1694
1695 var values = function values(data, name) {
1696 var rst = [];
1697 var tmpMap = {};
1698 for (var i = 0; i < data.length; i++) {
1699 var obj = data[i];
1700 var value = obj[name];
1701 if (!isNil(value)) {
1702 if (!isArray(value)) {
1703 value = [value];
1704 }
1705 each(value, function (val) {
1706 if (!tmpMap[val]) {
1707 rst.push(val);
1708 tmpMap[val] = true;
1709 }
1710 });
1711 }
1712 }
1713 return rst;
1714 };
1715
1716 module.exports = values;
1717
1718 /***/
1719 },
1720 /* 34 */
1721 /***/function (module, exports, __webpack_require__) {
1722
1723 module.exports = {
1724 getWrapBehavior: __webpack_require__(35),
1725 wrapBehavior: __webpack_require__(36)
1726 };
1727
1728 /***/
1729 },
1730 /* 35 */
1731 /***/function (module, exports) {
1732
1733 /**
1734 * 获取封装的事件
1735 * @protected
1736 * @param {Object} obj 对象
1737 * @param {String} action 事件名称
1738 * @return {Function} 返回事件处理函数
1739 */
1740 function getWrapBehavior(obj, action) {
1741 return obj['_wrap_' + action];
1742 }
1743
1744 module.exports = getWrapBehavior;
1745
1746 /***/
1747 },
1748 /* 36 */
1749 /***/function (module, exports) {
1750
1751 /**
1752 * 封装事件,便于使用上下文this,和便于解除事件时使用
1753 * @protected
1754 * @param {Object} obj 对象
1755 * @param {String} action 事件名称
1756 * @return {Function} 返回事件处理函数
1757 */
1758 function wrapBehavior(obj, action) {
1759 if (obj['_wrap_' + action]) {
1760 return obj['_wrap_' + action];
1761 }
1762 var method = function method(e) {
1763 obj[action](e);
1764 };
1765 obj['_wrap_' + action] = method;
1766 return method;
1767 }
1768
1769 module.exports = wrapBehavior;
1770
1771 /***/
1772 },
1773 /* 37 */
1774 /***/function (module, exports, __webpack_require__) {
1775
1776 module.exports = {
1777 clamp: __webpack_require__(38),
1778 fixedBase: __webpack_require__(39),
1779 isDecimal: __webpack_require__(40),
1780 isEven: __webpack_require__(41),
1781 isInteger: __webpack_require__(42),
1782 isNegative: __webpack_require__(43),
1783 isNumberEqual: __webpack_require__(44),
1784 isOdd: __webpack_require__(45),
1785 isPositive: __webpack_require__(46),
1786 maxBy: __webpack_require__(47),
1787 minBy: __webpack_require__(48),
1788 mod: __webpack_require__(49),
1789 toDegree: __webpack_require__(50),
1790 toInt: __webpack_require__(15),
1791 toInteger: __webpack_require__(15),
1792 toRadian: __webpack_require__(51)
1793 };
1794
1795 /***/
1796 },
1797 /* 38 */
1798 /***/function (module, exports) {
1799
1800 var clamp = function clamp(a, min, max) {
1801 if (a < min) {
1802 return min;
1803 } else if (a > max) {
1804 return max;
1805 }
1806 return a;
1807 };
1808
1809 module.exports = clamp;
1810
1811 /***/
1812 },
1813 /* 39 */
1814 /***/function (module, exports) {
1815
1816 var fixedBase = function fixedBase(v, base) {
1817 var str = base.toString();
1818 var index = str.indexOf('.');
1819 if (index === -1) {
1820 return Math.round(v);
1821 }
1822 var length = str.substr(index + 1).length;
1823 if (length > 20) {
1824 length = 20;
1825 }
1826 return parseFloat(v.toFixed(length));
1827 };
1828
1829 module.exports = fixedBase;
1830
1831 /***/
1832 },
1833 /* 40 */
1834 /***/function (module, exports, __webpack_require__) {
1835
1836 var isNumber = __webpack_require__(4);
1837
1838 var isDecimal = function isDecimal(num) {
1839 return isNumber(num) && num % 1 !== 0;
1840 };
1841
1842 module.exports = isDecimal;
1843
1844 /***/
1845 },
1846 /* 41 */
1847 /***/function (module, exports, __webpack_require__) {
1848
1849 var isNumber = __webpack_require__(4);
1850
1851 var isEven = function isEven(num) {
1852 return isNumber(num) && num % 2 === 0;
1853 };
1854
1855 module.exports = isEven;
1856
1857 /***/
1858 },
1859 /* 42 */
1860 /***/function (module, exports, __webpack_require__) {
1861
1862 var isNumber = __webpack_require__(4);
1863
1864 var isInteger = Number.isInteger ? Number.isInteger : function (num) {
1865 return isNumber(num) && num % 1 === 0;
1866 };
1867
1868 module.exports = isInteger;
1869
1870 /***/
1871 },
1872 /* 43 */
1873 /***/function (module, exports, __webpack_require__) {
1874
1875 var isNumber = __webpack_require__(4);
1876
1877 var isNagative = function isNagative(num) {
1878 return isNumber(num) && num < 0;
1879 };
1880
1881 module.exports = isNagative;
1882
1883 /***/
1884 },
1885 /* 44 */
1886 /***/function (module, exports) {
1887
1888 var PRECISION = 0.00001; // numbers less than this is considered as 0
1889
1890 var isNumberEqual = function isNumberEqual(a, b) {
1891 return Math.abs(a - b) < PRECISION;
1892 };
1893
1894 module.exports = isNumberEqual;
1895
1896 /***/
1897 },
1898 /* 45 */
1899 /***/function (module, exports, __webpack_require__) {
1900
1901 var isNumber = __webpack_require__(4);
1902
1903 var isOdd = function isOdd(num) {
1904 return isNumber(num) && num % 2 !== 0;
1905 };
1906
1907 module.exports = isOdd;
1908
1909 /***/
1910 },
1911 /* 46 */
1912 /***/function (module, exports, __webpack_require__) {
1913
1914 var isNumber = __webpack_require__(4);
1915
1916 var isPositive = function isPositive(num) {
1917 return isNumber(num) && num > 0;
1918 };
1919
1920 module.exports = isPositive;
1921
1922 /***/
1923 },
1924 /* 47 */
1925 /***/function (module, exports, __webpack_require__) {
1926
1927 var isArray = __webpack_require__(0);
1928 var isFunction = __webpack_require__(5);
1929 var each = __webpack_require__(1);
1930 /**
1931 * @param {Array} arr The array to iterate over.
1932 * @param {Function} [fn] The iteratee invoked per element.
1933 * @return {*} Returns the maximum value.
1934 * @example
1935 *
1936 * var objects = [{ 'n': 1 }, { 'n': 2 }];
1937 *
1938 * maxBy(objects, function(o) { return o.n; });
1939 * // => { 'n': 2 }
1940 *
1941 * maxBy(objects, 'n');
1942 * // => { 'n': 2 }
1943 */
1944 var maxBy = function maxBy(arr, fn) {
1945 if (!isArray(arr)) {
1946 return undefined;
1947 }
1948 var max = arr[0];
1949 var maxData = void 0;
1950 if (isFunction(fn)) {
1951 maxData = fn(arr[0]);
1952 } else {
1953 maxData = arr[0][fn];
1954 }
1955 var data = void 0;
1956 each(arr, function (val) {
1957 if (isFunction(fn)) {
1958 data = fn(val);
1959 } else {
1960 data = val[fn];
1961 }
1962 if (data > maxData) {
1963 max = val;
1964 maxData = data;
1965 }
1966 });
1967 return max;
1968 };
1969
1970 module.exports = maxBy;
1971
1972 /***/
1973 },
1974 /* 48 */
1975 /***/function (module, exports, __webpack_require__) {
1976
1977 var isArray = __webpack_require__(0);
1978 var isFunction = __webpack_require__(5);
1979 var each = __webpack_require__(1);
1980 /**
1981 * @param {Array} arr The array to iterate over.
1982 * @param {Function} [fn] The iteratee invoked per element.
1983 * @return {*} Returns the minimum value.
1984 * @example
1985 *
1986 * var objects = [{ 'n': 1 }, { 'n': 2 }];
1987 *
1988 * minBy(objects, function(o) { return o.n; });
1989 * // => { 'n': 1 }
1990 *
1991 * minBy(objects, 'n');
1992 * // => { 'n': 1 }
1993 */
1994 var minBy = function minBy(arr, fn) {
1995 if (!isArray(arr)) {
1996 return undefined;
1997 }
1998 var min = arr[0];
1999 var minData = void 0;
2000 if (isFunction(fn)) {
2001 minData = fn(arr[0]);
2002 } else {
2003 minData = arr[0][fn];
2004 }
2005 var data = void 0;
2006 each(arr, function (val) {
2007 if (isFunction(fn)) {
2008 data = fn(val);
2009 } else {
2010 data = val[fn];
2011 }
2012 if (data < minData) {
2013 min = val;
2014 minData = data;
2015 }
2016 });
2017 return min;
2018 };
2019
2020 module.exports = minBy;
2021
2022 /***/
2023 },
2024 /* 49 */
2025 /***/function (module, exports) {
2026
2027 var mod = function mod(n, m) {
2028 return (n % m + m) % m;
2029 };
2030
2031 module.exports = mod;
2032
2033 /***/
2034 },
2035 /* 50 */
2036 /***/function (module, exports) {
2037
2038 var DEGREE = 180 / Math.PI;
2039
2040 var toDegree = function toDegree(radian) {
2041 return DEGREE * radian;
2042 };
2043
2044 module.exports = toDegree;
2045
2046 /***/
2047 },
2048 /* 51 */
2049 /***/function (module, exports) {
2050
2051 var RADIAN = Math.PI / 180;
2052
2053 var toRadian = function toRadian(degree) {
2054 return RADIAN * degree;
2055 };
2056
2057 module.exports = toRadian;
2058
2059 /***/
2060 },
2061 /* 52 */
2062 /***/function (module, exports) {
2063
2064 function toString(value) {
2065 return value.toString();
2066 }
2067
2068 function upperCase(value) {
2069 return toString(value).toUpperCase();
2070 }
2071
2072 function lowerCase(value) {
2073 return toString(value).toLowerCase();
2074 }
2075
2076 var strUtil = {
2077 lc: lowerCase,
2078 lowerCase: lowerCase,
2079 lowerFirst: function lowerFirst(value) {
2080 value = toString(value);
2081 return lowerCase(value.charAt(0)) + value.substring(1);
2082 },
2083
2084 uc: upperCase,
2085 upperCase: upperCase,
2086 upperFirst: function upperFirst(value) {
2087 value = toString(value);
2088 return upperCase(value.charAt(0)) + value.substring(1);
2089 }
2090 };
2091
2092 module.exports = strUtil;
2093
2094 /***/
2095 },
2096 /* 53 */
2097 /***/function (module, exports, __webpack_require__) {
2098
2099 var isType = __webpack_require__(3);
2100
2101 var checkType = {
2102 getType: __webpack_require__(16),
2103 isArray: __webpack_require__(0),
2104 isArrayLike: __webpack_require__(2),
2105 isBoolean: __webpack_require__(54),
2106 isFunction: __webpack_require__(5),
2107 isNil: __webpack_require__(6),
2108 isNull: __webpack_require__(55),
2109 isNumber: __webpack_require__(4),
2110 isObject: __webpack_require__(12),
2111 isObjectLike: __webpack_require__(8),
2112 isPlainObject: __webpack_require__(7),
2113 isPrototype: __webpack_require__(17),
2114 isType: isType,
2115 isUndefined: __webpack_require__(56),
2116 isString: __webpack_require__(18),
2117 isRegExp: __webpack_require__(57)
2118 };
2119
2120 ['Arguments', 'Date', 'Error'].forEach(function (type) {
2121 checkType['is' + type] = function (value) {
2122 return isType(value, type);
2123 };
2124 });
2125
2126 module.exports = checkType;
2127
2128 /***/
2129 },
2130 /* 54 */
2131 /***/function (module, exports, __webpack_require__) {
2132
2133 /**
2134 * 是否是布尔类型
2135 *
2136 * @param {Object} value 测试的值
2137 * @return {Boolean}
2138 */
2139 var isType = __webpack_require__(3);
2140
2141 var isBoolean = function isBoolean(value) {
2142 return isType(value, 'Boolean');
2143 };
2144
2145 module.exports = isBoolean;
2146
2147 /***/
2148 },
2149 /* 55 */
2150 /***/function (module, exports) {
2151
2152 var isNull = function isNull(value) {
2153 return value === null;
2154 };
2155
2156 module.exports = isNull;
2157
2158 /***/
2159 },
2160 /* 56 */
2161 /***/function (module, exports) {
2162
2163 var isUndefined = function isUndefined(value) {
2164 return value === undefined;
2165 };
2166
2167 module.exports = isUndefined;
2168
2169 /***/
2170 },
2171 /* 57 */
2172 /***/function (module, exports, __webpack_require__) {
2173
2174 var isType = __webpack_require__(3);
2175
2176 var isRegExp = function isRegExp(str) {
2177 return isType(str, 'RegExp');
2178 };
2179
2180 module.exports = isRegExp;
2181
2182 /***/
2183 },
2184 /* 58 */
2185 /***/function (module, exports, __webpack_require__) {
2186
2187 var isFunction = __webpack_require__(5);
2188 var toArray = __webpack_require__(9);
2189 var mix = __webpack_require__(10);
2190
2191 var augment = function augment(c) {
2192 var args = toArray(arguments);
2193 for (var i = 1; i < args.length; i++) {
2194 var obj = args[i];
2195 if (isFunction(obj)) {
2196 obj = obj.prototype;
2197 }
2198 mix(c.prototype, obj);
2199 }
2200 };
2201
2202 module.exports = augment;
2203
2204 /***/
2205 },
2206 /* 59 */
2207 /***/function (module, exports, __webpack_require__) {
2208
2209 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
2210 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
2211 } : function (obj) {
2212 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
2213 };
2214
2215 var isArray = __webpack_require__(0);
2216
2217 var clone = function clone(obj) {
2218 if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
2219 return obj;
2220 }
2221 var rst = void 0;
2222 if (isArray(obj)) {
2223 rst = [];
2224 for (var i = 0, l = obj.length; i < l; i++) {
2225 if (_typeof(obj[i]) === 'object' && obj[i] != null) {
2226 rst[i] = clone(obj[i]);
2227 } else {
2228 rst[i] = obj[i];
2229 }
2230 }
2231 } else {
2232 rst = {};
2233 for (var k in obj) {
2234 if (_typeof(obj[k]) === 'object' && obj[k] != null) {
2235 rst[k] = clone(obj[k]);
2236 } else {
2237 rst[k] = obj[k];
2238 }
2239 }
2240 }
2241
2242 return rst;
2243 };
2244
2245 module.exports = clone;
2246
2247 /***/
2248 },
2249 /* 60 */
2250 /***/function (module, exports, __webpack_require__) {
2251
2252 var isPlainObject = __webpack_require__(7);
2253 var isArray = __webpack_require__(0);
2254
2255 var MAX_MIX_LEVEL = 5;
2256
2257 function _deepMix(dist, src, level, maxLevel) {
2258 level = level || 0;
2259 maxLevel = maxLevel || MAX_MIX_LEVEL;
2260 for (var key in src) {
2261 if (src.hasOwnProperty(key)) {
2262 var value = src[key];
2263 if (value !== null && isPlainObject(value)) {
2264 if (!isPlainObject(dist[key])) {
2265 dist[key] = {};
2266 }
2267 if (level < maxLevel) {
2268 _deepMix(dist[key], value, level + 1, maxLevel);
2269 } else {
2270 dist[key] = src[key];
2271 }
2272 } else if (isArray(value)) {
2273 dist[key] = [];
2274 dist[key] = dist[key].concat(value);
2275 } else if (value !== undefined) {
2276 dist[key] = value;
2277 }
2278 }
2279 }
2280 }
2281
2282 var deepMix = function deepMix() {
2283 var args = new Array(arguments.length);
2284 var length = args.length;
2285 for (var i = 0; i < length; i++) {
2286 args[i] = arguments[i];
2287 }
2288 var rst = args[0];
2289 for (var _i = 1; _i < length; _i++) {
2290 _deepMix(rst, args[_i]);
2291 }
2292 return rst;
2293 };
2294
2295 module.exports = deepMix;
2296
2297 /***/
2298 },
2299 /* 61 */
2300 /***/function (module, exports, __webpack_require__) {
2301
2302 var isFunction = __webpack_require__(5);
2303 var mix = __webpack_require__(10);
2304
2305 var extend = function extend(subclass, superclass, overrides, staticOverrides) {
2306 // 如果只提供父类构造函数,则自动生成子类构造函数
2307 if (!isFunction(superclass)) {
2308 overrides = superclass;
2309 superclass = subclass;
2310 subclass = function subclass() {};
2311 }
2312
2313 var create = Object.create ? function (proto, c) {
2314 return Object.create(proto, {
2315 constructor: {
2316 value: c
2317 }
2318 });
2319 } : function (proto, c) {
2320 function Tmp() {}
2321 Tmp.prototype = proto;
2322 var o = new Tmp();
2323 o.constructor = c;
2324 return o;
2325 };
2326
2327 var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
2328 subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
2329 subclass.superclass = create(superclass.prototype, superclass);
2330 mix(superObj, overrides);
2331 mix(subclass, staticOverrides);
2332 return subclass;
2333 };
2334
2335 module.exports = extend;
2336
2337 /***/
2338 },
2339 /* 62 */
2340 /***/function (module, exports, __webpack_require__) {
2341
2342 var groupToMap = __webpack_require__(19);
2343
2344 var group = function group(data, condition) {
2345 if (!condition) {
2346 return [data];
2347 }
2348 var groups = groupToMap(data, condition);
2349 var array = [];
2350 for (var i in groups) {
2351 array.push(groups[i]);
2352 }
2353 return array;
2354 };
2355
2356 module.exports = group;
2357
2358 /***/
2359 },
2360 /* 63 */
2361 /***/function (module, exports, __webpack_require__) {
2362
2363 var isArrayLike = __webpack_require__(2);
2364
2365 var indexOf = function indexOf(arr, obj) {
2366 if (!isArrayLike(arr)) {
2367 return -1;
2368 }
2369 var m = Array.prototype.indexOf;
2370 if (m) {
2371 return m.call(arr, obj);
2372 }
2373 var index = -1;
2374
2375 for (var i = 0; i < arr.length; i++) {
2376 if (arr[i] === obj) {
2377 index = i;
2378 break;
2379 }
2380 }
2381 return index;
2382 };
2383
2384 module.exports = indexOf;
2385
2386 /***/
2387 },
2388 /* 64 */
2389 /***/function (module, exports, __webpack_require__) {
2390
2391 var isNil = __webpack_require__(6);
2392 var isArrayLike = __webpack_require__(2);
2393 var getType = __webpack_require__(16);
2394 var isPrototype = __webpack_require__(17);
2395 var hasOwnProperty = Object.prototype.hasOwnProperty;
2396
2397 function isEmpty(value) {
2398 /**
2399 * isEmpty(null) => true
2400 * isEmpty() => true
2401 * isEmpty(true) => true
2402 * isEmpty(1) => true
2403 * isEmpty([1, 2, 3]) => false
2404 * isEmpty('abc') => false
2405 * isEmpty({ a: 1 }) => false
2406 */
2407 if (isNil(value)) {
2408 return true;
2409 }
2410 if (isArrayLike(value)) {
2411 return !value.length;
2412 }
2413 var type = getType(value);
2414 if (type === 'Map' || type === 'Set') {
2415 return !value.size;
2416 }
2417 if (isPrototype(value)) {
2418 return !Object.keys(value).length;
2419 }
2420 for (var key in value) {
2421 if (hasOwnProperty.call(value, key)) {
2422 return false;
2423 }
2424 }
2425 return true;
2426 }
2427
2428 module.exports = isEmpty;
2429
2430 /***/
2431 },
2432 /* 65 */
2433 /***/function (module, exports, __webpack_require__) {
2434
2435 var isFunction = __webpack_require__(5);
2436 var isEqual = __webpack_require__(21);
2437 /**
2438 * @param {*} value The value to compare.
2439 * @param {*} other The other value to compare.
2440 * @param {Function} [fn] The function to customize comparisons.
2441 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2442 * @example
2443 *
2444 * function isGreeting(value) {
2445 * return /^h(?:i|ello)$/.test(value);
2446 * }
2447 *
2448 * function customizer(objValue, othValue) {
2449 * if (isGreeting(objValue) && isGreeting(othValue)) {
2450 * return true;
2451 * }
2452 * }
2453 *
2454 * var array = ['hello', 'goodbye'];
2455 * var other = ['hi', 'goodbye'];
2456 *
2457 * _.isEqualWith(array, other, customizer); // => true
2458 */
2459
2460 var isEqualWith = function isEqualWith(value, other, fn) {
2461 if (!isFunction(fn)) {
2462 return isEqual(value, other);
2463 }
2464 return !!fn(value, other);
2465 };
2466
2467 module.exports = isEqualWith;
2468
2469 /***/
2470 },
2471 /* 66 */
2472 /***/function (module, exports, __webpack_require__) {
2473
2474 var each = __webpack_require__(1);
2475 var isArrayLike = __webpack_require__(2);
2476
2477 var map = function map(arr, func) {
2478 if (!isArrayLike(arr)) {
2479 return arr;
2480 }
2481 var result = [];
2482 each(arr, function (value, index) {
2483 result.push(func(value, index));
2484 });
2485 return result;
2486 };
2487
2488 module.exports = map;
2489
2490 /***/
2491 },
2492 /* 67 */
2493 /***/function (module, exports, __webpack_require__) {
2494
2495 var each = __webpack_require__(1);
2496 var isPlaineObject = __webpack_require__(7);
2497
2498 var hasOwnProperty = Object.prototype.hasOwnProperty;
2499 /**
2500 * Creates an object composed of the picked `object` properties.
2501 *
2502 * @param {Object} object The source object.
2503 * @param {...(string|string[])} [paths] The property paths to pick.
2504 * @returns {Object} Returns the new object.
2505 * @example
2506 *
2507 * var object = { 'a': 1, 'b': '2', 'c': 3 };
2508 * pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
2509 */
2510
2511 var pick = function pick(object, keys) {
2512 if (object === null || !isPlaineObject(object)) {
2513 return {};
2514 }
2515 var result = {};
2516 each(keys, function (key) {
2517 if (hasOwnProperty.call(object, key)) {
2518 result[key] = object[key];
2519 }
2520 });
2521 return result;
2522 };
2523
2524 module.exports = pick;
2525
2526 /***/
2527 },
2528 /* 68 */
2529 /***/function (module, exports) {
2530
2531 var uniqueId = function () {
2532 var map = {};
2533 return function (prefix) {
2534 prefix = prefix || 'g';
2535 if (!map[prefix]) {
2536 map[prefix] = 1;
2537 } else {
2538 map[prefix] += 1;
2539 }
2540 return prefix + map[prefix];
2541 };
2542 }();
2543
2544 module.exports = uniqueId;
2545
2546 /***/
2547 }]
2548 /******/)
2549 );
2550});
2551/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(28)(module)))
2552
2553/***/ }),
2554/* 11 */
2555/***/ (function(module, __webpack_exports__, __webpack_require__) {
2556
2557"use strict";
2558/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
2559 return a = +a, b -= a, function (t) {
2560 return a + b * t;
2561 };
2562});
2563
2564/***/ }),
2565/* 12 */
2566/***/ (function(module, exports, __webpack_require__) {
2567
2568var Util = __webpack_require__(0);
2569var vec2 = __webpack_require__(2).vec2;
2570
2571function cubicAt(p0, p1, p2, p3, t) {
2572 var onet = 1 - t;
2573 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
2574}
2575
2576function cubicDerivativeAt(p0, p1, p2, p3, t) {
2577 var onet = 1 - t;
2578 return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
2579}
2580
2581function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) {
2582 var t = void 0;
2583 var interval = 0.005;
2584 var d = Infinity;
2585 var _t = void 0;
2586 var v1 = void 0;
2587 var d1 = void 0;
2588 var d2 = void 0;
2589 var v2 = void 0;
2590 var prev = void 0;
2591 var next = void 0;
2592 var EPSILON = 0.0001;
2593 var v0 = [x, y];
2594
2595 for (_t = 0; _t < 1; _t += 0.05) {
2596 v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)];
2597
2598 d1 = vec2.squaredDistance(v0, v1);
2599 if (d1 < d) {
2600 t = _t;
2601 d = d1;
2602 }
2603 }
2604 d = Infinity;
2605
2606 for (var i = 0; i < 32; i++) {
2607 if (interval < EPSILON) {
2608 break;
2609 }
2610
2611 prev = t - interval;
2612 next = t + interval;
2613
2614 v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)];
2615
2616 d1 = vec2.squaredDistance(v0, v1);
2617
2618 if (prev >= 0 && d1 < d) {
2619 t = prev;
2620 d = d1;
2621 } else {
2622 v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)];
2623
2624 d2 = vec2.squaredDistance(v0, v2);
2625
2626 if (next <= 1 && d2 < d) {
2627 t = next;
2628 d = d2;
2629 } else {
2630 interval *= 0.5;
2631 }
2632 }
2633 }
2634
2635 if (out) {
2636 out.x = cubicAt(x1, x2, x3, x4, t);
2637 out.y = cubicAt(y1, y2, y3, y4, t);
2638 }
2639
2640 return Math.sqrt(d);
2641}
2642
2643function cubicExtrema(p0, p1, p2, p3) {
2644 var a = 3 * p0 - 9 * p1 + 9 * p2 - 3 * p3;
2645 var b = 6 * p1 - 12 * p2 + 6 * p3;
2646 var c = 3 * p2 - 3 * p3;
2647 var extrema = [];
2648 var t1 = void 0;
2649 var t2 = void 0;
2650 var discSqrt = void 0;
2651
2652 if (Util.isNumberEqual(a, 0)) {
2653 if (!Util.isNumberEqual(b, 0)) {
2654 t1 = -c / b;
2655 if (t1 >= 0 && t1 <= 1) {
2656 extrema.push(t1);
2657 }
2658 }
2659 } else {
2660 var disc = b * b - 4 * a * c;
2661 if (Util.isNumberEqual(disc, 0)) {
2662 extrema.push(-b / (2 * a));
2663 } else if (disc > 0) {
2664 discSqrt = Math.sqrt(disc);
2665 t1 = (-b + discSqrt) / (2 * a);
2666 t2 = (-b - discSqrt) / (2 * a);
2667 if (t1 >= 0 && t1 <= 1) {
2668 extrema.push(t1);
2669 }
2670 if (t2 >= 0 && t2 <= 1) {
2671 extrema.push(t2);
2672 }
2673 }
2674 }
2675 return extrema;
2676}
2677
2678function base3(t, p1, p2, p3, p4) {
2679 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
2680 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
2681 return t * t2 - 3 * p1 + 3 * p2;
2682}
2683
2684function cubiclLen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
2685 if (Util.isNil(z)) {
2686 z = 1;
2687 }
2688 z = z > 1 ? 1 : z < 0 ? 0 : z;
2689 var z2 = z / 2;
2690 var n = 12;
2691 var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
2692 var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
2693 var sum = 0;
2694 for (var i = 0; i < n; i++) {
2695 var ct = z2 * Tvalues[i] + z2;
2696 var xbase = base3(ct, x1, x2, x3, x4);
2697 var ybase = base3(ct, y1, y2, y3, y4);
2698 var comb = xbase * xbase + ybase * ybase;
2699 sum += Cvalues[i] * Math.sqrt(comb);
2700 }
2701 return z2 * sum;
2702}
2703
2704module.exports = {
2705 at: cubicAt,
2706 derivativeAt: cubicDerivativeAt,
2707 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y) {
2708 var rst = {};
2709 cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, rst);
2710 return rst;
2711 },
2712
2713 pointDistance: cubicProjectPoint,
2714 extrema: cubicExtrema,
2715 len: cubiclLen
2716};
2717
2718/***/ }),
2719/* 13 */
2720/***/ (function(module, exports, __webpack_require__) {
2721
2722var Util = __webpack_require__(0);
2723var Attribute = __webpack_require__(72);
2724var Transform = __webpack_require__(73);
2725var Animate = __webpack_require__(32);
2726var EventEmitter = __webpack_require__(41);
2727
2728var Element = function Element(cfg) {
2729 this.__cfg = {
2730 zIndex: 0,
2731 capture: true,
2732 visible: true,
2733 destroyed: false
2734 }; // 配置存放地
2735
2736 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
2737 // 在子元素的init中创建新svg元素,然后设置属性和变换。在这边设置id而不是attr里,是考虑id一旦设置后应不能修改
2738 this.init(cfg ? cfg.id : null); // 类型初始化
2739 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
2740 this.initTransform(); // 初始化变换
2741};
2742
2743Element.CFG = {
2744 /**
2745 * 唯一标示
2746 * @type {Number}
2747 */
2748 id: null,
2749 /**
2750 * Z轴的层叠关系,Z值越大离用户越近
2751 * @type {Number}
2752 */
2753 zIndex: 0,
2754 /**
2755 * Canvas对象
2756 * @type: {Object}
2757 */
2758 canvas: null,
2759 /**
2760 * 父元素指针
2761 * @type {Object}
2762 */
2763 parent: null,
2764 /**
2765 * 用来设置当前对象是否能被捕捉
2766 * true 能
2767 * false 不能
2768 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
2769 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
2770 * @type {Boolean}
2771 **/
2772 capture: true,
2773 /**
2774 * 画布的上下文
2775 * @type {Object}
2776 */
2777 context: null,
2778 /**
2779 * 是否显示
2780 * @type {Boolean}
2781 */
2782 visible: true,
2783 /**
2784 * 是否被销毁
2785 * @type: {Boolean}
2786 */
2787 destroyed: false
2788};
2789
2790Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
2791 init: function init() {
2792 this.setSilent('animable', true);
2793 this.setSilent('animating', false); // 初始时不处于动画状态
2794 },
2795 getParent: function getParent() {
2796 return this.get('parent');
2797 },
2798
2799 /**
2800 * 获取默认的配置信息
2801 * @protected
2802 * @return {Object} 默认的属性
2803 */
2804 getDefaultCfg: function getDefaultCfg() {
2805 return {};
2806 },
2807 set: function set(name, value) {
2808 if (name === 'zIndex') {
2809 this._beforeSetZIndex(value);
2810 }
2811 this.__cfg[name] = value;
2812 return this;
2813 },
2814 setSilent: function setSilent(name, value) {
2815 this.__cfg[name] = value;
2816 },
2817 get: function get(name) {
2818 return this.__cfg[name];
2819 },
2820 draw: function draw() {},
2821 drawInner: function drawInner() {},
2822 show: function show() {
2823 this.set('visible', true);
2824 var el = this.get('el');
2825 if (el) {
2826 el.setAttribute('visibility', 'visible');
2827 }
2828 return this;
2829 },
2830 hide: function hide() {
2831 this.set('visible', false);
2832 var el = this.get('el');
2833 if (el) {
2834 el.setAttribute('visibility', 'hidden');
2835 }
2836 return this;
2837 },
2838 remove: function remove(destroy) {
2839 var el = this.get('el');
2840 if (destroy === undefined) {
2841 destroy = true;
2842 }
2843
2844 if (this.get('parent')) {
2845 var parent = this.get('parent');
2846 var children = parent.get('children');
2847 Util.remove(children, this);
2848 el.parentNode.removeChild(el);
2849 }
2850
2851 if (destroy) {
2852 this.destroy();
2853 }
2854
2855 return this;
2856 },
2857 destroy: function destroy() {
2858 var destroyed = this.get('destroyed');
2859 if (destroyed) {
2860 return;
2861 }
2862 // 如果正在执行动画,清理动画
2863 if (this.get('animating')) {
2864 var timer = this.get('animateTimer');
2865 timer && timer.stop();
2866 }
2867 this.__cfg = {};
2868 this.__attrs = null;
2869 this.removeEvent(); // 移除所有的事件
2870 this.set('destroyed', true);
2871 },
2872 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
2873 this.__cfg.zIndex = zIndex;
2874
2875 if (!Util.isNil(this.get('parent'))) {
2876 this.get('parent').sort();
2877 }
2878 return zIndex;
2879 },
2880 _setAttrs: function _setAttrs(attrs) {
2881 this.attr(attrs);
2882 return attrs;
2883 },
2884 setZIndex: function setZIndex(zIndex) {
2885 this.__cfg.zIndex = zIndex;
2886 return zIndex;
2887 },
2888 clone: function clone() {
2889 return Util.clone(this);
2890 },
2891 getBBox: function getBBox() {
2892 var el = this.get('el');
2893 if (!el) {
2894 return {
2895 minX: 0,
2896 minY: 0,
2897 maxX: 0,
2898 maxY: 0,
2899 width: 0,
2900 height: 0,
2901 x: 0,
2902 y: 0
2903 };
2904 }
2905 var bbox = el.getBBox();
2906 if (!el.parentNode || bbox.width === 0 && bbox.height === 0) {
2907 var node = el.cloneNode();
2908 node.innerHTML = el.innerHTML;
2909 node.setAttribute('visible', 'hidden');
2910 var svg = document.getElementsByTagName('svg')[0];
2911 svg.appendChild(node);
2912 bbox = node.getBBox();
2913 svg.removeChild(node);
2914 }
2915 bbox.minX = bbox.x;
2916 bbox.minY = bbox.y;
2917 bbox.maxX = bbox.x + bbox.width;
2918 bbox.maxY = bbox.y + bbox.height;
2919 return {
2920 minX: bbox.x,
2921 minY: bbox.y,
2922 maxX: bbox.x + bbox.width,
2923 maxY: bbox.y + bbox.height,
2924 width: bbox.width,
2925 height: bbox.height,
2926 x: bbox.x,
2927 y: bbox.y
2928 };
2929 }
2930});
2931
2932module.exports = Element;
2933
2934/***/ }),
2935/* 14 */
2936/***/ (function(module, __webpack_exports__, __webpack_require__) {
2937
2938"use strict";
2939/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return EPSILON; });
2940/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ARRAY_TYPE; });
2941/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return RANDOM; });
2942/* unused harmony export setMatrixArrayType */
2943/* unused harmony export toRadian */
2944/* unused harmony export equals */
2945/**
2946 * Common utilities
2947 * @module glMatrix
2948 */
2949
2950// Configuration Constants
2951var EPSILON = 0.000001;
2952var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
2953var RANDOM = Math.random;
2954
2955/**
2956 * Sets the type of array used when creating new vectors and matrices
2957 *
2958 * @param {Type} type Array type, such as Float32Array or Array
2959 */
2960function setMatrixArrayType(type) {
2961 ARRAY_TYPE = type;
2962}
2963
2964var degree = Math.PI / 180;
2965
2966/**
2967 * Convert Degree To Radian
2968 *
2969 * @param {Number} a Angle in Degrees
2970 */
2971function toRadian(a) {
2972 return a * degree;
2973}
2974
2975/**
2976 * Tests whether or not the arguments have approximately the same value, within an absolute
2977 * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
2978 * than or equal to 1.0, and a relative tolerance is used for larger values)
2979 *
2980 * @param {Number} a The first number to test.
2981 * @param {Number} b The second number to test.
2982 * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
2983 */
2984function equals(a, b) {
2985 return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
2986}
2987
2988/***/ }),
2989/* 15 */
2990/***/ (function(module, exports, __webpack_require__) {
2991
2992var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2993
2994var Util = __webpack_require__(7);
2995var SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029';
2996var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
2997var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
2998
2999// Parses given path string into an array of arrays of path segments
3000var parsePathString = function parsePathString(pathString) {
3001 if (!pathString) {
3002 return null;
3003 }
3004
3005 if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
3006 return pathString;
3007 }
3008 var paramCounts = {
3009 a: 7,
3010 c: 6,
3011 o: 2,
3012 h: 1,
3013 l: 2,
3014 m: 2,
3015 r: 4,
3016 q: 4,
3017 s: 4,
3018 t: 2,
3019 v: 1,
3020 u: 3,
3021 z: 0
3022 };
3023 var data = [];
3024
3025 String(pathString).replace(PATH_COMMAND, function (a, b, c) {
3026 var params = [];
3027 var name = b.toLowerCase();
3028 c.replace(PATH_VALUES, function (a, b) {
3029 b && params.push(+b);
3030 });
3031 if (name === 'm' && params.length > 2) {
3032 data.push([b].concat(params.splice(0, 2)));
3033 name = 'l';
3034 b = b === 'm' ? 'l' : 'L';
3035 }
3036 if (name === 'o' && params.length === 1) {
3037 data.push([b, params[0]]);
3038 }
3039 if (name === 'r') {
3040 data.push([b].concat(params));
3041 } else {
3042 while (params.length >= paramCounts[name]) {
3043 data.push([b].concat(params.splice(0, paramCounts[name])));
3044 if (!paramCounts[name]) {
3045 break;
3046 }
3047 }
3048 }
3049 });
3050
3051 return data;
3052};
3053
3054// http://schepers.cc/getting-to-the-point
3055var catmullRom2bezier = function catmullRom2bezier(crp, z) {
3056 var d = [];
3057 for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
3058 var p = [{
3059 x: +crp[i - 2],
3060 y: +crp[i - 1]
3061 }, {
3062 x: +crp[i],
3063 y: +crp[i + 1]
3064 }, {
3065 x: +crp[i + 2],
3066 y: +crp[i + 3]
3067 }, {
3068 x: +crp[i + 4],
3069 y: +crp[i + 5]
3070 }];
3071 if (z) {
3072 if (!i) {
3073 p[0] = {
3074 x: +crp[iLen - 2],
3075 y: +crp[iLen - 1]
3076 };
3077 } else if (iLen - 4 === i) {
3078 p[3] = {
3079 x: +crp[0],
3080 y: +crp[1]
3081 };
3082 } else if (iLen - 2 === i) {
3083 p[2] = {
3084 x: +crp[0],
3085 y: +crp[1]
3086 };
3087 p[3] = {
3088 x: +crp[2],
3089 y: +crp[3]
3090 };
3091 }
3092 } else {
3093 if (iLen - 4 === i) {
3094 p[3] = p[2];
3095 } else if (!i) {
3096 p[0] = {
3097 x: +crp[i],
3098 y: +crp[i + 1]
3099 };
3100 }
3101 }
3102 d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]);
3103 }
3104
3105 return d;
3106};
3107
3108var ellipsePath = function ellipsePath(x, y, rx, ry, a) {
3109 var res = [];
3110 if (a === null && ry === null) {
3111 ry = rx;
3112 }
3113 x = +x;
3114 y = +y;
3115 rx = +rx;
3116 ry = +ry;
3117 if (a !== null) {
3118 var rad = Math.PI / 180;
3119 var x1 = x + rx * Math.cos(-ry * rad);
3120 var x2 = x + rx * Math.cos(-a * rad);
3121 var y1 = y + rx * Math.sin(-ry * rad);
3122 var y2 = y + rx * Math.sin(-a * rad);
3123 res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
3124 } else {
3125 res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
3126 }
3127 return res;
3128};
3129
3130var pathToAbsolute = function pathToAbsolute(pathArray) {
3131 pathArray = parsePathString(pathArray);
3132
3133 if (!pathArray || !pathArray.length) {
3134 return [['M', 0, 0]];
3135 }
3136 var res = [];
3137 var x = 0;
3138 var y = 0;
3139 var mx = 0;
3140 var my = 0;
3141 var start = 0;
3142 var pa0 = void 0;
3143 var dots = void 0;
3144 if (pathArray[0][0] === 'M') {
3145 x = +pathArray[0][1];
3146 y = +pathArray[0][2];
3147 mx = x;
3148 my = y;
3149 start++;
3150 res[0] = ['M', x, y];
3151 }
3152 var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
3153 for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
3154 res.push(r = []);
3155 pa = pathArray[i];
3156 pa0 = pa[0];
3157 if (pa0 !== pa0.toUpperCase()) {
3158 r[0] = pa0.toUpperCase();
3159 switch (r[0]) {
3160 case 'A':
3161 r[1] = pa[1];
3162 r[2] = pa[2];
3163 r[3] = pa[3];
3164 r[4] = pa[4];
3165 r[5] = pa[5];
3166 r[6] = +pa[6] + x;
3167 r[7] = +pa[7] + y;
3168 break;
3169 case 'V':
3170 r[1] = +pa[1] + y;
3171 break;
3172 case 'H':
3173 r[1] = +pa[1] + x;
3174 break;
3175 case 'R':
3176 dots = [x, y].concat(pa.slice(1));
3177 for (var j = 2, jj = dots.length; j < jj; j++) {
3178 dots[j] = +dots[j] + x;
3179 dots[++j] = +dots[j] + y;
3180 }
3181 res.pop();
3182 res = res.concat(catmullRom2bezier(dots, crz));
3183 break;
3184 case 'O':
3185 res.pop();
3186 dots = ellipsePath(x, y, pa[1], pa[2]);
3187 dots.push(dots[0]);
3188 res = res.concat(dots);
3189 break;
3190 case 'U':
3191 res.pop();
3192 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
3193 r = ['U'].concat(res[res.length - 1].slice(-2));
3194 break;
3195 case 'M':
3196 mx = +pa[1] + x;
3197 my = +pa[2] + y;
3198 break; // for lint
3199 default:
3200 for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
3201 r[_j] = +pa[_j] + (_j % 2 ? x : y);
3202 }
3203 }
3204 } else if (pa0 === 'R') {
3205 dots = [x, y].concat(pa.slice(1));
3206 res.pop();
3207 res = res.concat(catmullRom2bezier(dots, crz));
3208 r = ['R'].concat(pa.slice(-2));
3209 } else if (pa0 === 'O') {
3210 res.pop();
3211 dots = ellipsePath(x, y, pa[1], pa[2]);
3212 dots.push(dots[0]);
3213 res = res.concat(dots);
3214 } else if (pa0 === 'U') {
3215 res.pop();
3216 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
3217 r = ['U'].concat(res[res.length - 1].slice(-2));
3218 } else {
3219 for (var k = 0, kk = pa.length; k < kk; k++) {
3220 r[k] = pa[k];
3221 }
3222 }
3223 pa0 = pa0.toUpperCase();
3224 if (pa0 !== 'O') {
3225 switch (r[0]) {
3226 case 'Z':
3227 x = +mx;
3228 y = +my;
3229 break;
3230 case 'H':
3231 x = r[1];
3232 break;
3233 case 'V':
3234 y = r[1];
3235 break;
3236 case 'M':
3237 mx = r[r.length - 2];
3238 my = r[r.length - 1];
3239 break; // for lint
3240 default:
3241 x = r[r.length - 2];
3242 y = r[r.length - 1];
3243 }
3244 }
3245 }
3246
3247 return res;
3248};
3249
3250var l2c = function l2c(x1, y1, x2, y2) {
3251 return [x1, y1, x2, y2, x2, y2];
3252};
3253
3254var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
3255 var _13 = 1 / 3;
3256 var _23 = 2 / 3;
3257 return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
3258};
3259
3260var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
3261 // for more information of where this math came from visit:
3262 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
3263 if (rx === ry) {
3264 rx += 1;
3265 }
3266
3267 var _120 = Math.PI * 120 / 180;
3268 var rad = Math.PI / 180 * (+angle || 0);
3269 var res = [];
3270 var xy = void 0;
3271 var f1 = void 0;
3272 var f2 = void 0;
3273 var cx = void 0;
3274 var cy = void 0;
3275 var rotate = function rotate(x, y, rad) {
3276 var X = x * Math.cos(rad) - y * Math.sin(rad);
3277 var Y = x * Math.sin(rad) + y * Math.cos(rad);
3278 return {
3279 x: X,
3280 y: Y
3281 };
3282 };
3283 if (!recursive) {
3284 xy = rotate(x1, y1, -rad);
3285 x1 = xy.x;
3286 y1 = xy.y;
3287 xy = rotate(x2, y2, -rad);
3288 x2 = xy.x;
3289 y2 = xy.y;
3290 if (x1 === x2 && y1 === y2) {
3291 // 若弧的起始点和终点重叠则错开一点
3292 x2 += 1;
3293 y2 += 1;
3294 }
3295 // const cos = Math.cos(Math.PI / 180 * angle);
3296 // const sin = Math.sin(Math.PI / 180 * angle);
3297 var x = (x1 - x2) / 2;
3298 var y = (y1 - y2) / 2;
3299 var h = x * x / (rx * rx) + y * y / (ry * ry);
3300 if (h > 1) {
3301 h = Math.sqrt(h);
3302 rx = h * rx;
3303 ry = h * ry;
3304 }
3305 var rx2 = rx * rx;
3306 var ry2 = ry * ry;
3307 var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
3308 cx = k * rx * y / ry + (x1 + x2) / 2;
3309 cy = k * -ry * x / rx + (y1 + y2) / 2;
3310 f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
3311 f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
3312
3313 f1 = x1 < cx ? Math.PI - f1 : f1;
3314 f2 = x2 < cx ? Math.PI - f2 : f2;
3315 f1 < 0 && (f1 = Math.PI * 2 + f1);
3316 f2 < 0 && (f2 = Math.PI * 2 + f2);
3317 if (sweep_flag && f1 > f2) {
3318 f1 = f1 - Math.PI * 2;
3319 }
3320 if (!sweep_flag && f2 > f1) {
3321 f2 = f2 - Math.PI * 2;
3322 }
3323 } else {
3324 f1 = recursive[0];
3325 f2 = recursive[1];
3326 cx = recursive[2];
3327 cy = recursive[3];
3328 }
3329 var df = f2 - f1;
3330 if (Math.abs(df) > _120) {
3331 var f2old = f2;
3332 var x2old = x2;
3333 var y2old = y2;
3334 f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
3335 x2 = cx + rx * Math.cos(f2);
3336 y2 = cy + ry * Math.sin(f2);
3337 res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
3338 }
3339 df = f2 - f1;
3340 var c1 = Math.cos(f1);
3341 var s1 = Math.sin(f1);
3342 var c2 = Math.cos(f2);
3343 var s2 = Math.sin(f2);
3344 var t = Math.tan(df / 4);
3345 var hx = 4 / 3 * rx * t;
3346 var hy = 4 / 3 * ry * t;
3347 var m1 = [x1, y1];
3348 var m2 = [x1 + hx * s1, y1 - hy * c1];
3349 var m3 = [x2 + hx * s2, y2 - hy * c2];
3350 var m4 = [x2, y2];
3351 m2[0] = 2 * m1[0] - m2[0];
3352 m2[1] = 2 * m1[1] - m2[1];
3353 if (recursive) {
3354 return [m2, m3, m4].concat(res);
3355 }
3356 res = [m2, m3, m4].concat(res).join().split(',');
3357 var newres = [];
3358 for (var i = 0, ii = res.length; i < ii; i++) {
3359 newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
3360 }
3361 return newres;
3362};
3363
3364var pathTocurve = function pathTocurve(path, path2) {
3365 var p = pathToAbsolute(path);
3366 var p2 = path2 && pathToAbsolute(path2);
3367 var attrs = {
3368 x: 0,
3369 y: 0,
3370 bx: 0,
3371 by: 0,
3372 X: 0,
3373 Y: 0,
3374 qx: null,
3375 qy: null
3376 };
3377 var attrs2 = {
3378 x: 0,
3379 y: 0,
3380 bx: 0,
3381 by: 0,
3382 X: 0,
3383 Y: 0,
3384 qx: null,
3385 qy: null
3386 };
3387 var pcoms1 = []; // path commands of original path p
3388 var pcoms2 = []; // path commands of original path p2
3389 var pfirst = ''; // temporary holder for original path command
3390 var pcom = ''; // holder for previous path command of original path
3391 var ii = void 0;
3392 var processPath = function processPath(path, d, pcom) {
3393 var nx = void 0,
3394 ny = void 0;
3395 if (!path) {
3396 return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
3397 }!(path[0] in {
3398 T: 1,
3399 Q: 1
3400 }) && (d.qx = d.qy = null);
3401 switch (path[0]) {
3402 case 'M':
3403 d.X = path[1];
3404 d.Y = path[2];
3405 break;
3406 case 'A':
3407 path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
3408 break;
3409 case 'S':
3410 if (pcom === 'C' || pcom === 'S') {
3411 // In "S" case we have to take into account, if the previous command is C/S.
3412 nx = d.x * 2 - d.bx; // And reflect the previous
3413 ny = d.y * 2 - d.by; // command's control point relative to the current point.
3414 } else {
3415 // or some else or nothing
3416 nx = d.x;
3417 ny = d.y;
3418 }
3419 path = ['C', nx, ny].concat(path.slice(1));
3420 break;
3421 case 'T':
3422 if (pcom === 'Q' || pcom === 'T') {
3423 // In "T" case we have to take into account, if the previous command is Q/T.
3424 d.qx = d.x * 2 - d.qx; // And make a reflection similar
3425 d.qy = d.y * 2 - d.qy; // to case "S".
3426 } else {
3427 // or something else or nothing
3428 d.qx = d.x;
3429 d.qy = d.y;
3430 }
3431 path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
3432 break;
3433 case 'Q':
3434 d.qx = path[1];
3435 d.qy = path[2];
3436 path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
3437 break;
3438 case 'L':
3439 path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
3440 break;
3441 case 'H':
3442 path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
3443 break;
3444 case 'V':
3445 path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
3446 break;
3447 case 'Z':
3448 path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
3449 break;
3450 default:
3451 break;
3452 }
3453 return path;
3454 };
3455 var fixArc = function fixArc(pp, i) {
3456 if (pp[i].length > 7) {
3457 pp[i].shift();
3458 var pi = pp[i];
3459 while (pi.length) {
3460 pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
3461 p2 && (pcoms2[i] = 'A'); // the same as above
3462 pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
3463 }
3464 pp.splice(i, 1);
3465 ii = Math.max(p.length, p2 && p2.length || 0);
3466 }
3467 };
3468 var fixM = function fixM(path1, path2, a1, a2, i) {
3469 if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
3470 path2.splice(i, 0, ['M', a2.x, a2.y]);
3471 a1.bx = 0;
3472 a1.by = 0;
3473 a1.x = path1[i][1];
3474 a1.y = path1[i][2];
3475 ii = Math.max(p.length, p2 && p2.length || 0);
3476 }
3477 };
3478 ii = Math.max(p.length, p2 && p2.length || 0);
3479 for (var i = 0; i < ii; i++) {
3480
3481 p[i] && (pfirst = p[i][0]); // save current path command
3482
3483 if (pfirst !== 'C') {
3484 // C is not saved yet, because it may be result of conversion
3485 pcoms1[i] = pfirst; // Save current path command
3486 i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
3487 }
3488 p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
3489
3490 if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
3491 // which may produce multiple C:s
3492 // so we have to make sure that C is also C in original path
3493
3494 fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
3495
3496 if (p2) {
3497 // the same procedures is done to p2
3498 p2[i] && (pfirst = p2[i][0]);
3499 if (pfirst !== 'C') {
3500 pcoms2[i] = pfirst;
3501 i && (pcom = pcoms2[i - 1]);
3502 }
3503 p2[i] = processPath(p2[i], attrs2, pcom);
3504
3505 if (pcoms2[i] !== 'A' && pfirst === 'C') {
3506 pcoms2[i] = 'C';
3507 }
3508
3509 fixArc(p2, i);
3510 }
3511 fixM(p, p2, attrs, attrs2, i);
3512 fixM(p2, p, attrs2, attrs, i);
3513 var seg = p[i];
3514 var seg2 = p2 && p2[i];
3515 var seglen = seg.length;
3516 var seg2len = p2 && seg2.length;
3517 attrs.x = seg[seglen - 2];
3518 attrs.y = seg[seglen - 1];
3519 attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
3520 attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
3521 attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
3522 attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
3523 attrs2.x = p2 && seg2[seg2len - 2];
3524 attrs2.y = p2 && seg2[seg2len - 1];
3525 }
3526
3527 return p2 ? [p, p2] : p;
3528};
3529
3530var p2s = /,?([a-z]),?/gi;
3531var parsePathArray = function parsePathArray(path) {
3532 return path.join(',').replace(p2s, '$1');
3533};
3534
3535var base3 = function base3(t, p1, p2, p3, p4) {
3536 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
3537 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
3538 return t * t2 - 3 * p1 + 3 * p2;
3539};
3540
3541var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
3542 if (z === null) {
3543 z = 1;
3544 }
3545 z = z > 1 ? 1 : z < 0 ? 0 : z;
3546 var z2 = z / 2;
3547 var n = 12;
3548 var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
3549 var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
3550 var sum = 0;
3551 for (var i = 0; i < n; i++) {
3552 var ct = z2 * Tvalues[i] + z2;
3553 var xbase = base3(ct, x1, x2, x3, x4);
3554 var ybase = base3(ct, y1, y2, y3, y4);
3555 var comb = xbase * xbase + ybase * ybase;
3556 sum += Cvalues[i] * Math.sqrt(comb);
3557 }
3558 return z2 * sum;
3559};
3560
3561var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
3562 var tvalues = [];
3563 var bounds = [[], []];
3564 var a = void 0;
3565 var b = void 0;
3566 var c = void 0;
3567 var t = void 0;
3568
3569 for (var i = 0; i < 2; ++i) {
3570 if (i === 0) {
3571 b = 6 * x0 - 12 * x1 + 6 * x2;
3572 a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
3573 c = 3 * x1 - 3 * x0;
3574 } else {
3575 b = 6 * y0 - 12 * y1 + 6 * y2;
3576 a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
3577 c = 3 * y1 - 3 * y0;
3578 }
3579 if (Math.abs(a) < 1e-12) {
3580 if (Math.abs(b) < 1e-12) {
3581 continue;
3582 }
3583 t = -c / b;
3584 if (t > 0 && t < 1) {
3585 tvalues.push(t);
3586 }
3587 continue;
3588 }
3589 var b2ac = b * b - 4 * c * a;
3590 var sqrtb2ac = Math.sqrt(b2ac);
3591 if (b2ac < 0) {
3592 continue;
3593 }
3594 var t1 = (-b + sqrtb2ac) / (2 * a);
3595 if (t1 > 0 && t1 < 1) {
3596 tvalues.push(t1);
3597 }
3598 var t2 = (-b - sqrtb2ac) / (2 * a);
3599 if (t2 > 0 && t2 < 1) {
3600 tvalues.push(t2);
3601 }
3602 }
3603
3604 var j = tvalues.length;
3605 var jlen = j;
3606 var mt = void 0;
3607 while (j--) {
3608 t = tvalues[j];
3609 mt = 1 - t;
3610 bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
3611 bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
3612 }
3613
3614 bounds[0][jlen] = x0;
3615 bounds[1][jlen] = y0;
3616 bounds[0][jlen + 1] = x3;
3617 bounds[1][jlen + 1] = y3;
3618 bounds[0].length = bounds[1].length = jlen + 2;
3619
3620 return {
3621 min: {
3622 x: Math.min.apply(0, bounds[0]),
3623 y: Math.min.apply(0, bounds[1])
3624 },
3625 max: {
3626 x: Math.max.apply(0, bounds[0]),
3627 y: Math.max.apply(0, bounds[1])
3628 }
3629 };
3630};
3631
3632var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
3633 if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) {
3634 return;
3635 }
3636 var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
3637 var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
3638 var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
3639
3640 if (!denominator) {
3641 return;
3642 }
3643 var px = nx / denominator;
3644 var py = ny / denominator;
3645 var px2 = +px.toFixed(2);
3646 var py2 = +py.toFixed(2);
3647 if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) {
3648 return;
3649 }
3650 return {
3651 x: px,
3652 y: py
3653 };
3654};
3655
3656var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
3657 return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
3658};
3659
3660var rectPath = function rectPath(x, y, w, h, r) {
3661 if (r) {
3662 return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']];
3663 }
3664 var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
3665 res.parsePathArray = parsePathArray;
3666 return res;
3667};
3668
3669var box = function box(x, y, width, height) {
3670 if (x === null) {
3671 x = y = width = height = 0;
3672 }
3673 if (y === null) {
3674 y = x.y;
3675 width = x.width;
3676 height = x.height;
3677 x = x.x;
3678 }
3679 return {
3680 x: x,
3681 y: y,
3682 width: width,
3683 w: width,
3684 height: height,
3685 h: height,
3686 x2: x + width,
3687 y2: y + height,
3688 cx: x + width / 2,
3689 cy: y + height / 2,
3690 r1: Math.min(width, height) / 2,
3691 r2: Math.max(width, height) / 2,
3692 r0: Math.sqrt(width * width + height * height) / 2,
3693 path: rectPath(x, y, width, height),
3694 vb: [x, y, width, height].join(' ')
3695 };
3696};
3697
3698var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
3699 bbox1 = box(bbox1);
3700 bbox2 = box(bbox2);
3701 return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
3702};
3703
3704var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
3705 if (!Util.isArray(p1x)) {
3706 p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
3707 }
3708 var bbox = curveDim.apply(null, p1x);
3709 return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
3710};
3711
3712var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
3713 var t1 = 1 - t;
3714 var t13 = Math.pow(t1, 3);
3715 var t12 = Math.pow(t1, 2);
3716 var t2 = t * t;
3717 var t3 = t2 * t;
3718 var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
3719 var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
3720 var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
3721 var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
3722 var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
3723 var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
3724 var ax = t1 * p1x + t * c1x;
3725 var ay = t1 * p1y + t * c1y;
3726 var cx = t1 * c2x + t * p2x;
3727 var cy = t1 * c2y + t * p2y;
3728 var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
3729 // (mx > nx || my < ny) && (alpha += 180);
3730 return {
3731 x: x,
3732 y: y,
3733 m: {
3734 x: mx,
3735 y: my
3736 },
3737 n: {
3738 x: nx,
3739 y: ny
3740 },
3741 start: {
3742 x: ax,
3743 y: ay
3744 },
3745 end: {
3746 x: cx,
3747 y: cy
3748 },
3749 alpha: alpha
3750 };
3751};
3752
3753var interHelper = function interHelper(bez1, bez2, justCount) {
3754 var bbox1 = bezierBBox(bez1);
3755 var bbox2 = bezierBBox(bez2);
3756 if (!isBBoxIntersect(bbox1, bbox2)) {
3757 return justCount ? 0 : [];
3758 }
3759 var l1 = bezlen.apply(0, bez1);
3760 var l2 = bezlen.apply(0, bez2);
3761 var n1 = ~~(l1 / 8);
3762 var n2 = ~~(l2 / 8);
3763 var dots1 = [];
3764 var dots2 = [];
3765 var xy = {};
3766 var res = justCount ? 0 : [];
3767 for (var i = 0; i < n1 + 1; i++) {
3768 var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
3769 dots1.push({
3770 x: d.x,
3771 y: d.y,
3772 t: i / n1
3773 });
3774 }
3775 for (var _i = 0; _i < n2 + 1; _i++) {
3776 var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
3777 dots2.push({
3778 x: _d.x,
3779 y: _d.y,
3780 t: _i / n2
3781 });
3782 }
3783 for (var _i2 = 0; _i2 < n1; _i2++) {
3784 for (var j = 0; j < n2; j++) {
3785 var di = dots1[_i2];
3786 var di1 = dots1[_i2 + 1];
3787 var dj = dots2[j];
3788 var dj1 = dots2[j + 1];
3789 var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
3790 var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
3791 var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
3792 if (is) {
3793 if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
3794 continue;
3795 }
3796 xy[is.x.toFixed(4)] = is.y.toFixed(4);
3797 var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
3798 var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
3799 if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
3800 if (justCount) {
3801 res++;
3802 } else {
3803 res.push({
3804 x: is.x,
3805 y: is.y,
3806 t1: t1,
3807 t2: t2
3808 });
3809 }
3810 }
3811 }
3812 }
3813 }
3814 return res;
3815};
3816
3817var interPathHelper = function interPathHelper(path1, path2, justCount) {
3818 path1 = pathTocurve(path1);
3819 path2 = pathTocurve(path2);
3820 var x1 = void 0;
3821 var y1 = void 0;
3822 var x2 = void 0;
3823 var y2 = void 0;
3824 var x1m = void 0;
3825 var y1m = void 0;
3826 var x2m = void 0;
3827 var y2m = void 0;
3828 var bez1 = void 0;
3829 var bez2 = void 0;
3830 var res = justCount ? 0 : [];
3831 for (var i = 0, ii = path1.length; i < ii; i++) {
3832 var pi = path1[i];
3833 if (pi[0] === 'M') {
3834 x1 = x1m = pi[1];
3835 y1 = y1m = pi[2];
3836 } else {
3837 if (pi[0] === 'C') {
3838 bez1 = [x1, y1].concat(pi.slice(1));
3839 x1 = bez1[6];
3840 y1 = bez1[7];
3841 } else {
3842 bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
3843 x1 = x1m;
3844 y1 = y1m;
3845 }
3846 for (var j = 0, jj = path2.length; j < jj; j++) {
3847 var pj = path2[j];
3848 if (pj[0] === 'M') {
3849 x2 = x2m = pj[1];
3850 y2 = y2m = pj[2];
3851 } else {
3852 if (pj[0] === 'C') {
3853 bez2 = [x2, y2].concat(pj.slice(1));
3854 x2 = bez2[6];
3855 y2 = bez2[7];
3856 } else {
3857 bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
3858 x2 = x2m;
3859 y2 = y2m;
3860 }
3861 var intr = interHelper(bez1, bez2, justCount);
3862 if (justCount) {
3863 res += intr;
3864 } else {
3865 for (var k = 0, kk = intr.length; k < kk; k++) {
3866 intr[k].segment1 = i;
3867 intr[k].segment2 = j;
3868 intr[k].bez1 = bez1;
3869 intr[k].bez2 = bez2;
3870 }
3871 res = res.concat(intr);
3872 }
3873 }
3874 }
3875 }
3876 }
3877 return res;
3878};
3879
3880var pathIntersection = function pathIntersection(path1, path2) {
3881 return interPathHelper(path1, path2);
3882};
3883
3884module.exports = {
3885 parsePathString: parsePathString,
3886 parsePathArray: parsePathArray,
3887 pathTocurve: pathTocurve,
3888 pathToAbsolute: pathToAbsolute,
3889 catmullRomToBezier: catmullRom2bezier,
3890 rectPath: rectPath,
3891 intersection: pathIntersection
3892};
3893
3894/***/ }),
3895/* 16 */
3896/***/ (function(module, __webpack_exports__, __webpack_require__) {
3897
3898"use strict";
3899/* harmony export (immutable) */ __webpack_exports__["b"] = now;
3900/* harmony export (immutable) */ __webpack_exports__["a"] = Timer;
3901/* harmony export (immutable) */ __webpack_exports__["c"] = timer;
3902/* harmony export (immutable) */ __webpack_exports__["d"] = timerFlush;
3903var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
3904
3905var frame = 0,
3906 // is an animation frame pending?
3907timeout = 0,
3908 // is a timeout pending?
3909interval = 0,
3910 // are any timers active?
3911pokeDelay = 1000,
3912 // how frequently we check for clock skew
3913taskHead,
3914 taskTail,
3915 clockLast = 0,
3916 clockNow = 0,
3917 clockSkew = 0,
3918 clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === "object" && performance.now ? performance : Date,
3919 setFrame = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function (f) {
3920 setTimeout(f, 17);
3921};
3922
3923function now() {
3924 return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
3925}
3926
3927function clearNow() {
3928 clockNow = 0;
3929}
3930
3931function Timer() {
3932 this._call = this._time = this._next = null;
3933}
3934
3935Timer.prototype = timer.prototype = {
3936 constructor: Timer,
3937 restart: function restart(callback, delay, time) {
3938 if (typeof callback !== "function") throw new TypeError("callback is not a function");
3939 time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
3940 if (!this._next && taskTail !== this) {
3941 if (taskTail) taskTail._next = this;else taskHead = this;
3942 taskTail = this;
3943 }
3944 this._call = callback;
3945 this._time = time;
3946 sleep();
3947 },
3948 stop: function stop() {
3949 if (this._call) {
3950 this._call = null;
3951 this._time = Infinity;
3952 sleep();
3953 }
3954 }
3955};
3956
3957function timer(callback, delay, time) {
3958 var t = new Timer();
3959 t.restart(callback, delay, time);
3960 return t;
3961}
3962
3963function timerFlush() {
3964 now(); // Get the current time, if not already set.
3965 ++frame; // Pretend we’ve set an alarm, if we haven’t already.
3966 var t = taskHead,
3967 e;
3968 while (t) {
3969 if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
3970 t = t._next;
3971 }
3972 --frame;
3973}
3974
3975function wake() {
3976 clockNow = (clockLast = clock.now()) + clockSkew;
3977 frame = timeout = 0;
3978 try {
3979 timerFlush();
3980 } finally {
3981 frame = 0;
3982 nap();
3983 clockNow = 0;
3984 }
3985}
3986
3987function poke() {
3988 var now = clock.now(),
3989 delay = now - clockLast;
3990 if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
3991}
3992
3993function nap() {
3994 var t0,
3995 t1 = taskHead,
3996 t2,
3997 time = Infinity;
3998 while (t1) {
3999 if (t1._call) {
4000 if (time > t1._time) time = t1._time;
4001 t0 = t1, t1 = t1._next;
4002 } else {
4003 t2 = t1._next, t1._next = null;
4004 t1 = t0 ? t0._next = t2 : taskHead = t2;
4005 }
4006 }
4007 taskTail = t0;
4008 sleep(time);
4009}
4010
4011function sleep(time) {
4012 if (frame) return; // Soonest alarm already set, or will be.
4013 if (timeout) timeout = clearTimeout(timeout);
4014 var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
4015 if (delay > 24) {
4016 if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
4017 if (interval) interval = clearInterval(interval);
4018 } else {
4019 if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
4020 frame = 1, setFrame(wake);
4021 }
4022}
4023
4024/***/ }),
4025/* 17 */
4026/***/ (function(module, __webpack_exports__, __webpack_require__) {
4027
4028"use strict";
4029/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
4030/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(34);
4031/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(37);
4032/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(38);
4033/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(11);
4034/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(39);
4035/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(40);
4036/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(36);
4037var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
4049 var t = typeof b === "undefined" ? "undefined" : _typeof(b),
4050 c;
4051 return b == null || t === "boolean" ? Object(__WEBPACK_IMPORTED_MODULE_7__constant__["a" /* default */])(b) : (t === "number" ? __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */] : t === "string" ? (c = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]) : __WEBPACK_IMPORTED_MODULE_6__string__["a" /* default */] : b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */] ? __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */] : b instanceof Date ? __WEBPACK_IMPORTED_MODULE_3__date__["a" /* default */] : Array.isArray(b) ? __WEBPACK_IMPORTED_MODULE_2__array__["a" /* default */] : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? __WEBPACK_IMPORTED_MODULE_5__object__["a" /* default */] : __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */])(a, b);
4052});
4053
4054/***/ }),
4055/* 18 */
4056/***/ (function(module, __webpack_exports__, __webpack_require__) {
4057
4058"use strict";
4059/* harmony export (immutable) */ __webpack_exports__["a"] = Color;
4060/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return _darker; });
4061/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _brighter; });
4062/* harmony export (immutable) */ __webpack_exports__["e"] = color;
4063/* harmony export (immutable) */ __webpack_exports__["h"] = rgbConvert;
4064/* harmony export (immutable) */ __webpack_exports__["g"] = rgb;
4065/* harmony export (immutable) */ __webpack_exports__["b"] = Rgb;
4066/* unused harmony export hslConvert */
4067/* harmony export (immutable) */ __webpack_exports__["f"] = hsl;
4068/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(19);
4069
4070
4071function Color() {}
4072
4073var _darker = 0.7;
4074
4075var _brighter = 1 / _darker;
4076
4077
4078var reI = "\\s*([+-]?\\d+)\\s*",
4079 reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
4080 reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
4081 reHex3 = /^#([0-9a-f]{3})$/,
4082 reHex6 = /^#([0-9a-f]{6})$/,
4083 reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
4084 reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
4085 reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
4086 reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
4087 reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
4088 reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
4089
4090var named = {
4091 aliceblue: 0xf0f8ff,
4092 antiquewhite: 0xfaebd7,
4093 aqua: 0x00ffff,
4094 aquamarine: 0x7fffd4,
4095 azure: 0xf0ffff,
4096 beige: 0xf5f5dc,
4097 bisque: 0xffe4c4,
4098 black: 0x000000,
4099 blanchedalmond: 0xffebcd,
4100 blue: 0x0000ff,
4101 blueviolet: 0x8a2be2,
4102 brown: 0xa52a2a,
4103 burlywood: 0xdeb887,
4104 cadetblue: 0x5f9ea0,
4105 chartreuse: 0x7fff00,
4106 chocolate: 0xd2691e,
4107 coral: 0xff7f50,
4108 cornflowerblue: 0x6495ed,
4109 cornsilk: 0xfff8dc,
4110 crimson: 0xdc143c,
4111 cyan: 0x00ffff,
4112 darkblue: 0x00008b,
4113 darkcyan: 0x008b8b,
4114 darkgoldenrod: 0xb8860b,
4115 darkgray: 0xa9a9a9,
4116 darkgreen: 0x006400,
4117 darkgrey: 0xa9a9a9,
4118 darkkhaki: 0xbdb76b,
4119 darkmagenta: 0x8b008b,
4120 darkolivegreen: 0x556b2f,
4121 darkorange: 0xff8c00,
4122 darkorchid: 0x9932cc,
4123 darkred: 0x8b0000,
4124 darksalmon: 0xe9967a,
4125 darkseagreen: 0x8fbc8f,
4126 darkslateblue: 0x483d8b,
4127 darkslategray: 0x2f4f4f,
4128 darkslategrey: 0x2f4f4f,
4129 darkturquoise: 0x00ced1,
4130 darkviolet: 0x9400d3,
4131 deeppink: 0xff1493,
4132 deepskyblue: 0x00bfff,
4133 dimgray: 0x696969,
4134 dimgrey: 0x696969,
4135 dodgerblue: 0x1e90ff,
4136 firebrick: 0xb22222,
4137 floralwhite: 0xfffaf0,
4138 forestgreen: 0x228b22,
4139 fuchsia: 0xff00ff,
4140 gainsboro: 0xdcdcdc,
4141 ghostwhite: 0xf8f8ff,
4142 gold: 0xffd700,
4143 goldenrod: 0xdaa520,
4144 gray: 0x808080,
4145 green: 0x008000,
4146 greenyellow: 0xadff2f,
4147 grey: 0x808080,
4148 honeydew: 0xf0fff0,
4149 hotpink: 0xff69b4,
4150 indianred: 0xcd5c5c,
4151 indigo: 0x4b0082,
4152 ivory: 0xfffff0,
4153 khaki: 0xf0e68c,
4154 lavender: 0xe6e6fa,
4155 lavenderblush: 0xfff0f5,
4156 lawngreen: 0x7cfc00,
4157 lemonchiffon: 0xfffacd,
4158 lightblue: 0xadd8e6,
4159 lightcoral: 0xf08080,
4160 lightcyan: 0xe0ffff,
4161 lightgoldenrodyellow: 0xfafad2,
4162 lightgray: 0xd3d3d3,
4163 lightgreen: 0x90ee90,
4164 lightgrey: 0xd3d3d3,
4165 lightpink: 0xffb6c1,
4166 lightsalmon: 0xffa07a,
4167 lightseagreen: 0x20b2aa,
4168 lightskyblue: 0x87cefa,
4169 lightslategray: 0x778899,
4170 lightslategrey: 0x778899,
4171 lightsteelblue: 0xb0c4de,
4172 lightyellow: 0xffffe0,
4173 lime: 0x00ff00,
4174 limegreen: 0x32cd32,
4175 linen: 0xfaf0e6,
4176 magenta: 0xff00ff,
4177 maroon: 0x800000,
4178 mediumaquamarine: 0x66cdaa,
4179 mediumblue: 0x0000cd,
4180 mediumorchid: 0xba55d3,
4181 mediumpurple: 0x9370db,
4182 mediumseagreen: 0x3cb371,
4183 mediumslateblue: 0x7b68ee,
4184 mediumspringgreen: 0x00fa9a,
4185 mediumturquoise: 0x48d1cc,
4186 mediumvioletred: 0xc71585,
4187 midnightblue: 0x191970,
4188 mintcream: 0xf5fffa,
4189 mistyrose: 0xffe4e1,
4190 moccasin: 0xffe4b5,
4191 navajowhite: 0xffdead,
4192 navy: 0x000080,
4193 oldlace: 0xfdf5e6,
4194 olive: 0x808000,
4195 olivedrab: 0x6b8e23,
4196 orange: 0xffa500,
4197 orangered: 0xff4500,
4198 orchid: 0xda70d6,
4199 palegoldenrod: 0xeee8aa,
4200 palegreen: 0x98fb98,
4201 paleturquoise: 0xafeeee,
4202 palevioletred: 0xdb7093,
4203 papayawhip: 0xffefd5,
4204 peachpuff: 0xffdab9,
4205 peru: 0xcd853f,
4206 pink: 0xffc0cb,
4207 plum: 0xdda0dd,
4208 powderblue: 0xb0e0e6,
4209 purple: 0x800080,
4210 rebeccapurple: 0x663399,
4211 red: 0xff0000,
4212 rosybrown: 0xbc8f8f,
4213 royalblue: 0x4169e1,
4214 saddlebrown: 0x8b4513,
4215 salmon: 0xfa8072,
4216 sandybrown: 0xf4a460,
4217 seagreen: 0x2e8b57,
4218 seashell: 0xfff5ee,
4219 sienna: 0xa0522d,
4220 silver: 0xc0c0c0,
4221 skyblue: 0x87ceeb,
4222 slateblue: 0x6a5acd,
4223 slategray: 0x708090,
4224 slategrey: 0x708090,
4225 snow: 0xfffafa,
4226 springgreen: 0x00ff7f,
4227 steelblue: 0x4682b4,
4228 tan: 0xd2b48c,
4229 teal: 0x008080,
4230 thistle: 0xd8bfd8,
4231 tomato: 0xff6347,
4232 turquoise: 0x40e0d0,
4233 violet: 0xee82ee,
4234 wheat: 0xf5deb3,
4235 white: 0xffffff,
4236 whitesmoke: 0xf5f5f5,
4237 yellow: 0xffff00,
4238 yellowgreen: 0x9acd32
4239};
4240
4241Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Color, color, {
4242 displayable: function displayable() {
4243 return this.rgb().displayable();
4244 },
4245 hex: function hex() {
4246 return this.rgb().hex();
4247 },
4248 toString: function toString() {
4249 return this.rgb() + "";
4250 }
4251});
4252
4253function color(format) {
4254 var m;
4255 format = (format + "").trim().toLowerCase();
4256 return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb(m >> 8 & 0xf | m >> 4 & 0x0f0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00
4257 ) : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
4258 : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
4259 : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
4260 : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
4261 : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
4262 : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
4263 : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
4264 : named.hasOwnProperty(format) ? rgbn(named[format]) : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
4265}
4266
4267function rgbn(n) {
4268 return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
4269}
4270
4271function rgba(r, g, b, a) {
4272 if (a <= 0) r = g = b = NaN;
4273 return new Rgb(r, g, b, a);
4274}
4275
4276function rgbConvert(o) {
4277 if (!(o instanceof Color)) o = color(o);
4278 if (!o) return new Rgb();
4279 o = o.rgb();
4280 return new Rgb(o.r, o.g, o.b, o.opacity);
4281}
4282
4283function rgb(r, g, b, opacity) {
4284 return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
4285}
4286
4287function Rgb(r, g, b, opacity) {
4288 this.r = +r;
4289 this.g = +g;
4290 this.b = +b;
4291 this.opacity = +opacity;
4292}
4293
4294Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Rgb, rgb, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
4295 brighter: function brighter(k) {
4296 k = k == null ? _brighter : Math.pow(_brighter, k);
4297 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
4298 },
4299 darker: function darker(k) {
4300 k = k == null ? _darker : Math.pow(_darker, k);
4301 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
4302 },
4303 rgb: function rgb() {
4304 return this;
4305 },
4306 displayable: function displayable() {
4307 return 0 <= this.r && this.r <= 255 && 0 <= this.g && this.g <= 255 && 0 <= this.b && this.b <= 255 && 0 <= this.opacity && this.opacity <= 1;
4308 },
4309 hex: function hex() {
4310 return "#" + _hex(this.r) + _hex(this.g) + _hex(this.b);
4311 },
4312 toString: function toString() {
4313 var a = this.opacity;a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
4314 return (a === 1 ? "rgb(" : "rgba(") + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.b) || 0)) + (a === 1 ? ")" : ", " + a + ")");
4315 }
4316}));
4317
4318function _hex(value) {
4319 value = Math.max(0, Math.min(255, Math.round(value) || 0));
4320 return (value < 16 ? "0" : "") + value.toString(16);
4321}
4322
4323function hsla(h, s, l, a) {
4324 if (a <= 0) h = s = l = NaN;else if (l <= 0 || l >= 1) h = s = NaN;else if (s <= 0) h = NaN;
4325 return new Hsl(h, s, l, a);
4326}
4327
4328function hslConvert(o) {
4329 if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
4330 if (!(o instanceof Color)) o = color(o);
4331 if (!o) return new Hsl();
4332 if (o instanceof Hsl) return o;
4333 o = o.rgb();
4334 var r = o.r / 255,
4335 g = o.g / 255,
4336 b = o.b / 255,
4337 min = Math.min(r, g, b),
4338 max = Math.max(r, g, b),
4339 h = NaN,
4340 s = max - min,
4341 l = (max + min) / 2;
4342 if (s) {
4343 if (r === max) h = (g - b) / s + (g < b) * 6;else if (g === max) h = (b - r) / s + 2;else h = (r - g) / s + 4;
4344 s /= l < 0.5 ? max + min : 2 - max - min;
4345 h *= 60;
4346 } else {
4347 s = l > 0 && l < 1 ? 0 : h;
4348 }
4349 return new Hsl(h, s, l, o.opacity);
4350}
4351
4352function hsl(h, s, l, opacity) {
4353 return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
4354}
4355
4356function Hsl(h, s, l, opacity) {
4357 this.h = +h;
4358 this.s = +s;
4359 this.l = +l;
4360 this.opacity = +opacity;
4361}
4362
4363Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hsl, hsl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
4364 brighter: function brighter(k) {
4365 k = k == null ? _brighter : Math.pow(_brighter, k);
4366 return new Hsl(this.h, this.s, this.l * k, this.opacity);
4367 },
4368 darker: function darker(k) {
4369 k = k == null ? _darker : Math.pow(_darker, k);
4370 return new Hsl(this.h, this.s, this.l * k, this.opacity);
4371 },
4372 rgb: function rgb() {
4373 var h = this.h % 360 + (this.h < 0) * 360,
4374 s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
4375 l = this.l,
4376 m2 = l + (l < 0.5 ? l : 1 - l) * s,
4377 m1 = 2 * l - m2;
4378 return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity);
4379 },
4380 displayable: function displayable() {
4381 return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
4382 }
4383}));
4384
4385/* From FvD 13.37, CSS Color Module Level 3 */
4386function hsl2rgb(h, m1, m2) {
4387 return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
4388}
4389
4390/***/ }),
4391/* 19 */
4392/***/ (function(module, __webpack_exports__, __webpack_require__) {
4393
4394"use strict";
4395/* harmony export (immutable) */ __webpack_exports__["b"] = extend;
4396/* harmony default export */ __webpack_exports__["a"] = (function (constructor, factory, prototype) {
4397 constructor.prototype = factory.prototype = prototype;
4398 prototype.constructor = constructor;
4399});
4400
4401function extend(parent, definition) {
4402 var prototype = Object.create(parent.prototype);
4403 for (var key in definition) {
4404 prototype[key] = definition[key];
4405 }return prototype;
4406}
4407
4408/***/ }),
4409/* 20 */
4410/***/ (function(module, __webpack_exports__, __webpack_require__) {
4411
4412"use strict";
4413/* harmony export (immutable) */ __webpack_exports__["a"] = basis;
4414function basis(t1, v0, v1, v2, v3) {
4415 var t2 = t1 * t1,
4416 t3 = t2 * t1;
4417 return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
4418}
4419
4420/* harmony default export */ __webpack_exports__["b"] = (function (values) {
4421 var n = values.length - 1;
4422 return function (t) {
4423 var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
4424 v1 = values[i],
4425 v2 = values[i + 1],
4426 v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
4427 v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
4428 return basis((t - i / n) * n, v0, v1, v2, v3);
4429 };
4430});
4431
4432/***/ }),
4433/* 21 */
4434/***/ (function(module, exports, __webpack_require__) {
4435
4436var Util = __webpack_require__(0);
4437
4438var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
4439var regexDot = /[^\s\,]+/ig;
4440var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
4441var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
4442var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
4443var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
4444var numColorCache = {};
4445
4446function addStop(steps, gradient) {
4447 var arr = steps.match(regexColorStop);
4448 Util.each(arr, function (item) {
4449 item = item.split(':');
4450 gradient.addColorStop(item[0], item[1]);
4451 });
4452}
4453
4454function parseLineGradient(color, self) {
4455 var arr = regexLG.exec(color);
4456 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
4457 var steps = arr[2];
4458 var box = self.getBBox();
4459 var start = void 0;
4460 var end = void 0;
4461
4462 if (angle >= 0 && angle < 0.5 * Math.PI) {
4463 start = {
4464 x: box.minX,
4465 y: box.minY
4466 };
4467 end = {
4468 x: box.maxX,
4469 y: box.maxY
4470 };
4471 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
4472 start = {
4473 x: box.maxX,
4474 y: box.minY
4475 };
4476 end = {
4477 x: box.minX,
4478 y: box.maxY
4479 };
4480 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
4481 start = {
4482 x: box.maxX,
4483 y: box.maxY
4484 };
4485 end = {
4486 x: box.minX,
4487 y: box.minY
4488 };
4489 } else {
4490 start = {
4491 x: box.minX,
4492 y: box.maxY
4493 };
4494 end = {
4495 x: box.maxX,
4496 y: box.minY
4497 };
4498 }
4499
4500 var tanTheta = Math.tan(angle);
4501 var tanTheta2 = tanTheta * tanTheta;
4502
4503 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
4504 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
4505 var context = self.get('context');
4506 var gradient = context.createLinearGradient(start.x, start.y, x, y);
4507 addStop(steps, gradient);
4508 return gradient;
4509}
4510
4511function parseRadialGradient(color, self) {
4512 var arr = regexRG.exec(color);
4513 var fx = parseFloat(arr[1]);
4514 var fy = parseFloat(arr[2]);
4515 var fr = parseFloat(arr[3]);
4516 var steps = arr[4];
4517 // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
4518 if (fr === 0) {
4519 var colors = steps.match(regexColorStop);
4520 return colors[colors.length - 1].split(':')[1];
4521 }
4522 var box = self.getBBox();
4523 var context = self.get('context');
4524 var width = box.maxX - box.minX;
4525 var height = box.maxY - box.minY;
4526 var r = Math.sqrt(width * width + height * height) / 2;
4527 var gradient = context.createRadialGradient(box.minX + width * fx, box.minY + height * fy, fr * r, box.minX + width / 2, box.minY + height / 2, r);
4528 addStop(steps, gradient);
4529 return gradient;
4530}
4531
4532function parsePattern(color, self) {
4533 if (self.get('patternSource') && self.get('patternSource') === color) {
4534 return self.get('pattern');
4535 }
4536 var pattern = void 0;
4537 var img = void 0;
4538 var arr = regexPR.exec(color);
4539 var repeat = arr[1];
4540 var source = arr[2];
4541
4542 // Function to be called when pattern loads
4543 function onload() {
4544 // Create pattern
4545 var context = self.get('context');
4546 pattern = context.createPattern(img, repeat);
4547 self.setSilent('pattern', pattern); // be a cache
4548 self.setSilent('patternSource', color);
4549 }
4550
4551 switch (repeat) {
4552 case 'a':
4553 repeat = 'repeat';
4554 break;
4555 case 'x':
4556 repeat = 'repeat-x';
4557 break;
4558 case 'y':
4559 repeat = 'repeat-y';
4560 break;
4561 case 'n':
4562 repeat = 'no-repeat';
4563 break;
4564 default:
4565 repeat = 'no-repeat';
4566 }
4567
4568 img = new Image();
4569 // If source URL is not a data URL
4570 if (!source.match(/^data:/i)) {
4571 // Set crossOrigin for this image
4572 img.crossOrigin = 'Anonymous';
4573 }
4574 img.src = source;
4575
4576 if (img.complete) {
4577 onload();
4578 } else {
4579 img.onload = onload;
4580 // Fix onload() bug in IE9
4581 img.src = img.src;
4582 }
4583
4584 return pattern;
4585}
4586
4587module.exports = {
4588 parsePath: function parsePath(path) {
4589 path = path || [];
4590 if (Util.isArray(path)) {
4591 return path;
4592 }
4593
4594 if (Util.isString(path)) {
4595 path = path.match(regexTags);
4596 Util.each(path, function (item, index) {
4597 item = item.match(regexDot);
4598 if (item[0].length > 1) {
4599 var tag = item[0].charAt(0);
4600 item.splice(1, 0, item[0].substr(1));
4601 item[0] = tag;
4602 }
4603 Util.each(item, function (sub, i) {
4604 if (!isNaN(sub)) {
4605 item[i] = +sub;
4606 }
4607 });
4608 path[index] = item;
4609 });
4610 return path;
4611 }
4612 },
4613 parseStyle: function parseStyle(color, self) {
4614 if (Util.isString(color)) {
4615 if (color[1] === '(' || color[2] === '(') {
4616 if (color[0] === 'l') {
4617 // regexLG.test(color)
4618 return parseLineGradient(color, self);
4619 } else if (color[0] === 'r') {
4620 // regexRG.test(color)
4621 return parseRadialGradient(color, self);
4622 } else if (color[0] === 'p') {
4623 // regexPR.test(color)
4624 return parsePattern(color, self);
4625 }
4626 }
4627 return color;
4628 }
4629 },
4630 numberToColor: function numberToColor(num) {
4631 // 增加缓存
4632 var color = numColorCache[num];
4633 if (!color) {
4634 var str = num.toString(16);
4635 for (var i = str.length; i < 6; i++) {
4636 str = '0' + str;
4637 }
4638 color = '#' + str;
4639 numColorCache[num] = color;
4640 }
4641 return color;
4642 }
4643};
4644
4645/***/ }),
4646/* 22 */
4647/***/ (function(module, exports, __webpack_require__) {
4648
4649var vec2 = __webpack_require__(2).vec2;
4650
4651module.exports = {
4652 at: function at(p1, p2, t) {
4653 return (p2 - p1) * t + p1;
4654 },
4655 pointDistance: function pointDistance(x1, y1, x2, y2, x, y) {
4656 var d = [x2 - x1, y2 - y1];
4657 if (vec2.exactEquals(d, [0, 0])) {
4658 return NaN;
4659 }
4660
4661 var u = [-d[1], d[0]];
4662 vec2.normalize(u, u);
4663 var a = [x - x1, y - y1];
4664 return Math.abs(vec2.dot(a, u));
4665 },
4666 box: function box(x1, y1, x2, y2, lineWidth) {
4667 var halfWidth = lineWidth / 2;
4668 var minX = Math.min(x1, x2);
4669 var maxX = Math.max(x1, x2);
4670 var minY = Math.min(y1, y2);
4671 var maxY = Math.max(y1, y2);
4672
4673 return {
4674 minX: minX - halfWidth,
4675 minY: minY - halfWidth,
4676 maxX: maxX + halfWidth,
4677 maxY: maxY + halfWidth
4678 };
4679 },
4680 len: function len(x1, y1, x2, y2) {
4681 return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
4682 }
4683};
4684
4685/***/ }),
4686/* 23 */
4687/***/ (function(module, exports, __webpack_require__) {
4688
4689var Util = __webpack_require__(0);
4690var vec2 = __webpack_require__(2).vec2;
4691
4692function quadraticAt(p0, p1, p2, t) {
4693 var onet = 1 - t;
4694 return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
4695}
4696
4697function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) {
4698 var t = void 0;
4699 var interval = 0.005;
4700 var d = Infinity;
4701 var d1 = void 0;
4702 var v1 = void 0;
4703 var v2 = void 0;
4704 var _t = void 0;
4705 var d2 = void 0;
4706 var i = void 0;
4707 var EPSILON = 0.0001;
4708 var v0 = [x, y];
4709
4710 for (_t = 0; _t < 1; _t += 0.05) {
4711 v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)];
4712
4713 d1 = vec2.squaredDistance(v0, v1);
4714 if (d1 < d) {
4715 t = _t;
4716 d = d1;
4717 }
4718 }
4719 d = Infinity;
4720
4721 for (i = 0; i < 32; i++) {
4722 if (interval < EPSILON) {
4723 break;
4724 }
4725
4726 var prev = t - interval;
4727 var next = t + interval;
4728
4729 v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)];
4730
4731 d1 = vec2.squaredDistance(v0, v1);
4732
4733 if (prev >= 0 && d1 < d) {
4734 t = prev;
4735 d = d1;
4736 } else {
4737 v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)];
4738
4739 d2 = vec2.squaredDistance(v0, v2);
4740
4741 if (next <= 1 && d2 < d) {
4742 t = next;
4743 d = d2;
4744 } else {
4745 interval *= 0.5;
4746 }
4747 }
4748 }
4749
4750 if (out) {
4751 out.x = quadraticAt(x1, x2, x3, t);
4752 out.y = quadraticAt(y1, y2, y3, t);
4753 }
4754
4755 return Math.sqrt(d);
4756}
4757
4758function quadraticExtrema(p0, p1, p2) {
4759 var a = p0 + p2 - 2 * p1;
4760 if (Util.isNumberEqual(a, 0)) {
4761 return [0.5];
4762 }
4763 var rst = (p0 - p1) / a;
4764 if (rst <= 1 && rst >= 0) {
4765 return [rst];
4766 }
4767 return [];
4768}
4769
4770module.exports = {
4771 at: quadraticAt,
4772 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x, y) {
4773 var rst = {};
4774 quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, rst);
4775 return rst;
4776 },
4777
4778 pointDistance: quadraticProjectPoint,
4779 extrema: quadraticExtrema
4780};
4781
4782/***/ }),
4783/* 24 */
4784/***/ (function(module, exports, __webpack_require__) {
4785
4786var Util = __webpack_require__(0);
4787var vec2 = __webpack_require__(2).vec2;
4788
4789function circlePoint(cx, cy, r, angle) {
4790 return {
4791 x: Math.cos(angle) * r + cx,
4792 y: Math.sin(angle) * r + cy
4793 };
4794}
4795
4796function angleNearTo(angle, min, max, out) {
4797 var v1 = void 0;
4798 var v2 = void 0;
4799 if (out) {
4800 if (angle < min) {
4801 v1 = min - angle;
4802 v2 = Math.PI * 2 - max + angle;
4803 } else if (angle > max) {
4804 v1 = Math.PI * 2 - angle + min;
4805 v2 = angle - max;
4806 }
4807 } else {
4808 v1 = angle - min;
4809 v2 = max - angle;
4810 }
4811
4812 return v1 > v2 ? max : min;
4813}
4814
4815function nearAngle(angle, startAngle, endAngle, clockwise) {
4816 var plus = 0;
4817 if (endAngle - startAngle >= Math.PI * 2) {
4818 plus = Math.PI * 2;
4819 }
4820 startAngle = Util.mod(startAngle, Math.PI * 2);
4821 endAngle = Util.mod(endAngle, Math.PI * 2) + plus;
4822 angle = Util.mod(angle, Math.PI * 2);
4823 if (clockwise) {
4824 if (startAngle >= endAngle) {
4825 if (angle > endAngle && angle < startAngle) {
4826 return angle;
4827 }
4828 return angleNearTo(angle, endAngle, startAngle, true);
4829 }
4830 if (angle < startAngle || angle > endAngle) {
4831 return angle;
4832 }
4833 return angleNearTo(angle, startAngle, endAngle);
4834 }
4835 if (startAngle <= endAngle) {
4836 if (startAngle < angle && angle < endAngle) {
4837 return angle;
4838 }
4839 return angleNearTo(angle, startAngle, endAngle, true);
4840 }
4841 if (angle > startAngle || angle < endAngle) {
4842 return angle;
4843 }
4844 return angleNearTo(angle, endAngle, startAngle);
4845}
4846
4847function arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, out) {
4848 var v = [x, y];
4849 var v0 = [cx, cy];
4850 var v1 = [1, 0];
4851 var subv = vec2.subtract([], v, v0);
4852 var angle = vec2.angleTo(v1, subv);
4853
4854 angle = nearAngle(angle, startAngle, endAngle, clockwise);
4855 var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy];
4856 if (out) {
4857 out.x = vpoint[0];
4858 out.y = vpoint[1];
4859 }
4860 var d = vec2.distance(vpoint, v);
4861 return d;
4862}
4863
4864function arcBox(cx, cy, r, startAngle, endAngle, clockwise) {
4865 var angleRight = 0;
4866 var angleBottom = Math.PI / 2;
4867 var angleLeft = Math.PI;
4868 var angleTop = Math.PI * 3 / 2;
4869 var points = [];
4870 var angle = nearAngle(angleRight, startAngle, endAngle, clockwise);
4871 if (angle === angleRight) {
4872 points.push(circlePoint(cx, cy, r, angleRight));
4873 }
4874
4875 angle = nearAngle(angleBottom, startAngle, endAngle, clockwise);
4876 if (angle === angleBottom) {
4877 points.push(circlePoint(cx, cy, r, angleBottom));
4878 }
4879
4880 angle = nearAngle(angleLeft, startAngle, endAngle, clockwise);
4881 if (angle === angleLeft) {
4882 points.push(circlePoint(cx, cy, r, angleLeft));
4883 }
4884
4885 angle = nearAngle(angleTop, startAngle, endAngle, clockwise);
4886 if (angle === angleTop) {
4887 points.push(circlePoint(cx, cy, r, angleTop));
4888 }
4889
4890 points.push(circlePoint(cx, cy, r, startAngle));
4891 points.push(circlePoint(cx, cy, r, endAngle));
4892 var minX = Infinity;
4893 var maxX = -Infinity;
4894 var minY = Infinity;
4895 var maxY = -Infinity;
4896 Util.each(points, function (point) {
4897 if (minX > point.x) {
4898 minX = point.x;
4899 }
4900 if (maxX < point.x) {
4901 maxX = point.x;
4902 }
4903 if (minY > point.y) {
4904 minY = point.y;
4905 }
4906 if (maxY < point.y) {
4907 maxY = point.y;
4908 }
4909 });
4910
4911 return {
4912 minX: minX,
4913 minY: minY,
4914 maxX: maxX,
4915 maxY: maxY
4916 };
4917}
4918
4919module.exports = {
4920 nearAngle: nearAngle,
4921 projectPoint: function projectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y) {
4922 var rst = {};
4923 arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, rst);
4924 return rst;
4925 },
4926
4927 pointDistance: arcProjectPoint,
4928 box: arcBox
4929};
4930
4931/***/ }),
4932/* 25 */
4933/***/ (function(module, exports, __webpack_require__) {
4934
4935var Util = __webpack_require__(0);
4936var Shape = __webpack_require__(1);
4937var Inside = __webpack_require__(3);
4938
4939var Rect = function Rect(cfg) {
4940 Rect.superclass.constructor.call(this, cfg);
4941};
4942
4943Rect.ATTRS = {
4944 x: 0,
4945 y: 0,
4946 width: 0,
4947 height: 0,
4948 radius: 0,
4949 lineWidth: 1
4950};
4951
4952Util.extend(Rect, Shape);
4953
4954Util.augment(Rect, {
4955 canFill: true,
4956 canStroke: true,
4957 type: 'rect',
4958 getDefaultAttrs: function getDefaultAttrs() {
4959 return {
4960 lineWidth: 1,
4961 radius: 0
4962 };
4963 },
4964 calculateBox: function calculateBox() {
4965 var self = this;
4966 var attrs = self.__attrs;
4967 var x = attrs.x;
4968 var y = attrs.y;
4969 var width = attrs.width;
4970 var height = attrs.height;
4971 var lineWidth = this.getHitLineWidth();
4972
4973 var halfWidth = lineWidth / 2;
4974 return {
4975 minX: x - halfWidth,
4976 minY: y - halfWidth,
4977 maxX: x + width + halfWidth,
4978 maxY: y + height + halfWidth
4979 };
4980 },
4981 isPointInPath: function isPointInPath(x, y) {
4982 var self = this;
4983 var fill = self.hasFill();
4984 var stroke = self.hasStroke();
4985
4986 if (fill && stroke) {
4987 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
4988 }
4989
4990 if (fill) {
4991 return self._isPointInFill(x, y);
4992 }
4993
4994 if (stroke) {
4995 return self._isPointInStroke(x, y);
4996 }
4997
4998 return false;
4999 },
5000 _isPointInFill: function _isPointInFill(x, y) {
5001 var context = this.get('context');
5002
5003 if (!context) return false;
5004 this.createPath();
5005 return context.isPointInPath(x, y);
5006 },
5007 _isPointInStroke: function _isPointInStroke(x, y) {
5008 var self = this;
5009 var attrs = self.__attrs;
5010 var rx = attrs.x;
5011 var ry = attrs.y;
5012 var width = attrs.width;
5013 var height = attrs.height;
5014 var radius = attrs.radius;
5015 var lineWidth = this.getHitLineWidth();
5016
5017 if (radius === 0) {
5018 var halfWidth = lineWidth / 2;
5019 return Inside.line(rx - halfWidth, ry, rx + width + halfWidth, ry, lineWidth, x, y) || Inside.line(rx + width, ry - halfWidth, rx + width, ry + height + halfWidth, lineWidth, x, y) || Inside.line(rx + width + halfWidth, ry + height, rx - halfWidth, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height + halfWidth, rx, ry - halfWidth, lineWidth, x, y);
5020 }
5021
5022 return Inside.line(rx + radius, ry, rx + width - radius, ry, lineWidth, x, y) || Inside.line(rx + width, ry + radius, rx + width, ry + height - radius, lineWidth, x, y) || Inside.line(rx + width - radius, ry + height, rx + radius, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height - radius, rx, ry + radius, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + radius, radius, 1.5 * Math.PI, 2 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + height - radius, radius, 0, 0.5 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + height - radius, radius, 0.5 * Math.PI, Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + radius, radius, Math.PI, 1.5 * Math.PI, false, lineWidth, x, y);
5023 },
5024 createPath: function createPath(context) {
5025 var self = this;
5026 var attrs = self.__attrs;
5027 var x = attrs.x;
5028 var y = attrs.y;
5029 var width = attrs.width;
5030 var height = attrs.height;
5031 var radius = attrs.radius;
5032 context = context || self.get('context');
5033
5034 context.beginPath();
5035 if (radius === 0) {
5036 // 改成原生的rect方法
5037 context.rect(x, y, width, height);
5038 } else {
5039 context.moveTo(x + radius, y);
5040 context.lineTo(x + width - radius, y);
5041 context.arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0, false);
5042 context.lineTo(x + width, y + height - radius);
5043 context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2, false);
5044 context.lineTo(x + radius, y + height);
5045 context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI, false);
5046 context.lineTo(x, y + radius);
5047 context.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2, false);
5048 context.closePath();
5049 }
5050 }
5051});
5052
5053module.exports = Rect;
5054
5055/***/ }),
5056/* 26 */
5057/***/ (function(module, exports, __webpack_require__) {
5058
5059var Util = __webpack_require__(0);
5060var Inside = __webpack_require__(3);
5061var Cubic = __webpack_require__(12);
5062var Quadratic = __webpack_require__(23);
5063var Ellipse = __webpack_require__(115);
5064var vec3 = __webpack_require__(2).vec3;
5065var mat3 = __webpack_require__(2).mat3;
5066
5067var ARR_CMD = ['m', 'l', 'c', 'a', 'q', 'h', 'v', 't', 's', 'z'];
5068
5069function toAbsolute(x, y, curPoint) {
5070 // 获取绝对坐标
5071 return {
5072 x: curPoint.x + x,
5073 y: curPoint.y + y
5074 };
5075}
5076
5077function toSymmetry(point, center) {
5078 // 点对称
5079 return {
5080 x: center.x + (center.x - point.x),
5081 y: center.y + (center.y - point.y)
5082 };
5083}
5084
5085function vMag(v) {
5086 return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
5087}
5088
5089function vRatio(u, v) {
5090 return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
5091}
5092
5093function vAngle(u, v) {
5094 return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
5095}
5096
5097function getArcParams(point1, point2, fa, fs, rx, ry, psiDeg) {
5098 var psi = Util.mod(Util.toRadian(psiDeg), Math.PI * 2);
5099 var x1 = point1.x;
5100 var y1 = point1.y;
5101 var x2 = point2.x;
5102 var y2 = point2.y;
5103 var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
5104 var yp = -1 * Math.sin(psi) * (x1 - x2) / 2.0 + Math.cos(psi) * (y1 - y2) / 2.0;
5105 var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
5106 if (lambda > 1) {
5107 rx *= Math.sqrt(lambda);
5108 ry *= Math.sqrt(lambda);
5109 }
5110 var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);
5111 var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff);
5112
5113 if (fa === fs) {
5114 f *= -1;
5115 }
5116 if (isNaN(f)) {
5117 f = 0;
5118 }
5119
5120 var cxp = f * rx * yp / ry;
5121 var cyp = f * -ry * xp / rx;
5122
5123 var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
5124 var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
5125
5126 var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
5127 var u = [(xp - cxp) / rx, (yp - cyp) / ry];
5128 var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
5129 var dTheta = vAngle(u, v);
5130 if (fs === 0 && dTheta > 0) {
5131 dTheta = dTheta - 2 * Math.PI;
5132 }
5133 if (fs === 1 && dTheta < 0) {
5134 dTheta = dTheta + 2 * Math.PI;
5135 }
5136 return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs];
5137}
5138
5139var PathSegment = function PathSegment(item, preSegment, isLast) {
5140 this.preSegment = preSegment;
5141 this.isLast = isLast;
5142 this.init(item, preSegment);
5143};
5144
5145Util.augment(PathSegment, {
5146 init: function init(item, preSegment) {
5147 var command = item[0];
5148 preSegment = preSegment || {
5149 endPoint: {
5150 x: 0,
5151 y: 0
5152 }
5153 };
5154 var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command);
5155 var cmd = relative ? command.toUpperCase() : command;
5156 var p = item;
5157 var point1 = void 0;
5158 var point2 = void 0;
5159 var point3 = void 0;
5160 var point = void 0;
5161 var preEndPoint = preSegment.endPoint;
5162
5163 var p1 = p[1];
5164 var p2 = p[2];
5165 switch (cmd) {
5166 default:
5167 break;
5168 case 'M':
5169 if (relative) {
5170 point = toAbsolute(p1, p2, preEndPoint);
5171 } else {
5172 point = {
5173 x: p1,
5174 y: p2
5175 };
5176 }
5177 this.command = 'M';
5178 this.params = [preEndPoint, point];
5179 this.subStart = point;
5180 this.endPoint = point;
5181 break;
5182 case 'L':
5183 if (relative) {
5184 point = toAbsolute(p1, p2, preEndPoint);
5185 } else {
5186 point = {
5187 x: p1,
5188 y: p2
5189 };
5190 }
5191 this.command = 'L';
5192 this.params = [preEndPoint, point];
5193 this.subStart = preSegment.subStart;
5194 this.endPoint = point;
5195 this.endTangent = function () {
5196 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
5197 };
5198 this.startTangent = function () {
5199 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
5200 };
5201 break;
5202 case 'H':
5203 if (relative) {
5204 point = toAbsolute(p1, 0, preEndPoint);
5205 } else {
5206 point = {
5207 x: p1,
5208 y: preEndPoint.y
5209 };
5210 }
5211 this.command = 'L';
5212 this.params = [preEndPoint, point];
5213 this.subStart = preSegment.subStart;
5214 this.endPoint = point;
5215 this.endTangent = function () {
5216 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
5217 };
5218 this.startTangent = function () {
5219 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
5220 };
5221 break;
5222 case 'V':
5223 if (relative) {
5224 point = toAbsolute(0, p1, preEndPoint);
5225 } else {
5226 point = {
5227 x: preEndPoint.x,
5228 y: p1
5229 };
5230 }
5231 this.command = 'L';
5232 this.params = [preEndPoint, point];
5233 this.subStart = preSegment.subStart;
5234 this.endPoint = point;
5235 this.endTangent = function () {
5236 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
5237 };
5238 this.startTangent = function () {
5239 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
5240 };
5241 break;
5242 case 'Q':
5243 if (relative) {
5244 point1 = toAbsolute(p1, p2, preEndPoint);
5245 point2 = toAbsolute(p[3], p[4], preEndPoint);
5246 } else {
5247 point1 = {
5248 x: p1,
5249 y: p2
5250 };
5251 point2 = {
5252 x: p[3],
5253 y: p[4]
5254 };
5255 }
5256 this.command = 'Q';
5257 this.params = [preEndPoint, point1, point2];
5258 this.subStart = preSegment.subStart;
5259 this.endPoint = point2;
5260 this.endTangent = function () {
5261 return [point2.x - point1.x, point2.y - point1.y];
5262 };
5263 this.startTangent = function () {
5264 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5265 };
5266 break;
5267 case 'T':
5268 if (relative) {
5269 point2 = toAbsolute(p1, p2, preEndPoint);
5270 } else {
5271 point2 = {
5272 x: p1,
5273 y: p2
5274 };
5275 }
5276 if (preSegment.command === 'Q') {
5277 point1 = toSymmetry(preSegment.params[1], preEndPoint);
5278 this.command = 'Q';
5279 this.params = [preEndPoint, point1, point2];
5280 this.subStart = preSegment.subStart;
5281 this.endPoint = point2;
5282 this.endTangent = function () {
5283 return [point2.x - point1.x, point2.y - point1.y];
5284 };
5285 this.startTangent = function () {
5286 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5287 };
5288 } else {
5289 this.command = 'TL';
5290 this.params = [preEndPoint, point2];
5291 this.subStart = preSegment.subStart;
5292 this.endPoint = point2;
5293 this.endTangent = function () {
5294 return [point2.x - preEndPoint.x, point2.y - preEndPoint.y];
5295 };
5296 this.startTangent = function () {
5297 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
5298 };
5299 }
5300
5301 break;
5302 case 'C':
5303 if (relative) {
5304 point1 = toAbsolute(p1, p2, preEndPoint);
5305 point2 = toAbsolute(p[3], p[4], preEndPoint);
5306 point3 = toAbsolute(p[5], p[6], preEndPoint);
5307 } else {
5308 point1 = {
5309 x: p1,
5310 y: p2
5311 };
5312 point2 = {
5313 x: p[3],
5314 y: p[4]
5315 };
5316 point3 = {
5317 x: p[5],
5318 y: p[6]
5319 };
5320 }
5321 this.command = 'C';
5322 this.params = [preEndPoint, point1, point2, point3];
5323 this.subStart = preSegment.subStart;
5324 this.endPoint = point3;
5325 this.endTangent = function () {
5326 return [point3.x - point2.x, point3.y - point2.y];
5327 };
5328 this.startTangent = function () {
5329 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5330 };
5331 break;
5332 case 'S':
5333 if (relative) {
5334 point2 = toAbsolute(p1, p2, preEndPoint);
5335 point3 = toAbsolute(p[3], p[4], preEndPoint);
5336 } else {
5337 point2 = {
5338 x: p1,
5339 y: p2
5340 };
5341 point3 = {
5342 x: p[3],
5343 y: p[4]
5344 };
5345 }
5346 if (preSegment.command === 'C') {
5347 point1 = toSymmetry(preSegment.params[2], preEndPoint);
5348 this.command = 'C';
5349 this.params = [preEndPoint, point1, point2, point3];
5350 this.subStart = preSegment.subStart;
5351 this.endPoint = point3;
5352 this.endTangent = function () {
5353 return [point3.x - point2.x, point3.y - point2.y];
5354 };
5355 this.startTangent = function () {
5356 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5357 };
5358 } else {
5359 this.command = 'SQ';
5360 this.params = [preEndPoint, point2, point3];
5361 this.subStart = preSegment.subStart;
5362 this.endPoint = point3;
5363 this.endTangent = function () {
5364 return [point3.x - point2.x, point3.y - point2.y];
5365 };
5366 this.startTangent = function () {
5367 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
5368 };
5369 }
5370 break;
5371 case 'A':
5372 {
5373 var rx = p1;
5374 var ry = p2;
5375 var psi = p[3];
5376 var fa = p[4];
5377 var fs = p[5];
5378 if (relative) {
5379 point = toAbsolute(p[6], p[7], preEndPoint);
5380 } else {
5381 point = {
5382 x: p[6],
5383 y: p[7]
5384 };
5385 }
5386
5387 this.command = 'A';
5388 var params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi);
5389 this.params = params;
5390 var start = preSegment.subStart;
5391 this.subStart = start;
5392 this.endPoint = point;
5393 var startAngle = params[5] % (Math.PI * 2);
5394 if (Util.isNumberEqual(startAngle, Math.PI * 2)) {
5395 startAngle = 0;
5396 }
5397 var endAngle = params[6] % (Math.PI * 2);
5398 if (Util.isNumberEqual(endAngle, Math.PI * 2)) {
5399 endAngle = 0;
5400 }
5401 var d = 0.001;
5402 this.startTangent = function () {
5403 if (fs === 0) {
5404 d *= -1;
5405 }
5406 var dx = params[3] * Math.cos(startAngle - d) + params[1];
5407 var dy = params[4] * Math.sin(startAngle - d) + params[2];
5408 return [dx - start.x, dy - start.y];
5409 };
5410 this.endTangent = function () {
5411 var endAngle = params[6];
5412 if (endAngle - Math.PI * 2 < 0.0001) {
5413 endAngle = 0;
5414 }
5415 var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1];
5416 var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2];
5417 return [preEndPoint.x - dx, preEndPoint.y - dy];
5418 };
5419 break;
5420 }
5421 case 'Z':
5422 {
5423 this.command = 'Z';
5424 this.params = [preEndPoint, preSegment.subStart];
5425 this.subStart = preSegment.subStart;
5426 this.endPoint = preSegment.subStart;
5427 }
5428 }
5429 },
5430 isInside: function isInside(x, y, lineWidth) {
5431 var self = this;
5432 var command = self.command;
5433 var params = self.params;
5434 var box = self.box;
5435 if (box) {
5436 if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
5437 return false;
5438 }
5439 }
5440 switch (command) {
5441 default:
5442 break;
5443 case 'M':
5444 return false;
5445 case 'TL':
5446 case 'L':
5447 case 'Z':
5448 return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y);
5449 case 'SQ':
5450 case 'Q':
5451 return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y);
5452 case 'C':
5453 {
5454 return Inside.cubicline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, params[3].x, params[3].y, lineWidth, x, y);
5455 }
5456 case 'A':
5457 {
5458 var p = params;
5459 var cx = p[1];
5460 var cy = p[2];
5461 var rx = p[3];
5462 var ry = p[4];
5463 var theta = p[5];
5464 var dTheta = p[6];
5465 var psi = p[7];
5466 var fs = p[8];
5467
5468 var r = rx > ry ? rx : ry;
5469 var scaleX = rx > ry ? 1 : rx / ry;
5470 var scaleY = rx > ry ? ry / rx : 1;
5471
5472 p = [x, y, 1];
5473 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
5474 mat3.translate(m, m, [-cx, -cy]);
5475 mat3.rotate(m, m, -psi);
5476 mat3.scale(m, m, [1 / scaleX, 1 / scaleY]);
5477 vec3.transformMat3(p, p, m);
5478 return Inside.arcline(0, 0, r, theta, theta + dTheta, 1 - fs, lineWidth, p[0], p[1]);
5479 }
5480 }
5481 return false;
5482 },
5483 draw: function draw(context) {
5484 var command = this.command;
5485 var params = this.params;
5486 var point1 = void 0;
5487 var point2 = void 0;
5488 var point3 = void 0;
5489
5490 switch (command) {
5491 default:
5492 break;
5493 case 'M':
5494 context.moveTo(params[1].x, params[1].y);
5495 break;
5496 case 'TL':
5497 case 'L':
5498 context.lineTo(params[1].x, params[1].y);
5499 break;
5500 case 'SQ':
5501 case 'Q':
5502 point1 = params[1];
5503 point2 = params[2];
5504 context.quadraticCurveTo(point1.x, point1.y, point2.x, point2.y);
5505 break;
5506 case 'C':
5507 point1 = params[1];
5508 point2 = params[2];
5509 point3 = params[3];
5510 context.bezierCurveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
5511 break;
5512 case 'A':
5513 {
5514 var p = params;
5515 var p1 = p[1];
5516 var p2 = p[2];
5517 var cx = p1;
5518 var cy = p2;
5519 var rx = p[3];
5520 var ry = p[4];
5521 var theta = p[5];
5522 var dTheta = p[6];
5523 var psi = p[7];
5524 var fs = p[8];
5525
5526 var r = rx > ry ? rx : ry;
5527 var scaleX = rx > ry ? 1 : rx / ry;
5528 var scaleY = rx > ry ? ry / rx : 1;
5529
5530 context.translate(cx, cy);
5531 context.rotate(psi);
5532 context.scale(scaleX, scaleY);
5533 context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);
5534 context.scale(1 / scaleX, 1 / scaleY);
5535 context.rotate(-psi);
5536 context.translate(-cx, -cy);
5537 break;
5538 }
5539 case 'Z':
5540 context.closePath();
5541 break;
5542 }
5543 },
5544 getBBox: function getBBox(lineWidth) {
5545 var halfWidth = lineWidth / 2;
5546 var params = this.params;
5547 var yDims = void 0;
5548 var xDims = void 0;
5549 var i = void 0;
5550 var l = void 0;
5551
5552 switch (this.command) {
5553 default:
5554 case 'M':
5555 case 'Z':
5556 break;
5557 case 'TL':
5558 case 'L':
5559 this.box = {
5560 minX: Math.min(params[0].x, params[1].x) - halfWidth,
5561 maxX: Math.max(params[0].x, params[1].x) + halfWidth,
5562 minY: Math.min(params[0].y, params[1].y) - halfWidth,
5563 maxY: Math.max(params[0].y, params[1].y) + halfWidth
5564 };
5565 break;
5566 case 'SQ':
5567 case 'Q':
5568 xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x);
5569 for (i = 0, l = xDims.length; i < l; i++) {
5570 xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]);
5571 }
5572 xDims.push(params[0].x, params[2].x);
5573 yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y);
5574 for (i = 0, l = yDims.length; i < l; i++) {
5575 yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims);
5576 }
5577 yDims.push(params[0].y, params[2].y);
5578 this.box = {
5579 minX: Math.min.apply(Math, xDims) - halfWidth,
5580 maxX: Math.max.apply(Math, xDims) + halfWidth,
5581 minY: Math.min.apply(Math, yDims) - halfWidth,
5582 maxY: Math.max.apply(Math, yDims) + halfWidth
5583 };
5584 break;
5585 case 'C':
5586 xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x);
5587 for (i = 0, l = xDims.length; i < l; i++) {
5588 xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]);
5589 }
5590 yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y);
5591 for (i = 0, l = yDims.length; i < l; i++) {
5592 yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]);
5593 }
5594 xDims.push(params[0].x, params[3].x);
5595 yDims.push(params[0].y, params[3].y);
5596 this.box = {
5597 minX: Math.min.apply(Math, xDims) - halfWidth,
5598 maxX: Math.max.apply(Math, xDims) + halfWidth,
5599 minY: Math.min.apply(Math, yDims) - halfWidth,
5600 maxY: Math.max.apply(Math, yDims) + halfWidth
5601 };
5602 break;
5603 case 'A':
5604 {
5605 // todo 待优化
5606 var p = params;
5607 var cx = p[1];
5608 var cy = p[2];
5609 var rx = p[3];
5610 var ry = p[4];
5611 var theta = p[5];
5612 var dTheta = p[6];
5613 var psi = p[7];
5614 var fs = p[8];
5615 var start = theta;
5616 var end = theta + dTheta;
5617
5618 var xDim = Ellipse.xExtrema(psi, rx, ry);
5619 var minX = Infinity;
5620 var maxX = -Infinity;
5621 var xs = [start, end];
5622 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
5623 var xAngle = xDim + i;
5624 if (fs === 1) {
5625 if (start < xAngle && xAngle < end) {
5626 xs.push(xAngle);
5627 }
5628 } else {
5629 if (end < xAngle && xAngle < start) {
5630 xs.push(xAngle);
5631 }
5632 }
5633 }
5634
5635 for (i = 0, l = xs.length; i < l; i++) {
5636 var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]);
5637 if (x < minX) {
5638 minX = x;
5639 }
5640 if (x > maxX) {
5641 maxX = x;
5642 }
5643 }
5644
5645 var yDim = Ellipse.yExtrema(psi, rx, ry);
5646 var minY = Infinity;
5647 var maxY = -Infinity;
5648 var ys = [start, end];
5649 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
5650 var yAngle = yDim + i;
5651 if (fs === 1) {
5652 if (start < yAngle && yAngle < end) {
5653 ys.push(yAngle);
5654 }
5655 } else {
5656 if (end < yAngle && yAngle < start) {
5657 ys.push(yAngle);
5658 }
5659 }
5660 }
5661
5662 for (i = 0, l = ys.length; i < l; i++) {
5663 var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]);
5664 if (y < minY) {
5665 minY = y;
5666 }
5667 if (y > maxY) {
5668 maxY = y;
5669 }
5670 }
5671 this.box = {
5672 minX: minX - halfWidth,
5673 maxX: maxX + halfWidth,
5674 minY: minY - halfWidth,
5675 maxY: maxY + halfWidth
5676 };
5677 break;
5678 }
5679 }
5680 }
5681});
5682
5683module.exports = PathSegment;
5684
5685/***/ }),
5686/* 27 */
5687/***/ (function(module, exports, __webpack_require__) {
5688
5689var Util = __webpack_require__(0);
5690var Shape = __webpack_require__(1);
5691var Inside = __webpack_require__(3);
5692var Format = __webpack_require__(21);
5693var PathSegment = __webpack_require__(26);
5694
5695var Marker = function Marker(cfg) {
5696 Marker.superclass.constructor.call(this, cfg);
5697};
5698
5699Marker.Symbols = {
5700 // 圆
5701 circle: function circle(x, y, r) {
5702 return [['M', x, y], ['m', -r, 0], ['a', r, r, 0, 1, 0, r * 2, 0], ['a', r, r, 0, 1, 0, -r * 2, 0]];
5703 },
5704
5705 // 正方形
5706 square: function square(x, y, r) {
5707 return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];
5708 },
5709
5710 // 菱形
5711 diamond: function diamond(x, y, r) {
5712 return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];
5713 },
5714
5715 // 三角形
5716 triangle: function triangle(x, y, r) {
5717 var diffY = r * Math.sin(1 / 3 * Math.PI);
5718 return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['z']];
5719 },
5720
5721 // 倒三角形
5722 'triangle-down': function triangleDown(x, y, r) {
5723 var diffY = r * Math.sin(1 / 3 * Math.PI);
5724 return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];
5725 }
5726};
5727
5728Marker.ATTRS = {
5729 path: null,
5730 lineWidth: 1
5731};
5732
5733Util.extend(Marker, Shape);
5734
5735Util.augment(Marker, {
5736 type: 'marker',
5737 canFill: true,
5738 canStroke: true,
5739 getDefaultAttrs: function getDefaultAttrs() {
5740 return {
5741 x: 0,
5742 y: 0,
5743 lineWidth: 1
5744 };
5745 },
5746 calculateBox: function calculateBox() {
5747 var attrs = this.__attrs;
5748 var cx = attrs.x;
5749 var cy = attrs.y;
5750 var r = attrs.radius;
5751 var lineWidth = this.getHitLineWidth();
5752 var halfWidth = lineWidth / 2 + r;
5753 return {
5754 minX: cx - halfWidth,
5755 minY: cy - halfWidth,
5756 maxX: cx + halfWidth,
5757 maxY: cy + halfWidth
5758 };
5759 },
5760 isPointInPath: function isPointInPath(x, y) {
5761 var attrs = this.__attrs;
5762 var cx = attrs.x;
5763 var cy = attrs.y;
5764 var r = attrs.radius || attrs.r;
5765 var lineWidth = this.getHitLineWidth();
5766 return Inside.circle(cx, cy, r + lineWidth / 2, x, y);
5767 },
5768 createPath: function createPath(context) {
5769 var attrs = this.__attrs;
5770 var x = attrs.x;
5771 var y = attrs.y;
5772 var r = attrs.radius || attrs.r;
5773 var symbol = attrs.symbol || 'circle';
5774 var method = void 0;
5775 if (Util.isFunction(symbol)) {
5776 method = symbol;
5777 } else {
5778 method = Marker.Symbols[symbol];
5779 }
5780 var path = method(x, y, r);
5781 path = Format.parsePath(path);
5782 context.beginPath();
5783 var preSegment = void 0;
5784 for (var i = 0; i < path.length; i++) {
5785 var item = path[i];
5786 preSegment = new PathSegment(item, preSegment, i === path.length - 1);
5787 preSegment.draw(context);
5788 }
5789 }
5790});
5791
5792module.exports = Marker;
5793
5794/***/ }),
5795/* 28 */
5796/***/ (function(module, exports) {
5797
5798module.exports = function (module) {
5799 if (!module.webpackPolyfill) {
5800 module.deprecate = function () {};
5801 module.paths = [];
5802 // module.parent = undefined by default
5803 if (!module.children) module.children = [];
5804 Object.defineProperty(module, "loaded", {
5805 enumerable: true,
5806 get: function get() {
5807 return module.l;
5808 }
5809 });
5810 Object.defineProperty(module, "id", {
5811 enumerable: true,
5812 get: function get() {
5813 return module.i;
5814 }
5815 });
5816 module.webpackPolyfill = 1;
5817 }
5818 return module;
5819};
5820
5821/***/ }),
5822/* 29 */
5823/***/ (function(module, exports, __webpack_require__) {
5824
5825var Util = __webpack_require__(7);
5826
5827var TABLE = document.createElement('table');
5828var TABLE_TR = document.createElement('tr');
5829var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
5830var CONTAINERS = {
5831 tr: document.createElement('tbody'),
5832 tbody: TABLE,
5833 thead: TABLE,
5834 tfoot: TABLE,
5835 td: TABLE_TR,
5836 th: TABLE_TR,
5837 '*': document.createElement('div')
5838};
5839
5840module.exports = {
5841 getBoundingClientRect: function getBoundingClientRect(node, defaultValue) {
5842 if (node && node.getBoundingClientRect) {
5843 var rect = node.getBoundingClientRect();
5844 var top = document.documentElement.clientTop;
5845 var left = document.documentElement.clientLeft;
5846 return {
5847 top: rect.top - top,
5848 bottom: rect.bottom - top,
5849 left: rect.left - left,
5850 right: rect.right - left
5851 };
5852 }
5853 return defaultValue || null;
5854 },
5855
5856 /**
5857 * 获取样式
5858 * @param {Object} dom DOM节点
5859 * @param {String} name 样式名
5860 * @param {Any} defaultValue 默认值
5861 * @return {String} 属性值
5862 */
5863 getStyle: function getStyle(dom, name, defaultValue) {
5864 try {
5865 if (window.getComputedStyle) {
5866 return window.getComputedStyle(dom, null)[name];
5867 }
5868 return dom.currentStyle[name];
5869 } catch (e) {
5870 if (!Util.isNil(defaultValue)) {
5871 return defaultValue;
5872 }
5873 return null;
5874 }
5875 },
5876 modifyCSS: function modifyCSS(dom, css) {
5877 if (dom) {
5878 for (var key in css) {
5879 if (css.hasOwnProperty(key)) {
5880 dom.style[key] = css[key];
5881 }
5882 }
5883 }
5884 return dom;
5885 },
5886
5887 /**
5888 * 创建DOM 节点
5889 * @param {String} str Dom 字符串
5890 * @return {HTMLElement} DOM 节点
5891 */
5892 createDom: function createDom(str) {
5893 var name = FRAGMENT_REG.test(str) && RegExp.$1;
5894 if (!(name in CONTAINERS)) {
5895 name = '*';
5896 }
5897 var container = CONTAINERS[name];
5898 str = str.replace(/(^\s*)|(\s*$)/g, '');
5899 container.innerHTML = '' + str;
5900 var dom = container.childNodes[0];
5901 container.removeChild(dom);
5902 return dom;
5903 },
5904 getRatio: function getRatio() {
5905 return window.devicePixelRatio ? window.devicePixelRatio : 2;
5906 },
5907
5908 /**
5909 * 获取宽度
5910 * @param {HTMLElement} el dom节点
5911 * @param {Number} defaultValue 默认值
5912 * @return {Number} 宽度
5913 */
5914 getWidth: function getWidth(el, defaultValue) {
5915 var width = this.getStyle(el, 'width', defaultValue);
5916 if (width === 'auto') {
5917 width = el.offsetWidth;
5918 }
5919 return parseFloat(width);
5920 },
5921
5922 /**
5923 * 获取高度
5924 * @param {HTMLElement} el dom节点
5925 * @param {Number} defaultValue 默认值
5926 * @return {Number} 高度
5927 */
5928 getHeight: function getHeight(el, defaultValue) {
5929 var height = this.getStyle(el, 'height', defaultValue);
5930 if (height === 'auto') {
5931 height = el.offsetHeight;
5932 }
5933 return parseFloat(height);
5934 },
5935
5936 /**
5937 * 获取外层高度
5938 * @param {HTMLElement} el dom节点
5939 * @param {Number} defaultValue 默认值
5940 * @return {Number} 高度
5941 */
5942 getOuterHeight: function getOuterHeight(el, defaultValue) {
5943 var height = this.getHeight(el, defaultValue);
5944 var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
5945 var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
5946 var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
5947 var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
5948 return height + bTop + bBottom + pTop + pBottom;
5949 },
5950
5951 /**
5952 * 获取外层宽度
5953 * @param {HTMLElement} el dom节点
5954 * @param {Number} defaultValue 默认值
5955 * @return {Number} 宽度
5956 */
5957 getOuterWidth: function getOuterWidth(el, defaultValue) {
5958 var width = this.getWidth(el, defaultValue);
5959 var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
5960 var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
5961 var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
5962 var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
5963 return width + bLeft + bRight + pLeft + pRight;
5964 },
5965
5966 /**
5967 * 添加事件监听器
5968 * @param {Object} target DOM对象
5969 * @param {String} eventType 事件名
5970 * @param {Funtion} callback 回调函数
5971 * @return {Object} 返回对象
5972 */
5973 addEventListener: function addEventListener(target, eventType, callback) {
5974 if (target) {
5975 if (target.addEventListener) {
5976 target.addEventListener(eventType, callback, false);
5977 return {
5978 remove: function remove() {
5979 target.removeEventListener(eventType, callback, false);
5980 }
5981 };
5982 } else if (target.attachEvent) {
5983 target.attachEvent('on' + eventType, callback);
5984 return {
5985 remove: function remove() {
5986 target.detachEvent('on' + eventType, callback);
5987 }
5988 };
5989 }
5990 }
5991 },
5992 requestAnimationFrame: function requestAnimationFrame(fn) {
5993 var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
5994 return setTimeout(fn, 16);
5995 };
5996
5997 return method(fn);
5998 }
5999};
6000
6001/***/ }),
6002/* 30 */
6003/***/ (function(module, exports, __webpack_require__) {
6004
6005var Util = __webpack_require__(0);
6006
6007var Event = function Event(type, event, bubbles, cancelable) {
6008 this.type = type; // 事件类型
6009 this.target = null; // 目标
6010 this.currentTarget = null; // 当前目标
6011 this.bubbles = bubbles; // 冒泡
6012 this.cancelable = cancelable; // 是否能够阻止
6013 this.timeStamp = new Date().getTime(); // 时间戳
6014 this.defaultPrevented = false; // 阻止默认
6015 this.propagationStopped = false; // 阻止冒泡
6016 this.removed = false; // 是否被移除
6017 this.event = event; // 触发的原生事件
6018};
6019
6020Util.augment(Event, {
6021 preventDefault: function preventDefault() {
6022 this.defaultPrevented = this.cancelable && true;
6023 },
6024 stopPropagation: function stopPropagation() {
6025 this.propagationStopped = true;
6026 },
6027 remove: function remove() {
6028 this.remove = true;
6029 },
6030 clone: function clone() {
6031 return Util.clone(this);
6032 },
6033 toString: function toString() {
6034 return '[Event (type=' + this.type + ')]';
6035 }
6036});
6037
6038module.exports = Event;
6039
6040/***/ }),
6041/* 31 */
6042/***/ (function(module, exports, __webpack_require__) {
6043
6044var Util = __webpack_require__(0);
6045var Element = __webpack_require__(13);
6046var Shape = __webpack_require__(104);
6047
6048var SHAPE_MAP = {}; // 缓存图形类型
6049var INDEX = '_INDEX';
6050
6051function getComparer(compare) {
6052 return function (left, right) {
6053 var result = compare(left, right);
6054 return result === 0 ? left[INDEX] - right[INDEX] : result;
6055 };
6056}
6057
6058var Group = function Group(cfg) {
6059 Group.superclass.constructor.call(this, cfg);
6060 this.set('children', []);
6061
6062 this._beforeRenderUI();
6063 this._renderUI();
6064 this._bindUI();
6065};
6066
6067function initClassCfgs(c) {
6068 if (c.__cfg || c === Group) {
6069 return;
6070 }
6071 var superCon = c.superclass.constructor;
6072 if (superCon && !superCon.__cfg) {
6073 initClassCfgs(superCon);
6074 }
6075 c.__cfg = {};
6076
6077 Util.merge(c.__cfg, superCon.__cfg);
6078 Util.merge(c.__cfg, c.CFG);
6079}
6080
6081Util.extend(Group, Element);
6082
6083Util.augment(Group, {
6084 isGroup: true,
6085 canFill: true,
6086 canStroke: true,
6087 init: function init(id) {
6088 Group.superclass.init.call(this);
6089 var shape = document.createElementNS('http://www.w3.org/2000/svg', 'g');
6090 id = id || Util.uniqueId('g_');
6091 shape.setAttribute('id', id);
6092 this.setSilent('el', shape);
6093 this.setSilent('id', id);
6094 },
6095 getDefaultCfg: function getDefaultCfg() {
6096 initClassCfgs(this.constructor);
6097 return Util.merge({}, this.constructor.__cfg);
6098 },
6099 _beforeRenderUI: function _beforeRenderUI() {},
6100 _renderUI: function _renderUI() {},
6101 _bindUI: function _bindUI() {},
6102 addShape: function addShape(type, cfg) {
6103 var canvas = this.get('canvas');
6104 cfg = cfg || {};
6105 var shapeType = SHAPE_MAP[type];
6106 if (!shapeType) {
6107 shapeType = Util.upperFirst(type);
6108 SHAPE_MAP[type] = shapeType;
6109 }
6110 if (cfg.attrs) {
6111 var attrs = cfg.attrs;
6112 if (type === 'text') {
6113 // 临时解决
6114 var topFontFamily = canvas.get('fontFamily');
6115 if (topFontFamily) {
6116 attrs.fontFamily = attrs.fontFamily || topFontFamily;
6117 }
6118 }
6119 }
6120 cfg.canvas = canvas;
6121 cfg.defs = this.get('defs');
6122 cfg.type = type;
6123 var shape = Shape[shapeType];
6124 if (!shape) {
6125 throw new TypeError('the shape ' + shapeType + ' is not supported by svg version, use canvas instead');
6126 }
6127 var rst = new shape(cfg);
6128 this.add(rst);
6129 return rst;
6130 },
6131
6132 /** 添加图组
6133 * @param {Function|Object|undefined} param 图组类
6134 * @param {Object} cfg 配置项
6135 * @return {Object} rst 图组
6136 */
6137 addGroup: function addGroup(param, cfg) {
6138 var canvas = this.get('canvas');
6139 var rst = void 0;
6140 cfg = Util.merge({}, cfg);
6141 if (Util.isFunction(param)) {
6142 if (cfg) {
6143 cfg.canvas = canvas;
6144 cfg.parent = this;
6145 rst = new param(cfg);
6146 } else {
6147 rst = new param({
6148 canvas: canvas,
6149 parent: this
6150 });
6151 }
6152 this.add(rst);
6153 } else if (Util.isObject(param)) {
6154 param.canvas = canvas;
6155 rst = new Group(param);
6156 this.add(rst);
6157 } else if (param === undefined) {
6158 rst = new Group();
6159 this.add(rst);
6160 } else {
6161 return false;
6162 }
6163 return rst;
6164 },
6165
6166 /** 绘制背景
6167 * @param {Array} padding 内边距
6168 * @param {Attrs} attrs 图形属性
6169 * @param {Shape} backShape 背景图形
6170 * @return {Object} 背景层对象
6171 */
6172 renderBack: function renderBack(padding, attrs) {
6173 var backShape = this.get('backShape');
6174 var innerBox = this.getBBox();
6175 // const parent = this.get('parent'); // getParent
6176 Util.merge(attrs, {
6177 x: innerBox.minX - padding[3],
6178 y: innerBox.minY - padding[0],
6179 width: innerBox.width + padding[1] + padding[3],
6180 height: innerBox.height + padding[0] + padding[2]
6181 });
6182 if (backShape) {
6183 backShape.attr(attrs);
6184 } else {
6185 backShape = this.addShape('rect', {
6186 zIndex: -1,
6187 attrs: attrs
6188 });
6189 }
6190 this.set('backShape', backShape);
6191 this.sort();
6192 return backShape;
6193 },
6194 removeChild: function removeChild(item, destroy) {
6195 if (arguments.length >= 2) {
6196 if (this.contain(item)) {
6197 item.remove(destroy);
6198 }
6199 } else {
6200 if (arguments.length === 1) {
6201 if (Util.isBoolean(item)) {
6202 destroy = item;
6203 } else {
6204 if (this.contain(item)) {
6205 item.remove(true);
6206 }
6207 return this;
6208 }
6209 }
6210 if (arguments.length === 0) {
6211 destroy = true;
6212 }
6213
6214 Group.superclass.remove.call(this, destroy);
6215 }
6216 return this;
6217 },
6218
6219 /**
6220 * 向组中添加shape或者group
6221 * @param {Object} items 图形或者分组
6222 * @return {Object} group 本尊
6223 */
6224 add: function add(items) {
6225 var self = this;
6226 var children = self.get('children');
6227 var el = self.get('el');
6228 if (Util.isArray(items)) {
6229 Util.each(items, function (item) {
6230 var parent = item.get('parent');
6231 if (parent) {
6232 parent.removeChild(item, false);
6233 }
6234 if (item.get('dependencies')) {
6235 self._addDependency(item);
6236 }
6237 self._setEvn(item);
6238 el.appendChild(item.get('el'));
6239 });
6240 children.push.apply(children, items);
6241 } else {
6242 var item = items;
6243 var parent = item.get('parent');
6244 if (parent) {
6245 parent.removeChild(item, false);
6246 }
6247 self._setEvn(item);
6248 if (item.get('dependencies')) {
6249 self._addDependency(item);
6250 }
6251 el.appendChild(item.get('el'));
6252 children.push(item);
6253 }
6254 return self;
6255 },
6256 contain: function contain(item) {
6257 var children = this.get('children');
6258 return children.indexOf(item) > -1;
6259 },
6260 getChildByIndex: function getChildByIndex(index) {
6261 var children = this.get('children');
6262 return children[index];
6263 },
6264 getFirst: function getFirst() {
6265 return this.getChildByIndex(0);
6266 },
6267 getLast: function getLast() {
6268 var lastIndex = this.get('children').length - 1;
6269 return this.getChildByIndex(lastIndex);
6270 },
6271 _addDependency: function _addDependency(item) {
6272 var dependencies = item.get('dependencies');
6273 item.attr(dependencies);
6274 item.__cfg.dependencies = {};
6275 },
6276 _setEvn: function _setEvn(item) {
6277 var self = this;
6278 item.__cfg.parent = self;
6279 item.__cfg.parent = self;
6280 item.__cfg.canvas = self.__cfg.canvas;
6281 item.__cfg.defs = self.__cfg.defs;
6282 var clip = item.__attrs.clip;
6283 if (clip) {
6284 clip.setSilent('parent', self);
6285 clip.setSilent('context', self.get('context'));
6286 }
6287 var children = item.__cfg.children;
6288 if (children) {
6289 Util.each(children, function (child) {
6290 item._setEvn(child);
6291 });
6292 }
6293 },
6294 getCount: function getCount() {
6295 return this.get('children').length;
6296 },
6297 sort: function sort() {
6298 var children = this.get('children');
6299 // 稳定排序
6300 Util.each(children, function (child, index) {
6301 child[INDEX] = index;
6302 return child;
6303 });
6304
6305 children.sort(getComparer(function (obj1, obj2) {
6306 return obj1.get('zIndex') - obj2.get('zIndex');
6307 }));
6308
6309 return this;
6310 },
6311 findById: function findById(id) {
6312 return this.find(function (item) {
6313 return item.get('id') === id;
6314 });
6315 },
6316
6317 /**
6318 * 根据查找函数查找分组或者图形
6319 * @param {Function} fn 匹配函数
6320 * @return {Canvas.Base} 分组或者图形
6321 */
6322 find: function find(fn) {
6323 if (Util.isString(fn)) {
6324 return this.findById(fn);
6325 }
6326 var children = this.get('children');
6327 var rst = null;
6328
6329 Util.each(children, function (item) {
6330 if (fn(item)) {
6331 rst = item;
6332 } else if (item.find) {
6333 rst = item.find(fn);
6334 }
6335 if (rst) {
6336 return false;
6337 }
6338 });
6339 return rst;
6340 },
6341
6342 /**
6343 * @param {Function} fn filter mathod
6344 * @return {Array} all the matching shapes and groups
6345 */
6346 findAll: function findAll(fn) {
6347 var children = this.get('children');
6348 var rst = [];
6349 var childRst = [];
6350 Util.each(children, function (item) {
6351 if (fn(item)) {
6352 rst.push(item);
6353 }
6354 if (item.findAllBy) {
6355 childRst = item.findAllBy(fn);
6356 rst = rst.concat(childRst);
6357 }
6358 });
6359 return rst;
6360 },
6361
6362 /**
6363 * @Deprecated
6364 * @param {Function} fn filter method
6365 * @return {Object} found shape or group
6366 */
6367 findBy: function findBy(fn) {
6368 var children = this.get('children');
6369 var rst = null;
6370
6371 Util.each(children, function (item) {
6372 if (fn(item)) {
6373 rst = item;
6374 } else if (item.findBy) {
6375 rst = item.findBy(fn);
6376 }
6377 if (rst) {
6378 return false;
6379 }
6380 });
6381 return rst;
6382 },
6383
6384 /**
6385 * @Deprecated
6386 * @param {Function} fn filter mathod
6387 * @return {Array} all the matching shapes and groups
6388 */
6389 findAllBy: function findAllBy(fn) {
6390 var children = this.get('children');
6391 var rst = [];
6392 var childRst = [];
6393 Util.each(children, function (item) {
6394 if (fn(item)) {
6395 rst.push(item);
6396 }
6397 if (item.findAllBy) {
6398 childRst = item.findAllBy(fn);
6399 rst = rst.concat(childRst);
6400 }
6401 });
6402 return rst;
6403 },
6404
6405 // svg不进行拾取,仅保留接口
6406 getShape: function getShape() {
6407 return null;
6408 },
6409
6410 /**
6411 * 根据点击事件的element获取对应的图形对象
6412 * @param {Object} el 点击的dom元素
6413 * @return {Object} 对应图形对象
6414 */
6415 findShape: function findShape(el) {
6416 if (this.__cfg.visible && this.__cfg.capture && this.get('el') === el) {
6417 return this;
6418 }
6419 var children = this.__cfg.children;
6420 var shape = null;
6421 for (var i = children.length - 1; i >= 0; i--) {
6422 var child = children[i];
6423 if (child.isGroup) {
6424 shape = child.findShape(el);
6425 shape = child.findShape(el);
6426 } else if (child.get('visible') && child.get('el') === el) {
6427 shape = child;
6428 }
6429 if (shape) {
6430 break;
6431 }
6432 }
6433 return shape;
6434 },
6435 clearTotalMatrix: function clearTotalMatrix() {
6436 var m = this.get('totalMatrix');
6437 if (m) {
6438 this.setSilent('totalMatrix', null);
6439 var children = this.__cfg.children;
6440 for (var i = 0; i < children.length; i++) {
6441 var child = children[i];
6442 child.clearTotalMatrix();
6443 }
6444 }
6445 },
6446 clear: function clear() {
6447 var children = this.get('children');
6448
6449 while (children.length !== 0) {
6450 children[children.length - 1].remove();
6451 }
6452 return this;
6453 },
6454 destroy: function destroy() {
6455 if (this.get('destroyed')) {
6456 return;
6457 }
6458 this.clear();
6459 Group.superclass.destroy.call(this);
6460 }
6461});
6462
6463module.exports = Group;
6464
6465/***/ }),
6466/* 32 */
6467/***/ (function(module, exports, __webpack_require__) {
6468
6469var MatrixUtil = __webpack_require__(2);
6470var PathUtil = __webpack_require__(15);
6471var Util = __webpack_require__(0);
6472var d3Ease = __webpack_require__(77);
6473var d3Timer = __webpack_require__(88);
6474
6475var _require = __webpack_require__(91),
6476 interpolate = _require.interpolate,
6477 interpolateArray = _require.interpolateArray; // 目前整体动画只需要数值和数组的差值计算
6478
6479
6480var ReservedProps = {
6481 delay: 'delay'
6482};
6483module.exports = {
6484 stopAnimate: function stopAnimate() {
6485 var self = this;
6486 var canvas = self.get('canvas');
6487 if (self.get('destroyed')) {
6488 return;
6489 }
6490 if (self.get('animating')) {
6491 var clip = self.attr('clip');
6492 // 如果 clip 在执行动画
6493 if (clip && clip.get('animating')) {
6494 clip.stopAnimate();
6495 }
6496 var timer = self.get('animateTimer');
6497 if (timer) {
6498 timer.stop();
6499 self.setSilent('animateTimer', null);
6500 }
6501 var animateCfg = self.get('animateCfg');
6502 if (animateCfg) {
6503 self.attr(animateCfg.toAttrs);
6504 if (animateCfg.toM) {
6505 self.setMatrix(animateCfg.toM);
6506 }
6507 if (animateCfg.callback) {
6508 animateCfg.callback();
6509 }
6510 self.setSilent('animateCfg', null);
6511 }
6512 self.setSilent('animating', false); // 动画停止
6513 canvas.draw();
6514 }
6515 },
6516
6517 /**
6518 * 执行动画
6519 * @param {Object} toProps 动画最终状态
6520 * @param {Number} duration 动画执行时间
6521 * @param {String} easing 动画缓动效果
6522 * @param {Function} callback 动画执行后的回调
6523 * @param {Number} delay 动画延迟时间
6524 */
6525 animate: function animate(toProps, duration, easing, callback) {
6526 var delay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
6527
6528 var self = this;
6529 var canvas = self.get('canvas');
6530 var formatProps = getFormatProps(toProps);
6531 var toAttrs = formatProps.attrs;
6532 var toM = formatProps.M;
6533 var fromAttrs = getfromAttrs(toAttrs);
6534 var fromM = Util.clone(self.getMatrix());
6535 var repeat = toProps.repeat;
6536 var timer = self.get('animateTimer');
6537 timer && timer.stop();
6538 // 可能不设置 easing
6539 if (Util.isNumber(callback)) {
6540 delay = callback;
6541 callback = null;
6542 }
6543 if (Util.isFunction(easing)) {
6544 callback = easing;
6545 easing = 'easeLinear';
6546 } else {
6547 easing = easing ? easing : 'easeLinear';
6548 }
6549
6550 self.setSilent('animating', true); // 处于动画状态
6551 self.setSilent('animateCfg', {
6552 toAttrs: toAttrs,
6553 toM: toM,
6554 callback: callback
6555 });
6556
6557 // 执行动画
6558 timer = d3Timer.timer(function (elapsed) {
6559 if (repeat) {
6560 excuteRepeat(elapsed);
6561 } else {
6562 excuteOnce(elapsed);
6563 }
6564 }, delay);
6565
6566 self.setSilent('animateTimer', timer);
6567
6568 function excuteRepeat(elapsed) {
6569 var ratio = elapsed % duration / duration;
6570 ratio = d3Ease[easing](ratio);
6571 update(ratio);
6572 }
6573
6574 function excuteOnce(elapsed) {
6575 var ratio = elapsed / duration;
6576 if (ratio < 1) {
6577 ratio = d3Ease[easing](ratio);
6578 update(ratio);
6579 } else {
6580 update(1); // 保证最后一帧的绘制
6581 callback && callback();
6582 self.setSilent('animating', false); // 动画停止
6583 self.setSilent('animateCfg', null);
6584 self.setSilent('animateTimer', null);
6585 timer.stop();
6586 }
6587 }
6588
6589 function update(ratio) {
6590 var cProps = {}; // 此刻属性
6591 if (self.get('destroyed')) {
6592 return;
6593 }
6594 var interf = void 0; // 差值函数
6595
6596 for (var k in toAttrs) {
6597 if (!Util.isEqual(fromAttrs[k], toAttrs[k])) {
6598 if (k === 'path') {
6599 var toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态
6600 var fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态
6601 cProps[k] = [];
6602 for (var i = 0; i < toPath.length; i++) {
6603 var toPathPoint = toPath[i];
6604 var fromPathPoint = fromPath[i];
6605 var cPathPoint = [];
6606 for (var j = 0; j < toPathPoint.length; j++) {
6607 if (Util.isNumber(toPathPoint[j]) && fromPathPoint) {
6608 interf = interpolate(fromPathPoint[j], toPathPoint[j]);
6609 cPathPoint.push(interf(ratio));
6610 } else {
6611 cPathPoint.push(toPathPoint[j]);
6612 }
6613 }
6614 cProps[k].push(cPathPoint);
6615 }
6616 } else {
6617 interf = interpolate(fromAttrs[k], toAttrs[k]);
6618 cProps[k] = interf(ratio);
6619 }
6620 }
6621 }
6622 if (toM) {
6623 var mf = interpolateArray(fromM, toM);
6624 var cM = mf(ratio);
6625 self.setMatrix(cM);
6626 }
6627 self.attr(cProps);
6628 canvas.draw();
6629 }
6630
6631 function getFormatProps(props) {
6632 var rst = {
6633 M: null,
6634 attrs: {}
6635 };
6636 for (var k in props) {
6637 if (k === 'transform') {
6638 rst.M = MatrixUtil.transform(self.getMatrix(), props[k]);
6639 } else if (k === 'matrix') {
6640 rst.M = props[k];
6641 } else if (!ReservedProps[k]) {
6642 rst.attrs[k] = props[k];
6643 }
6644 }
6645 return rst;
6646 }
6647
6648 function getfromAttrs(toAttrs) {
6649 var rst = {};
6650 for (var k in toAttrs) {
6651 rst[k] = self.attr(k);
6652 }
6653 return rst;
6654 }
6655 }
6656};
6657
6658/***/ }),
6659/* 33 */
6660/***/ (function(module, __webpack_exports__, __webpack_require__) {
6661
6662"use strict";
6663/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return deg2rad; });
6664/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rad2deg; });
6665var deg2rad = Math.PI / 180;
6666var rad2deg = 180 / Math.PI;
6667
6668/***/ }),
6669/* 34 */
6670/***/ (function(module, __webpack_exports__, __webpack_require__) {
6671
6672"use strict";
6673/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rgbBasis; });
6674/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return rgbBasisClosed; });
6675/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
6676/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(20);
6677/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(35);
6678/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(8);
6679
6680
6681
6682
6683
6684/* harmony default export */ __webpack_exports__["a"] = ((function rgbGamma(y) {
6685 var color = Object(__WEBPACK_IMPORTED_MODULE_3__color__["b" /* gamma */])(y);
6686
6687 function rgb(start, end) {
6688 var r = color((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(start)).r, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(end)).r),
6689 g = color(start.g, end.g),
6690 b = color(start.b, end.b),
6691 opacity = Object(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity);
6692 return function (t) {
6693 start.r = r(t);
6694 start.g = g(t);
6695 start.b = b(t);
6696 start.opacity = opacity(t);
6697 return start + "";
6698 };
6699 }
6700
6701 rgb.gamma = rgbGamma;
6702
6703 return rgb;
6704})(1));
6705
6706function rgbSpline(spline) {
6707 return function (colors) {
6708 var n = colors.length,
6709 r = new Array(n),
6710 g = new Array(n),
6711 b = new Array(n),
6712 i,
6713 color;
6714 for (i = 0; i < n; ++i) {
6715 color = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(colors[i]);
6716 r[i] = color.r || 0;
6717 g[i] = color.g || 0;
6718 b[i] = color.b || 0;
6719 }
6720 r = spline(r);
6721 g = spline(g);
6722 b = spline(b);
6723 color.opacity = 1;
6724 return function (t) {
6725 color.r = r(t);
6726 color.g = g(t);
6727 color.b = b(t);
6728 return color + "";
6729 };
6730 };
6731}
6732
6733var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["b" /* default */]);
6734var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]);
6735
6736/***/ }),
6737/* 35 */
6738/***/ (function(module, __webpack_exports__, __webpack_require__) {
6739
6740"use strict";
6741/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(20);
6742
6743
6744/* harmony default export */ __webpack_exports__["a"] = (function (values) {
6745 var n = values.length;
6746 return function (t) {
6747 var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
6748 v0 = values[(i + n - 1) % n],
6749 v1 = values[i % n],
6750 v2 = values[(i + 1) % n],
6751 v3 = values[(i + 2) % n];
6752 return Object(__WEBPACK_IMPORTED_MODULE_0__basis__["a" /* basis */])((t - i / n) * n, v0, v1, v2, v3);
6753 };
6754});
6755
6756/***/ }),
6757/* 36 */
6758/***/ (function(module, __webpack_exports__, __webpack_require__) {
6759
6760"use strict";
6761/* harmony default export */ __webpack_exports__["a"] = (function (x) {
6762 return function () {
6763 return x;
6764 };
6765});
6766
6767/***/ }),
6768/* 37 */
6769/***/ (function(module, __webpack_exports__, __webpack_require__) {
6770
6771"use strict";
6772/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(17);
6773
6774
6775/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6776 var nb = b ? b.length : 0,
6777 na = a ? Math.min(nb, a.length) : 0,
6778 x = new Array(na),
6779 c = new Array(nb),
6780 i;
6781
6782 for (i = 0; i < na; ++i) {
6783 x[i] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[i], b[i]);
6784 }for (; i < nb; ++i) {
6785 c[i] = b[i];
6786 }return function (t) {
6787 for (i = 0; i < na; ++i) {
6788 c[i] = x[i](t);
6789 }return c;
6790 };
6791});
6792
6793/***/ }),
6794/* 38 */
6795/***/ (function(module, __webpack_exports__, __webpack_require__) {
6796
6797"use strict";
6798/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6799 var d = new Date();
6800 return a = +a, b -= a, function (t) {
6801 return d.setTime(a + b * t), d;
6802 };
6803});
6804
6805/***/ }),
6806/* 39 */
6807/***/ (function(module, __webpack_exports__, __webpack_require__) {
6808
6809"use strict";
6810/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(17);
6811var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
6812
6813
6814
6815/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6816 var i = {},
6817 c = {},
6818 k;
6819
6820 if (a === null || (typeof a === "undefined" ? "undefined" : _typeof(a)) !== "object") a = {};
6821 if (b === null || (typeof b === "undefined" ? "undefined" : _typeof(b)) !== "object") b = {};
6822
6823 for (k in b) {
6824 if (k in a) {
6825 i[k] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]);
6826 } else {
6827 c[k] = b[k];
6828 }
6829 }
6830
6831 return function (t) {
6832 for (k in i) {
6833 c[k] = i[k](t);
6834 }return c;
6835 };
6836});
6837
6838/***/ }),
6839/* 40 */
6840/***/ (function(module, __webpack_exports__, __webpack_require__) {
6841
6842"use strict";
6843/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(11);
6844
6845
6846var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
6847 reB = new RegExp(reA.source, "g");
6848
6849function zero(b) {
6850 return function () {
6851 return b;
6852 };
6853}
6854
6855function one(b) {
6856 return function (t) {
6857 return b(t) + "";
6858 };
6859}
6860
6861/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6862 var bi = reA.lastIndex = reB.lastIndex = 0,
6863 // scan index for next number in b
6864 am,
6865 // current match in a
6866 bm,
6867 // current match in b
6868 bs,
6869 // string preceding current number in b, if any
6870 i = -1,
6871 // index in s
6872 s = [],
6873 // string constants and placeholders
6874 q = []; // number interpolators
6875
6876 // Coerce inputs to strings.
6877 a = a + "", b = b + "";
6878
6879 // Interpolate pairs of numbers in a & b.
6880 while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
6881 if ((bs = bm.index) > bi) {
6882 // a string precedes the next number in b
6883 bs = b.slice(bi, bs);
6884 if (s[i]) s[i] += bs; // coalesce with previous string
6885 else s[++i] = bs;
6886 }
6887 if ((am = am[0]) === (bm = bm[0])) {
6888 // numbers in a & b match
6889 if (s[i]) s[i] += bm; // coalesce with previous string
6890 else s[++i] = bm;
6891 } else {
6892 // interpolate non-matching numbers
6893 s[++i] = null;
6894 q.push({ i: i, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm) });
6895 }
6896 bi = reB.lastIndex;
6897 }
6898
6899 // Add remains of b.
6900 if (bi < b.length) {
6901 bs = b.slice(bi);
6902 if (s[i]) s[i] += bs; // coalesce with previous string
6903 else s[++i] = bs;
6904 }
6905
6906 // Special optimization for only a single match.
6907 // Otherwise, interpolate each of the numbers and rejoin the string.
6908 return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) {
6909 for (var i = 0, o; i < b; ++i) {
6910 s[(o = q[i]).i] = o.x(t);
6911 }return s.join("");
6912 });
6913});
6914
6915/***/ }),
6916/* 41 */
6917/***/ (function(module, exports, __webpack_require__) {
6918
6919var __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
6920
6921/*!
6922 * EventEmitter v5.1.0 - git.io/ee
6923 * Unlicense - http://unlicense.org/
6924 * Oliver Caldwell - http://oli.me.uk/
6925 * @preserve
6926 */
6927
6928;(function (exports) {
6929 'use strict';
6930
6931 /**
6932 * Class for managing events.
6933 * Can be extended to provide event functionality in other classes.
6934 *
6935 * @class EventEmitter Manages event registering and emitting.
6936 */
6937
6938 function EventEmitter() {}
6939
6940 // Shortcuts to improve speed and size
6941 var proto = EventEmitter.prototype;
6942 var originalGlobalValue = exports.EventEmitter;
6943
6944 /**
6945 * Finds the index of the listener for the event in its storage array.
6946 *
6947 * @param {Function[]} listeners Array of listeners to search through.
6948 * @param {Function} listener Method to look for.
6949 * @return {Number} Index of the specified listener, -1 if not found
6950 * @api private
6951 */
6952 function indexOfListener(listeners, listener) {
6953 var i = listeners.length;
6954 while (i--) {
6955 if (listeners[i].listener === listener) {
6956 return i;
6957 }
6958 }
6959
6960 return -1;
6961 }
6962
6963 /**
6964 * Alias a method while keeping the context correct, to allow for overwriting of target method.
6965 *
6966 * @param {String} name The name of the target method.
6967 * @return {Function} The aliased method
6968 * @api private
6969 */
6970 function alias(name) {
6971 return function aliasClosure() {
6972 return this[name].apply(this, arguments);
6973 };
6974 }
6975
6976 /**
6977 * Returns the listener array for the specified event.
6978 * Will initialise the event object and listener arrays if required.
6979 * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
6980 * Each property in the object response is an array of listener functions.
6981 *
6982 * @param {String|RegExp} evt Name of the event to return the listeners from.
6983 * @return {Function[]|Object} All listener functions for the event.
6984 */
6985 proto.getListeners = function getListeners(evt) {
6986 var events = this._getEvents();
6987 var response;
6988 var key;
6989
6990 // Return a concatenated array of all matching events if
6991 // the selector is a regular expression.
6992 if (evt instanceof RegExp) {
6993 response = {};
6994 for (key in events) {
6995 if (events.hasOwnProperty(key) && evt.test(key)) {
6996 response[key] = events[key];
6997 }
6998 }
6999 } else {
7000 response = events[evt] || (events[evt] = []);
7001 }
7002
7003 return response;
7004 };
7005
7006 /**
7007 * Takes a list of listener objects and flattens it into a list of listener functions.
7008 *
7009 * @param {Object[]} listeners Raw listener objects.
7010 * @return {Function[]} Just the listener functions.
7011 */
7012 proto.flattenListeners = function flattenListeners(listeners) {
7013 var flatListeners = [];
7014 var i;
7015
7016 for (i = 0; i < listeners.length; i += 1) {
7017 flatListeners.push(listeners[i].listener);
7018 }
7019
7020 return flatListeners;
7021 };
7022
7023 /**
7024 * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
7025 *
7026 * @param {String|RegExp} evt Name of the event to return the listeners from.
7027 * @return {Object} All listener functions for an event in an object.
7028 */
7029 proto.getListenersAsObject = function getListenersAsObject(evt) {
7030 var listeners = this.getListeners(evt);
7031 var response;
7032
7033 if (listeners instanceof Array) {
7034 response = {};
7035 response[evt] = listeners;
7036 }
7037
7038 return response || listeners;
7039 };
7040
7041 function isValidListener(listener) {
7042 if (typeof listener === 'function' || listener instanceof RegExp) {
7043 return true;
7044 } else if (listener && (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object') {
7045 return isValidListener(listener.listener);
7046 } else {
7047 return false;
7048 }
7049 }
7050
7051 /**
7052 * Adds a listener function to the specified event.
7053 * The listener will not be added if it is a duplicate.
7054 * If the listener returns true then it will be removed after it is called.
7055 * If you pass a regular expression as the event name then the listener will be added to all events that match it.
7056 *
7057 * @param {String|RegExp} evt Name of the event to attach the listener to.
7058 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
7059 * @return {Object} Current instance of EventEmitter for chaining.
7060 */
7061 proto.addListener = function addListener(evt, listener) {
7062 if (!isValidListener(listener)) {
7063 throw new TypeError('listener must be a function');
7064 }
7065
7066 var listeners = this.getListenersAsObject(evt);
7067 var listenerIsWrapped = (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object';
7068 var key;
7069
7070 for (key in listeners) {
7071 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
7072 listeners[key].push(listenerIsWrapped ? listener : {
7073 listener: listener,
7074 once: false
7075 });
7076 }
7077 }
7078
7079 return this;
7080 };
7081
7082 /**
7083 * Alias of addListener
7084 */
7085 proto.on = alias('addListener');
7086
7087 /**
7088 * Semi-alias of addListener. It will add a listener that will be
7089 * automatically removed after its first execution.
7090 *
7091 * @param {String|RegExp} evt Name of the event to attach the listener to.
7092 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
7093 * @return {Object} Current instance of EventEmitter for chaining.
7094 */
7095 proto.addOnceListener = function addOnceListener(evt, listener) {
7096 return this.addListener(evt, {
7097 listener: listener,
7098 once: true
7099 });
7100 };
7101
7102 /**
7103 * Alias of addOnceListener.
7104 */
7105 proto.once = alias('addOnceListener');
7106
7107 /**
7108 * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
7109 * You need to tell it what event names should be matched by a regex.
7110 *
7111 * @param {String} evt Name of the event to create.
7112 * @return {Object} Current instance of EventEmitter for chaining.
7113 */
7114 proto.defineEvent = function defineEvent(evt) {
7115 this.getListeners(evt);
7116 return this;
7117 };
7118
7119 /**
7120 * Uses defineEvent to define multiple events.
7121 *
7122 * @param {String[]} evts An array of event names to define.
7123 * @return {Object} Current instance of EventEmitter for chaining.
7124 */
7125 proto.defineEvents = function defineEvents(evts) {
7126 for (var i = 0; i < evts.length; i += 1) {
7127 this.defineEvent(evts[i]);
7128 }
7129 return this;
7130 };
7131
7132 /**
7133 * Removes a listener function from the specified event.
7134 * When passed a regular expression as the event name, it will remove the listener from all events that match it.
7135 *
7136 * @param {String|RegExp} evt Name of the event to remove the listener from.
7137 * @param {Function} listener Method to remove from the event.
7138 * @return {Object} Current instance of EventEmitter for chaining.
7139 */
7140 proto.removeListener = function removeListener(evt, listener) {
7141 var listeners = this.getListenersAsObject(evt);
7142 var index;
7143 var key;
7144
7145 for (key in listeners) {
7146 if (listeners.hasOwnProperty(key)) {
7147 index = indexOfListener(listeners[key], listener);
7148
7149 if (index !== -1) {
7150 listeners[key].splice(index, 1);
7151 }
7152 }
7153 }
7154
7155 return this;
7156 };
7157
7158 /**
7159 * Alias of removeListener
7160 */
7161 proto.off = alias('removeListener');
7162
7163 /**
7164 * Adds listeners in bulk using the manipulateListeners method.
7165 * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
7166 * You can also pass it a regular expression to add the array of listeners to all events that match it.
7167 * Yeah, this function does quite a bit. That's probably a bad thing.
7168 *
7169 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
7170 * @param {Function[]} [listeners] An optional array of listener functions to add.
7171 * @return {Object} Current instance of EventEmitter for chaining.
7172 */
7173 proto.addListeners = function addListeners(evt, listeners) {
7174 // Pass through to manipulateListeners
7175 return this.manipulateListeners(false, evt, listeners);
7176 };
7177
7178 /**
7179 * Removes listeners in bulk using the manipulateListeners method.
7180 * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
7181 * You can also pass it an event name and an array of listeners to be removed.
7182 * You can also pass it a regular expression to remove the listeners from all events that match it.
7183 *
7184 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
7185 * @param {Function[]} [listeners] An optional array of listener functions to remove.
7186 * @return {Object} Current instance of EventEmitter for chaining.
7187 */
7188 proto.removeListeners = function removeListeners(evt, listeners) {
7189 // Pass through to manipulateListeners
7190 return this.manipulateListeners(true, evt, listeners);
7191 };
7192
7193 /**
7194 * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
7195 * The first argument will determine if the listeners are removed (true) or added (false).
7196 * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
7197 * You can also pass it an event name and an array of listeners to be added/removed.
7198 * You can also pass it a regular expression to manipulate the listeners of all events that match it.
7199 *
7200 * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
7201 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
7202 * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
7203 * @return {Object} Current instance of EventEmitter for chaining.
7204 */
7205 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
7206 var i;
7207 var value;
7208 var single = remove ? this.removeListener : this.addListener;
7209 var multiple = remove ? this.removeListeners : this.addListeners;
7210
7211 // If evt is an object then pass each of its properties to this method
7212 if ((typeof evt === 'undefined' ? 'undefined' : _typeof(evt)) === 'object' && !(evt instanceof RegExp)) {
7213 for (i in evt) {
7214 if (evt.hasOwnProperty(i) && (value = evt[i])) {
7215 // Pass the single listener straight through to the singular method
7216 if (typeof value === 'function') {
7217 single.call(this, i, value);
7218 } else {
7219 // Otherwise pass back to the multiple function
7220 multiple.call(this, i, value);
7221 }
7222 }
7223 }
7224 } else {
7225 // So evt must be a string
7226 // And listeners must be an array of listeners
7227 // Loop over it and pass each one to the multiple method
7228 i = listeners.length;
7229 while (i--) {
7230 single.call(this, evt, listeners[i]);
7231 }
7232 }
7233
7234 return this;
7235 };
7236
7237 /**
7238 * Removes all listeners from a specified event.
7239 * If you do not specify an event then all listeners will be removed.
7240 * That means every event will be emptied.
7241 * You can also pass a regex to remove all events that match it.
7242 *
7243 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
7244 * @return {Object} Current instance of EventEmitter for chaining.
7245 */
7246 proto.removeEvent = function removeEvent(evt) {
7247 var type = typeof evt === 'undefined' ? 'undefined' : _typeof(evt);
7248 var events = this._getEvents();
7249 var key;
7250
7251 // Remove different things depending on the state of evt
7252 if (type === 'string') {
7253 // Remove all listeners for the specified event
7254 delete events[evt];
7255 } else if (evt instanceof RegExp) {
7256 // Remove all events matching the regex.
7257 for (key in events) {
7258 if (events.hasOwnProperty(key) && evt.test(key)) {
7259 delete events[key];
7260 }
7261 }
7262 } else {
7263 // Remove all listeners in all events
7264 delete this._events;
7265 }
7266
7267 return this;
7268 };
7269
7270 /**
7271 * Alias of removeEvent.
7272 *
7273 * Added to mirror the node API.
7274 */
7275 proto.removeAllListeners = alias('removeEvent');
7276
7277 /**
7278 * Emits an event of your choice.
7279 * When emitted, every listener attached to that event will be executed.
7280 * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
7281 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
7282 * So they will not arrive within the array on the other side, they will be separate.
7283 * You can also pass a regular expression to emit to all events that match it.
7284 *
7285 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
7286 * @param {Array} [args] Optional array of arguments to be passed to each listener.
7287 * @return {Object} Current instance of EventEmitter for chaining.
7288 */
7289 proto.emitEvent = function emitEvent(evt, args) {
7290 var listenersMap = this.getListenersAsObject(evt);
7291 var listeners;
7292 var listener;
7293 var i;
7294 var key;
7295 var response;
7296
7297 for (key in listenersMap) {
7298 if (listenersMap.hasOwnProperty(key)) {
7299 listeners = listenersMap[key].slice(0);
7300
7301 for (i = 0; i < listeners.length; i++) {
7302 // If the listener returns true then it shall be removed from the event
7303 // The function is executed either with a basic call or an apply if there is an args array
7304 listener = listeners[i];
7305
7306 if (listener.once === true) {
7307 this.removeListener(evt, listener.listener);
7308 }
7309
7310 response = listener.listener.apply(this, args || []);
7311
7312 if (response === this._getOnceReturnValue()) {
7313 this.removeListener(evt, listener.listener);
7314 }
7315 }
7316 }
7317 }
7318
7319 return this;
7320 };
7321
7322 /**
7323 * Alias of emitEvent
7324 */
7325 proto.trigger = alias('emitEvent');
7326
7327 /**
7328 * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
7329 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
7330 *
7331 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
7332 * @param {...*} Optional additional arguments to be passed to each listener.
7333 * @return {Object} Current instance of EventEmitter for chaining.
7334 */
7335 proto.emit = function emit(evt) {
7336 var args = Array.prototype.slice.call(arguments, 1);
7337 return this.emitEvent(evt, args);
7338 };
7339
7340 /**
7341 * Sets the current value to check against when executing listeners. If a
7342 * listeners return value matches the one set here then it will be removed
7343 * after execution. This value defaults to true.
7344 *
7345 * @param {*} value The new value to check for when executing listeners.
7346 * @return {Object} Current instance of EventEmitter for chaining.
7347 */
7348 proto.setOnceReturnValue = function setOnceReturnValue(value) {
7349 this._onceReturnValue = value;
7350 return this;
7351 };
7352
7353 /**
7354 * Fetches the current value to check against when executing listeners. If
7355 * the listeners return value matches this one then it should be removed
7356 * automatically. It will return true by default.
7357 *
7358 * @return {*|Boolean} The current value to check for or the default, true.
7359 * @api private
7360 */
7361 proto._getOnceReturnValue = function _getOnceReturnValue() {
7362 if (this.hasOwnProperty('_onceReturnValue')) {
7363 return this._onceReturnValue;
7364 } else {
7365 return true;
7366 }
7367 };
7368
7369 /**
7370 * Fetches the events object and creates one if required.
7371 *
7372 * @return {Object} The events storage object.
7373 * @api private
7374 */
7375 proto._getEvents = function _getEvents() {
7376 return this._events || (this._events = {});
7377 };
7378
7379 /**
7380 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
7381 *
7382 * @return {Function} Non conflicting EventEmitter class.
7383 */
7384 EventEmitter.noConflict = function noConflict() {
7385 exports.EventEmitter = originalGlobalValue;
7386 return EventEmitter;
7387 };
7388
7389 // Expose the class either via AMD, CommonJS or the global object
7390 if (true) {
7391 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
7392 return EventEmitter;
7393 }).call(exports, __webpack_require__, exports, module),
7394 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
7395 } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports) {
7396 module.exports = EventEmitter;
7397 } else {
7398 exports.EventEmitter = EventEmitter;
7399 }
7400})(this || {});
7401
7402/***/ }),
7403/* 42 */
7404/***/ (function(module, exports, __webpack_require__) {
7405
7406var Util = __webpack_require__(0);
7407var Shape = __webpack_require__(4);
7408
7409var Rect = function Rect(cfg) {
7410 Rect.superclass.constructor.call(this, cfg);
7411};
7412
7413Rect.ATTRS = {
7414 x: 0,
7415 y: 0,
7416 width: 0,
7417 height: 0,
7418 radius: 0,
7419 lineWidth: 1,
7420 fill: 'none'
7421};
7422
7423Util.extend(Rect, Shape);
7424
7425Util.augment(Rect, {
7426 canFill: true,
7427 canStroke: true,
7428 type: 'rect',
7429 getDefaultAttrs: function getDefaultAttrs() {
7430 return {
7431 lineWidth: 1,
7432 fill: 'none'
7433 };
7434 },
7435 _afterSetRadius: function _afterSetRadius() {
7436 var el = this.get('el');
7437 el.setAttribute('rx', this.__attrs.radius);
7438 el.setAttribute('ry', this.__attrs.radius);
7439 },
7440 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7441 if ('radius' in objs) {
7442 this._afterSetRadius();
7443 }
7444 }
7445});
7446
7447module.exports = Rect;
7448
7449/***/ }),
7450/* 43 */
7451/***/ (function(module, exports, __webpack_require__) {
7452
7453var Util = __webpack_require__(0);
7454var Shape = __webpack_require__(4);
7455
7456var Circle = function Circle(cfg) {
7457 Circle.superclass.constructor.call(this, cfg);
7458};
7459
7460Circle.ATTRS = {
7461 x: 0,
7462 y: 0,
7463 r: 0,
7464 lineWidth: 1
7465};
7466
7467Util.extend(Circle, Shape);
7468
7469Util.augment(Circle, {
7470 canFill: true,
7471 canStroke: true,
7472 type: 'circle',
7473 getDefaultAttrs: function getDefaultAttrs() {
7474 return {
7475 lineWidth: 1,
7476 fill: 'none'
7477 };
7478 }
7479});
7480
7481module.exports = Circle;
7482
7483/***/ }),
7484/* 44 */
7485/***/ (function(module, exports, __webpack_require__) {
7486
7487var Util = __webpack_require__(0);
7488var Shape = __webpack_require__(4);
7489
7490var Ellipse = function Ellipse(cfg) {
7491 Ellipse.superclass.constructor.call(this, cfg);
7492};
7493
7494Ellipse.ATTRS = {
7495 x: 0,
7496 y: 0,
7497 rx: 1,
7498 ry: 1,
7499 lineWidth: 1
7500};
7501
7502Util.extend(Ellipse, Shape);
7503
7504Util.augment(Ellipse, {
7505 canFill: true,
7506 canStroke: true,
7507 type: 'ellipse',
7508 getDefaultAttrs: function getDefaultAttrs() {
7509 return {
7510 lineWidth: 1
7511 };
7512 }
7513});
7514
7515module.exports = Ellipse;
7516
7517/***/ }),
7518/* 45 */
7519/***/ (function(module, exports, __webpack_require__) {
7520
7521var Util = __webpack_require__(0);
7522var Shape = __webpack_require__(4);
7523
7524var Path = function Path(cfg) {
7525 Path.superclass.constructor.call(this, cfg);
7526};
7527
7528function at(p0, p1, p2, p3, t) {
7529 var onet = 1 - t;
7530 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
7531}
7532
7533Path.ATTRS = {
7534 path: null,
7535 lineWidth: 1,
7536 curve: null, // 曲线path
7537 tCache: null,
7538 startArrow: false,
7539 endArrow: false
7540};
7541
7542Util.extend(Path, Shape);
7543
7544Util.augment(Path, {
7545 canFill: true,
7546 canStroke: true,
7547 type: 'path',
7548 getDefaultAttrs: function getDefaultAttrs() {
7549 return {
7550 lineWidth: 1,
7551 fill: 'none',
7552 startArrow: false,
7553 endArrow: false
7554 };
7555 },
7556 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
7557 var start = this.get('marker-start');
7558 var end = this.get('marker-end');
7559 if (start) {
7560 this.get('defs').findById(start).update(null, value);
7561 }
7562 if (end) {
7563 this.get('defs').findById(end).update(null, value);
7564 }
7565 },
7566 _afterSetAttrPath: function _afterSetAttrPath(value) {
7567 var el = this.get('el');
7568 var d = value;
7569 if (Util.isArray(d)) {
7570 d = d.map(function (path) {
7571 return path.join(' ');
7572 }).join('');
7573 }
7574 if (~d.indexOf('NaN')) {
7575 el.setAttribute('d', '');
7576 } else {
7577 el.setAttribute('d', d);
7578 }
7579 },
7580 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7581 if (objs.path) {
7582 this._afterSetAttrPath(objs.path);
7583 }
7584 if (objs.stroke) {
7585 this._afterSetAttrStroke(objs.stroke);
7586 }
7587 },
7588 getPoint: function getPoint(t) {
7589 var tCache = this.tCache;
7590 var subt = void 0;
7591 var index = void 0;
7592
7593 if (!tCache) {
7594 this._calculateCurve();
7595 this._setTcache();
7596 tCache = this.tCache;
7597 }
7598
7599 var curve = this.curve;
7600
7601 if (!tCache) {
7602 if (curve) {
7603 return {
7604 x: curve[0][1],
7605 y: curve[0][2]
7606 };
7607 }
7608 return null;
7609 }
7610 Util.each(tCache, function (v, i) {
7611 if (t >= v[0] && t <= v[1]) {
7612 subt = (t - v[0]) / (v[1] - v[0]);
7613 index = i;
7614 }
7615 });
7616 var seg = curve[index];
7617 if (Util.isNil(seg) || Util.isNil(index)) {
7618 return null;
7619 }
7620 var l = seg.length;
7621 var nextSeg = curve[index + 1];
7622
7623 return {
7624 x: at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
7625 y: at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
7626 };
7627 },
7628 createPath: function createPath() {}
7629});
7630
7631module.exports = Path;
7632
7633/***/ }),
7634/* 46 */
7635/***/ (function(module, exports, __webpack_require__) {
7636
7637var Util = __webpack_require__(0);
7638var Shape = __webpack_require__(4);
7639
7640var CText = function CText(cfg) {
7641 CText.superclass.constructor.call(this, cfg);
7642};
7643
7644var BASELINE_MAP = {
7645 top: 'before-edge',
7646 middle: 'central',
7647 bottom: 'after-edge',
7648 alphabetic: 'baseline',
7649 hanging: 'hanging'
7650};
7651
7652var ANCHOR_MAP = {
7653 left: 'left',
7654 start: 'left',
7655 center: 'middle',
7656 right: 'end',
7657 end: 'end'
7658};
7659
7660CText.ATTRS = {
7661 x: 0,
7662 y: 0,
7663 text: null,
7664 fontSize: 12,
7665 fontFamily: 'sans-serif',
7666 fontStyle: 'normal',
7667 fontWeight: 'normal',
7668 fontVariant: 'normal',
7669 textAlign: 'start',
7670 textBaseline: 'bottom',
7671 lineHeight: null,
7672 textArr: null
7673};
7674
7675Util.extend(CText, Shape);
7676
7677Util.augment(CText, {
7678 canFill: true,
7679 canStroke: true,
7680 type: 'text',
7681 getDefaultAttrs: function getDefaultAttrs() {
7682 return {
7683 lineWidth: 1,
7684 lineCount: 1,
7685 fontSize: 12,
7686 fill: '#000',
7687 fontFamily: 'sans-serif',
7688 fontStyle: 'normal',
7689 fontWeight: 'normal',
7690 fontVariant: 'normal',
7691 textAlign: 'start',
7692 textBaseline: 'bottom'
7693 };
7694 },
7695 initTransform: function initTransform() {
7696 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
7697 var fontSize = this.__attrs.fontSize;
7698 if (fontSize && +fontSize < 12) {
7699 // 小于 12 像素的文本进行 scale 处理
7700 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
7701 }
7702 },
7703 _assembleFont: function _assembleFont() {
7704 var el = this.get('el');
7705 var attrs = this.__attrs;
7706 var fontSize = attrs.fontSize;
7707 var fontFamily = attrs.fontFamily;
7708 var fontWeight = attrs.fontWeight;
7709 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
7710 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
7711 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
7712 var font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
7713 attrs.font = font;
7714 el.setAttribute('font', attrs.font);
7715 },
7716 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
7717 /* this.attr({
7718 height: this._getTextHeight()
7719 }); */
7720 this._assembleFont();
7721 },
7722 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
7723 this._assembleFont();
7724 },
7725 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
7726 this._assembleFont();
7727 },
7728 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
7729 this._assembleFont();
7730 },
7731 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
7732 this._assembleFont();
7733 },
7734 _afterSetAttrTextAlign: function _afterSetAttrTextAlign() {
7735 // 由于本身不支持设置direction,所以left = start, right = end。之后看是否需要根据direction判断
7736 var attr = this.__attrs.textAlign;
7737 var el = this.get('el');
7738 el.setAttribute('text-anchor', ANCHOR_MAP[attr]);
7739 },
7740 _afterSetAttrTextBaseLine: function _afterSetAttrTextBaseLine() {
7741 var attr = this.__attrs.textBaseline;
7742 this.get('el').setAttribute('alignment-baseline', BASELINE_MAP[attr] || 'baseline');
7743 },
7744 _afterSetAttrText: function _afterSetAttrText(text) {
7745 var attrs = this.__attrs;
7746 var textArr = void 0;
7747 if (Util.isString(text) && text.indexOf('\n') !== -1) {
7748 textArr = text.split('\n');
7749 var lineCount = textArr.length;
7750 attrs.lineCount = lineCount;
7751 attrs.textArr = textArr;
7752 }
7753 var el = this.get('el');
7754 if (~['undefined', 'null', 'NaN'].indexOf(String(text)) && el) {
7755 el.innerHTML = '';
7756 } else if (~text.indexOf('\n')) {
7757 textArr = text.split('\n');
7758 attrs.lineCount = textArr.length;
7759 attrs.textArr = textArr;
7760 var arr = '';
7761 Util.each(textArr, function (segment, i) {
7762 arr += '<tspan x="0" y="' + (i + 1) + 'em">' + segment + '</tspan>';
7763 });
7764 el.innerHTML = arr;
7765 } else {
7766 el.innerHTML = text;
7767 }
7768 },
7769 _afterSetAttrOutline: function _afterSetAttrOutline(val) {
7770 var el = this.get('el');
7771 if (!val) {
7772 el.setAttribute('paint-order', 'normal');
7773 }
7774 var stroke = val.stroke || '#000';
7775 var fill = val.fill || this.__attrs.stroke;
7776 var lineWidth = val.lineWidth || this.__attrs.lineWidth * 2;
7777 el.setAttribute('paint-order', 'stroke');
7778 el.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');
7779 el.setAttribute('stroke', stroke);
7780 el.setAttribute('fill', fill);
7781 el.setAttribute('stroke-width', lineWidth);
7782 },
7783
7784 // 计算浪费,效率低,待优化
7785 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7786 var self = this;
7787 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
7788 self._assembleFont();
7789 }
7790 if ('textAlign' in objs) {
7791 this._afterSetAttrTextAlign();
7792 }
7793 if ('textBaseline' in objs) {
7794 this._afterSetAttrTextBaseLine();
7795 }
7796 if ('text' in objs) {
7797 self._afterSetAttrText(objs.text);
7798 }
7799 if ('outline' in objs) {
7800 self._afterSetAttrOutline(objs.outline);
7801 }
7802 }
7803});
7804
7805module.exports = CText;
7806
7807/***/ }),
7808/* 47 */
7809/***/ (function(module, exports, __webpack_require__) {
7810
7811var Util = __webpack_require__(0);
7812var Shape = __webpack_require__(4);
7813
7814var Line = function Line(cfg) {
7815 Line.superclass.constructor.call(this, cfg);
7816};
7817
7818Line.ATTRS = {
7819 x1: 0,
7820 y1: 0,
7821 x2: 0,
7822 y2: 0,
7823 lineWidth: 1,
7824 startArrow: false,
7825 endArrow: false
7826};
7827
7828Util.extend(Line, Shape);
7829
7830Util.augment(Line, {
7831 canStroke: true,
7832 type: 'line',
7833 getDefaultAttrs: function getDefaultAttrs() {
7834 return {
7835 lineWidth: 1,
7836 stroke: '#000',
7837 startArrow: false,
7838 endArrow: false
7839 };
7840 },
7841 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
7842 var start = this.get('marker-start');
7843 var end = this.get('marker-end');
7844 if (start) {
7845 this.get('defs').findById(start).update(value);
7846 }
7847 if (end) {
7848 this.get('defs').findById(end).update(value);
7849 }
7850 },
7851 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7852 if (objs.stroke) {
7853 this._afterSetAttrStroke(objs.stroke);
7854 }
7855 },
7856 createPath: function createPath() {},
7857 getPoint: function getPoint(t) {
7858 var attrs = this.__attrs;
7859 return {
7860 x: (attrs.x2 - attrs.x1) * t + attrs.x1,
7861 y: (attrs.y2 - attrs.y1) * t + attrs.y1
7862 };
7863 }
7864});
7865
7866module.exports = Line;
7867
7868/***/ }),
7869/* 48 */
7870/***/ (function(module, exports, __webpack_require__) {
7871
7872var Util = __webpack_require__(0);
7873var Shape = __webpack_require__(4);
7874
7875var CImage = function CImage(cfg) {
7876 CImage.superclass.constructor.call(this, cfg);
7877};
7878
7879CImage.ATTRS = {
7880 x: 0,
7881 y: 0,
7882 img: undefined,
7883 width: 0,
7884 height: 0,
7885 sx: null,
7886 sy: null,
7887 swidth: null,
7888 sheight: null
7889};
7890
7891Util.extend(CImage, Shape);
7892
7893Util.augment(CImage, {
7894 type: 'image',
7895 _afterSetAttrImg: function _afterSetAttrImg(img) {
7896 this._setAttrImg(img);
7897 },
7898 _afterSetAttrAll: function _afterSetAttrAll(params) {
7899 if (params.img) {
7900 this._setAttrImg(params.img);
7901 }
7902 },
7903 _setAttrImg: function _setAttrImg(image) {
7904 var self = this;
7905 var el = this.get('el');
7906 var attrs = self.__attrs;
7907 var img = image;
7908
7909 if (Util.isString(img)) {
7910 // 如果传入的
7911 el.setAttribute('href', img);
7912 } else if (img instanceof Image) {
7913 if (!attrs.width) {
7914 self.attr('width', img.width);
7915 }
7916 if (!attrs.height) {
7917 self.attr('height', img.height);
7918 }
7919 el.setAttribute('href', img.src);
7920 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
7921 el.setAttribute('href', img.toDataURL());
7922 } else if (img instanceof ImageData) {
7923 var canvas = document.createElement('canvas');
7924 canvas.setAttribute('width', img.width);
7925 canvas.setAttribute('height', img.height);
7926 canvas.getContext('2d').putImageData(img, 0, 0);
7927 if (!attrs.width) {
7928 self.attr('width', img.width);
7929 }
7930
7931 if (!attrs.height) {
7932 self.attr('height', img.height);
7933 }
7934 el.setAttribute('href', canvas.toDataURL());
7935 }
7936 },
7937 drawInner: function drawInner() {}
7938});
7939
7940module.exports = CImage;
7941
7942/***/ }),
7943/* 49 */
7944/***/ (function(module, exports, __webpack_require__) {
7945
7946var Util = __webpack_require__(0);
7947var Shape = __webpack_require__(4);
7948
7949var Polygon = function Polygon(cfg) {
7950 Polygon.superclass.constructor.call(this, cfg);
7951};
7952
7953Polygon.ATTRS = {
7954 points: null,
7955 lineWidth: 1
7956};
7957
7958Util.extend(Polygon, Shape);
7959
7960Util.augment(Polygon, {
7961 canFill: true,
7962 canStroke: true,
7963 type: 'polygon',
7964 getDefaultAttrs: function getDefaultAttrs() {
7965 return {
7966 lineWidth: 1,
7967 fill: 'none'
7968 };
7969 },
7970 _afterSetAttrPoints: function _afterSetAttrPoints() {
7971 var value = this.__attrs.points;
7972 var el = this.get('el');
7973 var points = value;
7974 if (!value || value.length === 0) {
7975 points = '';
7976 } else if (Util.isArray(value)) {
7977 points = points.map(function (point) {
7978 return point[0] + ',' + point[1];
7979 });
7980 points = points.join(' ');
7981 }
7982 el.setAttribute('points', points);
7983 },
7984 _afterSetAttrAll: function _afterSetAttrAll(obj) {
7985 if ('points' in obj) {
7986 this._afterSetAttrPoints();
7987 }
7988 },
7989 createPath: function createPath() {}
7990});
7991
7992module.exports = Polygon;
7993
7994/***/ }),
7995/* 50 */
7996/***/ (function(module, exports, __webpack_require__) {
7997
7998var Util = __webpack_require__(0);
7999var Shape = __webpack_require__(4);
8000
8001var Marker = function Marker(cfg) {
8002 Marker.superclass.constructor.call(this, cfg);
8003};
8004
8005Marker.Symbols = {
8006 // 圆
8007 circle: function circle(x, y, r) {
8008 return 'M' + x + ',' + y + '\n m' + -r + ',0\n a ' + r + ',' + r + ',0,1,0,' + r * 2 + ',0\n a ' + r + ',' + r + ',0,1,0,' + -r * 2 + ',0';
8009 },
8010
8011 // 正方形
8012 square: function square(x, y, r) {
8013 return 'M' + (x - r) + ',' + (y - r) + '\n H' + (x + r) + 'V' + (y + r) + '\n H' + (x - r) + 'Z';
8014 },
8015
8016 // 菱形
8017 diamond: function diamond(x, y, r) {
8018 return 'M' + (x - r) + ',' + y + '\n L' + x + ',' + (y - r) + '\n L' + (x + r) + ',' + y + ',\n L' + x + ',' + (y + r) + 'Z';
8019 },
8020
8021 // 三角形
8022 triangle: function triangle(x, y, r) {
8023 var diff = r * Math.sin(1 / 3 * Math.PI);
8024 return 'M' + (x - r) + ',' + (y + diff) + '\n L' + x + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y + diff) + 'Z';
8025 },
8026
8027 // 倒三角形
8028 'triangle-down': function triangleDown(x, y, r) {
8029 var diff = r * Math.sin(1 / 3 * Math.PI);
8030 return 'M' + (x - r) + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y - diff) + '\n L' + x + ',' + (y + diff) + 'Z';
8031 }
8032};
8033
8034Marker.ATTRS = {
8035 path: null,
8036 lineWidth: 1
8037};
8038
8039Util.extend(Marker, Shape);
8040
8041Util.augment(Marker, {
8042 type: 'marker',
8043 canFill: true,
8044 canStroke: true,
8045 init: function init(id) {
8046 Marker.superclass.init.call(this);
8047 var marker = document.createElementNS('http://www.w3.org/2000/svg', 'path');
8048 id = id || Util.uniqueId(this.type + '_');
8049 marker.setAttribute('id', id);
8050 this.setSilent('el', marker);
8051 },
8052 getDefaultAttrs: function getDefaultAttrs() {
8053 return {
8054 x: 0,
8055 y: 0,
8056 lineWidth: 1,
8057 fill: 'none'
8058 };
8059 },
8060 _afterSetX: function _afterSetX() {
8061 this._assembleShape();
8062 },
8063 _afterSetY: function _afterSetY() {
8064 this._assembleShape();
8065 },
8066 _afterSetRadius: function _afterSetRadius() {
8067 this._assembleShape();
8068 },
8069 _afterSetR: function _afterSetR() {
8070 this._assembleShape();
8071 },
8072 _afterSetAttrAll: function _afterSetAttrAll(objs) {
8073 if ('x' in objs || 'y' in objs || 'radius' in objs) {
8074 this._assembleShape();
8075 }
8076 },
8077 _assembleShape: function _assembleShape() {
8078 var attrs = this.__attrs;
8079 var r = attrs.r;
8080 if (typeof attrs.r === 'undefined') {
8081 r = attrs.radius;
8082 }
8083 if (isNaN(Number(attrs.x)) || isNaN(Number(attrs.y)) || isNaN(Number(r))) {
8084 return;
8085 }
8086 var d = '';
8087 if (typeof attrs.symbol === 'function') {
8088 d = attrs.symbol(attrs.x, attrs.y, r);
8089 } else {
8090 d = Marker.Symbols[attrs.symbol || 'circle'](attrs.x, attrs.y, r);
8091 }
8092 if (Util.isArray(d)) {
8093 d = d.map(function (path) {
8094 return path.join(' ');
8095 }).join('');
8096 }
8097 this.get('el').setAttribute('d', d);
8098 }
8099});
8100
8101module.exports = Marker;
8102
8103/***/ }),
8104/* 51 */
8105/***/ (function(module, exports, __webpack_require__) {
8106
8107var Util = __webpack_require__(0);
8108var Shape = __webpack_require__(4);
8109
8110var Dom = function Dom(cfg) {
8111 Dom.superclass.constructor.call(this, cfg);
8112};
8113
8114Util.extend(Dom, Shape);
8115
8116Util.augment(Dom, {
8117 canFill: true,
8118 canStroke: true,
8119 type: 'dom',
8120 _afterSetAttrHtml: function _afterSetAttrHtml() {
8121 var html = this.__attrs.html;
8122 var el = this.get('el');
8123 if (typeof html === 'string') {
8124 el.innerHTML = html;
8125 } else {
8126 el.innerHTML = '';
8127 el.appendChild(html);
8128 }
8129 },
8130 _afterSetAttrAll: function _afterSetAttrAll(objs) {
8131 if ('html' in objs) {
8132 this._afterSetAttrHtml();
8133 }
8134 }
8135});
8136
8137module.exports = Dom;
8138
8139/***/ }),
8140/* 52 */
8141/***/ (function(module, exports, __webpack_require__) {
8142
8143var Util = __webpack_require__(0);
8144var Shape = __webpack_require__(4);
8145
8146var Fan = function Fan(cfg) {
8147 Fan.superclass.constructor.call(this, cfg);
8148};
8149
8150function getPoint(angle, radius, center) {
8151 return {
8152 x: radius * Math.cos(angle) + center.x,
8153 y: radius * Math.sin(angle) + center.y
8154 };
8155}
8156
8157Fan.ATTRS = {
8158 x: 0,
8159 y: 0,
8160 rs: 0,
8161 re: 0,
8162 startAngle: 0,
8163 endAngle: 0,
8164 clockwise: false,
8165 lineWidth: 1
8166};
8167
8168Util.extend(Fan, Shape);
8169
8170Util.augment(Fan, {
8171 canFill: true,
8172 canStroke: true,
8173 type: 'fan',
8174 getDefaultAttrs: function getDefaultAttrs() {
8175 return {
8176 clockwise: false,
8177 lineWidth: 1,
8178 rs: 0,
8179 re: 0,
8180 fill: 'none'
8181 };
8182 },
8183 _afterSetAttrX: function _afterSetAttrX() {
8184 this._calculatePath();
8185 },
8186 _afterSetAttrY: function _afterSetAttrY() {
8187 this._calculatePath();
8188 },
8189 _afterSetAttrRs: function _afterSetAttrRs() {
8190 this._calculatePath();
8191 },
8192 _afterSetAttrRe: function _afterSetAttrRe() {
8193 this._calculatePath();
8194 },
8195 _afterSetAttrStartAngle: function _afterSetAttrStartAngle() {
8196 this._calculatePath();
8197 },
8198 _afterSetAttrEndAngle: function _afterSetAttrEndAngle() {
8199 this._calculatePath();
8200 },
8201 _afterSetAttrClockwise: function _afterSetAttrClockwise() {
8202 this._calculatePath();
8203 },
8204 _afterSetAttrAll: function _afterSetAttrAll(obj) {
8205 if ('x' in obj || 'y' in obj || 'rs' in obj || 're' in obj || 'startAngle' in obj || 'endAngle' in obj || 'clockwise' in obj) {
8206 this._calculatePath();
8207 }
8208 },
8209 _calculatePath: function _calculatePath() {
8210 var self = this;
8211 var attrs = self.__attrs;
8212 var center = {
8213 x: attrs.x,
8214 y: attrs.y
8215 };
8216 var d = [];
8217 var startAngle = attrs.startAngle;
8218 var endAngle = attrs.endAngle;
8219 if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
8220 endAngle -= 0.00001;
8221 }
8222 var outerStart = getPoint(startAngle, attrs.re, center);
8223 var outerEnd = getPoint(endAngle, attrs.re, center);
8224 var fa = endAngle > startAngle ? 1 : 0;
8225 var fs = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
8226 var rs = attrs.rs;
8227 var re = attrs.re;
8228 var innerStart = getPoint(startAngle, attrs.rs, center);
8229 var innerEnd = getPoint(endAngle, attrs.rs, center);
8230 if (attrs.rs > 0) {
8231 d.push('M ' + outerEnd.x + ',' + outerEnd.y);
8232 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
8233 /* if (endAngle - startAngle >= Math.PI) {
8234 const endPoint = getSymmetricalPoint(innerStart, center);
8235 d.push(`A ${rs},${rs},0,0,${fa},${endPoint.x},${endPoint.y}`);
8236 d.push(`M ${endPoint.x},${endPoint.y}`);
8237 }*/
8238 d.push('A ' + rs + ',' + rs + ',0,' + fs + ',' + (fa === 1 ? 0 : 1) + ',' + innerStart.x + ',' + innerStart.y);
8239 d.push('L ' + outerStart.x + ' ' + outerStart.y);
8240 } else {
8241 d.push('M ' + center.x + ',' + center.y);
8242 d.push('L ' + outerStart.x + ',' + outerStart.y);
8243 }
8244 /* if (endAngle - startAngle >= Math.PI) {
8245 const endPoint = getSymmetricalPoint(outerStart, center);
8246 d.push(`A ${re},${re},0,0,${fa},${endPoint.x},${endPoint.y}`);
8247 }*/
8248 d.push('A ' + re + ',' + re + ',0,' + fs + ',' + fa + ',' + outerEnd.x + ',' + outerEnd.y);
8249 if (attrs.rs > 0) {
8250 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
8251 } else {
8252 d.push('Z');
8253 }
8254 self.get('el').setAttribute('d', d.join(' '));
8255 }
8256});
8257
8258module.exports = Fan;
8259
8260/***/ }),
8261/* 53 */
8262/***/ (function(module, exports, __webpack_require__) {
8263
8264var Util = __webpack_require__(0);
8265
8266var Event = function Event(type, event, bubbles, cancelable) {
8267 this.type = type; // 事件类型
8268 this.target = null; // 目标
8269 this.currentTarget = null; // 当前目标
8270 this.bubbles = bubbles; // 冒泡
8271 this.cancelable = cancelable; // 是否能够阻止
8272 this.timeStamp = new Date().getTime(); // 时间戳
8273 this.defaultPrevented = false; // 阻止默认
8274 this.propagationStopped = false; // 阻止冒泡
8275 this.removed = false; // 是否被移除
8276 this.event = event; // 触发的原生事件
8277};
8278
8279Util.augment(Event, {
8280 preventDefault: function preventDefault() {
8281 this.defaultPrevented = this.cancelable && true;
8282 },
8283 stopPropagation: function stopPropagation() {
8284 this.propagationStopped = true;
8285 },
8286 remove: function remove() {
8287 this.remove = true;
8288 },
8289 clone: function clone() {
8290 return Util.clone(this);
8291 },
8292 toString: function toString() {
8293 return '[Event (type=' + this.type + ')]';
8294 }
8295});
8296
8297module.exports = Event;
8298
8299/***/ }),
8300/* 54 */
8301/***/ (function(module, exports, __webpack_require__) {
8302
8303var Util = __webpack_require__(0);
8304var Element = __webpack_require__(55);
8305var Shape = __webpack_require__(114);
8306var SHAPE_MAP = {}; // 缓存图形类型
8307var INDEX = '_INDEX';
8308
8309function find(children, x, y) {
8310 var rst = void 0;
8311 for (var i = children.length - 1; i >= 0; i--) {
8312 var child = children[i];
8313 if (child.__cfg.visible && child.__cfg.capture) {
8314 if (child.isGroup) {
8315 rst = child.getShape(x, y);
8316 } else if (child.isHit(x, y)) {
8317 rst = child;
8318 }
8319 }
8320 if (rst) {
8321 break;
8322 }
8323 }
8324 return rst;
8325}
8326
8327function getComparer(compare) {
8328 return function (left, right) {
8329 var result = compare(left, right);
8330 return result === 0 ? left[INDEX] - right[INDEX] : result;
8331 };
8332}
8333
8334var Group = function Group(cfg) {
8335 Group.superclass.constructor.call(this, cfg);
8336 this.set('children', []);
8337
8338 this._beforeRenderUI();
8339 this._renderUI();
8340 this._bindUI();
8341};
8342
8343function initClassCfgs(c) {
8344 if (c.__cfg || c === Group) {
8345 return;
8346 }
8347 var superCon = c.superclass.constructor;
8348 if (superCon && !superCon.__cfg) {
8349 initClassCfgs(superCon);
8350 }
8351 c.__cfg = {};
8352
8353 Util.merge(c.__cfg, superCon.__cfg);
8354 Util.merge(c.__cfg, c.CFG);
8355}
8356
8357Util.extend(Group, Element);
8358
8359Util.augment(Group, {
8360 isGroup: true,
8361 canFill: true,
8362 canStroke: true,
8363 getDefaultCfg: function getDefaultCfg() {
8364 initClassCfgs(this.constructor);
8365 return Util.merge({}, this.constructor.__cfg);
8366 },
8367 _beforeRenderUI: function _beforeRenderUI() {},
8368 _renderUI: function _renderUI() {},
8369 _bindUI: function _bindUI() {},
8370 addShape: function addShape(type, cfg) {
8371 var canvas = this.get('canvas');
8372 cfg = cfg || {};
8373 var shapeType = SHAPE_MAP[type];
8374 if (!shapeType) {
8375 shapeType = Util.upperFirst(type);
8376 SHAPE_MAP[type] = shapeType;
8377 }
8378 if (cfg.attrs) {
8379 var attrs = cfg.attrs;
8380 if (type === 'text') {
8381 // 临时解决
8382 var topFontFamily = canvas.get('fontFamily');
8383 if (topFontFamily) {
8384 attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily;
8385 }
8386 }
8387 }
8388 cfg.canvas = canvas;
8389 cfg.type = type;
8390 var rst = new Shape[shapeType](cfg);
8391 this.add(rst);
8392 return rst;
8393 },
8394
8395 /** 添加图组
8396 * @param {Function|Object|undefined} param 图组类
8397 * @param {Object} cfg 配置项
8398 * @return {Object} rst 图组
8399 */
8400 addGroup: function addGroup(param, cfg) {
8401 var canvas = this.get('canvas');
8402 var rst = void 0;
8403 cfg = Util.merge({}, cfg);
8404 if (Util.isFunction(param)) {
8405 if (cfg) {
8406 cfg.canvas = canvas;
8407 cfg.parent = this;
8408 rst = new param(cfg);
8409 } else {
8410 rst = new param({
8411 canvas: canvas,
8412 parent: this
8413 });
8414 }
8415 this.add(rst);
8416 } else if (Util.isObject(param)) {
8417 param.canvas = canvas;
8418 rst = new Group(param);
8419 this.add(rst);
8420 } else if (param === undefined) {
8421 rst = new Group();
8422 this.add(rst);
8423 } else {
8424 return false;
8425 }
8426 return rst;
8427 },
8428
8429 /** 绘制背景
8430 * @param {Array} padding 内边距
8431 * @param {Attrs} attrs 图形属性
8432 * @param {Shape} backShape 背景图形
8433 * @return {Object} 背景层对象
8434 */
8435 renderBack: function renderBack(padding, attrs) {
8436 var backShape = this.get('backShape');
8437 var innerBox = this.getBBox();
8438 // const parent = this.get('parent'); // getParent
8439 Util.merge(attrs, {
8440 x: innerBox.minX - padding[3],
8441 y: innerBox.minY - padding[0],
8442 width: innerBox.width + padding[1] + padding[3],
8443 height: innerBox.height + padding[0] + padding[2]
8444 });
8445 if (backShape) {
8446 backShape.attr(attrs);
8447 } else {
8448 backShape = this.addShape('rect', {
8449 zIndex: -1,
8450 attrs: attrs
8451 });
8452 }
8453 this.set('backShape', backShape);
8454 this.sort();
8455 return backShape;
8456 },
8457 removeChild: function removeChild(item, destroy) {
8458 if (arguments.length >= 2) {
8459 if (this.contain(item)) {
8460 item.remove(destroy);
8461 }
8462 } else {
8463 if (arguments.length === 1) {
8464 if (Util.isBoolean(item)) {
8465 destroy = item;
8466 } else {
8467 if (this.contain(item)) {
8468 item.remove(true);
8469 }
8470 return this;
8471 }
8472 }
8473 if (arguments.length === 0) {
8474 destroy = true;
8475 }
8476
8477 Group.superclass.remove.call(this, destroy);
8478 }
8479 return this;
8480 },
8481
8482 /**
8483 * 向组中添加shape或者group
8484 * @param {Object} items 图形或者分组
8485 * @return {Object} group 本尊
8486 */
8487 add: function add(items) {
8488 var self = this;
8489 var children = self.get('children');
8490 if (Util.isArray(items)) {
8491 Util.each(items, function (item) {
8492 var parent = item.get('parent');
8493 if (parent) {
8494 parent.removeChild(item, false);
8495 }
8496 self._setEvn(item);
8497 });
8498 children.push.apply(children, items);
8499 } else {
8500 var item = items;
8501 var parent = item.get('parent');
8502 if (parent) {
8503 parent.removeChild(item, false);
8504 }
8505 self._setEvn(item);
8506 children.push(item);
8507 }
8508 return self;
8509 },
8510 contain: function contain(item) {
8511 var children = this.get('children');
8512 return children.indexOf(item) > -1;
8513 },
8514 getChildByIndex: function getChildByIndex(index) {
8515 var children = this.get('children');
8516 return children[index];
8517 },
8518 getFirst: function getFirst() {
8519 return this.getChildByIndex(0);
8520 },
8521 getLast: function getLast() {
8522 var lastIndex = this.get('children').length - 1;
8523 return this.getChildByIndex(lastIndex);
8524 },
8525 _setEvn: function _setEvn(item) {
8526 var self = this;
8527 item.__cfg.parent = self;
8528 item.__cfg.context = self.__cfg.context;
8529 item.__cfg.canvas = self.__cfg.canvas;
8530 var clip = item.__attrs.clip;
8531 if (clip) {
8532 clip.setSilent('parent', self);
8533 clip.setSilent('context', self.get('context'));
8534 }
8535 var children = item.__cfg.children;
8536 if (children) {
8537 Util.each(children, function (child) {
8538 item._setEvn(child);
8539 });
8540 }
8541 },
8542 getBBox: function getBBox() {
8543 var self = this;
8544 var minX = Infinity;
8545 var maxX = -Infinity;
8546 var minY = Infinity;
8547 var maxY = -Infinity;
8548 var children = self.get('children');
8549 if (children.length > 0) {
8550 Util.each(children, function (child) {
8551 if (child.get('visible')) {
8552 var _box = child.getBBox();
8553 if (!_box) {
8554 return true;
8555 }
8556
8557 var leftTop = [_box.minX, _box.minY, 1];
8558 var leftBottom = [_box.minX, _box.maxY, 1];
8559 var rightTop = [_box.maxX, _box.minY, 1];
8560 var rightBottom = [_box.maxX, _box.maxY, 1];
8561
8562 child.apply(leftTop);
8563 child.apply(leftBottom);
8564 child.apply(rightTop);
8565 child.apply(rightBottom);
8566
8567 var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
8568 var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
8569 var boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
8570 var boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
8571
8572 if (boxMinX < minX) {
8573 minX = boxMinX;
8574 }
8575
8576 if (boxMaxX > maxX) {
8577 maxX = boxMaxX;
8578 }
8579
8580 if (boxMinY < minY) {
8581 minY = boxMinY;
8582 }
8583
8584 if (boxMaxY > maxY) {
8585 maxY = boxMaxY;
8586 }
8587 }
8588 });
8589 } else {
8590 minX = 0;
8591 maxX = 0;
8592 minY = 0;
8593 maxY = 0;
8594 }
8595
8596 var box = {
8597 minX: minX,
8598 minY: minY,
8599 maxX: maxX,
8600 maxY: maxY
8601 };
8602 box.x = box.minX;
8603 box.y = box.minY;
8604 box.width = box.maxX - box.minX;
8605 box.height = box.maxY - box.minY;
8606 return box;
8607 },
8608 drawInner: function drawInner(context) {
8609 var children = this.get('children');
8610 for (var i = 0; i < children.length; i++) {
8611 var child = children[i];
8612 child.draw(context);
8613 }
8614 return this;
8615 },
8616 getCount: function getCount() {
8617 return this.get('children').length;
8618 },
8619 sort: function sort() {
8620 var children = this.get('children');
8621 // 稳定排序
8622 Util.each(children, function (child, index) {
8623 child[INDEX] = index;
8624 return child;
8625 });
8626
8627 children.sort(getComparer(function (obj1, obj2) {
8628 return obj1.get('zIndex') - obj2.get('zIndex');
8629 }));
8630
8631 return this;
8632 },
8633 findById: function findById(id) {
8634 return this.find(function (item) {
8635 return item.get('id') === id;
8636 });
8637 },
8638
8639 /**
8640 * 根据查找函数查找分组或者图形
8641 * @param {Function} fn 匹配函数
8642 * @return {Canvas.Base} 分组或者图形
8643 */
8644 find: function find(fn) {
8645 if (Util.isString(fn)) {
8646 return this.findById(fn);
8647 }
8648 var children = this.get('children');
8649 var rst = null;
8650
8651 Util.each(children, function (item) {
8652 if (fn(item)) {
8653 rst = item;
8654 } else if (item.find) {
8655 rst = item.find(fn);
8656 }
8657 if (rst) {
8658 return false;
8659 }
8660 });
8661 return rst;
8662 },
8663
8664 /**
8665 * @param {Function} fn filter mathod
8666 * @return {Array} all the matching shapes and groups
8667 */
8668 findAll: function findAll(fn) {
8669 var children = this.get('children');
8670 var rst = [];
8671 var childRst = [];
8672 Util.each(children, function (item) {
8673 if (fn(item)) {
8674 rst.push(item);
8675 }
8676 if (item.findAllBy) {
8677 childRst = item.findAllBy(fn);
8678 rst = rst.concat(childRst);
8679 }
8680 });
8681 return rst;
8682 },
8683
8684 /**
8685 * @Deprecated
8686 * @param {Function} fn filter method
8687 * @return {Object} found shape or group
8688 */
8689 findBy: function findBy(fn) {
8690 var children = this.get('children');
8691 var rst = null;
8692
8693 Util.each(children, function (item) {
8694 if (fn(item)) {
8695 rst = item;
8696 } else if (item.findBy) {
8697 rst = item.findBy(fn);
8698 }
8699 if (rst) {
8700 return false;
8701 }
8702 });
8703 return rst;
8704 },
8705
8706 /**
8707 * @Deprecated
8708 * @param {Function} fn filter mathod
8709 * @return {Array} all the matching shapes and groups
8710 */
8711 findAllBy: function findAllBy(fn) {
8712 var children = this.get('children');
8713 var rst = [];
8714 var childRst = [];
8715 Util.each(children, function (item) {
8716 if (fn(item)) {
8717 rst.push(item);
8718 }
8719 if (item.findAllBy) {
8720 childRst = item.findAllBy(fn);
8721 rst = rst.concat(childRst);
8722 }
8723 });
8724 return rst;
8725 },
8726
8727 /**
8728 * 根据x,y轴坐标获取对应的图形
8729 * @param {Number} x x坐标
8730 * @param {Number} y y坐标
8731 * @return {Object} 最上面的图形
8732 */
8733 getShape: function getShape(x, y) {
8734 var self = this;
8735 var clip = self.__attrs.clip;
8736 var children = self.__cfg.children;
8737 var rst = void 0;
8738 if (clip) {
8739 if (clip.inside(x, y)) {
8740 rst = find(children, x, y);
8741 }
8742 } else {
8743 rst = find(children, x, y);
8744 }
8745 return rst;
8746 },
8747 clearTotalMatrix: function clearTotalMatrix() {
8748 var m = this.get('totalMatrix');
8749 if (m) {
8750 this.setSilent('totalMatrix', null);
8751 var children = this.__cfg.children;
8752 for (var i = 0; i < children.length; i++) {
8753 var child = children[i];
8754 child.clearTotalMatrix();
8755 }
8756 }
8757 },
8758 clear: function clear() {
8759 var children = this.get('children');
8760
8761 while (children.length !== 0) {
8762 children[children.length - 1].remove();
8763 }
8764 return this;
8765 },
8766 destroy: function destroy() {
8767 if (this.get('destroyed')) {
8768 return;
8769 }
8770 this.clear();
8771 Group.superclass.destroy.call(this);
8772 }
8773});
8774
8775module.exports = Group;
8776
8777/***/ }),
8778/* 55 */
8779/***/ (function(module, exports, __webpack_require__) {
8780
8781var Util = __webpack_require__(0);
8782var Attribute = __webpack_require__(112);
8783var Transform = __webpack_require__(113);
8784var Animate = __webpack_require__(32);
8785var Format = __webpack_require__(21);
8786var EventEmitter = __webpack_require__(41);
8787
8788var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'lineDashOffset'];
8789
8790var Element = function Element(cfg) {
8791 this.__cfg = {
8792 zIndex: 0,
8793 capture: true,
8794 visible: true,
8795 destroyed: false
8796 }; // 配置存放地
8797
8798 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
8799 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
8800 this.initTransform(); // 初始化变换
8801 this.init(); // 类型初始化
8802};
8803
8804Element.CFG = {
8805 /**
8806 * 唯一标示
8807 * @type {Number}
8808 */
8809 id: null,
8810 /**
8811 * Z轴的层叠关系,Z值越大离用户越近
8812 * @type {Number}
8813 */
8814 zIndex: 0,
8815 /**
8816 * Canvas对象
8817 * @type: {Object}
8818 */
8819 canvas: null,
8820 /**
8821 * 父元素指针
8822 * @type {Object}
8823 */
8824 parent: null,
8825 /**
8826 * 用来设置当前对象是否能被捕捉
8827 * true 能
8828 * false 不能
8829 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
8830 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
8831 * @type {Boolean}
8832 **/
8833 capture: true,
8834 /**
8835 * 画布的上下文
8836 * @type {Object}
8837 */
8838 context: null,
8839 /**
8840 * 是否显示
8841 * @type {Boolean}
8842 */
8843 visible: true,
8844 /**
8845 * 是否被销毁
8846 * @type: {Boolean}
8847 */
8848 destroyed: false
8849};
8850
8851Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
8852 init: function init() {
8853 this.setSilent('animable', true);
8854 this.setSilent('animating', false); // 初始时不处于动画状态
8855 var attrs = this.__attrs;
8856 if (attrs && attrs.rotate) {
8857 this.rotateAtStart(attrs.rotate);
8858 }
8859 },
8860 getParent: function getParent() {
8861 return this.get('parent');
8862 },
8863
8864 /**
8865 * 获取默认的配置信息
8866 * @protected
8867 * @return {Object} 默认的属性
8868 */
8869 getDefaultCfg: function getDefaultCfg() {
8870 return {};
8871 },
8872 set: function set(name, value) {
8873 if (name === 'zIndex' && this._beforeSetZIndex) {
8874 this._beforeSetZIndex(value);
8875 }
8876 if (name === 'loading' && this._beforeSetLoading) {
8877 this._beforeSetLoading(value);
8878 }
8879 this.__cfg[name] = value;
8880 return this;
8881 },
8882 setSilent: function setSilent(name, value) {
8883 this.__cfg[name] = value;
8884 },
8885 get: function get(name) {
8886 return this.__cfg[name];
8887 },
8888 draw: function draw(context) {
8889 if (this.get('destroyed')) {
8890 return;
8891 }
8892 if (this.get('visible')) {
8893 this.setContext(context);
8894 this.drawInner(context);
8895 this.restoreContext(context);
8896 }
8897 },
8898 setContext: function setContext(context) {
8899 var clip = this.__attrs.clip;
8900 context.save();
8901 if (clip) {
8902 // context.save();
8903 clip.resetTransform(context);
8904 clip.createPath(context);
8905 context.clip();
8906 // context.restore();
8907 }
8908 this.resetContext(context);
8909 this.resetTransform(context);
8910 },
8911 restoreContext: function restoreContext(context) {
8912 context.restore();
8913 },
8914 resetContext: function resetContext(context) {
8915 var elAttrs = this.__attrs;
8916 // var canvas = this.get('canvas');
8917 if (!this.isGroup) {
8918 // canvas.registShape(this); // 快速拾取方案暂时不执行
8919 for (var k in elAttrs) {
8920 if (SHAPE_ATTRS.indexOf(k) > -1) {
8921 // 非canvas属性不附加
8922 var v = elAttrs[k];
8923 if (k === 'fillStyle') {
8924 v = Format.parseStyle(v, this);
8925 }
8926 if (k === 'strokeStyle') {
8927 v = Format.parseStyle(v, this);
8928 }
8929 if (k === 'lineDash' && context.setLineDash) {
8930 if (Util.isArray(v)) {
8931 context.setLineDash(v);
8932 } else if (Util.isString(v)) {
8933 context.setLineDash(v.split(' '));
8934 }
8935 } else {
8936 context[k] = v;
8937 }
8938 }
8939 }
8940 }
8941 },
8942 drawInner: function drawInner() /* context */{},
8943 show: function show() {
8944 this.set('visible', true);
8945 return this;
8946 },
8947 hide: function hide() {
8948 this.set('visible', false);
8949 return this;
8950 },
8951 remove: function remove(destroy) {
8952 if (destroy === undefined) {
8953 destroy = true;
8954 }
8955
8956 if (this.get('parent')) {
8957 var parent = this.get('parent');
8958 var children = parent.get('children');
8959 Util.remove(children, this);
8960 }
8961
8962 if (destroy) {
8963 this.destroy();
8964 }
8965
8966 return this;
8967 },
8968 destroy: function destroy() {
8969 var destroyed = this.get('destroyed');
8970 if (destroyed) {
8971 return;
8972 }
8973 // 如果正在执行动画,清理动画
8974 if (this.get('animating')) {
8975 var timer = this.get('animateTimer');
8976 timer && timer.stop();
8977 }
8978 this.__cfg = {};
8979 this.__attrs = null;
8980 this.removeEvent(); // 移除所有的事件
8981 this.set('destroyed', true);
8982 },
8983 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
8984 this.__cfg.zIndex = zIndex;
8985
8986 if (!Util.isNil(this.get('parent'))) {
8987 this.get('parent').sort();
8988 }
8989 return zIndex;
8990 },
8991 _setAttrs: function _setAttrs(attrs) {
8992 this.attr(attrs);
8993 return attrs;
8994 },
8995 setZIndex: function setZIndex(zIndex) {
8996 this.__cfg.zIndex = zIndex;
8997 return zIndex;
8998 },
8999 clone: function clone() {
9000 return Util.clone(this);
9001 },
9002 getBBox: function getBBox() {
9003 return {
9004 minX: 0,
9005 maxX: 0,
9006 minY: 0,
9007 maxY: 0
9008 };
9009 }
9010});
9011
9012module.exports = Element;
9013
9014/***/ }),
9015/* 56 */
9016/***/ (function(module, exports, __webpack_require__) {
9017
9018var Util = __webpack_require__(0);
9019var Shape = __webpack_require__(1);
9020var Inside = __webpack_require__(3);
9021
9022var Circle = function Circle(cfg) {
9023 Circle.superclass.constructor.call(this, cfg);
9024};
9025
9026Circle.ATTRS = {
9027 x: 0,
9028 y: 0,
9029 r: 0,
9030 lineWidth: 1
9031};
9032
9033Util.extend(Circle, Shape);
9034
9035Util.augment(Circle, {
9036 canFill: true,
9037 canStroke: true,
9038 type: 'circle',
9039 getDefaultAttrs: function getDefaultAttrs() {
9040 return {
9041 lineWidth: 1
9042 };
9043 },
9044 calculateBox: function calculateBox() {
9045 var attrs = this.__attrs;
9046 var cx = attrs.x;
9047 var cy = attrs.y;
9048 var r = attrs.r;
9049 var lineWidth = this.getHitLineWidth();
9050 var halfWidth = lineWidth / 2 + r;
9051 return {
9052 minX: cx - halfWidth,
9053 minY: cy - halfWidth,
9054 maxX: cx + halfWidth,
9055 maxY: cy + halfWidth
9056 };
9057 },
9058 isPointInPath: function isPointInPath(x, y) {
9059 var fill = this.hasFill();
9060 var stroke = this.hasStroke();
9061 if (fill && stroke) {
9062 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
9063 }
9064
9065 if (fill) {
9066 return this._isPointInFill(x, y);
9067 }
9068
9069 if (stroke) {
9070 return this._isPointInStroke(x, y);
9071 }
9072
9073 return false;
9074 },
9075 _isPointInFill: function _isPointInFill(x, y) {
9076 var attrs = this.__attrs;
9077 var cx = attrs.x;
9078 var cy = attrs.y;
9079 var r = attrs.r;
9080
9081 return Inside.circle(cx, cy, r, x, y);
9082 },
9083 _isPointInStroke: function _isPointInStroke(x, y) {
9084 var attrs = this.__attrs;
9085 var cx = attrs.x;
9086 var cy = attrs.y;
9087 var r = attrs.r;
9088 var lineWidth = this.getHitLineWidth();
9089
9090 return Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y);
9091 },
9092 createPath: function createPath(context) {
9093 var attrs = this.__attrs;
9094 var cx = attrs.x;
9095 var cy = attrs.y;
9096 var r = attrs.r;
9097 context = context || self.get('context');
9098
9099 context.beginPath();
9100 context.arc(cx, cy, r, 0, Math.PI * 2, false);
9101 }
9102});
9103
9104module.exports = Circle;
9105
9106/***/ }),
9107/* 57 */
9108/***/ (function(module, exports, __webpack_require__) {
9109
9110var Util = __webpack_require__(0);
9111var Shape = __webpack_require__(1);
9112var Inside = __webpack_require__(3);
9113var mat3 = __webpack_require__(2).mat3;
9114var vec3 = __webpack_require__(2).vec3;
9115
9116var Ellipse = function Ellipse(cfg) {
9117 Ellipse.superclass.constructor.call(this, cfg);
9118};
9119
9120Ellipse.ATTRS = {
9121 x: 0,
9122 y: 0,
9123 rx: 1,
9124 ry: 1,
9125 lineWidth: 1
9126};
9127
9128Util.extend(Ellipse, Shape);
9129
9130Util.augment(Ellipse, {
9131 canFill: true,
9132 canStroke: true,
9133 type: 'ellipse',
9134 getDefaultAttrs: function getDefaultAttrs() {
9135 return {
9136 lineWidth: 1
9137 };
9138 },
9139 calculateBox: function calculateBox() {
9140 var attrs = this.__attrs;
9141 var cx = attrs.x;
9142 var cy = attrs.y;
9143 var rx = attrs.rx;
9144 var ry = attrs.ry;
9145 var lineWidth = this.getHitLineWidth();
9146 var halfXWidth = rx + lineWidth / 2;
9147 var halfYWidth = ry + lineWidth / 2;
9148
9149 return {
9150 minX: cx - halfXWidth,
9151 minY: cy - halfYWidth,
9152 maxX: cx + halfXWidth,
9153 maxY: cy + halfYWidth
9154 };
9155 },
9156 isPointInPath: function isPointInPath(x, y) {
9157 var fill = this.hasFill();
9158 var stroke = this.hasStroke();
9159
9160 if (fill && stroke) {
9161 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
9162 }
9163
9164 if (fill) {
9165 return this._isPointInFill(x, y);
9166 }
9167
9168 if (stroke) {
9169 return this._isPointInStroke(x, y);
9170 }
9171
9172 return false;
9173 },
9174 _isPointInFill: function _isPointInFill(x, y) {
9175 var attrs = this.__attrs;
9176 var cx = attrs.x;
9177 var cy = attrs.y;
9178 var rx = attrs.rx;
9179 var ry = attrs.ry;
9180
9181 var r = rx > ry ? rx : ry;
9182 var scaleX = rx > ry ? 1 : rx / ry;
9183 var scaleY = rx > ry ? ry / rx : 1;
9184
9185 var p = [x, y, 1];
9186 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
9187 mat3.scale(m, m, [scaleX, scaleY]);
9188 mat3.translate(m, m, [cx, cy]);
9189 var inm = mat3.invert([], m);
9190 vec3.transformMat3(p, p, inm);
9191
9192 return Inside.circle(0, 0, r, p[0], p[1]);
9193 },
9194 _isPointInStroke: function _isPointInStroke(x, y) {
9195 var attrs = this.__attrs;
9196 var cx = attrs.x;
9197 var cy = attrs.y;
9198 var rx = attrs.rx;
9199 var ry = attrs.ry;
9200 var lineWidth = this.getHitLineWidth();
9201
9202 var r = rx > ry ? rx : ry;
9203 var scaleX = rx > ry ? 1 : rx / ry;
9204 var scaleY = rx > ry ? ry / rx : 1;
9205 var p = [x, y, 1];
9206 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
9207 mat3.scale(m, m, [scaleX, scaleY]);
9208 mat3.translate(m, m, [cx, cy]);
9209 var inm = mat3.invert([], m);
9210 vec3.transformMat3(p, p, inm);
9211
9212 return Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]);
9213 },
9214 createPath: function createPath(context) {
9215 var attrs = this.__attrs;
9216 var cx = attrs.x;
9217 var cy = attrs.y;
9218 var rx = attrs.rx;
9219 var ry = attrs.ry;
9220
9221 context = context || self.get('context');
9222 var r = rx > ry ? rx : ry;
9223 var scaleX = rx > ry ? 1 : rx / ry;
9224 var scaleY = rx > ry ? ry / rx : 1;
9225
9226 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
9227 mat3.scale(m, m, [scaleX, scaleY]);
9228 mat3.translate(m, m, [cx, cy]);
9229 context.beginPath();
9230 context.save();
9231 context.transform(m[0], m[1], m[3], m[4], m[6], m[7]);
9232 context.arc(0, 0, r, 0, Math.PI * 2);
9233 context.restore();
9234 context.closePath();
9235 }
9236});
9237
9238module.exports = Ellipse;
9239
9240/***/ }),
9241/* 58 */
9242/***/ (function(module, exports, __webpack_require__) {
9243
9244var Util = __webpack_require__(0);
9245var Shape = __webpack_require__(1);
9246var PathSegment = __webpack_require__(26);
9247var Format = __webpack_require__(21);
9248var Arrow = __webpack_require__(6);
9249var PathUtil = __webpack_require__(15);
9250var CubicMath = __webpack_require__(12);
9251
9252var Path = function Path(cfg) {
9253 Path.superclass.constructor.call(this, cfg);
9254};
9255
9256Path.ATTRS = {
9257 path: null,
9258 lineWidth: 1,
9259 curve: null, // 曲线path
9260 tCache: null,
9261 startArrow: false,
9262 endArrow: false
9263};
9264
9265Util.extend(Path, Shape);
9266
9267Util.augment(Path, {
9268 canFill: true,
9269 canStroke: true,
9270 type: 'path',
9271 getDefaultAttrs: function getDefaultAttrs() {
9272 return {
9273 lineWidth: 1,
9274 startArrow: false,
9275 endArrow: false
9276 };
9277 },
9278 _afterSetAttrPath: function _afterSetAttrPath(path) {
9279 var self = this;
9280 if (Util.isNil(path)) {
9281 self.setSilent('segments', null);
9282 self.setSilent('box', undefined);
9283 return;
9284 }
9285 var pathArray = Format.parsePath(path);
9286 var preSegment = void 0;
9287 var segments = [];
9288
9289 if (!Util.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {
9290 return;
9291 }
9292 var count = pathArray.length;
9293 for (var i = 0; i < pathArray.length; i++) {
9294 var item = pathArray[i];
9295 preSegment = new PathSegment(item, preSegment, i === count - 1);
9296 segments.push(preSegment);
9297 }
9298 self.setSilent('segments', segments);
9299 self.set('tCache', null);
9300 this.setSilent('box', null);
9301 },
9302 _afterSetAttrAll: function _afterSetAttrAll(objs) {
9303 if (objs.path) {
9304 this._afterSetAttrPath(objs.path);
9305 }
9306 },
9307 calculateBox: function calculateBox() {
9308 var self = this;
9309 var segments = self.get('segments');
9310
9311 if (!segments) {
9312 return null;
9313 }
9314 var lineWidth = this.getHitLineWidth();
9315 var minX = Infinity;
9316 var maxX = -Infinity;
9317 var minY = Infinity;
9318 var maxY = -Infinity;
9319 Util.each(segments, function (segment) {
9320 segment.getBBox(lineWidth);
9321 var box = segment.box;
9322 if (box) {
9323 if (box.minX < minX) {
9324 minX = box.minX;
9325 }
9326
9327 if (box.maxX > maxX) {
9328 maxX = box.maxX;
9329 }
9330
9331 if (box.minY < minY) {
9332 minY = box.minY;
9333 }
9334
9335 if (box.maxY > maxY) {
9336 maxY = box.maxY;
9337 }
9338 }
9339 });
9340 return {
9341 minX: minX,
9342 minY: minY,
9343 maxX: maxX,
9344 maxY: maxY
9345 };
9346 },
9347 isPointInPath: function isPointInPath(x, y) {
9348 var self = this;
9349 var fill = self.hasFill();
9350 var stroke = self.hasStroke();
9351
9352 if (fill && stroke) {
9353 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
9354 }
9355
9356 if (fill) {
9357 return self._isPointInFill(x, y);
9358 }
9359
9360 if (stroke) {
9361 return self._isPointInStroke(x, y);
9362 }
9363
9364 return false;
9365 },
9366 _isPointInFill: function _isPointInFill(x, y) {
9367 var self = this;
9368 var context = self.get('context');
9369 if (!context) return undefined;
9370 self.createPath();
9371 return context.isPointInPath(x, y);
9372 },
9373 _isPointInStroke: function _isPointInStroke(x, y) {
9374 var self = this;
9375 var segments = self.get('segments');
9376 if (!Util.isEmpty(segments)) {
9377 var lineWidth = self.getHitLineWidth();
9378 for (var i = 0, l = segments.length; i < l; i++) {
9379 if (segments[i].isInside(x, y, lineWidth)) {
9380 return true;
9381 }
9382 }
9383 }
9384
9385 return false;
9386 },
9387 _setTcache: function _setTcache() {
9388 var totalLength = 0;
9389 var tempLength = 0;
9390 var tCache = [];
9391 var segmentT = void 0;
9392 var segmentL = void 0;
9393 var segmentN = void 0;
9394 var l = void 0;
9395 var curve = this.curve;
9396
9397 if (!curve) {
9398 return;
9399 }
9400
9401 Util.each(curve, function (segment, i) {
9402 segmentN = curve[i + 1];
9403 l = segment.length;
9404 if (segmentN) {
9405 totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
9406 }
9407 });
9408
9409 Util.each(curve, function (segment, i) {
9410 segmentN = curve[i + 1];
9411 l = segment.length;
9412 if (segmentN) {
9413 segmentT = [];
9414 segmentT[0] = tempLength / totalLength;
9415 segmentL = CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
9416 tempLength += segmentL;
9417 segmentT[1] = tempLength / totalLength;
9418 tCache.push(segmentT);
9419 }
9420 });
9421
9422 this.tCache = tCache;
9423 },
9424 _calculateCurve: function _calculateCurve() {
9425 var self = this;
9426 var attrs = self.__attrs;
9427 var path = attrs.path;
9428 this.curve = PathUtil.pathTocurve(path);
9429 },
9430 getPoint: function getPoint(t) {
9431 var tCache = this.tCache;
9432 var subt = void 0;
9433 var index = void 0;
9434
9435 if (!tCache) {
9436 this._calculateCurve();
9437 this._setTcache();
9438 tCache = this.tCache;
9439 }
9440
9441 var curve = this.curve;
9442
9443 if (!tCache) {
9444 if (curve) {
9445 return {
9446 x: curve[0][1],
9447 y: curve[0][2]
9448 };
9449 }
9450 return null;
9451 }
9452 Util.each(tCache, function (v, i) {
9453 if (t >= v[0] && t <= v[1]) {
9454 subt = (t - v[0]) / (v[1] - v[0]);
9455 index = i;
9456 }
9457 });
9458 var seg = curve[index];
9459 if (Util.isNil(seg) || Util.isNil(index)) {
9460 return null;
9461 }
9462 var l = seg.length;
9463 var nextSeg = curve[index + 1];
9464 return {
9465 x: CubicMath.at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
9466 y: CubicMath.at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
9467 };
9468 },
9469 createPath: function createPath(context) {
9470 var self = this;
9471 var segments = self.get('segments');
9472 if (!Util.isArray(segments)) return;
9473
9474 context = context || self.get('context');
9475
9476 context.beginPath();
9477 var segmentsLen = segments.length;
9478
9479 for (var i = 0; i < segmentsLen; i++) {
9480 segments[i].draw(context);
9481 }
9482 },
9483 afterPath: function afterPath(context) {
9484 var self = this;
9485 var attrs = self.__attrs;
9486 var segments = self.get('segments');
9487 var path = attrs.path;
9488 var startPoint = void 0,
9489 endPoint = void 0,
9490 tangent = void 0;
9491 context = context || self.get('context');
9492 if (!Util.isArray(segments)) return;
9493 if (!attrs.startArrow && !attrs.endArrow) {
9494 return;
9495 }
9496 if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) {
9497 // 闭合路径不绘制箭头
9498 return;
9499 }
9500 var segmentsLen = segments.length;
9501 if (segmentsLen > 1) {
9502 startPoint = segments[0].endPoint;
9503 endPoint = segments[1].endPoint;
9504 tangent = segments[1].startTangent;
9505 if (Util.isFunction(tangent)) {
9506 var v = tangent();
9507 Arrow.addStartArrow(context, attrs, startPoint.x - v[0], startPoint.y - v[1], startPoint.x, startPoint.y);
9508 } else {
9509 Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y);
9510 }
9511 }
9512
9513 if (segmentsLen > 1 && !closed) {
9514 startPoint = segments[segmentsLen - 2].endPoint;
9515 endPoint = segments[segmentsLen - 1].endPoint;
9516 tangent = segments[segmentsLen - 1].endTangent;
9517 if (Util.isFunction(tangent)) {
9518 var _v = tangent();
9519 Arrow.addEndArrow(context, attrs, endPoint.x - _v[0], endPoint.y - _v[1], endPoint.x, endPoint.y, tangent());
9520 } else {
9521 Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y);
9522 }
9523 }
9524 }
9525});
9526
9527module.exports = Path;
9528
9529/***/ }),
9530/* 59 */
9531/***/ (function(module, exports, __webpack_require__) {
9532
9533var Util = __webpack_require__(0);
9534var Shape = __webpack_require__(1);
9535var Inside = __webpack_require__(3);
9536
9537var CText = function CText(cfg) {
9538 CText.superclass.constructor.call(this, cfg);
9539};
9540
9541CText.ATTRS = {
9542 x: 0,
9543 y: 0,
9544 text: null,
9545 fontSize: 12,
9546 fontFamily: 'sans-serif',
9547 fontStyle: 'normal',
9548 fontWeight: 'normal',
9549 fontVariant: 'normal',
9550 textAlign: 'start',
9551 textBaseline: 'bottom',
9552 lineHeight: null,
9553 textArr: null
9554};
9555
9556Util.extend(CText, Shape);
9557
9558Util.augment(CText, {
9559 canFill: true,
9560 canStroke: true,
9561 type: 'text',
9562 getDefaultAttrs: function getDefaultAttrs() {
9563 return {
9564 lineWidth: 1,
9565 lineCount: 1,
9566 fontSize: 12,
9567 fontFamily: 'sans-serif',
9568 fontStyle: 'normal',
9569 fontWeight: 'normal',
9570 fontVariant: 'normal',
9571 textAlign: 'start',
9572 textBaseline: 'bottom'
9573 };
9574 },
9575 initTransform: function initTransform() {
9576 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
9577 var fontSize = this.__attrs.fontSize;
9578 if (fontSize && +fontSize < 12) {
9579 // 小于 12 像素的文本进行 scale 处理
9580 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
9581 }
9582 },
9583 _assembleFont: function _assembleFont() {
9584 // var self = this;
9585 var attrs = this.__attrs;
9586 var fontSize = attrs.fontSize;
9587 var fontFamily = attrs.fontFamily;
9588 var fontWeight = attrs.fontWeight;
9589 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
9590 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
9591 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
9592 attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
9593 },
9594 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
9595 /* this.attr({
9596 height: this.__getTextHeight()
9597 }); */
9598 this._assembleFont();
9599 },
9600 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
9601 this._assembleFont();
9602 },
9603 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
9604 this._assembleFont();
9605 },
9606 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
9607 this._assembleFont();
9608 },
9609 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
9610 this._assembleFont();
9611 },
9612 _afterSetAttrFont: function _afterSetAttrFont() {
9613 // this.attr('width', this.measureText());
9614 },
9615 _afterSetAttrText: function _afterSetAttrText() {
9616 var attrs = this.__attrs;
9617 var text = attrs.text;
9618 var textArr = void 0;
9619 if (Util.isString(text) && text.indexOf('\n') !== -1) {
9620 textArr = text.split('\n');
9621 var lineCount = textArr.length;
9622 attrs.lineCount = lineCount;
9623 attrs.textArr = textArr;
9624 }
9625 // attrs.height = this.__getTextHeight();
9626 // attrs.width = this.measureText();
9627 },
9628 _getTextHeight: function _getTextHeight() {
9629 var attrs = this.__attrs;
9630 var lineCount = attrs.lineCount;
9631 var fontSize = attrs.fontSize * 1;
9632 if (lineCount > 1) {
9633 var spaceingY = this._getSpaceingY();
9634 return fontSize * lineCount + spaceingY * (lineCount - 1);
9635 }
9636 return fontSize;
9637 },
9638
9639 // 计算浪费,效率低,待优化
9640 _afterSetAttrAll: function _afterSetAttrAll(objs) {
9641 var self = this;
9642 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
9643 self._assembleFont();
9644 }
9645
9646 if ('text' in objs) {
9647 self._afterSetAttrText(objs.text);
9648 }
9649 },
9650 isHitBox: function isHitBox() {
9651 return false;
9652 },
9653 calculateBox: function calculateBox() {
9654 var self = this;
9655 var attrs = self.__attrs;
9656 var x = attrs.x;
9657 var y = attrs.y;
9658 var width = self.measureText(); // attrs.width
9659 if (!width) {
9660 // 如果width不存在,四点共其实点
9661 return {
9662 minX: x,
9663 minY: y,
9664 maxX: x,
9665 maxY: y
9666 };
9667 }
9668 var height = self._getTextHeight(); // attrs.height
9669 var textAlign = attrs.textAlign;
9670 var textBaseline = attrs.textBaseline;
9671 var lineWidth = self.getHitLineWidth();
9672 var point = {
9673 x: x,
9674 y: y - height
9675 };
9676
9677 if (textAlign) {
9678 if (textAlign === 'end' || textAlign === 'right') {
9679 point.x -= width;
9680 } else if (textAlign === 'center') {
9681 point.x -= width / 2;
9682 }
9683 }
9684
9685 if (textBaseline) {
9686 if (textBaseline === 'top') {
9687 point.y += height;
9688 } else if (textBaseline === 'middle') {
9689 point.y += height / 2;
9690 }
9691 }
9692
9693 this.set('startPoint', point);
9694 var halfWidth = lineWidth / 2;
9695 return {
9696 minX: point.x - halfWidth,
9697 minY: point.y - halfWidth,
9698 maxX: point.x + width + halfWidth,
9699 maxY: point.y + height + halfWidth
9700 };
9701 },
9702 _getSpaceingY: function _getSpaceingY() {
9703 var attrs = this.__attrs;
9704 var lineHeight = attrs.lineHeight;
9705 var fontSize = attrs.fontSize * 1;
9706 return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
9707 },
9708 isPointInPath: function isPointInPath(x, y) {
9709 var self = this;
9710 var box = self.getBBox();
9711 if (self.hasFill() || self.hasStroke()) {
9712 return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y);
9713 }
9714 },
9715 drawInner: function drawInner(context) {
9716 var self = this;
9717 var attrs = self.__attrs;
9718 var text = attrs.text;
9719 if (!text) {
9720 return;
9721 }
9722 var textArr = attrs.textArr;
9723 var x = attrs.x;
9724 var y = attrs.y;
9725
9726 context.beginPath();
9727 if (self.hasStroke()) {
9728 if (textArr) {
9729 self._drawTextArr(context, false);
9730 } else {
9731 context.strokeText(text, x, y);
9732 }
9733 }
9734 if (self.hasFill()) {
9735 var fillOpacity = attrs.fillOpacity;
9736 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
9737 context.globalAlpha = fillOpacity;
9738 }
9739 if (textArr) {
9740 self._drawTextArr(context, true);
9741 } else {
9742 context.fillText(text, x, y);
9743 }
9744 }
9745 },
9746 _drawTextArr: function _drawTextArr(context, fill) {
9747 var textArr = this.__attrs.textArr;
9748 var textBaseline = this.__attrs.textBaseline;
9749 var fontSize = this.__attrs.fontSize * 1;
9750 var spaceingY = this._getSpaceingY();
9751 var x = this.__attrs.x;
9752 var y = this.__attrs.y;
9753 var box = this.getBBox();
9754 var height = box.maxY - box.minY;
9755 var subY = void 0;
9756
9757 Util.each(textArr, function (subText, index) {
9758 subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;
9759 if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;
9760 if (textBaseline === 'top') subY += height - fontSize;
9761 if (fill) {
9762 context.fillText(subText, x, subY);
9763 } else {
9764 context.strokeText(subText, x, subY);
9765 }
9766 });
9767 },
9768 measureText: function measureText() {
9769 var self = this;
9770 var attrs = self.__attrs;
9771 var text = attrs.text;
9772 var font = attrs.font;
9773 var textArr = attrs.textArr;
9774 var measureWidth = void 0;
9775 var width = 0;
9776
9777 if (Util.isNil(text)) return undefined;
9778 var context = document.createElement('canvas').getContext('2d');
9779 context.save();
9780 context.font = font;
9781 if (textArr) {
9782 Util.each(textArr, function (subText) {
9783 measureWidth = context.measureText(subText).width;
9784 if (width < measureWidth) {
9785 width = measureWidth;
9786 }
9787 context.restore();
9788 });
9789 } else {
9790 width = context.measureText(text).width;
9791 context.restore();
9792 }
9793 return width;
9794 }
9795});
9796
9797module.exports = CText;
9798
9799/***/ }),
9800/* 60 */
9801/***/ (function(module, exports, __webpack_require__) {
9802
9803var Util = __webpack_require__(0);
9804var Shape = __webpack_require__(1);
9805var Inside = __webpack_require__(3);
9806var Arrow = __webpack_require__(6);
9807var LineMath = __webpack_require__(22);
9808
9809var Line = function Line(cfg) {
9810 Line.superclass.constructor.call(this, cfg);
9811};
9812
9813Line.ATTRS = {
9814 x1: 0,
9815 y1: 0,
9816 x2: 0,
9817 y2: 0,
9818 lineWidth: 1,
9819 startArrow: false,
9820 endArrow: false
9821};
9822
9823Util.extend(Line, Shape);
9824
9825Util.augment(Line, {
9826 canStroke: true,
9827 type: 'line',
9828 getDefaultAttrs: function getDefaultAttrs() {
9829 return {
9830 lineWidth: 1,
9831 startArrow: false,
9832 endArrow: false
9833 };
9834 },
9835 calculateBox: function calculateBox() {
9836 var attrs = this.__attrs;
9837 var x1 = attrs.x1,
9838 y1 = attrs.y1,
9839 x2 = attrs.x2,
9840 y2 = attrs.y2;
9841
9842 var lineWidth = this.getHitLineWidth();
9843 return LineMath.box(x1, y1, x2, y2, lineWidth);
9844 },
9845 isPointInPath: function isPointInPath(x, y) {
9846 var attrs = this.__attrs;
9847 var x1 = attrs.x1,
9848 y1 = attrs.y1,
9849 x2 = attrs.x2,
9850 y2 = attrs.y2;
9851
9852 var lineWidth = this.getHitLineWidth();
9853
9854 if (this.hasStroke()) {
9855 return Inside.line(x1, y1, x2, y2, lineWidth, x, y);
9856 }
9857
9858 return false;
9859 },
9860 createPath: function createPath(context) {
9861 var attrs = this.__attrs;
9862 var x1 = attrs.x1,
9863 y1 = attrs.y1,
9864 x2 = attrs.x2,
9865 y2 = attrs.y2;
9866
9867 context = context || self.get('context');
9868 context.beginPath();
9869 context.moveTo(x1, y1);
9870 context.lineTo(x2, y2);
9871 },
9872 afterPath: function afterPath(context) {
9873 var attrs = this.__attrs;
9874 var x1 = attrs.x1,
9875 y1 = attrs.y1,
9876 x2 = attrs.x2,
9877 y2 = attrs.y2;
9878
9879 context = context || this.get('context');
9880 if (attrs.startArrow) {
9881 Arrow.addStartArrow(context, attrs, x2, y2, x1, y1);
9882 }
9883 if (attrs.endArrow) {
9884 Arrow.addEndArrow(context, attrs, x1, y1, x2, y2);
9885 }
9886 },
9887 getPoint: function getPoint(t) {
9888 var attrs = this.__attrs;
9889 return {
9890 x: LineMath.at(attrs.x1, attrs.x2, t),
9891 y: LineMath.at(attrs.y1, attrs.y2, t)
9892 };
9893 }
9894});
9895
9896module.exports = Line;
9897
9898/***/ }),
9899/* 61 */
9900/***/ (function(module, exports, __webpack_require__) {
9901
9902var Util = __webpack_require__(0);
9903var Shape = __webpack_require__(1);
9904var Inside = __webpack_require__(3);
9905
9906var CImage = function CImage(cfg) {
9907 CImage.superclass.constructor.call(this, cfg);
9908};
9909
9910CImage.ATTRS = {
9911 x: 0,
9912 y: 0,
9913 img: undefined,
9914 width: 0,
9915 height: 0,
9916 sx: null,
9917 sy: null,
9918 swidth: null,
9919 sheight: null
9920};
9921
9922Util.extend(CImage, Shape);
9923
9924Util.augment(CImage, {
9925 type: 'image',
9926 _afterSetAttrImg: function _afterSetAttrImg(img) {
9927 this._setAttrImg(img);
9928 },
9929 _afterSetAttrAll: function _afterSetAttrAll(params) {
9930 if (params.img) {
9931 this._setAttrImg(params.img);
9932 }
9933 },
9934 isHitBox: function isHitBox() {
9935 return false;
9936 },
9937 calculateBox: function calculateBox() {
9938 var attrs = this.__attrs;
9939 var x = attrs.x;
9940 var y = attrs.y;
9941 var width = attrs.width;
9942 var height = attrs.height;
9943
9944 return {
9945 minX: x,
9946 minY: y,
9947 maxX: x + width,
9948 maxY: y + height
9949 };
9950 },
9951 isPointInPath: function isPointInPath(x, y) {
9952 var attrs = this.__attrs;
9953 if (this.get('toDraw') || !attrs.img) {
9954 return false;
9955 }
9956 var rx = attrs.x;
9957 var ry = attrs.y;
9958 var width = attrs.width;
9959 var height = attrs.height;
9960 return Inside.rect(rx, ry, width, height, x, y);
9961 },
9962 _beforeSetLoading: function _beforeSetLoading(loading) {
9963 var canvas = this.get('canvas');
9964 if (loading === false && this.get('toDraw') === true) {
9965 this.__cfg.loading = false;
9966 canvas.draw();
9967 }
9968 return loading;
9969 },
9970 _setAttrImg: function _setAttrImg(img) {
9971 var self = this;
9972 var attrs = self.__attrs;
9973 if (Util.isString(img)) {
9974 var image = new Image();
9975 image.onload = function () {
9976 if (self.get('destroyed')) return false;
9977 self.attr('imgSrc', img);
9978 self.attr('img', image);
9979 var callback = self.get('callback');
9980 if (callback) {
9981 callback.call(self);
9982 }
9983 self.set('loading', false);
9984 };
9985 image.src = img;
9986 self.set('loading', true);
9987 } else if (img instanceof Image) {
9988 if (!attrs.width) {
9989 self.attr('width', img.width);
9990 }
9991
9992 if (!attrs.height) {
9993 self.attr('height', img.height);
9994 }
9995 return img;
9996 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
9997 if (!attrs.width) {
9998 self.attr('width', Number(img.getAttribute('width')));
9999 }
10000
10001 if (!attrs.height) {
10002 self.attr('height', Number(img.getAttribute('height')));
10003 }
10004 return img;
10005 } else if (img instanceof ImageData) {
10006 if (!attrs.width) {
10007 self.attr('width', img.width);
10008 }
10009
10010 if (!attrs.height) {
10011 self.attr('height', img.height);
10012 }
10013 return img;
10014 } else {
10015 return null;
10016 }
10017 },
10018 drawInner: function drawInner(context) {
10019 if (this.get('loading')) {
10020 this.set('toDraw', true);
10021 return;
10022 }
10023 this._drawImage(context);
10024 },
10025 _drawImage: function _drawImage(context) {
10026 var attrs = this.__attrs;
10027 var x = attrs.x;
10028 var y = attrs.y;
10029 var image = attrs.img;
10030 var width = attrs.width;
10031 var height = attrs.height;
10032 var sx = attrs.sx;
10033 var sy = attrs.sy;
10034 var swidth = attrs.swidth;
10035 var sheight = attrs.sheight;
10036 this.set('toDraw', false);
10037
10038 var img = image;
10039 if (img instanceof ImageData) {
10040 img = new Image();
10041 img.src = image;
10042 }
10043 if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
10044 if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) {
10045 context.drawImage(img, x, y, width, height);
10046 return;
10047 }
10048 if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) {
10049 context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);
10050 return;
10051 }
10052 }
10053 return;
10054 }
10055});
10056
10057module.exports = CImage;
10058
10059/***/ }),
10060/* 62 */
10061/***/ (function(module, exports, __webpack_require__) {
10062
10063var Util = __webpack_require__(0);
10064var Shape = __webpack_require__(1);
10065var Inside = __webpack_require__(3);
10066
10067var Polygon = function Polygon(cfg) {
10068 Polygon.superclass.constructor.call(this, cfg);
10069};
10070
10071Polygon.ATTRS = {
10072 points: null,
10073 lineWidth: 1
10074};
10075
10076Util.extend(Polygon, Shape);
10077
10078Util.augment(Polygon, {
10079 canFill: true,
10080 canStroke: true,
10081 type: 'polygon',
10082 getDefaultAttrs: function getDefaultAttrs() {
10083 return {
10084 lineWidth: 1
10085 };
10086 },
10087 calculateBox: function calculateBox() {
10088 var self = this;
10089 var attrs = self.__attrs;
10090 var points = attrs.points;
10091 var lineWidth = this.getHitLineWidth();
10092 if (!points || points.length === 0) {
10093 return null;
10094 }
10095 var minX = Infinity;
10096 var minY = Infinity;
10097 var maxX = -Infinity;
10098 var maxY = -Infinity;
10099
10100 Util.each(points, function (point) {
10101 var x = point[0];
10102 var y = point[1];
10103 if (x < minX) {
10104 minX = x;
10105 }
10106 if (x > maxX) {
10107 maxX = x;
10108 }
10109
10110 if (y < minY) {
10111 minY = y;
10112 }
10113
10114 if (y > maxY) {
10115 maxY = y;
10116 }
10117 });
10118
10119 var halfWidth = lineWidth / 2;
10120 return {
10121 minX: minX - halfWidth,
10122 minY: minY - halfWidth,
10123 maxX: maxX + halfWidth,
10124 maxY: maxY + halfWidth
10125 };
10126 },
10127 isPointInPath: function isPointInPath(x, y) {
10128 var self = this;
10129 var fill = self.hasFill();
10130 var stroke = self.hasStroke();
10131
10132 if (fill && stroke) {
10133 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
10134 }
10135
10136 if (fill) {
10137 return self._isPointInFill(x, y);
10138 }
10139
10140 if (stroke) {
10141 return self._isPointInStroke(x, y);
10142 }
10143
10144 return false;
10145 },
10146 _isPointInFill: function _isPointInFill(x, y) {
10147 var self = this;
10148 var context = self.get('context');
10149 self.createPath();
10150 return context.isPointInPath(x, y);
10151 },
10152 _isPointInStroke: function _isPointInStroke(x, y) {
10153 var self = this;
10154 var attrs = self.__attrs;
10155 var points = attrs.points;
10156 if (points.length < 2) {
10157 return false;
10158 }
10159 var lineWidth = this.getHitLineWidth();
10160 var outPoints = points.slice(0);
10161 if (points.length >= 3) {
10162 outPoints.push(points[0]);
10163 }
10164
10165 return Inside.polyline(outPoints, lineWidth, x, y);
10166 },
10167 createPath: function createPath(context) {
10168 var self = this;
10169 var attrs = self.__attrs;
10170 var points = attrs.points;
10171 if (points.length < 2) {
10172 return;
10173 }
10174 context = context || self.get('context');
10175 context.beginPath();
10176 Util.each(points, function (point, index) {
10177 if (index === 0) {
10178 context.moveTo(point[0], point[1]);
10179 } else {
10180 context.lineTo(point[0], point[1]);
10181 }
10182 });
10183 context.closePath();
10184 }
10185});
10186
10187module.exports = Polygon;
10188
10189/***/ }),
10190/* 63 */
10191/***/ (function(module, exports, __webpack_require__) {
10192
10193var Util = __webpack_require__(0);
10194var Shape = __webpack_require__(1);
10195var Inside = __webpack_require__(3);
10196var Arrow = __webpack_require__(6);
10197var LineMath = __webpack_require__(22);
10198
10199var Polyline = function Polyline(cfg) {
10200 Polyline.superclass.constructor.call(this, cfg);
10201};
10202
10203Polyline.ATTRS = {
10204 points: null,
10205 lineWidth: 1,
10206 startArrow: false,
10207 endArrow: false,
10208 tCache: null
10209};
10210
10211Util.extend(Polyline, Shape);
10212
10213Util.augment(Polyline, {
10214 canStroke: true,
10215 type: 'polyline',
10216 tCache: null, // 缓存各点的t
10217 getDefaultAttrs: function getDefaultAttrs() {
10218 return {
10219 lineWidth: 1,
10220 startArrow: false,
10221 endArrow: false
10222 };
10223 },
10224 calculateBox: function calculateBox() {
10225 var self = this;
10226 var attrs = self.__attrs;
10227 var lineWidth = this.getHitLineWidth();
10228 var points = attrs.points;
10229 if (!points || points.length === 0) {
10230 return null;
10231 }
10232 var minX = Infinity;
10233 var minY = Infinity;
10234 var maxX = -Infinity;
10235 var maxY = -Infinity;
10236
10237 Util.each(points, function (point) {
10238 var x = point[0];
10239 var y = point[1];
10240 if (x < minX) {
10241 minX = x;
10242 }
10243 if (x > maxX) {
10244 maxX = x;
10245 }
10246
10247 if (y < minY) {
10248 minY = y;
10249 }
10250
10251 if (y > maxY) {
10252 maxY = y;
10253 }
10254 });
10255
10256 var halfWidth = lineWidth / 2;
10257 return {
10258 minX: minX - halfWidth,
10259 minY: minY - halfWidth,
10260 maxX: maxX + halfWidth,
10261 maxY: maxY + halfWidth
10262 };
10263 },
10264 _setTcache: function _setTcache() {
10265 var self = this;
10266 var attrs = self.__attrs;
10267 var points = attrs.points;
10268 var totalLength = 0;
10269 var tempLength = 0;
10270 var tCache = [];
10271 var segmentT = void 0;
10272 var segmentL = void 0;
10273 if (!points || points.length === 0) {
10274 return;
10275 }
10276
10277 Util.each(points, function (p, i) {
10278 if (points[i + 1]) {
10279 totalLength += LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
10280 }
10281 });
10282 if (totalLength <= 0) {
10283 return;
10284 }
10285 Util.each(points, function (p, i) {
10286 if (points[i + 1]) {
10287 segmentT = [];
10288 segmentT[0] = tempLength / totalLength;
10289 segmentL = LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
10290 tempLength += segmentL;
10291 segmentT[1] = tempLength / totalLength;
10292 tCache.push(segmentT);
10293 }
10294 });
10295 this.tCache = tCache;
10296 },
10297 isPointInPath: function isPointInPath(x, y) {
10298 var self = this;
10299 var attrs = self.__attrs;
10300 if (self.hasStroke()) {
10301 var points = attrs.points;
10302 if (points.length < 2) {
10303 return false;
10304 }
10305 var lineWidth = attrs.lineWidth;
10306 return Inside.polyline(points, lineWidth, x, y);
10307 }
10308 return false;
10309 },
10310 createPath: function createPath(context) {
10311 var self = this;
10312 var attrs = self.__attrs;
10313 var points = attrs.points;
10314 var l = void 0;
10315 var i = void 0;
10316
10317 if (points.length < 2) {
10318 return;
10319 }
10320 context = context || self.get('context');
10321 context.beginPath();
10322
10323 context.moveTo(points[0][0], points[0][1]);
10324 for (i = 1, l = points.length - 1; i < l; i++) {
10325 context.lineTo(points[i][0], points[i][1]);
10326 }
10327 context.lineTo(points[l][0], points[l][1]);
10328 },
10329 afterPath: function afterPath(context) {
10330 var self = this;
10331 var attrs = self.__attrs;
10332 var points = attrs.points;
10333 var l = points.length - 1;
10334 context = context || self.get('context');
10335
10336 if (attrs.startArrow) {
10337 Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]);
10338 }
10339 if (attrs.endArrow) {
10340 Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]);
10341 }
10342 },
10343 getPoint: function getPoint(t) {
10344 var attrs = this.__attrs;
10345 var points = attrs.points;
10346 var tCache = this.tCache;
10347 var subt = void 0;
10348 var index = void 0;
10349 if (!tCache) {
10350 this._setTcache();
10351 tCache = this.tCache;
10352 }
10353 Util.each(tCache, function (v, i) {
10354 if (t >= v[0] && t <= v[1]) {
10355 subt = (t - v[0]) / (v[1] - v[0]);
10356 index = i;
10357 }
10358 });
10359 return {
10360 x: LineMath.at(points[index][0], points[index + 1][0], subt),
10361 y: LineMath.at(points[index][1], points[index + 1][1], subt)
10362 };
10363 }
10364});
10365
10366module.exports = Polyline;
10367
10368/***/ }),
10369/* 64 */
10370/***/ (function(module, exports, __webpack_require__) {
10371
10372var Util = __webpack_require__(0);
10373var Shape = __webpack_require__(1);
10374var Inside = __webpack_require__(3);
10375var ArcMath = __webpack_require__(24);
10376var Arrow = __webpack_require__(6);
10377
10378function _getArcX(x, radius, angle) {
10379 return x + radius * Math.cos(angle);
10380}
10381function _getArcY(y, radius, angle) {
10382 return y + radius * Math.sin(angle);
10383}
10384
10385var Arc = function Arc(cfg) {
10386 Arc.superclass.constructor.call(this, cfg);
10387};
10388
10389Arc.ATTRS = {
10390 x: 0,
10391 y: 0,
10392 r: 0,
10393 startAngle: 0,
10394 endAngle: 0,
10395 clockwise: false,
10396 lineWidth: 1,
10397 startArrow: false,
10398 endArrow: false
10399};
10400
10401Util.extend(Arc, Shape);
10402
10403Util.augment(Arc, {
10404 canStroke: true,
10405 type: 'arc',
10406 getDefaultAttrs: function getDefaultAttrs() {
10407 return {
10408 x: 0,
10409 y: 0,
10410 r: 0,
10411 startAngle: 0,
10412 endAngle: 0,
10413 clockwise: false,
10414 lineWidth: 1,
10415 startArrow: false,
10416 endArrow: false
10417 };
10418 },
10419 calculateBox: function calculateBox() {
10420 var attrs = this.__attrs;
10421 var x = attrs.x,
10422 y = attrs.y,
10423 r = attrs.r,
10424 startAngle = attrs.startAngle,
10425 endAngle = attrs.endAngle,
10426 clockwise = attrs.clockwise;
10427
10428 var lineWidth = this.getHitLineWidth();
10429 var halfWidth = lineWidth / 2;
10430 var box = ArcMath.box(x, y, r, startAngle, endAngle, clockwise);
10431 box.minX -= halfWidth;
10432 box.minY -= halfWidth;
10433 box.maxX += halfWidth;
10434 box.maxY += halfWidth;
10435 return box;
10436 },
10437 isPointInPath: function isPointInPath(x, y) {
10438 var attrs = this.__attrs;
10439 var cx = attrs.x;
10440 var cy = attrs.y;
10441 var r = attrs.r,
10442 startAngle = attrs.startAngle,
10443 endAngle = attrs.endAngle,
10444 clockwise = attrs.clockwise;
10445
10446 var lineWidth = this.getHitLineWidth();
10447 if (this.hasStroke()) {
10448 return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y);
10449 }
10450 return false;
10451 },
10452 createPath: function createPath(context) {
10453 var attrs = this.__attrs;
10454 var x = attrs.x,
10455 y = attrs.y,
10456 r = attrs.r,
10457 startAngle = attrs.startAngle,
10458 endAngle = attrs.endAngle,
10459 clockwise = attrs.clockwise;
10460
10461 context = context || self.get('context');
10462
10463 context.beginPath();
10464 context.arc(x, y, r, startAngle, endAngle, clockwise);
10465 },
10466 afterPath: function afterPath(context) {
10467 var attrs = this.__attrs;
10468 var x = attrs.x,
10469 y = attrs.y,
10470 r = attrs.r,
10471 startAngle = attrs.startAngle,
10472 endAngle = attrs.endAngle,
10473 clockwise = attrs.clockwise;
10474
10475 context = context || this.get('context');
10476 var diff = void 0;
10477 var x1 = void 0;
10478 var y1 = void 0;
10479 var x2 = void 0;
10480 var y2 = void 0;
10481
10482 if (attrs.startArrow) {
10483 diff = Math.PI / 180;
10484 if (clockwise) {
10485 diff *= -1;
10486 }
10487 x1 = _getArcX(x, r, startAngle + diff);
10488 y1 = _getArcY(y, r, startAngle + diff);
10489 x2 = _getArcX(x, r, startAngle);
10490 y2 = _getArcY(y, r, startAngle);
10491 Arrow.addStartArrow(context, attrs, x1, y1, x2, y2);
10492 }
10493
10494 if (attrs.endArrow) {
10495 diff = Math.PI / 180;
10496 if (clockwise) {
10497 diff *= -1;
10498 }
10499 x1 = _getArcX(x, r, endAngle + diff);
10500 y1 = _getArcY(y, r, endAngle + diff);
10501 x2 = _getArcX(x, r, endAngle);
10502 y2 = _getArcY(y, r, endAngle);
10503 Arrow.addEndArrow(context, attrs, x2, y2, x1, y1);
10504 }
10505 }
10506});
10507
10508module.exports = Arc;
10509
10510/***/ }),
10511/* 65 */
10512/***/ (function(module, exports, __webpack_require__) {
10513
10514var Util = __webpack_require__(0);
10515var Shape = __webpack_require__(1);
10516var Inside = __webpack_require__(3);
10517var ArcMath = __webpack_require__(24);
10518var vec2 = __webpack_require__(2).vec2;
10519
10520var Fan = function Fan(cfg) {
10521 Fan.superclass.constructor.call(this, cfg);
10522};
10523
10524Fan.ATTRS = {
10525 x: 0,
10526 y: 0,
10527 rs: 0,
10528 re: 0,
10529 startAngle: 0,
10530 endAngle: 0,
10531 clockwise: false,
10532 lineWidth: 1
10533};
10534
10535Util.extend(Fan, Shape);
10536
10537Util.augment(Fan, {
10538 canFill: true,
10539 canStroke: true,
10540 type: 'fan',
10541 getDefaultAttrs: function getDefaultAttrs() {
10542 return {
10543 clockwise: false,
10544 lineWidth: 1,
10545 rs: 0,
10546 re: 0
10547 };
10548 },
10549 calculateBox: function calculateBox() {
10550 var self = this;
10551 var attrs = self.__attrs;
10552 var cx = attrs.x;
10553 var cy = attrs.y;
10554 var rs = attrs.rs;
10555 var re = attrs.re;
10556 var startAngle = attrs.startAngle;
10557 var endAngle = attrs.endAngle;
10558 var clockwise = attrs.clockwise;
10559 var lineWidth = this.getHitLineWidth();
10560
10561 var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise);
10562 var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise);
10563 var minX = Math.min(boxs.minX, boxe.minX);
10564 var minY = Math.min(boxs.minY, boxe.minY);
10565 var maxX = Math.max(boxs.maxX, boxe.maxX);
10566 var maxY = Math.max(boxs.maxY, boxe.maxY);
10567
10568 var halfWidth = lineWidth / 2;
10569 return {
10570 minX: minX - halfWidth,
10571 minY: minY - halfWidth,
10572 maxX: maxX + halfWidth,
10573 maxY: maxY + halfWidth
10574 };
10575 },
10576 isPointInPath: function isPointInPath(x, y) {
10577 var fill = this.hasFill();
10578 var stroke = this.hasStroke();
10579
10580 if (fill && stroke) {
10581 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
10582 }
10583
10584 if (fill) {
10585 return this._isPointInFill(x, y);
10586 }
10587
10588 if (stroke) {
10589 return this._isPointInStroke(x, y);
10590 }
10591 return false;
10592 },
10593 _isPointInFill: function _isPointInFill(x, y) {
10594 var attrs = this.__attrs;
10595 var cx = attrs.x;
10596 var cy = attrs.y;
10597 var rs = attrs.rs;
10598 var re = attrs.re;
10599 var startAngle = attrs.startAngle;
10600 var endAngle = attrs.endAngle;
10601 var clockwise = attrs.clockwise;
10602 var v1 = [1, 0];
10603 var subv = [x - cx, y - cy];
10604 var angle = vec2.angleTo(v1, subv);
10605
10606 var angle1 = ArcMath.nearAngle(angle, startAngle, endAngle, clockwise);
10607
10608 if (Util.isNumberEqual(angle, angle1)) {
10609 var ls = vec2.squaredLength(subv);
10610 if (rs * rs <= ls && ls <= re * re) {
10611 return true;
10612 }
10613 }
10614 return false;
10615 },
10616 _isPointInStroke: function _isPointInStroke(x, y) {
10617 var attrs = this.__attrs;
10618 var cx = attrs.x;
10619 var cy = attrs.y;
10620 var rs = attrs.rs;
10621 var re = attrs.re;
10622 var startAngle = attrs.startAngle;
10623 var endAngle = attrs.endAngle;
10624 var clockwise = attrs.clockwise;
10625 var lineWidth = this.getHitLineWidth();
10626
10627 var ssp = {
10628 x: Math.cos(startAngle) * rs + cx,
10629 y: Math.sin(startAngle) * rs + cy
10630 };
10631 var sep = {
10632 x: Math.cos(startAngle) * re + cx,
10633 y: Math.sin(startAngle) * re + cy
10634 };
10635 var esp = {
10636 x: Math.cos(endAngle) * rs + cx,
10637 y: Math.sin(endAngle) * rs + cy
10638 };
10639 var eep = {
10640 x: Math.cos(endAngle) * re + cx,
10641 y: Math.sin(endAngle) * re + cy
10642 };
10643
10644 if (Inside.line(ssp.x, ssp.y, sep.x, sep.y, lineWidth, x, y)) {
10645 return true;
10646 }
10647
10648 if (Inside.line(esp.x, esp.y, eep.x, eep.y, lineWidth, x, y)) {
10649 return true;
10650 }
10651
10652 if (Inside.arcline(cx, cy, rs, startAngle, endAngle, clockwise, lineWidth, x, y)) {
10653 return true;
10654 }
10655
10656 if (Inside.arcline(cx, cy, re, startAngle, endAngle, clockwise, lineWidth, x, y)) {
10657 return true;
10658 }
10659
10660 return false;
10661 },
10662 createPath: function createPath(context) {
10663 var attrs = this.__attrs;
10664 var cx = attrs.x;
10665 var cy = attrs.y;
10666 var rs = attrs.rs;
10667 var re = attrs.re;
10668 var startAngle = attrs.startAngle;
10669 var endAngle = attrs.endAngle;
10670 var clockwise = attrs.clockwise;
10671
10672 var ssp = {
10673 x: Math.cos(startAngle) * rs + cx,
10674 y: Math.sin(startAngle) * rs + cy
10675 };
10676 var sep = {
10677 x: Math.cos(startAngle) * re + cx,
10678 y: Math.sin(startAngle) * re + cy
10679 };
10680 var esp = {
10681 x: Math.cos(endAngle) * rs + cx,
10682 y: Math.sin(endAngle) * rs + cy
10683 };
10684
10685 context = context || self.get('context');
10686 context.beginPath();
10687 context.moveTo(ssp.x, ssp.y);
10688 context.lineTo(sep.x, sep.y);
10689 context.arc(cx, cy, re, startAngle, endAngle, clockwise);
10690 context.lineTo(esp.x, esp.y);
10691 context.arc(cx, cy, rs, endAngle, startAngle, !clockwise);
10692 context.closePath();
10693 }
10694});
10695
10696module.exports = Fan;
10697
10698/***/ }),
10699/* 66 */
10700/***/ (function(module, exports, __webpack_require__) {
10701
10702var Util = __webpack_require__(0);
10703var Shape = __webpack_require__(1);
10704var Inside = __webpack_require__(3);
10705var Arrow = __webpack_require__(6);
10706var CubicMath = __webpack_require__(12);
10707
10708var Cubic = function Cubic(cfg) {
10709 Cubic.superclass.constructor.call(this, cfg);
10710};
10711
10712Cubic.ATTRS = {
10713 p1: null, // 起始点
10714 p2: null, // 第一个控制点
10715 p3: null, // 第二个控制点
10716 p4: null, // 终点
10717 lineWidth: 1,
10718 startArrow: false,
10719 endArrow: false
10720};
10721
10722Util.extend(Cubic, Shape);
10723
10724Util.augment(Cubic, {
10725 canStroke: true,
10726 type: 'cubic',
10727 getDefaultAttrs: function getDefaultAttrs() {
10728 return {
10729 lineWidth: 1,
10730 startArrow: false,
10731 endArrow: false
10732 };
10733 },
10734 calculateBox: function calculateBox() {
10735 var attrs = this.__attrs;
10736 var p1 = attrs.p1,
10737 p2 = attrs.p2,
10738 p3 = attrs.p3,
10739 p4 = attrs.p4;
10740
10741 var lineWidth = this.getHitLineWidth();
10742 var i = void 0;
10743 var l = void 0;
10744
10745 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
10746 return null;
10747 }
10748 var halfWidth = lineWidth / 2;
10749
10750 var xDim = CubicMath.extrema(p1[0], p2[0], p3[0], p4[0]);
10751 for (i = 0, l = xDim.length; i < l; i++) {
10752 xDim[i] = CubicMath.at(p1[0], p2[0], p3[0], p4[0], xDim[i]);
10753 }
10754 var yDim = CubicMath.extrema(p1[1], p2[1], p3[1], p4[1]);
10755 for (i = 0, l = yDim.length; i < l; i++) {
10756 yDim[i] = CubicMath.at(p1[1], p2[1], p3[1], p4[1], yDim[i]);
10757 }
10758 xDim.push(p1[0], p4[0]);
10759 yDim.push(p1[1], p4[1]);
10760
10761 return {
10762 minX: Math.min.apply(Math, xDim) - halfWidth,
10763 maxX: Math.max.apply(Math, xDim) + halfWidth,
10764 minY: Math.min.apply(Math, yDim) - halfWidth,
10765 maxY: Math.max.apply(Math, yDim) + halfWidth
10766 };
10767 },
10768 isPointInPath: function isPointInPath(x, y) {
10769 var attrs = this.__attrs;
10770 var p1 = attrs.p1,
10771 p2 = attrs.p2,
10772 p3 = attrs.p3,
10773 p4 = attrs.p4;
10774
10775 var lineWidth = this.getHitLineWidth();
10776 return Inside.cubicline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], p4[0], p4[1], lineWidth, x, y);
10777 },
10778 createPath: function createPath(context) {
10779 var attrs = this.__attrs;
10780 var p1 = attrs.p1,
10781 p2 = attrs.p2,
10782 p3 = attrs.p3,
10783 p4 = attrs.p4;
10784
10785 context = context || self.get('context');
10786 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
10787 return;
10788 }
10789 context.beginPath();
10790 context.moveTo(p1[0], p1[1]);
10791 context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]);
10792 },
10793 afterPath: function afterPath(context) {
10794 var attrs = this.__attrs;
10795 var p1 = attrs.p1,
10796 p2 = attrs.p2,
10797 p3 = attrs.p3,
10798 p4 = attrs.p4;
10799
10800 context = context || this.get('context');
10801 if (attrs.startArrow) {
10802 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
10803 }
10804 if (attrs.endArrow) {
10805 Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]);
10806 }
10807 },
10808 getPoint: function getPoint(t) {
10809 var attrs = this.__attrs;
10810 return {
10811 x: CubicMath.at(attrs.p4[0], attrs.p3[0], attrs.p2[0], attrs.p1[0], t),
10812 y: CubicMath.at(attrs.p4[1], attrs.p3[1], attrs.p2[1], attrs.p1[1], t)
10813 };
10814 }
10815});
10816
10817module.exports = Cubic;
10818
10819/***/ }),
10820/* 67 */
10821/***/ (function(module, exports, __webpack_require__) {
10822
10823var Util = __webpack_require__(0);
10824var Shape = __webpack_require__(1);
10825var Inside = __webpack_require__(3);
10826var Arrow = __webpack_require__(6);
10827var QuadraticMath = __webpack_require__(23);
10828
10829var Quadratic = function Quadratic(cfg) {
10830 Quadratic.superclass.constructor.call(this, cfg);
10831};
10832
10833Quadratic.ATTRS = {
10834 p1: null, // 起始点
10835 p2: null, // 控制点
10836 p3: null, // 结束点
10837 lineWidth: 1,
10838 startArrow: false,
10839 endArrow: false
10840};
10841
10842Util.extend(Quadratic, Shape);
10843
10844Util.augment(Quadratic, {
10845 canStroke: true,
10846 type: 'quadratic',
10847 getDefaultAttrs: function getDefaultAttrs() {
10848 return {
10849 lineWidth: 1,
10850 startArrow: false,
10851 endArrow: false
10852 };
10853 },
10854 calculateBox: function calculateBox() {
10855 var self = this;
10856 var attrs = self.__attrs;
10857 var p1 = attrs.p1,
10858 p2 = attrs.p2,
10859 p3 = attrs.p3;
10860
10861 var lineWidth = this.getHitLineWidth();
10862 var i = void 0;
10863 var l = void 0;
10864
10865 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
10866 return null;
10867 }
10868 var halfWidth = lineWidth / 2;
10869 var xDims = QuadraticMath.extrema(p1[0], p2[0], p3[0]);
10870 for (i = 0, l = xDims.length; i < l; i++) {
10871 xDims[i] = QuadraticMath.at(p1[0], p2[0], p3[0], xDims[i]);
10872 }
10873 xDims.push(p1[0], p3[0]);
10874 var yDims = QuadraticMath.extrema(p1[1], p2[1], p3[1]);
10875 for (i = 0, l = yDims.length; i < l; i++) {
10876 yDims[i] = QuadraticMath.at(p1[1], p2[1], p3[1], yDims[i]);
10877 }
10878 yDims.push(p1[1], p3[1]);
10879
10880 return {
10881 minX: Math.min.apply(Math, xDims) - halfWidth,
10882 maxX: Math.max.apply(Math, xDims) + halfWidth,
10883 minY: Math.min.apply(Math, yDims) - halfWidth,
10884 maxY: Math.max.apply(Math, yDims) + halfWidth
10885 };
10886 },
10887 isPointInPath: function isPointInPath(x, y) {
10888 var self = this;
10889 var attrs = self.__attrs;
10890 var p1 = attrs.p1,
10891 p2 = attrs.p2,
10892 p3 = attrs.p3;
10893
10894 var lineWidth = this.getHitLineWidth();
10895
10896 return Inside.quadraticline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], lineWidth, x, y);
10897 },
10898 createPath: function createPath(context) {
10899 var self = this;
10900 var attrs = self.__attrs;
10901 var p1 = attrs.p1,
10902 p2 = attrs.p2,
10903 p3 = attrs.p3;
10904
10905
10906 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
10907 return;
10908 }
10909 context = context || self.get('context');
10910 context.beginPath();
10911 context.moveTo(p1[0], p1[1]);
10912 context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]);
10913 },
10914 afterPath: function afterPath(context) {
10915 var self = this;
10916 var attrs = self.__attrs;
10917 var p1 = attrs.p1,
10918 p2 = attrs.p2,
10919 p3 = attrs.p3;
10920
10921 context = context || self.get('context');
10922
10923 if (attrs.startArrow) {
10924 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
10925 }
10926
10927 if (attrs.endArrow) {
10928 Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]);
10929 }
10930 },
10931 getPoint: function getPoint(t) {
10932 var attrs = this.__attrs;
10933 return {
10934 x: QuadraticMath.at(attrs.p1[0], attrs.p2[0], attrs.p3[0], t),
10935 y: QuadraticMath.at(attrs.p1[1], attrs.p2[1], attrs.p3[1], t)
10936 };
10937 }
10938});
10939
10940module.exports = Quadratic;
10941
10942/***/ }),
10943/* 68 */
10944/***/ (function(module, exports, __webpack_require__) {
10945
10946/**
10947 * @fileOverview Interaction
10948 * @author leungwensen@gmail.com
10949 */
10950
10951var Interactions = {
10952 Base: __webpack_require__(9),
10953 Brush: __webpack_require__(119),
10954 Drag: __webpack_require__(120),
10955 Zoom: __webpack_require__(121),
10956 helper: {
10957 bindInteraction: __webpack_require__(122)
10958 }
10959};
10960
10961module.exports = Interactions;
10962
10963/***/ }),
10964/* 69 */
10965/***/ (function(module, exports, __webpack_require__) {
10966
10967module.exports = {
10968 // renderers
10969 svg: __webpack_require__(70),
10970 canvas: __webpack_require__(110),
10971 // utils
10972 CommonUtil: __webpack_require__(7),
10973 DomUtil: __webpack_require__(29),
10974 MatrixUtil: __webpack_require__(2),
10975 PathUtil: __webpack_require__(15),
10976 // version, etc.
10977 version: '3.0.0-beta.4'
10978};
10979
10980/***/ }),
10981/* 70 */
10982/***/ (function(module, exports, __webpack_require__) {
10983
10984module.exports = {
10985 Canvas: __webpack_require__(71),
10986 Group: __webpack_require__(31),
10987 Shape: __webpack_require__(4),
10988 Rect: __webpack_require__(42),
10989 Circle: __webpack_require__(43),
10990 Ellipse: __webpack_require__(44),
10991 Path: __webpack_require__(45),
10992 Text: __webpack_require__(46),
10993 Line: __webpack_require__(47),
10994 Image: __webpack_require__(48),
10995 Polygon: __webpack_require__(49),
10996 Marker: __webpack_require__(50),
10997 Dom: __webpack_require__(51),
10998 Fan: __webpack_require__(52),
10999 Event: __webpack_require__(30)
11000};
11001
11002/***/ }),
11003/* 71 */
11004/***/ (function(module, exports, __webpack_require__) {
11005
11006var Util = __webpack_require__(0);
11007var Event = __webpack_require__(30);
11008var Group = __webpack_require__(31);
11009var Defs = __webpack_require__(105);
11010
11011var Canvas = function Canvas(cfg) {
11012 Canvas.superclass.constructor.call(this, cfg);
11013};
11014
11015var defs = new Defs();
11016
11017Canvas.CFG = {
11018 eventEnable: true,
11019 /**
11020 * 像素宽度
11021 * @type {Number}
11022 */
11023 width: null,
11024 /**
11025 * 像素高度
11026 * @type {Number}
11027 */
11028 height: null,
11029 /**
11030 * 画布宽度
11031 * @type {Number}
11032 */
11033 widthCanvas: null,
11034 /**
11035 * 画布高度
11036 * @type {Number}
11037 */
11038 heightCanvas: null,
11039 /**
11040 * CSS宽
11041 * CSS宽
11042 * @type {String}
11043 */
11044 widthStyle: null,
11045 /**
11046 * CSS高
11047 * @type {String}
11048 */
11049 heightStyle: null,
11050 /**
11051 * 容器DOM
11052 * @type {Object}
11053 */
11054 containerDOM: null,
11055 /**
11056 * 当前Canvas的DOM
11057 * @type {Object}
11058 */
11059 canvasDOM: null,
11060 /**
11061 * 屏幕像素比
11062 * @type {Number}
11063 */
11064 pixelRatio: Util.getRatio()
11065};
11066
11067Util.extend(Canvas, Group);
11068
11069Util.augment(Canvas, {
11070 init: function init() {
11071 Canvas.superclass.init.call(this);
11072 this._setDOM();
11073 this._setInitSize();
11074 // this._scale();
11075 if (this.get('eventEnable')) {
11076 this._registEvents();
11077 }
11078 },
11079 getEmitter: function getEmitter(element, event) {
11080 if (element) {
11081 if (Util.isEmpty(element._getEvents())) {
11082 var parent = element.get('parent');
11083 if (parent && !event.propagationStopped) {
11084 return this.getEmitter(parent, event);
11085 }
11086 } else {
11087 return element;
11088 }
11089 }
11090 },
11091 _getEventObj: function _getEventObj(type, e, point, target) {
11092 var event = new Event(type, e, true, true);
11093 event.x = point.x;
11094 event.y = point.y;
11095 event.clientX = e.clientX;
11096 event.clientY = e.clientY;
11097 event.currentTarget = target;
11098 event.target = target;
11099 return event;
11100 },
11101 _triggerEvent: function _triggerEvent(type, e) {
11102 var point = this.getPointByClient(e.clientX, e.clientY);
11103 var shape = this.findShape(e.srcElement);
11104 var emitObj = void 0;
11105 if (type === 'mousemove') {
11106 var preShape = this.get('preShape');
11107 if (preShape && preShape !== shape) {
11108 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
11109 emitObj = this.getEmitter(preShape, e);
11110 emitObj && emitObj.emit('mouseleave', mouseleave);
11111 }
11112
11113 if (shape) {
11114 var mousemove = this._getEventObj('mousemove', e, point, shape);
11115 emitObj = this.getEmitter(shape, e);
11116 emitObj && emitObj.emit('mousemove', mousemove);
11117
11118 if (preShape !== shape) {
11119 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
11120 emitObj && emitObj.emit('mouseenter', mouseenter, e);
11121 }
11122 } else {
11123 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
11124 this.emit('mousemove', canvasmousemove);
11125 }
11126 this.set('preShape', shape);
11127 } else {
11128 var event = this._getEventObj(type, e, point, shape || this);
11129 emitObj = this.getEmitter(shape, e);
11130 if (emitObj && emitObj !== this) {
11131 emitObj.emit(type, event);
11132 }
11133 this.emit(type, event);
11134 }
11135
11136 var el = this.get('el');
11137 if (shape && !shape.get('destroyed')) {
11138 el.style.cursor = shape.attr('cursor') || 'default';
11139 }
11140 },
11141 _registEvents: function _registEvents() {
11142 var self = this;
11143 var el = self.get('el');
11144 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
11145
11146 Util.each(events, function (event) {
11147 el.addEventListener(event, function (e) {
11148 self._triggerEvent(event, e);
11149 }, false);
11150 });
11151 el.addEventListener('touchstart', function (e) {
11152 if (!Util.isEmpty(e.touches)) {
11153 self._triggerEvent('touchstart', e.touches[0]);
11154 }
11155 }, false);
11156
11157 el.addEventListener('touchmove', function (e) {
11158 if (!Util.isEmpty(e.touches)) {
11159 self._triggerEvent('touchmove', e.touches[0]);
11160 }
11161 }, false);
11162
11163 el.addEventListener('touchend', function (e) {
11164 if (!Util.isEmpty(e.changedTouches)) {
11165 self._triggerEvent('touchend', e.changedTouches[0]);
11166 }
11167 }, false);
11168 },
11169 _setDOM: function _setDOM() {
11170 this._setContainer();
11171 this._setLayer();
11172 },
11173 _setContainer: function _setContainer() {
11174 var containerId = this.get('containerId');
11175 var containerDOM = this.get('containerDOM');
11176 if (!containerDOM) {
11177 containerDOM = document.getElementById(containerId);
11178 this.set('containerDOM', containerDOM);
11179 }
11180 Util.modifyCSS(containerDOM, {
11181 position: 'relative'
11182 });
11183 },
11184 _setLayer: function _setLayer() {
11185 var containerDOM = this.get('containerDOM');
11186 var canvasId = Util.uniqueId('svg_');
11187 if (containerDOM) {
11188 var _canvasDOM = Util.createDom('<svg id="' + canvasId + '"></svg>');
11189 containerDOM.appendChild(_canvasDOM);
11190 _canvasDOM.appendChild(defs.get('el'));
11191 this.set('canvasDOM', _canvasDOM);
11192 this.set('el', _canvasDOM);
11193 this.set('defs', defs);
11194 this.set('canvas', this);
11195 }
11196 var canvasDOM = this.get('canvasDOM');
11197 this.set('context', canvasDOM);
11198 },
11199 _setInitSize: function _setInitSize() {
11200 this.changeSize(this.get('width'), this.get('height'));
11201 this.set('pixelRatio', 1);
11202 },
11203 _resize: function _resize() {
11204 var canvasDOM = this.get('canvasDOM');
11205 var widthCanvas = this.get('widthCanvas');
11206 var heightCanvas = this.get('heightCanvas');
11207 var widthStyle = this.get('widthStyle');
11208 var heightStyle = this.get('heightStyle');
11209
11210 canvasDOM.style.width = widthStyle;
11211 canvasDOM.style.height = heightStyle;
11212 canvasDOM.setAttribute('width', widthCanvas);
11213 canvasDOM.setAttribute('height', heightCanvas);
11214 },
11215 getWidth: function getWidth() {
11216 return this.get('width');
11217 },
11218 getHeight: function getHeight() {
11219 return this.get('height');
11220 },
11221 changeSize: function changeSize(width, height) {
11222 this.set('widthCanvas', width);
11223 this.set('heightCanvas', height);
11224 this.set('widthStyle', width + 'px');
11225 this.set('heightStyle', height + 'px');
11226 this.set('width', width);
11227 this.set('height', height);
11228 this._resize();
11229 },
11230
11231 /**
11232 * 将窗口坐标转变成 canvas 坐标
11233 * @param {Number} clientX 窗口x坐标
11234 * @param {Number} clientY 窗口y坐标
11235 * @return {Object} canvas坐标
11236 */
11237 getPointByClient: function getPointByClient(clientX, clientY) {
11238 var el = this.get('el');
11239 var bbox = el.getBoundingClientRect();
11240 return {
11241 x: clientX - bbox.left,
11242 y: clientY - bbox.top
11243 };
11244 },
11245 getClientByPoint: function getClientByPoint(x, y) {
11246 var el = this.get('el');
11247 var bbox = el.getBoundingClientRect();
11248 return {
11249 clientX: x + bbox.left,
11250 clientY: y + bbox.top
11251 };
11252 },
11253 beforeDraw: function beforeDraw() {
11254 var el = this.get('el');
11255 // canvas版本用盖一个canvas大小的矩阵清空画布,svg换成清空html
11256 el.innerHTML = '';
11257 },
11258 _beginDraw: function _beginDraw() {
11259 this.setSilent('toDraw', true);
11260 },
11261 _endDraw: function _endDraw() {
11262 this.setSilent('toDraw', false);
11263 },
11264
11265 // svg实时渲染,兼容canvas版本留个空接口
11266 draw: function draw() {},
11267 destroy: function destroy() {
11268 var containerDOM = this.get('containerDOM');
11269 var canvasDOM = this.get('canvasDOM');
11270 if (canvasDOM && containerDOM) {
11271 containerDOM.removeChild(canvasDOM);
11272 }
11273 Canvas.superclass.destroy.call(this);
11274 }
11275});
11276
11277module.exports = Canvas;
11278
11279/***/ }),
11280/* 72 */
11281/***/ (function(module, exports, __webpack_require__) {
11282
11283var Util = __webpack_require__(0);
11284
11285var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
11286var CAPITALIZED_ATTRS_MAP = {
11287 r: 'R',
11288 opacity: 'Opacity',
11289 lineWidth: 'LineWidth',
11290 clip: 'Clip',
11291 stroke: 'Stroke',
11292 fill: 'Fill',
11293 strokeOpacity: 'Stroke',
11294 fillOpacity: 'Fill',
11295 x: 'X',
11296 y: 'Y',
11297 rx: 'Rx',
11298 ry: 'Ry',
11299 re: 'Re',
11300 rs: 'Rs',
11301 width: 'Width',
11302 height: 'Height',
11303 img: 'Img',
11304 x1: 'X1',
11305 x2: 'X2',
11306 y1: 'Y1',
11307 y2: 'Y2',
11308 points: 'Points',
11309 p1: 'P1',
11310 p2: 'P2',
11311 p3: 'P3',
11312 p4: 'P4',
11313 text: 'Text',
11314 radius: 'Radius',
11315 textAlign: 'TextAlign',
11316 textBaseline: 'TextBaseline',
11317 font: 'Font',
11318 fontSize: 'FontSize',
11319 fontStyle: 'FontStyle',
11320 fontVariant: 'FontVariant',
11321 fontWeight: 'FontWeight',
11322 fontFamily: 'FontFamily',
11323 clockwise: 'Clockwise',
11324 startAngle: 'StartAngle',
11325 endAngle: 'EndAngle',
11326 path: 'Path',
11327 outline: 'Outline',
11328 html: 'Html'
11329};
11330var SVG_ATTR_MAP = {
11331 opacity: 'opacity',
11332 clip: 'clip',
11333 stroke: 'stroke',
11334 fill: 'fill',
11335 strokeOpacity: 'stroke-opacity',
11336 fillOpacity: 'fill-opacity',
11337 strokeStyle: 'stroke',
11338 fillStyle: 'fill',
11339 x: 'x',
11340 y: 'y',
11341 r: 'r',
11342 rx: 'rx',
11343 ry: 'ry',
11344 re: 're',
11345 rs: 'rs',
11346 width: 'width',
11347 height: 'height',
11348 image: 'href',
11349 x1: 'x1',
11350 x2: 'x2',
11351 y1: 'y1',
11352 y2: 'y2',
11353 lineCap: 'stroke-linecap',
11354 lineJoin: 'stroke-linejoin',
11355 lineWidth: 'stroke-width',
11356 lineDash: 'stroke-dasharray',
11357 miterLimit: 'stroke-miterlimit',
11358 font: 'font',
11359 fontSize: 'font-size',
11360 fontStyle: 'font-style',
11361 fontVariant: 'font-variant',
11362 fontWeight: 'font-weight',
11363 fontFamily: 'font-family',
11364 startArrow: 'marker-start',
11365 endArrow: 'marker-end',
11366 preserveAspectRatio: 'preserveAspectRatio'
11367};
11368var ALIAS_ATTRS_MAP = {
11369 stroke: 'strokeStyle',
11370 fill: 'fillStyle',
11371 opacity: 'globalAlpha'
11372};
11373
11374module.exports = {
11375 canFill: false,
11376 canStroke: false,
11377 initAttrs: function initAttrs(attrs) {
11378 this.__attrs = {
11379 opacity: 1,
11380 fillOpacity: 1,
11381 strokeOpacity: 1
11382 };
11383 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
11384 return this;
11385 },
11386 getDefaultAttrs: function getDefaultAttrs() {
11387 return {};
11388 },
11389
11390 /**
11391 * 设置或者设置属性,有以下 4 种情形:
11392 * - name 不存在, 则返回属性集合
11393 * - name 为字符串,value 为空,获取属性值
11394 * - name 为字符串,value 不为空,设置属性值,返回 this
11395 * - name 为键值对,value 为空,设置属性值
11396 *
11397 * @param {String | Object} name 属性名
11398 * @param {*} value 属性值
11399 * @return {*} 属性值
11400 */
11401 attr: function attr(name, value) {
11402 var self = this;
11403 if (arguments.length === 0) {
11404 return self.__attrs;
11405 }
11406 if (Util.isObject(name)) {
11407 for (var k in name) {
11408 if (ALIAS_ATTRS.indexOf(k) === -1) {
11409 var v = name[k];
11410 self._setAttr(k, v);
11411 }
11412 }
11413 if (self._afterSetAttrAll) {
11414 self._afterSetAttrAll(name);
11415 }
11416 // self.setSilent('box', null);
11417 self.clearBBox();
11418 return self;
11419 }
11420 if (arguments.length === 2) {
11421 self._setAttr(name, value);
11422 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
11423 if (CAPITALIZED_ATTRS_MAP[name] && self[m]) {
11424 self[m](value);
11425 }
11426 self.clearBBox();
11427 return self;
11428 }
11429 return self._getAttr(name);
11430 },
11431 clearBBox: function clearBBox() {
11432 this.setSilent('box', null);
11433 },
11434 _afterSetAttrAll: function _afterSetAttrAll() {},
11435
11436 // 属性获取触发函数
11437 _getAttr: function _getAttr(name) {
11438 return this.__attrs[name];
11439 },
11440
11441 // 属性设置触发函数
11442 _setAttr: function _setAttr(name, value) {
11443 var self = this;
11444 var el = self.get('el');
11445
11446 if (name === 'clip') {
11447 self._setAttrClip(name, value);
11448 return;
11449 }
11450 self.__attrs[name] = value;
11451 if (typeof value === 'number' && isNaN(value)) {
11452 return;
11453 }
11454 if (self.get('destroyed')) {
11455 return;
11456 }
11457 if (name === 'transform' || name === 'rotate') {
11458 self._setAttrTrans(name, value);
11459 } else if (name.startsWith('shadow')) {
11460 self._setAttrShadow(name, value);
11461 } else if (~['stroke', 'strokeStyle', 'fill', 'fillStyle'].indexOf(name) && el) {
11462 if (!value) {
11463 el.setAttribute(SVG_ATTR_MAP[name], 'none');
11464 } else if (/^[r,R,L,l]{1}[\s]*\(/.test(value.trim())) {
11465 self._setAttrGradients(name, value.trim());
11466 } else {
11467 el.setAttribute(SVG_ATTR_MAP[name], value);
11468 }
11469 } else if (~name.toLowerCase().indexOf('arrow')) {
11470 if (!value) {
11471 return self;
11472 }
11473 self._setAttrArrow(name, value);
11474 } else {
11475 // 先存好属性,然后对一些svg和canvas中不同的属性进行特判
11476 if (~['circle', 'ellipse', 'marker'].indexOf(self.type) && ~['x', 'y'].indexOf(name)) {
11477 /**
11478 * 本来考虑想写到对应图形里面的,但是x,y又是svg通用属性,这样会同时存在x,y, cx,cy
11479 * 如果在下面svgAttr设置的时候还是要特判,不如就在这边特殊处理一下吧
11480 */
11481 if (self.type !== 'marker' && typeof value === 'number') {
11482 el.setAttribute('c' + name, value);
11483 }
11484 } else {
11485 var svgAttr = SVG_ATTR_MAP[name];
11486 if (el && svgAttr) {
11487 el.setAttribute(svgAttr, value);
11488 }
11489 var alias = ALIAS_ATTRS_MAP[name];
11490 if (alias) {
11491 svgAttr = SVG_ATTR_MAP[alias];
11492 if (el && svgAttr) {
11493 el.setAttribute(svgAttr, value);
11494 }
11495 self.__attrs[alias] = value;
11496 }
11497 }
11498 }
11499 return self;
11500 },
11501 hasFill: function hasFill() {
11502 return this.canFill && this.__attrs.fillStyle;
11503 },
11504 hasStroke: function hasStroke() {
11505 return this.canStroke && this.__attrs.strokeStyle;
11506 },
11507 _setAttrArrow: function _setAttrArrow(name, value) {
11508 var self = this;
11509 var el = self.get('el');
11510 var defs = self.get('defs');
11511 if (!defs) {
11512 var canvas = self.get('canvas');
11513 if (!canvas) {
11514 this._setAttrDependency(name, value);
11515 return this;
11516 }
11517 defs = canvas.get('defs');
11518 }
11519 name = SVG_ATTR_MAP[name];
11520 if (!name) {
11521 return this;
11522 }
11523 if (!value) {
11524 el.removeAttribute(name);
11525 return this;
11526 }
11527 var id = defs.find(name, { value: value, stroke: self.__attrs.stroke });
11528 if (!id) {
11529 id = defs.addArrow(name, value, self.__attrs.stroke);
11530 }
11531 self.__cfg[name] = id;
11532 self.get('el').setAttribute(name, 'url(#' + id + ')');
11533 },
11534 _setAttrShadow: function _setAttrShadow(name, value) {
11535 var attrs = this.__attrs;
11536 var filter = this.get('filter');
11537 var defs = this.get('defs');
11538 if (!value) {
11539 this.get('el').removeAttribute('filter');
11540 return this;
11541 }
11542 if (filter) {
11543 defs.findById(filter).update(name, value);
11544 return this;
11545 }
11546 if (!defs) {
11547 var canvas = this.get('canvas');
11548 if (!canvas) {
11549 this._setAttrDependency(name, value);
11550 return this;
11551 }
11552 defs = canvas.get('defs');
11553 }
11554 var cfg = {
11555 dx: attrs.shadowOffsetX,
11556 dy: attrs.shadowOffsetY,
11557 blur: attrs.shadowBlur,
11558 color: attrs.shadowColor
11559 };
11560 if (isNaN(Number(cfg.dx)) || isNaN(Number(cfg.dy))) {
11561 return this;
11562 }
11563 var id = defs.find('filter', cfg);
11564 if (!id) {
11565 id = defs.addShadow(cfg, this);
11566 }
11567 this.__cfg.filter = id;
11568 this.get('el').setAttribute('filter', 'url(#' + id + ')');
11569 },
11570 _setAttrGradients: function _setAttrGradients(name, value) {
11571 name = name.replace('Style', '');
11572 var defs = this.get('defs');
11573 if (!value) {
11574 this.get('el').removeAttribute('gradient');
11575 return this;
11576 }
11577 if (!defs) {
11578 var canvas = this.get('canvas');
11579 if (!canvas) {
11580 this._setAttrDependency(name, value);
11581 return this;
11582 }
11583 defs = canvas.get('defs');
11584 }
11585 var id = defs.find('gradient', value);
11586 if (!id) {
11587 id = defs.addGradient(value, this);
11588 }
11589 this.get('el').setAttribute(name, 'url(#' + id + ')');
11590 },
11591 _setAttrDependency: function _setAttrDependency(name, value) {
11592 var dependencies = this.get('dependencies');
11593 if (!dependencies) {
11594 dependencies = {};
11595 }
11596 dependencies[name] = value;
11597 this.__cfg.dependencies = dependencies;
11598 return this;
11599 },
11600 _setAttrClip: function _setAttrClip(name, value) {
11601 var defs = this.get('defs');
11602 var canvas = this.get('canvas');
11603 if (!value) {
11604 this.get('el').removeAttribute('clip-path');
11605 return this;
11606 }
11607 if (!defs) {
11608 var _canvas = this.get('canvas');
11609 if (!_canvas) {
11610 this._setAttrDependency(name, value);
11611 return this;
11612 }
11613 defs = _canvas.get('defs');
11614 }
11615 value.__cfg.canvas = canvas;
11616 var id = defs.addClip(value);
11617 this.get('el').setAttribute('clip-path', 'url(#' + id + ')');
11618 },
11619 _setAttrTrans: function _setAttrTrans(name, value) {
11620 var attrs = this.__attrs;
11621 if (!value) {
11622 this.get('el').removeAttribute('transform');
11623 }
11624 if (!attrs.matrix) {
11625 this.initTransform();
11626 }
11627 if (name === 'transform') {
11628 this.transform(value);
11629 } else {
11630 if (typeof attrs.x === 'undefined' || typeof attrs.y === 'undefined') {
11631 this._setAttrDependency(name, value);
11632 return this;
11633 }
11634 this.rotateAtStart(value);
11635 }
11636 return this;
11637 }
11638};
11639
11640/***/ }),
11641/* 73 */
11642/***/ (function(module, exports, __webpack_require__) {
11643
11644var Util = __webpack_require__(0);
11645var mat3 = __webpack_require__(2).mat3;
11646var vec3 = __webpack_require__(2).vec3;
11647
11648// 是否未改变
11649function isUnchanged(m) {
11650 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
11651}
11652
11653// 是否仅仅是scale
11654function isScale(m) {
11655 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
11656}
11657
11658/* function multiple(m1, m2) {
11659 if (!isUnchanged(m2)) {
11660 if (isScale(m2)) {
11661 m1[0] *= m2[0];
11662 m1[4] *= m2[4];
11663 } else {
11664 mat3.multiply(m1, m1, m2);
11665 mat3.multiply(m1, m1, m2);
11666 }
11667 }
11668}*/
11669
11670module.exports = {
11671 initTransform: function initTransform() {
11672 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
11673 },
11674 translate: function translate(tx, ty, perform) {
11675 var matrix = this.attr('matrix');
11676 mat3.translate(matrix, matrix, [tx, ty]);
11677 this.attr('matrix', matrix);
11678 if (arguments.length === 2 || perform) {
11679 this._performTransform();
11680 }
11681 return this;
11682 },
11683 rotate: function rotate(radian, perform) {
11684 var matrix = this.attr('matrix');
11685 if (Math.abs(radian) > Math.PI * 2) {
11686 radian = radian / 180 * Math.PI;
11687 }
11688 mat3.rotate(matrix, matrix, radian);
11689 this.attr('matrix', matrix);
11690 if (arguments.length === 1 || perform) {
11691 this._performTransform();
11692 }
11693 return this;
11694 },
11695
11696 /**
11697 * 绕起始点旋转
11698 * @param {Number} rotate 0~360
11699 */
11700 rotateAtStart: function rotateAtStart(rotate) {
11701 var x = this.attr('x');
11702 var y = this.attr('y');
11703 if (Math.abs(rotate) > Math.PI * 2) {
11704 rotate = rotate / 180 * Math.PI;
11705 }
11706 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
11707 },
11708 scale: function scale(s1, s2, perform) {
11709 var matrix = this.attr('matrix');
11710 mat3.scale(matrix, matrix, [s1, s2]);
11711 this.attr('matrix', matrix);
11712 if (arguments.length === 2 || perform) {
11713 this._performTransform();
11714 }
11715 return this;
11716 },
11717
11718 /**
11719 * 移动的到位置
11720 * @param {Number} x 移动到x
11721 * @param {Number} y 移动到y
11722 */
11723 move: function move(x, y) {
11724 var cx = this.get('x') || 0; // 当前的x
11725 var cy = this.get('y') || 0; // 当前的y
11726 this.translate(x - cx, y - cy);
11727 this.set('x', x);
11728 this.set('y', y);
11729 },
11730 _performTransform: function _performTransform() {
11731 var matrix = this.__attrs.matrix;
11732 var transform = [];
11733 for (var i = 0; i < 9; i += 3) {
11734 transform.push(matrix[i] + ',' + matrix[i + 1]);
11735 }
11736 var el = this.get('el');
11737 if (el) {
11738 el.setAttribute('transform', 'matrix(' + transform.join(',') + ')');
11739 }
11740 },
11741 transform: function transform(ts) {
11742 var self = this;
11743 var matrix = self.attr('matrix');
11744 Util.each(ts, function (t) {
11745 switch (t[0]) {
11746 case 't':
11747 self.translate(t[1], t[2], false);
11748 break;
11749 case 's':
11750 self.scale(t[1], t[2], false);
11751 break;
11752 case 'r':
11753 self.rotate(t[1], false);
11754 break;
11755 case 'm':
11756 self.attr('matrix', mat3.multiply([], matrix, t[1]));
11757 break;
11758 default:
11759 break;
11760 }
11761 });
11762 this._performTransform();
11763 return self;
11764 },
11765 setTransform: function setTransform(ts) {
11766 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
11767 return this.transform(ts);
11768 },
11769 getMatrix: function getMatrix() {
11770 return this.attr('matrix');
11771 },
11772 setMatrix: function setMatrix(m) {
11773 this.attr('matrix', m);
11774 this._performTransform();
11775 this.clearTotalMatrix();
11776 return this;
11777 },
11778 apply: function apply(v, root) {
11779 var m = void 0;
11780 if (root) {
11781 m = this._getMatrixByRoot(root);
11782 } else {
11783 m = this.attr('matrix');
11784 }
11785 vec3.transformMat3(v, v, m);
11786 return this;
11787 },
11788 invert: function invert(v) {
11789 var m = this.attr('matrix');
11790 // 单精屏幕下大多数矩阵没变化
11791 if (isScale(m)) {
11792 v[0] /= m[0];
11793 v[1] /= m[4];
11794 } else {
11795 var inm = mat3.invert([], m);
11796 if (inm) {
11797 vec3.transformMat3(v, v, inm);
11798 }
11799 }
11800 return this;
11801 },
11802 resetTransform: function resetTransform(context) {
11803 var mo = this.attr('matrix');
11804 // 不改变时
11805 if (!isUnchanged(mo)) {
11806 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
11807 }
11808 }
11809};
11810
11811/***/ }),
11812/* 74 */
11813/***/ (function(module, __webpack_exports__, __webpack_require__) {
11814
11815"use strict";
11816Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
11817/* harmony export (immutable) */ __webpack_exports__["create"] = create;
11818/* harmony export (immutable) */ __webpack_exports__["fromMat4"] = fromMat4;
11819/* harmony export (immutable) */ __webpack_exports__["clone"] = clone;
11820/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
11821/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues;
11822/* harmony export (immutable) */ __webpack_exports__["set"] = set;
11823/* harmony export (immutable) */ __webpack_exports__["identity"] = identity;
11824/* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose;
11825/* harmony export (immutable) */ __webpack_exports__["invert"] = invert;
11826/* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint;
11827/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant;
11828/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply;
11829/* harmony export (immutable) */ __webpack_exports__["translate"] = translate;
11830/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate;
11831/* harmony export (immutable) */ __webpack_exports__["scale"] = scale;
11832/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation;
11833/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation;
11834/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling;
11835/* harmony export (immutable) */ __webpack_exports__["fromMat2d"] = fromMat2d;
11836/* harmony export (immutable) */ __webpack_exports__["fromQuat"] = fromQuat;
11837/* harmony export (immutable) */ __webpack_exports__["normalFromMat4"] = normalFromMat4;
11838/* harmony export (immutable) */ __webpack_exports__["projection"] = projection;
11839/* harmony export (immutable) */ __webpack_exports__["str"] = str;
11840/* harmony export (immutable) */ __webpack_exports__["frob"] = frob;
11841/* harmony export (immutable) */ __webpack_exports__["add"] = add;
11842/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract;
11843/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar;
11844/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd;
11845/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals;
11846/* harmony export (immutable) */ __webpack_exports__["equals"] = equals;
11847/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
11848/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
11849/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(14);
11850
11851
11852/**
11853 * 3x3 Matrix
11854 * @module mat3
11855 */
11856
11857/**
11858 * Creates a new identity mat3
11859 *
11860 * @returns {mat3} a new 3x3 matrix
11861 */
11862function create() {
11863 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
11864 out[0] = 1;
11865 out[1] = 0;
11866 out[2] = 0;
11867 out[3] = 0;
11868 out[4] = 1;
11869 out[5] = 0;
11870 out[6] = 0;
11871 out[7] = 0;
11872 out[8] = 1;
11873 return out;
11874}
11875
11876/**
11877 * Copies the upper-left 3x3 values into the given mat3.
11878 *
11879 * @param {mat3} out the receiving 3x3 matrix
11880 * @param {mat4} a the source 4x4 matrix
11881 * @returns {mat3} out
11882 */
11883function fromMat4(out, a) {
11884 out[0] = a[0];
11885 out[1] = a[1];
11886 out[2] = a[2];
11887 out[3] = a[4];
11888 out[4] = a[5];
11889 out[5] = a[6];
11890 out[6] = a[8];
11891 out[7] = a[9];
11892 out[8] = a[10];
11893 return out;
11894}
11895
11896/**
11897 * Creates a new mat3 initialized with values from an existing matrix
11898 *
11899 * @param {mat3} a matrix to clone
11900 * @returns {mat3} a new 3x3 matrix
11901 */
11902function clone(a) {
11903 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
11904 out[0] = a[0];
11905 out[1] = a[1];
11906 out[2] = a[2];
11907 out[3] = a[3];
11908 out[4] = a[4];
11909 out[5] = a[5];
11910 out[6] = a[6];
11911 out[7] = a[7];
11912 out[8] = a[8];
11913 return out;
11914}
11915
11916/**
11917 * Copy the values from one mat3 to another
11918 *
11919 * @param {mat3} out the receiving matrix
11920 * @param {mat3} a the source matrix
11921 * @returns {mat3} out
11922 */
11923function copy(out, a) {
11924 out[0] = a[0];
11925 out[1] = a[1];
11926 out[2] = a[2];
11927 out[3] = a[3];
11928 out[4] = a[4];
11929 out[5] = a[5];
11930 out[6] = a[6];
11931 out[7] = a[7];
11932 out[8] = a[8];
11933 return out;
11934}
11935
11936/**
11937 * Create a new mat3 with the given values
11938 *
11939 * @param {Number} m00 Component in column 0, row 0 position (index 0)
11940 * @param {Number} m01 Component in column 0, row 1 position (index 1)
11941 * @param {Number} m02 Component in column 0, row 2 position (index 2)
11942 * @param {Number} m10 Component in column 1, row 0 position (index 3)
11943 * @param {Number} m11 Component in column 1, row 1 position (index 4)
11944 * @param {Number} m12 Component in column 1, row 2 position (index 5)
11945 * @param {Number} m20 Component in column 2, row 0 position (index 6)
11946 * @param {Number} m21 Component in column 2, row 1 position (index 7)
11947 * @param {Number} m22 Component in column 2, row 2 position (index 8)
11948 * @returns {mat3} A new mat3
11949 */
11950function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
11951 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
11952 out[0] = m00;
11953 out[1] = m01;
11954 out[2] = m02;
11955 out[3] = m10;
11956 out[4] = m11;
11957 out[5] = m12;
11958 out[6] = m20;
11959 out[7] = m21;
11960 out[8] = m22;
11961 return out;
11962}
11963
11964/**
11965 * Set the components of a mat3 to the given values
11966 *
11967 * @param {mat3} out the receiving matrix
11968 * @param {Number} m00 Component in column 0, row 0 position (index 0)
11969 * @param {Number} m01 Component in column 0, row 1 position (index 1)
11970 * @param {Number} m02 Component in column 0, row 2 position (index 2)
11971 * @param {Number} m10 Component in column 1, row 0 position (index 3)
11972 * @param {Number} m11 Component in column 1, row 1 position (index 4)
11973 * @param {Number} m12 Component in column 1, row 2 position (index 5)
11974 * @param {Number} m20 Component in column 2, row 0 position (index 6)
11975 * @param {Number} m21 Component in column 2, row 1 position (index 7)
11976 * @param {Number} m22 Component in column 2, row 2 position (index 8)
11977 * @returns {mat3} out
11978 */
11979function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
11980 out[0] = m00;
11981 out[1] = m01;
11982 out[2] = m02;
11983 out[3] = m10;
11984 out[4] = m11;
11985 out[5] = m12;
11986 out[6] = m20;
11987 out[7] = m21;
11988 out[8] = m22;
11989 return out;
11990}
11991
11992/**
11993 * Set a mat3 to the identity matrix
11994 *
11995 * @param {mat3} out the receiving matrix
11996 * @returns {mat3} out
11997 */
11998function identity(out) {
11999 out[0] = 1;
12000 out[1] = 0;
12001 out[2] = 0;
12002 out[3] = 0;
12003 out[4] = 1;
12004 out[5] = 0;
12005 out[6] = 0;
12006 out[7] = 0;
12007 out[8] = 1;
12008 return out;
12009}
12010
12011/**
12012 * Transpose the values of a mat3
12013 *
12014 * @param {mat3} out the receiving matrix
12015 * @param {mat3} a the source matrix
12016 * @returns {mat3} out
12017 */
12018function transpose(out, a) {
12019 // If we are transposing ourselves we can skip a few steps but have to cache some values
12020 if (out === a) {
12021 var a01 = a[1],
12022 a02 = a[2],
12023 a12 = a[5];
12024 out[1] = a[3];
12025 out[2] = a[6];
12026 out[3] = a01;
12027 out[5] = a[7];
12028 out[6] = a02;
12029 out[7] = a12;
12030 } else {
12031 out[0] = a[0];
12032 out[1] = a[3];
12033 out[2] = a[6];
12034 out[3] = a[1];
12035 out[4] = a[4];
12036 out[5] = a[7];
12037 out[6] = a[2];
12038 out[7] = a[5];
12039 out[8] = a[8];
12040 }
12041
12042 return out;
12043}
12044
12045/**
12046 * Inverts a mat3
12047 *
12048 * @param {mat3} out the receiving matrix
12049 * @param {mat3} a the source matrix
12050 * @returns {mat3} out
12051 */
12052function invert(out, a) {
12053 var a00 = a[0],
12054 a01 = a[1],
12055 a02 = a[2];
12056 var a10 = a[3],
12057 a11 = a[4],
12058 a12 = a[5];
12059 var a20 = a[6],
12060 a21 = a[7],
12061 a22 = a[8];
12062
12063 var b01 = a22 * a11 - a12 * a21;
12064 var b11 = -a22 * a10 + a12 * a20;
12065 var b21 = a21 * a10 - a11 * a20;
12066
12067 // Calculate the determinant
12068 var det = a00 * b01 + a01 * b11 + a02 * b21;
12069
12070 if (!det) {
12071 return null;
12072 }
12073 det = 1.0 / det;
12074
12075 out[0] = b01 * det;
12076 out[1] = (-a22 * a01 + a02 * a21) * det;
12077 out[2] = (a12 * a01 - a02 * a11) * det;
12078 out[3] = b11 * det;
12079 out[4] = (a22 * a00 - a02 * a20) * det;
12080 out[5] = (-a12 * a00 + a02 * a10) * det;
12081 out[6] = b21 * det;
12082 out[7] = (-a21 * a00 + a01 * a20) * det;
12083 out[8] = (a11 * a00 - a01 * a10) * det;
12084 return out;
12085}
12086
12087/**
12088 * Calculates the adjugate of a mat3
12089 *
12090 * @param {mat3} out the receiving matrix
12091 * @param {mat3} a the source matrix
12092 * @returns {mat3} out
12093 */
12094function adjoint(out, a) {
12095 var a00 = a[0],
12096 a01 = a[1],
12097 a02 = a[2];
12098 var a10 = a[3],
12099 a11 = a[4],
12100 a12 = a[5];
12101 var a20 = a[6],
12102 a21 = a[7],
12103 a22 = a[8];
12104
12105 out[0] = a11 * a22 - a12 * a21;
12106 out[1] = a02 * a21 - a01 * a22;
12107 out[2] = a01 * a12 - a02 * a11;
12108 out[3] = a12 * a20 - a10 * a22;
12109 out[4] = a00 * a22 - a02 * a20;
12110 out[5] = a02 * a10 - a00 * a12;
12111 out[6] = a10 * a21 - a11 * a20;
12112 out[7] = a01 * a20 - a00 * a21;
12113 out[8] = a00 * a11 - a01 * a10;
12114 return out;
12115}
12116
12117/**
12118 * Calculates the determinant of a mat3
12119 *
12120 * @param {mat3} a the source matrix
12121 * @returns {Number} determinant of a
12122 */
12123function determinant(a) {
12124 var a00 = a[0],
12125 a01 = a[1],
12126 a02 = a[2];
12127 var a10 = a[3],
12128 a11 = a[4],
12129 a12 = a[5];
12130 var a20 = a[6],
12131 a21 = a[7],
12132 a22 = a[8];
12133
12134 return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
12135}
12136
12137/**
12138 * Multiplies two mat3's
12139 *
12140 * @param {mat3} out the receiving matrix
12141 * @param {mat3} a the first operand
12142 * @param {mat3} b the second operand
12143 * @returns {mat3} out
12144 */
12145function multiply(out, a, b) {
12146 var a00 = a[0],
12147 a01 = a[1],
12148 a02 = a[2];
12149 var a10 = a[3],
12150 a11 = a[4],
12151 a12 = a[5];
12152 var a20 = a[6],
12153 a21 = a[7],
12154 a22 = a[8];
12155
12156 var b00 = b[0],
12157 b01 = b[1],
12158 b02 = b[2];
12159 var b10 = b[3],
12160 b11 = b[4],
12161 b12 = b[5];
12162 var b20 = b[6],
12163 b21 = b[7],
12164 b22 = b[8];
12165
12166 out[0] = b00 * a00 + b01 * a10 + b02 * a20;
12167 out[1] = b00 * a01 + b01 * a11 + b02 * a21;
12168 out[2] = b00 * a02 + b01 * a12 + b02 * a22;
12169
12170 out[3] = b10 * a00 + b11 * a10 + b12 * a20;
12171 out[4] = b10 * a01 + b11 * a11 + b12 * a21;
12172 out[5] = b10 * a02 + b11 * a12 + b12 * a22;
12173
12174 out[6] = b20 * a00 + b21 * a10 + b22 * a20;
12175 out[7] = b20 * a01 + b21 * a11 + b22 * a21;
12176 out[8] = b20 * a02 + b21 * a12 + b22 * a22;
12177 return out;
12178}
12179
12180/**
12181 * Translate a mat3 by the given vector
12182 *
12183 * @param {mat3} out the receiving matrix
12184 * @param {mat3} a the matrix to translate
12185 * @param {vec2} v vector to translate by
12186 * @returns {mat3} out
12187 */
12188function translate(out, a, v) {
12189 var a00 = a[0],
12190 a01 = a[1],
12191 a02 = a[2],
12192 a10 = a[3],
12193 a11 = a[4],
12194 a12 = a[5],
12195 a20 = a[6],
12196 a21 = a[7],
12197 a22 = a[8],
12198 x = v[0],
12199 y = v[1];
12200
12201 out[0] = a00;
12202 out[1] = a01;
12203 out[2] = a02;
12204
12205 out[3] = a10;
12206 out[4] = a11;
12207 out[5] = a12;
12208
12209 out[6] = x * a00 + y * a10 + a20;
12210 out[7] = x * a01 + y * a11 + a21;
12211 out[8] = x * a02 + y * a12 + a22;
12212 return out;
12213}
12214
12215/**
12216 * Rotates a mat3 by the given angle
12217 *
12218 * @param {mat3} out the receiving matrix
12219 * @param {mat3} a the matrix to rotate
12220 * @param {Number} rad the angle to rotate the matrix by
12221 * @returns {mat3} out
12222 */
12223function rotate(out, a, rad) {
12224 var a00 = a[0],
12225 a01 = a[1],
12226 a02 = a[2],
12227 a10 = a[3],
12228 a11 = a[4],
12229 a12 = a[5],
12230 a20 = a[6],
12231 a21 = a[7],
12232 a22 = a[8],
12233 s = Math.sin(rad),
12234 c = Math.cos(rad);
12235
12236 out[0] = c * a00 + s * a10;
12237 out[1] = c * a01 + s * a11;
12238 out[2] = c * a02 + s * a12;
12239
12240 out[3] = c * a10 - s * a00;
12241 out[4] = c * a11 - s * a01;
12242 out[5] = c * a12 - s * a02;
12243
12244 out[6] = a20;
12245 out[7] = a21;
12246 out[8] = a22;
12247 return out;
12248};
12249
12250/**
12251 * Scales the mat3 by the dimensions in the given vec2
12252 *
12253 * @param {mat3} out the receiving matrix
12254 * @param {mat3} a the matrix to rotate
12255 * @param {vec2} v the vec2 to scale the matrix by
12256 * @returns {mat3} out
12257 **/
12258function scale(out, a, v) {
12259 var x = v[0],
12260 y = v[1];
12261
12262 out[0] = x * a[0];
12263 out[1] = x * a[1];
12264 out[2] = x * a[2];
12265
12266 out[3] = y * a[3];
12267 out[4] = y * a[4];
12268 out[5] = y * a[5];
12269
12270 out[6] = a[6];
12271 out[7] = a[7];
12272 out[8] = a[8];
12273 return out;
12274}
12275
12276/**
12277 * Creates a matrix from a vector translation
12278 * This is equivalent to (but much faster than):
12279 *
12280 * mat3.identity(dest);
12281 * mat3.translate(dest, dest, vec);
12282 *
12283 * @param {mat3} out mat3 receiving operation result
12284 * @param {vec2} v Translation vector
12285 * @returns {mat3} out
12286 */
12287function fromTranslation(out, v) {
12288 out[0] = 1;
12289 out[1] = 0;
12290 out[2] = 0;
12291 out[3] = 0;
12292 out[4] = 1;
12293 out[5] = 0;
12294 out[6] = v[0];
12295 out[7] = v[1];
12296 out[8] = 1;
12297 return out;
12298}
12299
12300/**
12301 * Creates a matrix from a given angle
12302 * This is equivalent to (but much faster than):
12303 *
12304 * mat3.identity(dest);
12305 * mat3.rotate(dest, dest, rad);
12306 *
12307 * @param {mat3} out mat3 receiving operation result
12308 * @param {Number} rad the angle to rotate the matrix by
12309 * @returns {mat3} out
12310 */
12311function fromRotation(out, rad) {
12312 var s = Math.sin(rad),
12313 c = Math.cos(rad);
12314
12315 out[0] = c;
12316 out[1] = s;
12317 out[2] = 0;
12318
12319 out[3] = -s;
12320 out[4] = c;
12321 out[5] = 0;
12322
12323 out[6] = 0;
12324 out[7] = 0;
12325 out[8] = 1;
12326 return out;
12327}
12328
12329/**
12330 * Creates a matrix from a vector scaling
12331 * This is equivalent to (but much faster than):
12332 *
12333 * mat3.identity(dest);
12334 * mat3.scale(dest, dest, vec);
12335 *
12336 * @param {mat3} out mat3 receiving operation result
12337 * @param {vec2} v Scaling vector
12338 * @returns {mat3} out
12339 */
12340function fromScaling(out, v) {
12341 out[0] = v[0];
12342 out[1] = 0;
12343 out[2] = 0;
12344
12345 out[3] = 0;
12346 out[4] = v[1];
12347 out[5] = 0;
12348
12349 out[6] = 0;
12350 out[7] = 0;
12351 out[8] = 1;
12352 return out;
12353}
12354
12355/**
12356 * Copies the values from a mat2d into a mat3
12357 *
12358 * @param {mat3} out the receiving matrix
12359 * @param {mat2d} a the matrix to copy
12360 * @returns {mat3} out
12361 **/
12362function fromMat2d(out, a) {
12363 out[0] = a[0];
12364 out[1] = a[1];
12365 out[2] = 0;
12366
12367 out[3] = a[2];
12368 out[4] = a[3];
12369 out[5] = 0;
12370
12371 out[6] = a[4];
12372 out[7] = a[5];
12373 out[8] = 1;
12374 return out;
12375}
12376
12377/**
12378* Calculates a 3x3 matrix from the given quaternion
12379*
12380* @param {mat3} out mat3 receiving operation result
12381* @param {quat} q Quaternion to create matrix from
12382*
12383* @returns {mat3} out
12384*/
12385function fromQuat(out, q) {
12386 var x = q[0],
12387 y = q[1],
12388 z = q[2],
12389 w = q[3];
12390 var x2 = x + x;
12391 var y2 = y + y;
12392 var z2 = z + z;
12393
12394 var xx = x * x2;
12395 var yx = y * x2;
12396 var yy = y * y2;
12397 var zx = z * x2;
12398 var zy = z * y2;
12399 var zz = z * z2;
12400 var wx = w * x2;
12401 var wy = w * y2;
12402 var wz = w * z2;
12403
12404 out[0] = 1 - yy - zz;
12405 out[3] = yx - wz;
12406 out[6] = zx + wy;
12407
12408 out[1] = yx + wz;
12409 out[4] = 1 - xx - zz;
12410 out[7] = zy - wx;
12411
12412 out[2] = zx - wy;
12413 out[5] = zy + wx;
12414 out[8] = 1 - xx - yy;
12415
12416 return out;
12417}
12418
12419/**
12420* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
12421*
12422* @param {mat3} out mat3 receiving operation result
12423* @param {mat4} a Mat4 to derive the normal matrix from
12424*
12425* @returns {mat3} out
12426*/
12427function normalFromMat4(out, a) {
12428 var a00 = a[0],
12429 a01 = a[1],
12430 a02 = a[2],
12431 a03 = a[3];
12432 var a10 = a[4],
12433 a11 = a[5],
12434 a12 = a[6],
12435 a13 = a[7];
12436 var a20 = a[8],
12437 a21 = a[9],
12438 a22 = a[10],
12439 a23 = a[11];
12440 var a30 = a[12],
12441 a31 = a[13],
12442 a32 = a[14],
12443 a33 = a[15];
12444
12445 var b00 = a00 * a11 - a01 * a10;
12446 var b01 = a00 * a12 - a02 * a10;
12447 var b02 = a00 * a13 - a03 * a10;
12448 var b03 = a01 * a12 - a02 * a11;
12449 var b04 = a01 * a13 - a03 * a11;
12450 var b05 = a02 * a13 - a03 * a12;
12451 var b06 = a20 * a31 - a21 * a30;
12452 var b07 = a20 * a32 - a22 * a30;
12453 var b08 = a20 * a33 - a23 * a30;
12454 var b09 = a21 * a32 - a22 * a31;
12455 var b10 = a21 * a33 - a23 * a31;
12456 var b11 = a22 * a33 - a23 * a32;
12457
12458 // Calculate the determinant
12459 var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
12460
12461 if (!det) {
12462 return null;
12463 }
12464 det = 1.0 / det;
12465
12466 out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
12467 out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
12468 out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
12469
12470 out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
12471 out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
12472 out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
12473
12474 out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
12475 out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
12476 out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
12477
12478 return out;
12479}
12480
12481/**
12482 * Generates a 2D projection matrix with the given bounds
12483 *
12484 * @param {mat3} out mat3 frustum matrix will be written into
12485 * @param {number} width Width of your gl context
12486 * @param {number} height Height of gl context
12487 * @returns {mat3} out
12488 */
12489function projection(out, width, height) {
12490 out[0] = 2 / width;
12491 out[1] = 0;
12492 out[2] = 0;
12493 out[3] = 0;
12494 out[4] = -2 / height;
12495 out[5] = 0;
12496 out[6] = -1;
12497 out[7] = 1;
12498 out[8] = 1;
12499 return out;
12500}
12501
12502/**
12503 * Returns a string representation of a mat3
12504 *
12505 * @param {mat3} a matrix to represent as a string
12506 * @returns {String} string representation of the matrix
12507 */
12508function str(a) {
12509 return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
12510}
12511
12512/**
12513 * Returns Frobenius norm of a mat3
12514 *
12515 * @param {mat3} a the matrix to calculate Frobenius norm of
12516 * @returns {Number} Frobenius norm
12517 */
12518function frob(a) {
12519 return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2));
12520}
12521
12522/**
12523 * Adds two mat3's
12524 *
12525 * @param {mat3} out the receiving matrix
12526 * @param {mat3} a the first operand
12527 * @param {mat3} b the second operand
12528 * @returns {mat3} out
12529 */
12530function add(out, a, b) {
12531 out[0] = a[0] + b[0];
12532 out[1] = a[1] + b[1];
12533 out[2] = a[2] + b[2];
12534 out[3] = a[3] + b[3];
12535 out[4] = a[4] + b[4];
12536 out[5] = a[5] + b[5];
12537 out[6] = a[6] + b[6];
12538 out[7] = a[7] + b[7];
12539 out[8] = a[8] + b[8];
12540 return out;
12541}
12542
12543/**
12544 * Subtracts matrix b from matrix a
12545 *
12546 * @param {mat3} out the receiving matrix
12547 * @param {mat3} a the first operand
12548 * @param {mat3} b the second operand
12549 * @returns {mat3} out
12550 */
12551function subtract(out, a, b) {
12552 out[0] = a[0] - b[0];
12553 out[1] = a[1] - b[1];
12554 out[2] = a[2] - b[2];
12555 out[3] = a[3] - b[3];
12556 out[4] = a[4] - b[4];
12557 out[5] = a[5] - b[5];
12558 out[6] = a[6] - b[6];
12559 out[7] = a[7] - b[7];
12560 out[8] = a[8] - b[8];
12561 return out;
12562}
12563
12564/**
12565 * Multiply each element of the matrix by a scalar.
12566 *
12567 * @param {mat3} out the receiving matrix
12568 * @param {mat3} a the matrix to scale
12569 * @param {Number} b amount to scale the matrix's elements by
12570 * @returns {mat3} out
12571 */
12572function multiplyScalar(out, a, b) {
12573 out[0] = a[0] * b;
12574 out[1] = a[1] * b;
12575 out[2] = a[2] * b;
12576 out[3] = a[3] * b;
12577 out[4] = a[4] * b;
12578 out[5] = a[5] * b;
12579 out[6] = a[6] * b;
12580 out[7] = a[7] * b;
12581 out[8] = a[8] * b;
12582 return out;
12583}
12584
12585/**
12586 * Adds two mat3's after multiplying each element of the second operand by a scalar value.
12587 *
12588 * @param {mat3} out the receiving vector
12589 * @param {mat3} a the first operand
12590 * @param {mat3} b the second operand
12591 * @param {Number} scale the amount to scale b's elements by before adding
12592 * @returns {mat3} out
12593 */
12594function multiplyScalarAndAdd(out, a, b, scale) {
12595 out[0] = a[0] + b[0] * scale;
12596 out[1] = a[1] + b[1] * scale;
12597 out[2] = a[2] + b[2] * scale;
12598 out[3] = a[3] + b[3] * scale;
12599 out[4] = a[4] + b[4] * scale;
12600 out[5] = a[5] + b[5] * scale;
12601 out[6] = a[6] + b[6] * scale;
12602 out[7] = a[7] + b[7] * scale;
12603 out[8] = a[8] + b[8] * scale;
12604 return out;
12605}
12606
12607/**
12608 * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
12609 *
12610 * @param {mat3} a The first matrix.
12611 * @param {mat3} b The second matrix.
12612 * @returns {Boolean} True if the matrices are equal, false otherwise.
12613 */
12614function exactEquals(a, b) {
12615 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
12616}
12617
12618/**
12619 * Returns whether or not the matrices have approximately the same elements in the same position.
12620 *
12621 * @param {mat3} a The first matrix.
12622 * @param {mat3} b The second matrix.
12623 * @returns {Boolean} True if the matrices are equal, false otherwise.
12624 */
12625function equals(a, b) {
12626 var a0 = a[0],
12627 a1 = a[1],
12628 a2 = a[2],
12629 a3 = a[3],
12630 a4 = a[4],
12631 a5 = a[5],
12632 a6 = a[6],
12633 a7 = a[7],
12634 a8 = a[8];
12635 var b0 = b[0],
12636 b1 = b[1],
12637 b2 = b[2],
12638 b3 = b[3],
12639 b4 = b[4],
12640 b5 = b[5],
12641 b6 = b[6],
12642 b7 = b[7],
12643 b8 = b[8];
12644 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a8), Math.abs(b8));
12645}
12646
12647/**
12648 * Alias for {@link mat3.multiply}
12649 * @function
12650 */
12651var mul = multiply;
12652
12653/**
12654 * Alias for {@link mat3.subtract}
12655 * @function
12656 */
12657var sub = subtract;
12658
12659/***/ }),
12660/* 75 */
12661/***/ (function(module, __webpack_exports__, __webpack_require__) {
12662
12663"use strict";
12664Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
12665/* harmony export (immutable) */ __webpack_exports__["create"] = create;
12666/* harmony export (immutable) */ __webpack_exports__["clone"] = clone;
12667/* harmony export (immutable) */ __webpack_exports__["length"] = length;
12668/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues;
12669/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
12670/* harmony export (immutable) */ __webpack_exports__["set"] = set;
12671/* harmony export (immutable) */ __webpack_exports__["add"] = add;
12672/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract;
12673/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply;
12674/* harmony export (immutable) */ __webpack_exports__["divide"] = divide;
12675/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil;
12676/* harmony export (immutable) */ __webpack_exports__["floor"] = floor;
12677/* harmony export (immutable) */ __webpack_exports__["min"] = min;
12678/* harmony export (immutable) */ __webpack_exports__["max"] = max;
12679/* harmony export (immutable) */ __webpack_exports__["round"] = round;
12680/* harmony export (immutable) */ __webpack_exports__["scale"] = scale;
12681/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd;
12682/* harmony export (immutable) */ __webpack_exports__["distance"] = distance;
12683/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance;
12684/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength;
12685/* harmony export (immutable) */ __webpack_exports__["negate"] = negate;
12686/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse;
12687/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize;
12688/* harmony export (immutable) */ __webpack_exports__["dot"] = dot;
12689/* harmony export (immutable) */ __webpack_exports__["cross"] = cross;
12690/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp;
12691/* harmony export (immutable) */ __webpack_exports__["hermite"] = hermite;
12692/* harmony export (immutable) */ __webpack_exports__["bezier"] = bezier;
12693/* harmony export (immutable) */ __webpack_exports__["random"] = random;
12694/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4;
12695/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3;
12696/* harmony export (immutable) */ __webpack_exports__["transformQuat"] = transformQuat;
12697/* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX;
12698/* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY;
12699/* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ;
12700/* harmony export (immutable) */ __webpack_exports__["angle"] = angle;
12701/* harmony export (immutable) */ __webpack_exports__["str"] = str;
12702/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals;
12703/* harmony export (immutable) */ __webpack_exports__["equals"] = equals;
12704/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
12705/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
12706/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
12707/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
12708/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
12709/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
12710/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
12711/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
12712/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(14);
12713
12714
12715/**
12716 * 3 Dimensional Vector
12717 * @module vec3
12718 */
12719
12720/**
12721 * Creates a new, empty vec3
12722 *
12723 * @returns {vec3} a new 3D vector
12724 */
12725function create() {
12726 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
12727 out[0] = 0;
12728 out[1] = 0;
12729 out[2] = 0;
12730 return out;
12731}
12732
12733/**
12734 * Creates a new vec3 initialized with values from an existing vector
12735 *
12736 * @param {vec3} a vector to clone
12737 * @returns {vec3} a new 3D vector
12738 */
12739function clone(a) {
12740 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
12741 out[0] = a[0];
12742 out[1] = a[1];
12743 out[2] = a[2];
12744 return out;
12745}
12746
12747/**
12748 * Calculates the length of a vec3
12749 *
12750 * @param {vec3} a vector to calculate length of
12751 * @returns {Number} length of a
12752 */
12753function length(a) {
12754 var x = a[0];
12755 var y = a[1];
12756 var z = a[2];
12757 return Math.sqrt(x * x + y * y + z * z);
12758}
12759
12760/**
12761 * Creates a new vec3 initialized with the given values
12762 *
12763 * @param {Number} x X component
12764 * @param {Number} y Y component
12765 * @param {Number} z Z component
12766 * @returns {vec3} a new 3D vector
12767 */
12768function fromValues(x, y, z) {
12769 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
12770 out[0] = x;
12771 out[1] = y;
12772 out[2] = z;
12773 return out;
12774}
12775
12776/**
12777 * Copy the values from one vec3 to another
12778 *
12779 * @param {vec3} out the receiving vector
12780 * @param {vec3} a the source vector
12781 * @returns {vec3} out
12782 */
12783function copy(out, a) {
12784 out[0] = a[0];
12785 out[1] = a[1];
12786 out[2] = a[2];
12787 return out;
12788}
12789
12790/**
12791 * Set the components of a vec3 to the given values
12792 *
12793 * @param {vec3} out the receiving vector
12794 * @param {Number} x X component
12795 * @param {Number} y Y component
12796 * @param {Number} z Z component
12797 * @returns {vec3} out
12798 */
12799function set(out, x, y, z) {
12800 out[0] = x;
12801 out[1] = y;
12802 out[2] = z;
12803 return out;
12804}
12805
12806/**
12807 * Adds two vec3's
12808 *
12809 * @param {vec3} out the receiving vector
12810 * @param {vec3} a the first operand
12811 * @param {vec3} b the second operand
12812 * @returns {vec3} out
12813 */
12814function add(out, a, b) {
12815 out[0] = a[0] + b[0];
12816 out[1] = a[1] + b[1];
12817 out[2] = a[2] + b[2];
12818 return out;
12819}
12820
12821/**
12822 * Subtracts vector b from vector a
12823 *
12824 * @param {vec3} out the receiving vector
12825 * @param {vec3} a the first operand
12826 * @param {vec3} b the second operand
12827 * @returns {vec3} out
12828 */
12829function subtract(out, a, b) {
12830 out[0] = a[0] - b[0];
12831 out[1] = a[1] - b[1];
12832 out[2] = a[2] - b[2];
12833 return out;
12834}
12835
12836/**
12837 * Multiplies two vec3's
12838 *
12839 * @param {vec3} out the receiving vector
12840 * @param {vec3} a the first operand
12841 * @param {vec3} b the second operand
12842 * @returns {vec3} out
12843 */
12844function multiply(out, a, b) {
12845 out[0] = a[0] * b[0];
12846 out[1] = a[1] * b[1];
12847 out[2] = a[2] * b[2];
12848 return out;
12849}
12850
12851/**
12852 * Divides two vec3's
12853 *
12854 * @param {vec3} out the receiving vector
12855 * @param {vec3} a the first operand
12856 * @param {vec3} b the second operand
12857 * @returns {vec3} out
12858 */
12859function divide(out, a, b) {
12860 out[0] = a[0] / b[0];
12861 out[1] = a[1] / b[1];
12862 out[2] = a[2] / b[2];
12863 return out;
12864}
12865
12866/**
12867 * Math.ceil the components of a vec3
12868 *
12869 * @param {vec3} out the receiving vector
12870 * @param {vec3} a vector to ceil
12871 * @returns {vec3} out
12872 */
12873function ceil(out, a) {
12874 out[0] = Math.ceil(a[0]);
12875 out[1] = Math.ceil(a[1]);
12876 out[2] = Math.ceil(a[2]);
12877 return out;
12878}
12879
12880/**
12881 * Math.floor the components of a vec3
12882 *
12883 * @param {vec3} out the receiving vector
12884 * @param {vec3} a vector to floor
12885 * @returns {vec3} out
12886 */
12887function floor(out, a) {
12888 out[0] = Math.floor(a[0]);
12889 out[1] = Math.floor(a[1]);
12890 out[2] = Math.floor(a[2]);
12891 return out;
12892}
12893
12894/**
12895 * Returns the minimum of two vec3's
12896 *
12897 * @param {vec3} out the receiving vector
12898 * @param {vec3} a the first operand
12899 * @param {vec3} b the second operand
12900 * @returns {vec3} out
12901 */
12902function min(out, a, b) {
12903 out[0] = Math.min(a[0], b[0]);
12904 out[1] = Math.min(a[1], b[1]);
12905 out[2] = Math.min(a[2], b[2]);
12906 return out;
12907}
12908
12909/**
12910 * Returns the maximum of two vec3's
12911 *
12912 * @param {vec3} out the receiving vector
12913 * @param {vec3} a the first operand
12914 * @param {vec3} b the second operand
12915 * @returns {vec3} out
12916 */
12917function max(out, a, b) {
12918 out[0] = Math.max(a[0], b[0]);
12919 out[1] = Math.max(a[1], b[1]);
12920 out[2] = Math.max(a[2], b[2]);
12921 return out;
12922}
12923
12924/**
12925 * Math.round the components of a vec3
12926 *
12927 * @param {vec3} out the receiving vector
12928 * @param {vec3} a vector to round
12929 * @returns {vec3} out
12930 */
12931function round(out, a) {
12932 out[0] = Math.round(a[0]);
12933 out[1] = Math.round(a[1]);
12934 out[2] = Math.round(a[2]);
12935 return out;
12936}
12937
12938/**
12939 * Scales a vec3 by a scalar number
12940 *
12941 * @param {vec3} out the receiving vector
12942 * @param {vec3} a the vector to scale
12943 * @param {Number} b amount to scale the vector by
12944 * @returns {vec3} out
12945 */
12946function scale(out, a, b) {
12947 out[0] = a[0] * b;
12948 out[1] = a[1] * b;
12949 out[2] = a[2] * b;
12950 return out;
12951}
12952
12953/**
12954 * Adds two vec3's after scaling the second operand by a scalar value
12955 *
12956 * @param {vec3} out the receiving vector
12957 * @param {vec3} a the first operand
12958 * @param {vec3} b the second operand
12959 * @param {Number} scale the amount to scale b by before adding
12960 * @returns {vec3} out
12961 */
12962function scaleAndAdd(out, a, b, scale) {
12963 out[0] = a[0] + b[0] * scale;
12964 out[1] = a[1] + b[1] * scale;
12965 out[2] = a[2] + b[2] * scale;
12966 return out;
12967}
12968
12969/**
12970 * Calculates the euclidian distance between two vec3's
12971 *
12972 * @param {vec3} a the first operand
12973 * @param {vec3} b the second operand
12974 * @returns {Number} distance between a and b
12975 */
12976function distance(a, b) {
12977 var x = b[0] - a[0];
12978 var y = b[1] - a[1];
12979 var z = b[2] - a[2];
12980 return Math.sqrt(x * x + y * y + z * z);
12981}
12982
12983/**
12984 * Calculates the squared euclidian distance between two vec3's
12985 *
12986 * @param {vec3} a the first operand
12987 * @param {vec3} b the second operand
12988 * @returns {Number} squared distance between a and b
12989 */
12990function squaredDistance(a, b) {
12991 var x = b[0] - a[0];
12992 var y = b[1] - a[1];
12993 var z = b[2] - a[2];
12994 return x * x + y * y + z * z;
12995}
12996
12997/**
12998 * Calculates the squared length of a vec3
12999 *
13000 * @param {vec3} a vector to calculate squared length of
13001 * @returns {Number} squared length of a
13002 */
13003function squaredLength(a) {
13004 var x = a[0];
13005 var y = a[1];
13006 var z = a[2];
13007 return x * x + y * y + z * z;
13008}
13009
13010/**
13011 * Negates the components of a vec3
13012 *
13013 * @param {vec3} out the receiving vector
13014 * @param {vec3} a vector to negate
13015 * @returns {vec3} out
13016 */
13017function negate(out, a) {
13018 out[0] = -a[0];
13019 out[1] = -a[1];
13020 out[2] = -a[2];
13021 return out;
13022}
13023
13024/**
13025 * Returns the inverse of the components of a vec3
13026 *
13027 * @param {vec3} out the receiving vector
13028 * @param {vec3} a vector to invert
13029 * @returns {vec3} out
13030 */
13031function inverse(out, a) {
13032 out[0] = 1.0 / a[0];
13033 out[1] = 1.0 / a[1];
13034 out[2] = 1.0 / a[2];
13035 return out;
13036}
13037
13038/**
13039 * Normalize a vec3
13040 *
13041 * @param {vec3} out the receiving vector
13042 * @param {vec3} a vector to normalize
13043 * @returns {vec3} out
13044 */
13045function normalize(out, a) {
13046 var x = a[0];
13047 var y = a[1];
13048 var z = a[2];
13049 var len = x * x + y * y + z * z;
13050 if (len > 0) {
13051 //TODO: evaluate use of glm_invsqrt here?
13052 len = 1 / Math.sqrt(len);
13053 out[0] = a[0] * len;
13054 out[1] = a[1] * len;
13055 out[2] = a[2] * len;
13056 }
13057 return out;
13058}
13059
13060/**
13061 * Calculates the dot product of two vec3's
13062 *
13063 * @param {vec3} a the first operand
13064 * @param {vec3} b the second operand
13065 * @returns {Number} dot product of a and b
13066 */
13067function dot(a, b) {
13068 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
13069}
13070
13071/**
13072 * Computes the cross product of two vec3's
13073 *
13074 * @param {vec3} out the receiving vector
13075 * @param {vec3} a the first operand
13076 * @param {vec3} b the second operand
13077 * @returns {vec3} out
13078 */
13079function cross(out, a, b) {
13080 var ax = a[0],
13081 ay = a[1],
13082 az = a[2];
13083 var bx = b[0],
13084 by = b[1],
13085 bz = b[2];
13086
13087 out[0] = ay * bz - az * by;
13088 out[1] = az * bx - ax * bz;
13089 out[2] = ax * by - ay * bx;
13090 return out;
13091}
13092
13093/**
13094 * Performs a linear interpolation between two vec3's
13095 *
13096 * @param {vec3} out the receiving vector
13097 * @param {vec3} a the first operand
13098 * @param {vec3} b the second operand
13099 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13100 * @returns {vec3} out
13101 */
13102function lerp(out, a, b, t) {
13103 var ax = a[0];
13104 var ay = a[1];
13105 var az = a[2];
13106 out[0] = ax + t * (b[0] - ax);
13107 out[1] = ay + t * (b[1] - ay);
13108 out[2] = az + t * (b[2] - az);
13109 return out;
13110}
13111
13112/**
13113 * Performs a hermite interpolation with two control points
13114 *
13115 * @param {vec3} out the receiving vector
13116 * @param {vec3} a the first operand
13117 * @param {vec3} b the second operand
13118 * @param {vec3} c the third operand
13119 * @param {vec3} d the fourth operand
13120 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13121 * @returns {vec3} out
13122 */
13123function hermite(out, a, b, c, d, t) {
13124 var factorTimes2 = t * t;
13125 var factor1 = factorTimes2 * (2 * t - 3) + 1;
13126 var factor2 = factorTimes2 * (t - 2) + t;
13127 var factor3 = factorTimes2 * (t - 1);
13128 var factor4 = factorTimes2 * (3 - 2 * t);
13129
13130 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
13131 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
13132 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
13133
13134 return out;
13135}
13136
13137/**
13138 * Performs a bezier interpolation with two control points
13139 *
13140 * @param {vec3} out the receiving vector
13141 * @param {vec3} a the first operand
13142 * @param {vec3} b the second operand
13143 * @param {vec3} c the third operand
13144 * @param {vec3} d the fourth operand
13145 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13146 * @returns {vec3} out
13147 */
13148function bezier(out, a, b, c, d, t) {
13149 var inverseFactor = 1 - t;
13150 var inverseFactorTimesTwo = inverseFactor * inverseFactor;
13151 var factorTimes2 = t * t;
13152 var factor1 = inverseFactorTimesTwo * inverseFactor;
13153 var factor2 = 3 * t * inverseFactorTimesTwo;
13154 var factor3 = 3 * factorTimes2 * inverseFactor;
13155 var factor4 = factorTimes2 * t;
13156
13157 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
13158 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
13159 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
13160
13161 return out;
13162}
13163
13164/**
13165 * Generates a random vector with the given scale
13166 *
13167 * @param {vec3} out the receiving vector
13168 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
13169 * @returns {vec3} out
13170 */
13171function random(out, scale) {
13172 scale = scale || 1.0;
13173
13174 var r = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 * Math.PI;
13175 var z = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 - 1.0;
13176 var zScale = Math.sqrt(1.0 - z * z) * scale;
13177
13178 out[0] = Math.cos(r) * zScale;
13179 out[1] = Math.sin(r) * zScale;
13180 out[2] = z * scale;
13181 return out;
13182}
13183
13184/**
13185 * Transforms the vec3 with a mat4.
13186 * 4th vector component is implicitly '1'
13187 *
13188 * @param {vec3} out the receiving vector
13189 * @param {vec3} a the vector to transform
13190 * @param {mat4} m matrix to transform with
13191 * @returns {vec3} out
13192 */
13193function transformMat4(out, a, m) {
13194 var x = a[0],
13195 y = a[1],
13196 z = a[2];
13197 var w = m[3] * x + m[7] * y + m[11] * z + m[15];
13198 w = w || 1.0;
13199 out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
13200 out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
13201 out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
13202 return out;
13203}
13204
13205/**
13206 * Transforms the vec3 with a mat3.
13207 *
13208 * @param {vec3} out the receiving vector
13209 * @param {vec3} a the vector to transform
13210 * @param {mat3} m the 3x3 matrix to transform with
13211 * @returns {vec3} out
13212 */
13213function transformMat3(out, a, m) {
13214 var x = a[0],
13215 y = a[1],
13216 z = a[2];
13217 out[0] = x * m[0] + y * m[3] + z * m[6];
13218 out[1] = x * m[1] + y * m[4] + z * m[7];
13219 out[2] = x * m[2] + y * m[5] + z * m[8];
13220 return out;
13221}
13222
13223/**
13224 * Transforms the vec3 with a quat
13225 * Can also be used for dual quaternions. (Multiply it with the real part)
13226 *
13227 * @param {vec3} out the receiving vector
13228 * @param {vec3} a the vector to transform
13229 * @param {quat} q quaternion to transform with
13230 * @returns {vec3} out
13231 */
13232function transformQuat(out, a, q) {
13233 // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
13234 var qx = q[0],
13235 qy = q[1],
13236 qz = q[2],
13237 qw = q[3];
13238 var x = a[0],
13239 y = a[1],
13240 z = a[2];
13241 // var qvec = [qx, qy, qz];
13242 // var uv = vec3.cross([], qvec, a);
13243 var uvx = qy * z - qz * y,
13244 uvy = qz * x - qx * z,
13245 uvz = qx * y - qy * x;
13246 // var uuv = vec3.cross([], qvec, uv);
13247 var uuvx = qy * uvz - qz * uvy,
13248 uuvy = qz * uvx - qx * uvz,
13249 uuvz = qx * uvy - qy * uvx;
13250 // vec3.scale(uv, uv, 2 * w);
13251 var w2 = qw * 2;
13252 uvx *= w2;
13253 uvy *= w2;
13254 uvz *= w2;
13255 // vec3.scale(uuv, uuv, 2);
13256 uuvx *= 2;
13257 uuvy *= 2;
13258 uuvz *= 2;
13259 // return vec3.add(out, a, vec3.add(out, uv, uuv));
13260 out[0] = x + uvx + uuvx;
13261 out[1] = y + uvy + uuvy;
13262 out[2] = z + uvz + uuvz;
13263 return out;
13264}
13265
13266/**
13267 * Rotate a 3D vector around the x-axis
13268 * @param {vec3} out The receiving vec3
13269 * @param {vec3} a The vec3 point to rotate
13270 * @param {vec3} b The origin of the rotation
13271 * @param {Number} c The angle of rotation
13272 * @returns {vec3} out
13273 */
13274function rotateX(out, a, b, c) {
13275 var p = [],
13276 r = [];
13277 //Translate point to the origin
13278 p[0] = a[0] - b[0];
13279 p[1] = a[1] - b[1];
13280 p[2] = a[2] - b[2];
13281
13282 //perform rotation
13283 r[0] = p[0];
13284 r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
13285 r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
13286
13287 //translate to correct position
13288 out[0] = r[0] + b[0];
13289 out[1] = r[1] + b[1];
13290 out[2] = r[2] + b[2];
13291
13292 return out;
13293}
13294
13295/**
13296 * Rotate a 3D vector around the y-axis
13297 * @param {vec3} out The receiving vec3
13298 * @param {vec3} a The vec3 point to rotate
13299 * @param {vec3} b The origin of the rotation
13300 * @param {Number} c The angle of rotation
13301 * @returns {vec3} out
13302 */
13303function rotateY(out, a, b, c) {
13304 var p = [],
13305 r = [];
13306 //Translate point to the origin
13307 p[0] = a[0] - b[0];
13308 p[1] = a[1] - b[1];
13309 p[2] = a[2] - b[2];
13310
13311 //perform rotation
13312 r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
13313 r[1] = p[1];
13314 r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
13315
13316 //translate to correct position
13317 out[0] = r[0] + b[0];
13318 out[1] = r[1] + b[1];
13319 out[2] = r[2] + b[2];
13320
13321 return out;
13322}
13323
13324/**
13325 * Rotate a 3D vector around the z-axis
13326 * @param {vec3} out The receiving vec3
13327 * @param {vec3} a The vec3 point to rotate
13328 * @param {vec3} b The origin of the rotation
13329 * @param {Number} c The angle of rotation
13330 * @returns {vec3} out
13331 */
13332function rotateZ(out, a, b, c) {
13333 var p = [],
13334 r = [];
13335 //Translate point to the origin
13336 p[0] = a[0] - b[0];
13337 p[1] = a[1] - b[1];
13338 p[2] = a[2] - b[2];
13339
13340 //perform rotation
13341 r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
13342 r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
13343 r[2] = p[2];
13344
13345 //translate to correct position
13346 out[0] = r[0] + b[0];
13347 out[1] = r[1] + b[1];
13348 out[2] = r[2] + b[2];
13349
13350 return out;
13351}
13352
13353/**
13354 * Get the angle between two 3D vectors
13355 * @param {vec3} a The first operand
13356 * @param {vec3} b The second operand
13357 * @returns {Number} The angle in radians
13358 */
13359function angle(a, b) {
13360 var tempA = fromValues(a[0], a[1], a[2]);
13361 var tempB = fromValues(b[0], b[1], b[2]);
13362
13363 normalize(tempA, tempA);
13364 normalize(tempB, tempB);
13365
13366 var cosine = dot(tempA, tempB);
13367
13368 if (cosine > 1.0) {
13369 return 0;
13370 } else if (cosine < -1.0) {
13371 return Math.PI;
13372 } else {
13373 return Math.acos(cosine);
13374 }
13375}
13376
13377/**
13378 * Returns a string representation of a vector
13379 *
13380 * @param {vec3} a vector to represent as a string
13381 * @returns {String} string representation of the vector
13382 */
13383function str(a) {
13384 return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
13385}
13386
13387/**
13388 * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
13389 *
13390 * @param {vec3} a The first vector.
13391 * @param {vec3} b The second vector.
13392 * @returns {Boolean} True if the vectors are equal, false otherwise.
13393 */
13394function exactEquals(a, b) {
13395 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
13396}
13397
13398/**
13399 * Returns whether or not the vectors have approximately the same elements in the same position.
13400 *
13401 * @param {vec3} a The first vector.
13402 * @param {vec3} b The second vector.
13403 * @returns {Boolean} True if the vectors are equal, false otherwise.
13404 */
13405function equals(a, b) {
13406 var a0 = a[0],
13407 a1 = a[1],
13408 a2 = a[2];
13409 var b0 = b[0],
13410 b1 = b[1],
13411 b2 = b[2];
13412 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2));
13413}
13414
13415/**
13416 * Alias for {@link vec3.subtract}
13417 * @function
13418 */
13419var sub = subtract;
13420
13421/**
13422 * Alias for {@link vec3.multiply}
13423 * @function
13424 */
13425var mul = multiply;
13426
13427/**
13428 * Alias for {@link vec3.divide}
13429 * @function
13430 */
13431var div = divide;
13432
13433/**
13434 * Alias for {@link vec3.distance}
13435 * @function
13436 */
13437var dist = distance;
13438
13439/**
13440 * Alias for {@link vec3.squaredDistance}
13441 * @function
13442 */
13443var sqrDist = squaredDistance;
13444
13445/**
13446 * Alias for {@link vec3.length}
13447 * @function
13448 */
13449var len = length;
13450
13451/**
13452 * Alias for {@link vec3.squaredLength}
13453 * @function
13454 */
13455var sqrLen = squaredLength;
13456
13457/**
13458 * Perform some operation over an array of vec3s.
13459 *
13460 * @param {Array} a the array of vectors to iterate over
13461 * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
13462 * @param {Number} offset Number of elements to skip at the beginning of the array
13463 * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
13464 * @param {Function} fn Function to call for each vector in the array
13465 * @param {Object} [arg] additional argument to pass to fn
13466 * @returns {Array} a
13467 * @function
13468 */
13469var forEach = function () {
13470 var vec = create();
13471
13472 return function (a, stride, offset, count, fn, arg) {
13473 var i = void 0,
13474 l = void 0;
13475 if (!stride) {
13476 stride = 3;
13477 }
13478
13479 if (!offset) {
13480 offset = 0;
13481 }
13482
13483 if (count) {
13484 l = Math.min(count * stride + offset, a.length);
13485 } else {
13486 l = a.length;
13487 }
13488
13489 for (i = offset; i < l; i += stride) {
13490 vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
13491 fn(vec, vec, arg);
13492 a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
13493 }
13494
13495 return a;
13496 };
13497}();
13498
13499/***/ }),
13500/* 76 */
13501/***/ (function(module, __webpack_exports__, __webpack_require__) {
13502
13503"use strict";
13504Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
13505/* harmony export (immutable) */ __webpack_exports__["create"] = create;
13506/* harmony export (immutable) */ __webpack_exports__["clone"] = clone;
13507/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues;
13508/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
13509/* harmony export (immutable) */ __webpack_exports__["set"] = set;
13510/* harmony export (immutable) */ __webpack_exports__["add"] = add;
13511/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract;
13512/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply;
13513/* harmony export (immutable) */ __webpack_exports__["divide"] = divide;
13514/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil;
13515/* harmony export (immutable) */ __webpack_exports__["floor"] = floor;
13516/* harmony export (immutable) */ __webpack_exports__["min"] = min;
13517/* harmony export (immutable) */ __webpack_exports__["max"] = max;
13518/* harmony export (immutable) */ __webpack_exports__["round"] = round;
13519/* harmony export (immutable) */ __webpack_exports__["scale"] = scale;
13520/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd;
13521/* harmony export (immutable) */ __webpack_exports__["distance"] = distance;
13522/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance;
13523/* harmony export (immutable) */ __webpack_exports__["length"] = length;
13524/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength;
13525/* harmony export (immutable) */ __webpack_exports__["negate"] = negate;
13526/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse;
13527/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize;
13528/* harmony export (immutable) */ __webpack_exports__["dot"] = dot;
13529/* harmony export (immutable) */ __webpack_exports__["cross"] = cross;
13530/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp;
13531/* harmony export (immutable) */ __webpack_exports__["random"] = random;
13532/* harmony export (immutable) */ __webpack_exports__["transformMat2"] = transformMat2;
13533/* harmony export (immutable) */ __webpack_exports__["transformMat2d"] = transformMat2d;
13534/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3;
13535/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4;
13536/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate;
13537/* harmony export (immutable) */ __webpack_exports__["angle"] = angle;
13538/* harmony export (immutable) */ __webpack_exports__["str"] = str;
13539/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals;
13540/* harmony export (immutable) */ __webpack_exports__["equals"] = equals;
13541/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
13542/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
13543/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
13544/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
13545/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
13546/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
13547/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
13548/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
13549/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(14);
13550
13551
13552/**
13553 * 2 Dimensional Vector
13554 * @module vec2
13555 */
13556
13557/**
13558 * Creates a new, empty vec2
13559 *
13560 * @returns {vec2} a new 2D vector
13561 */
13562function create() {
13563 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
13564 out[0] = 0;
13565 out[1] = 0;
13566 return out;
13567}
13568
13569/**
13570 * Creates a new vec2 initialized with values from an existing vector
13571 *
13572 * @param {vec2} a vector to clone
13573 * @returns {vec2} a new 2D vector
13574 */
13575function clone(a) {
13576 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
13577 out[0] = a[0];
13578 out[1] = a[1];
13579 return out;
13580}
13581
13582/**
13583 * Creates a new vec2 initialized with the given values
13584 *
13585 * @param {Number} x X component
13586 * @param {Number} y Y component
13587 * @returns {vec2} a new 2D vector
13588 */
13589function fromValues(x, y) {
13590 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
13591 out[0] = x;
13592 out[1] = y;
13593 return out;
13594}
13595
13596/**
13597 * Copy the values from one vec2 to another
13598 *
13599 * @param {vec2} out the receiving vector
13600 * @param {vec2} a the source vector
13601 * @returns {vec2} out
13602 */
13603function copy(out, a) {
13604 out[0] = a[0];
13605 out[1] = a[1];
13606 return out;
13607}
13608
13609/**
13610 * Set the components of a vec2 to the given values
13611 *
13612 * @param {vec2} out the receiving vector
13613 * @param {Number} x X component
13614 * @param {Number} y Y component
13615 * @returns {vec2} out
13616 */
13617function set(out, x, y) {
13618 out[0] = x;
13619 out[1] = y;
13620 return out;
13621}
13622
13623/**
13624 * Adds two vec2's
13625 *
13626 * @param {vec2} out the receiving vector
13627 * @param {vec2} a the first operand
13628 * @param {vec2} b the second operand
13629 * @returns {vec2} out
13630 */
13631function add(out, a, b) {
13632 out[0] = a[0] + b[0];
13633 out[1] = a[1] + b[1];
13634 return out;
13635}
13636
13637/**
13638 * Subtracts vector b from vector a
13639 *
13640 * @param {vec2} out the receiving vector
13641 * @param {vec2} a the first operand
13642 * @param {vec2} b the second operand
13643 * @returns {vec2} out
13644 */
13645function subtract(out, a, b) {
13646 out[0] = a[0] - b[0];
13647 out[1] = a[1] - b[1];
13648 return out;
13649}
13650
13651/**
13652 * Multiplies two vec2's
13653 *
13654 * @param {vec2} out the receiving vector
13655 * @param {vec2} a the first operand
13656 * @param {vec2} b the second operand
13657 * @returns {vec2} out
13658 */
13659function multiply(out, a, b) {
13660 out[0] = a[0] * b[0];
13661 out[1] = a[1] * b[1];
13662 return out;
13663}
13664
13665/**
13666 * Divides two vec2's
13667 *
13668 * @param {vec2} out the receiving vector
13669 * @param {vec2} a the first operand
13670 * @param {vec2} b the second operand
13671 * @returns {vec2} out
13672 */
13673function divide(out, a, b) {
13674 out[0] = a[0] / b[0];
13675 out[1] = a[1] / b[1];
13676 return out;
13677}
13678
13679/**
13680 * Math.ceil the components of a vec2
13681 *
13682 * @param {vec2} out the receiving vector
13683 * @param {vec2} a vector to ceil
13684 * @returns {vec2} out
13685 */
13686function ceil(out, a) {
13687 out[0] = Math.ceil(a[0]);
13688 out[1] = Math.ceil(a[1]);
13689 return out;
13690}
13691
13692/**
13693 * Math.floor the components of a vec2
13694 *
13695 * @param {vec2} out the receiving vector
13696 * @param {vec2} a vector to floor
13697 * @returns {vec2} out
13698 */
13699function floor(out, a) {
13700 out[0] = Math.floor(a[0]);
13701 out[1] = Math.floor(a[1]);
13702 return out;
13703}
13704
13705/**
13706 * Returns the minimum of two vec2's
13707 *
13708 * @param {vec2} out the receiving vector
13709 * @param {vec2} a the first operand
13710 * @param {vec2} b the second operand
13711 * @returns {vec2} out
13712 */
13713function min(out, a, b) {
13714 out[0] = Math.min(a[0], b[0]);
13715 out[1] = Math.min(a[1], b[1]);
13716 return out;
13717}
13718
13719/**
13720 * Returns the maximum of two vec2's
13721 *
13722 * @param {vec2} out the receiving vector
13723 * @param {vec2} a the first operand
13724 * @param {vec2} b the second operand
13725 * @returns {vec2} out
13726 */
13727function max(out, a, b) {
13728 out[0] = Math.max(a[0], b[0]);
13729 out[1] = Math.max(a[1], b[1]);
13730 return out;
13731}
13732
13733/**
13734 * Math.round the components of a vec2
13735 *
13736 * @param {vec2} out the receiving vector
13737 * @param {vec2} a vector to round
13738 * @returns {vec2} out
13739 */
13740function round(out, a) {
13741 out[0] = Math.round(a[0]);
13742 out[1] = Math.round(a[1]);
13743 return out;
13744}
13745
13746/**
13747 * Scales a vec2 by a scalar number
13748 *
13749 * @param {vec2} out the receiving vector
13750 * @param {vec2} a the vector to scale
13751 * @param {Number} b amount to scale the vector by
13752 * @returns {vec2} out
13753 */
13754function scale(out, a, b) {
13755 out[0] = a[0] * b;
13756 out[1] = a[1] * b;
13757 return out;
13758}
13759
13760/**
13761 * Adds two vec2's after scaling the second operand by a scalar value
13762 *
13763 * @param {vec2} out the receiving vector
13764 * @param {vec2} a the first operand
13765 * @param {vec2} b the second operand
13766 * @param {Number} scale the amount to scale b by before adding
13767 * @returns {vec2} out
13768 */
13769function scaleAndAdd(out, a, b, scale) {
13770 out[0] = a[0] + b[0] * scale;
13771 out[1] = a[1] + b[1] * scale;
13772 return out;
13773}
13774
13775/**
13776 * Calculates the euclidian distance between two vec2's
13777 *
13778 * @param {vec2} a the first operand
13779 * @param {vec2} b the second operand
13780 * @returns {Number} distance between a and b
13781 */
13782function distance(a, b) {
13783 var x = b[0] - a[0],
13784 y = b[1] - a[1];
13785 return Math.sqrt(x * x + y * y);
13786}
13787
13788/**
13789 * Calculates the squared euclidian distance between two vec2's
13790 *
13791 * @param {vec2} a the first operand
13792 * @param {vec2} b the second operand
13793 * @returns {Number} squared distance between a and b
13794 */
13795function squaredDistance(a, b) {
13796 var x = b[0] - a[0],
13797 y = b[1] - a[1];
13798 return x * x + y * y;
13799}
13800
13801/**
13802 * Calculates the length of a vec2
13803 *
13804 * @param {vec2} a vector to calculate length of
13805 * @returns {Number} length of a
13806 */
13807function length(a) {
13808 var x = a[0],
13809 y = a[1];
13810 return Math.sqrt(x * x + y * y);
13811}
13812
13813/**
13814 * Calculates the squared length of a vec2
13815 *
13816 * @param {vec2} a vector to calculate squared length of
13817 * @returns {Number} squared length of a
13818 */
13819function squaredLength(a) {
13820 var x = a[0],
13821 y = a[1];
13822 return x * x + y * y;
13823}
13824
13825/**
13826 * Negates the components of a vec2
13827 *
13828 * @param {vec2} out the receiving vector
13829 * @param {vec2} a vector to negate
13830 * @returns {vec2} out
13831 */
13832function negate(out, a) {
13833 out[0] = -a[0];
13834 out[1] = -a[1];
13835 return out;
13836}
13837
13838/**
13839 * Returns the inverse of the components of a vec2
13840 *
13841 * @param {vec2} out the receiving vector
13842 * @param {vec2} a vector to invert
13843 * @returns {vec2} out
13844 */
13845function inverse(out, a) {
13846 out[0] = 1.0 / a[0];
13847 out[1] = 1.0 / a[1];
13848 return out;
13849}
13850
13851/**
13852 * Normalize a vec2
13853 *
13854 * @param {vec2} out the receiving vector
13855 * @param {vec2} a vector to normalize
13856 * @returns {vec2} out
13857 */
13858function normalize(out, a) {
13859 var x = a[0],
13860 y = a[1];
13861 var len = x * x + y * y;
13862 if (len > 0) {
13863 //TODO: evaluate use of glm_invsqrt here?
13864 len = 1 / Math.sqrt(len);
13865 out[0] = a[0] * len;
13866 out[1] = a[1] * len;
13867 }
13868 return out;
13869}
13870
13871/**
13872 * Calculates the dot product of two vec2's
13873 *
13874 * @param {vec2} a the first operand
13875 * @param {vec2} b the second operand
13876 * @returns {Number} dot product of a and b
13877 */
13878function dot(a, b) {
13879 return a[0] * b[0] + a[1] * b[1];
13880}
13881
13882/**
13883 * Computes the cross product of two vec2's
13884 * Note that the cross product must by definition produce a 3D vector
13885 *
13886 * @param {vec3} out the receiving vector
13887 * @param {vec2} a the first operand
13888 * @param {vec2} b the second operand
13889 * @returns {vec3} out
13890 */
13891function cross(out, a, b) {
13892 var z = a[0] * b[1] - a[1] * b[0];
13893 out[0] = out[1] = 0;
13894 out[2] = z;
13895 return out;
13896}
13897
13898/**
13899 * Performs a linear interpolation between two vec2's
13900 *
13901 * @param {vec2} out the receiving vector
13902 * @param {vec2} a the first operand
13903 * @param {vec2} b the second operand
13904 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13905 * @returns {vec2} out
13906 */
13907function lerp(out, a, b, t) {
13908 var ax = a[0],
13909 ay = a[1];
13910 out[0] = ax + t * (b[0] - ax);
13911 out[1] = ay + t * (b[1] - ay);
13912 return out;
13913}
13914
13915/**
13916 * Generates a random vector with the given scale
13917 *
13918 * @param {vec2} out the receiving vector
13919 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
13920 * @returns {vec2} out
13921 */
13922function random(out, scale) {
13923 scale = scale || 1.0;
13924 var r = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 * Math.PI;
13925 out[0] = Math.cos(r) * scale;
13926 out[1] = Math.sin(r) * scale;
13927 return out;
13928}
13929
13930/**
13931 * Transforms the vec2 with a mat2
13932 *
13933 * @param {vec2} out the receiving vector
13934 * @param {vec2} a the vector to transform
13935 * @param {mat2} m matrix to transform with
13936 * @returns {vec2} out
13937 */
13938function transformMat2(out, a, m) {
13939 var x = a[0],
13940 y = a[1];
13941 out[0] = m[0] * x + m[2] * y;
13942 out[1] = m[1] * x + m[3] * y;
13943 return out;
13944}
13945
13946/**
13947 * Transforms the vec2 with a mat2d
13948 *
13949 * @param {vec2} out the receiving vector
13950 * @param {vec2} a the vector to transform
13951 * @param {mat2d} m matrix to transform with
13952 * @returns {vec2} out
13953 */
13954function transformMat2d(out, a, m) {
13955 var x = a[0],
13956 y = a[1];
13957 out[0] = m[0] * x + m[2] * y + m[4];
13958 out[1] = m[1] * x + m[3] * y + m[5];
13959 return out;
13960}
13961
13962/**
13963 * Transforms the vec2 with a mat3
13964 * 3rd vector component is implicitly '1'
13965 *
13966 * @param {vec2} out the receiving vector
13967 * @param {vec2} a the vector to transform
13968 * @param {mat3} m matrix to transform with
13969 * @returns {vec2} out
13970 */
13971function transformMat3(out, a, m) {
13972 var x = a[0],
13973 y = a[1];
13974 out[0] = m[0] * x + m[3] * y + m[6];
13975 out[1] = m[1] * x + m[4] * y + m[7];
13976 return out;
13977}
13978
13979/**
13980 * Transforms the vec2 with a mat4
13981 * 3rd vector component is implicitly '0'
13982 * 4th vector component is implicitly '1'
13983 *
13984 * @param {vec2} out the receiving vector
13985 * @param {vec2} a the vector to transform
13986 * @param {mat4} m matrix to transform with
13987 * @returns {vec2} out
13988 */
13989function transformMat4(out, a, m) {
13990 var x = a[0];
13991 var y = a[1];
13992 out[0] = m[0] * x + m[4] * y + m[12];
13993 out[1] = m[1] * x + m[5] * y + m[13];
13994 return out;
13995}
13996
13997/**
13998 * Rotate a 2D vector
13999 * @param {vec2} out The receiving vec2
14000 * @param {vec2} a The vec2 point to rotate
14001 * @param {vec2} b The origin of the rotation
14002 * @param {Number} c The angle of rotation
14003 * @returns {vec2} out
14004 */
14005function rotate(out, a, b, c) {
14006 //Translate point to the origin
14007 var p0 = a[0] - b[0],
14008 p1 = a[1] - b[1],
14009 sinC = Math.sin(c),
14010 cosC = Math.cos(c);
14011
14012 //perform rotation and translate to correct position
14013 out[0] = p0 * cosC - p1 * sinC + b[0];
14014 out[1] = p0 * sinC + p1 * cosC + b[1];
14015
14016 return out;
14017}
14018
14019/**
14020 * Get the angle between two 2D vectors
14021 * @param {vec2} a The first operand
14022 * @param {vec2} b The second operand
14023 * @returns {Number} The angle in radians
14024 */
14025function angle(a, b) {
14026 var x1 = a[0],
14027 y1 = a[1],
14028 x2 = b[0],
14029 y2 = b[1];
14030
14031 var len1 = x1 * x1 + y1 * y1;
14032 if (len1 > 0) {
14033 //TODO: evaluate use of glm_invsqrt here?
14034 len1 = 1 / Math.sqrt(len1);
14035 }
14036
14037 var len2 = x2 * x2 + y2 * y2;
14038 if (len2 > 0) {
14039 //TODO: evaluate use of glm_invsqrt here?
14040 len2 = 1 / Math.sqrt(len2);
14041 }
14042
14043 var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
14044
14045 if (cosine > 1.0) {
14046 return 0;
14047 } else if (cosine < -1.0) {
14048 return Math.PI;
14049 } else {
14050 return Math.acos(cosine);
14051 }
14052}
14053
14054/**
14055 * Returns a string representation of a vector
14056 *
14057 * @param {vec2} a vector to represent as a string
14058 * @returns {String} string representation of the vector
14059 */
14060function str(a) {
14061 return 'vec2(' + a[0] + ', ' + a[1] + ')';
14062}
14063
14064/**
14065 * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
14066 *
14067 * @param {vec2} a The first vector.
14068 * @param {vec2} b The second vector.
14069 * @returns {Boolean} True if the vectors are equal, false otherwise.
14070 */
14071function exactEquals(a, b) {
14072 return a[0] === b[0] && a[1] === b[1];
14073}
14074
14075/**
14076 * Returns whether or not the vectors have approximately the same elements in the same position.
14077 *
14078 * @param {vec2} a The first vector.
14079 * @param {vec2} b The second vector.
14080 * @returns {Boolean} True if the vectors are equal, false otherwise.
14081 */
14082function equals(a, b) {
14083 var a0 = a[0],
14084 a1 = a[1];
14085 var b0 = b[0],
14086 b1 = b[1];
14087 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1));
14088}
14089
14090/**
14091 * Alias for {@link vec2.length}
14092 * @function
14093 */
14094var len = length;
14095
14096/**
14097 * Alias for {@link vec2.subtract}
14098 * @function
14099 */
14100var sub = subtract;
14101
14102/**
14103 * Alias for {@link vec2.multiply}
14104 * @function
14105 */
14106var mul = multiply;
14107
14108/**
14109 * Alias for {@link vec2.divide}
14110 * @function
14111 */
14112var div = divide;
14113
14114/**
14115 * Alias for {@link vec2.distance}
14116 * @function
14117 */
14118var dist = distance;
14119
14120/**
14121 * Alias for {@link vec2.squaredDistance}
14122 * @function
14123 */
14124var sqrDist = squaredDistance;
14125
14126/**
14127 * Alias for {@link vec2.squaredLength}
14128 * @function
14129 */
14130var sqrLen = squaredLength;
14131
14132/**
14133 * Perform some operation over an array of vec2s.
14134 *
14135 * @param {Array} a the array of vectors to iterate over
14136 * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
14137 * @param {Number} offset Number of elements to skip at the beginning of the array
14138 * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
14139 * @param {Function} fn Function to call for each vector in the array
14140 * @param {Object} [arg] additional argument to pass to fn
14141 * @returns {Array} a
14142 * @function
14143 */
14144var forEach = function () {
14145 var vec = create();
14146
14147 return function (a, stride, offset, count, fn, arg) {
14148 var i = void 0,
14149 l = void 0;
14150 if (!stride) {
14151 stride = 2;
14152 }
14153
14154 if (!offset) {
14155 offset = 0;
14156 }
14157
14158 if (count) {
14159 l = Math.min(count * stride + offset, a.length);
14160 } else {
14161 l = a.length;
14162 }
14163
14164 for (i = offset; i < l; i += stride) {
14165 vec[0] = a[i];vec[1] = a[i + 1];
14166 fn(vec, vec, arg);
14167 a[i] = vec[0];a[i + 1] = vec[1];
14168 }
14169
14170 return a;
14171 };
14172}();
14173
14174/***/ }),
14175/* 77 */
14176/***/ (function(module, __webpack_exports__, __webpack_require__) {
14177
14178"use strict";
14179Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14180/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_linear__ = __webpack_require__(78);
14181/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeLinear", function() { return __WEBPACK_IMPORTED_MODULE_0__src_linear__["a"]; });
14182/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_quad__ = __webpack_require__(79);
14183/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuad", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; });
14184/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadIn", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["a"]; });
14185/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadOut", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["c"]; });
14186/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadInOut", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; });
14187/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_cubic__ = __webpack_require__(80);
14188/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubic", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; });
14189/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicIn", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["a"]; });
14190/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicOut", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["c"]; });
14191/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicInOut", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; });
14192/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_poly__ = __webpack_require__(81);
14193/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePoly", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; });
14194/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyIn", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["a"]; });
14195/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyOut", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["c"]; });
14196/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyInOut", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; });
14197/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_sin__ = __webpack_require__(82);
14198/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSin", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; });
14199/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinIn", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["a"]; });
14200/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinOut", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["c"]; });
14201/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinInOut", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; });
14202/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_exp__ = __webpack_require__(83);
14203/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExp", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; });
14204/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpIn", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["a"]; });
14205/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpOut", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["c"]; });
14206/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpInOut", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; });
14207/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_circle__ = __webpack_require__(84);
14208/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircle", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; });
14209/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleIn", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["a"]; });
14210/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleOut", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["c"]; });
14211/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleInOut", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; });
14212/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_bounce__ = __webpack_require__(85);
14213/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounce", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; });
14214/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceIn", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["a"]; });
14215/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceOut", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; });
14216/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceInOut", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["b"]; });
14217/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_back__ = __webpack_require__(86);
14218/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBack", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; });
14219/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackIn", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["a"]; });
14220/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackOut", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["c"]; });
14221/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackInOut", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; });
14222/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_elastic__ = __webpack_require__(87);
14223/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElastic", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; });
14224/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticIn", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["a"]; });
14225/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticOut", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; });
14226/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticInOut", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["b"]; });
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247/***/ }),
14248/* 78 */
14249/***/ (function(module, __webpack_exports__, __webpack_require__) {
14250
14251"use strict";
14252/* harmony export (immutable) */ __webpack_exports__["a"] = linear;
14253function linear(t) {
14254 return +t;
14255}
14256
14257/***/ }),
14258/* 79 */
14259/***/ (function(module, __webpack_exports__, __webpack_require__) {
14260
14261"use strict";
14262/* harmony export (immutable) */ __webpack_exports__["a"] = quadIn;
14263/* harmony export (immutable) */ __webpack_exports__["c"] = quadOut;
14264/* harmony export (immutable) */ __webpack_exports__["b"] = quadInOut;
14265function quadIn(t) {
14266 return t * t;
14267}
14268
14269function quadOut(t) {
14270 return t * (2 - t);
14271}
14272
14273function quadInOut(t) {
14274 return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
14275}
14276
14277/***/ }),
14278/* 80 */
14279/***/ (function(module, __webpack_exports__, __webpack_require__) {
14280
14281"use strict";
14282/* harmony export (immutable) */ __webpack_exports__["a"] = cubicIn;
14283/* harmony export (immutable) */ __webpack_exports__["c"] = cubicOut;
14284/* harmony export (immutable) */ __webpack_exports__["b"] = cubicInOut;
14285function cubicIn(t) {
14286 return t * t * t;
14287}
14288
14289function cubicOut(t) {
14290 return --t * t * t + 1;
14291}
14292
14293function cubicInOut(t) {
14294 return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
14295}
14296
14297/***/ }),
14298/* 81 */
14299/***/ (function(module, __webpack_exports__, __webpack_require__) {
14300
14301"use strict";
14302/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return polyIn; });
14303/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return polyOut; });
14304/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return polyInOut; });
14305var exponent = 3;
14306
14307var polyIn = function custom(e) {
14308 e = +e;
14309
14310 function polyIn(t) {
14311 return Math.pow(t, e);
14312 }
14313
14314 polyIn.exponent = custom;
14315
14316 return polyIn;
14317}(exponent);
14318
14319var polyOut = function custom(e) {
14320 e = +e;
14321
14322 function polyOut(t) {
14323 return 1 - Math.pow(1 - t, e);
14324 }
14325
14326 polyOut.exponent = custom;
14327
14328 return polyOut;
14329}(exponent);
14330
14331var polyInOut = function custom(e) {
14332 e = +e;
14333
14334 function polyInOut(t) {
14335 return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
14336 }
14337
14338 polyInOut.exponent = custom;
14339
14340 return polyInOut;
14341}(exponent);
14342
14343/***/ }),
14344/* 82 */
14345/***/ (function(module, __webpack_exports__, __webpack_require__) {
14346
14347"use strict";
14348/* harmony export (immutable) */ __webpack_exports__["a"] = sinIn;
14349/* harmony export (immutable) */ __webpack_exports__["c"] = sinOut;
14350/* harmony export (immutable) */ __webpack_exports__["b"] = sinInOut;
14351var pi = Math.PI,
14352 halfPi = pi / 2;
14353
14354function sinIn(t) {
14355 return 1 - Math.cos(t * halfPi);
14356}
14357
14358function sinOut(t) {
14359 return Math.sin(t * halfPi);
14360}
14361
14362function sinInOut(t) {
14363 return (1 - Math.cos(pi * t)) / 2;
14364}
14365
14366/***/ }),
14367/* 83 */
14368/***/ (function(module, __webpack_exports__, __webpack_require__) {
14369
14370"use strict";
14371/* harmony export (immutable) */ __webpack_exports__["a"] = expIn;
14372/* harmony export (immutable) */ __webpack_exports__["c"] = expOut;
14373/* harmony export (immutable) */ __webpack_exports__["b"] = expInOut;
14374function expIn(t) {
14375 return Math.pow(2, 10 * t - 10);
14376}
14377
14378function expOut(t) {
14379 return 1 - Math.pow(2, -10 * t);
14380}
14381
14382function expInOut(t) {
14383 return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
14384}
14385
14386/***/ }),
14387/* 84 */
14388/***/ (function(module, __webpack_exports__, __webpack_require__) {
14389
14390"use strict";
14391/* harmony export (immutable) */ __webpack_exports__["a"] = circleIn;
14392/* harmony export (immutable) */ __webpack_exports__["c"] = circleOut;
14393/* harmony export (immutable) */ __webpack_exports__["b"] = circleInOut;
14394function circleIn(t) {
14395 return 1 - Math.sqrt(1 - t * t);
14396}
14397
14398function circleOut(t) {
14399 return Math.sqrt(1 - --t * t);
14400}
14401
14402function circleInOut(t) {
14403 return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
14404}
14405
14406/***/ }),
14407/* 85 */
14408/***/ (function(module, __webpack_exports__, __webpack_require__) {
14409
14410"use strict";
14411/* harmony export (immutable) */ __webpack_exports__["a"] = bounceIn;
14412/* harmony export (immutable) */ __webpack_exports__["c"] = bounceOut;
14413/* harmony export (immutable) */ __webpack_exports__["b"] = bounceInOut;
14414var b1 = 4 / 11,
14415 b2 = 6 / 11,
14416 b3 = 8 / 11,
14417 b4 = 3 / 4,
14418 b5 = 9 / 11,
14419 b6 = 10 / 11,
14420 b7 = 15 / 16,
14421 b8 = 21 / 22,
14422 b9 = 63 / 64,
14423 b0 = 1 / b1 / b1;
14424
14425function bounceIn(t) {
14426 return 1 - bounceOut(1 - t);
14427}
14428
14429function bounceOut(t) {
14430 return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
14431}
14432
14433function bounceInOut(t) {
14434 return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
14435}
14436
14437/***/ }),
14438/* 86 */
14439/***/ (function(module, __webpack_exports__, __webpack_require__) {
14440
14441"use strict";
14442/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return backIn; });
14443/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return backOut; });
14444/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return backInOut; });
14445var overshoot = 1.70158;
14446
14447var backIn = function custom(s) {
14448 s = +s;
14449
14450 function backIn(t) {
14451 return t * t * ((s + 1) * t - s);
14452 }
14453
14454 backIn.overshoot = custom;
14455
14456 return backIn;
14457}(overshoot);
14458
14459var backOut = function custom(s) {
14460 s = +s;
14461
14462 function backOut(t) {
14463 return --t * t * ((s + 1) * t + s) + 1;
14464 }
14465
14466 backOut.overshoot = custom;
14467
14468 return backOut;
14469}(overshoot);
14470
14471var backInOut = function custom(s) {
14472 s = +s;
14473
14474 function backInOut(t) {
14475 return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
14476 }
14477
14478 backInOut.overshoot = custom;
14479
14480 return backInOut;
14481}(overshoot);
14482
14483/***/ }),
14484/* 87 */
14485/***/ (function(module, __webpack_exports__, __webpack_require__) {
14486
14487"use strict";
14488/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return elasticIn; });
14489/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return elasticOut; });
14490/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return elasticInOut; });
14491var tau = 2 * Math.PI,
14492 amplitude = 1,
14493 period = 0.3;
14494
14495var elasticIn = function custom(a, p) {
14496 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14497
14498 function elasticIn(t) {
14499 return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
14500 }
14501
14502 elasticIn.amplitude = function (a) {
14503 return custom(a, p * tau);
14504 };
14505 elasticIn.period = function (p) {
14506 return custom(a, p);
14507 };
14508
14509 return elasticIn;
14510}(amplitude, period);
14511
14512var elasticOut = function custom(a, p) {
14513 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14514
14515 function elasticOut(t) {
14516 return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
14517 }
14518
14519 elasticOut.amplitude = function (a) {
14520 return custom(a, p * tau);
14521 };
14522 elasticOut.period = function (p) {
14523 return custom(a, p);
14524 };
14525
14526 return elasticOut;
14527}(amplitude, period);
14528
14529var elasticInOut = function custom(a, p) {
14530 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14531
14532 function elasticInOut(t) {
14533 return ((t = t * 2 - 1) < 0 ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p) : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
14534 }
14535
14536 elasticInOut.amplitude = function (a) {
14537 return custom(a, p * tau);
14538 };
14539 elasticInOut.period = function (p) {
14540 return custom(a, p);
14541 };
14542
14543 return elasticInOut;
14544}(amplitude, period);
14545
14546/***/ }),
14547/* 88 */
14548/***/ (function(module, __webpack_exports__, __webpack_require__) {
14549
14550"use strict";
14551Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14552/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_timer__ = __webpack_require__(16);
14553/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "now", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["b"]; });
14554/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["c"]; });
14555/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timerFlush", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["d"]; });
14556/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_timeout__ = __webpack_require__(89);
14557/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timeout", function() { return __WEBPACK_IMPORTED_MODULE_1__src_timeout__["a"]; });
14558/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_interval__ = __webpack_require__(90);
14559/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interval", function() { return __WEBPACK_IMPORTED_MODULE_2__src_interval__["a"]; });
14560
14561
14562
14563
14564
14565
14566/***/ }),
14567/* 89 */
14568/***/ (function(module, __webpack_exports__, __webpack_require__) {
14569
14570"use strict";
14571/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(16);
14572
14573
14574/* harmony default export */ __webpack_exports__["a"] = (function (callback, delay, time) {
14575 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */]();
14576 delay = delay == null ? 0 : +delay;
14577 t.restart(function (elapsed) {
14578 t.stop();
14579 callback(elapsed + delay);
14580 }, delay, time);
14581 return t;
14582});
14583
14584/***/ }),
14585/* 90 */
14586/***/ (function(module, __webpack_exports__, __webpack_require__) {
14587
14588"use strict";
14589/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(16);
14590
14591
14592/* harmony default export */ __webpack_exports__["a"] = (function (callback, delay, time) {
14593 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */](),
14594 total = delay;
14595 if (delay == null) return t.restart(callback, delay, time), t;
14596 delay = +delay, time = time == null ? Object(__WEBPACK_IMPORTED_MODULE_0__timer__["b" /* now */])() : +time;
14597 t.restart(function tick(elapsed) {
14598 elapsed += total;
14599 t.restart(tick, total += delay, time);
14600 callback(elapsed);
14601 }, delay, time);
14602 return t;
14603});
14604
14605/***/ }),
14606/* 91 */
14607/***/ (function(module, __webpack_exports__, __webpack_require__) {
14608
14609"use strict";
14610Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14611/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_value__ = __webpack_require__(17);
14612/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolate", function() { return __WEBPACK_IMPORTED_MODULE_0__src_value__["a"]; });
14613/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_array__ = __webpack_require__(37);
14614/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateArray", function() { return __WEBPACK_IMPORTED_MODULE_1__src_array__["a"]; });
14615/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_basis__ = __webpack_require__(20);
14616/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasis", function() { return __WEBPACK_IMPORTED_MODULE_2__src_basis__["b"]; });
14617/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__ = __webpack_require__(35);
14618/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__["a"]; });
14619/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_date__ = __webpack_require__(38);
14620/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateDate", function() { return __WEBPACK_IMPORTED_MODULE_4__src_date__["a"]; });
14621/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_number__ = __webpack_require__(11);
14622/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateNumber", function() { return __WEBPACK_IMPORTED_MODULE_5__src_number__["a"]; });
14623/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_object__ = __webpack_require__(39);
14624/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateObject", function() { return __WEBPACK_IMPORTED_MODULE_6__src_object__["a"]; });
14625/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_round__ = __webpack_require__(94);
14626/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRound", function() { return __WEBPACK_IMPORTED_MODULE_7__src_round__["a"]; });
14627/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_string__ = __webpack_require__(40);
14628/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateString", function() { return __WEBPACK_IMPORTED_MODULE_8__src_string__["a"]; });
14629/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_transform_index__ = __webpack_require__(95);
14630/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformCss", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["a"]; });
14631/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformSvg", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["b"]; });
14632/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_zoom__ = __webpack_require__(98);
14633/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateZoom", function() { return __WEBPACK_IMPORTED_MODULE_10__src_zoom__["a"]; });
14634/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_rgb__ = __webpack_require__(34);
14635/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgb", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["a"]; });
14636/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasis", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["b"]; });
14637/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["c"]; });
14638/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_hsl__ = __webpack_require__(99);
14639/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHsl", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["a"]; });
14640/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHslLong", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["b"]; });
14641/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_lab__ = __webpack_require__(100);
14642/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateLab", function() { return __WEBPACK_IMPORTED_MODULE_13__src_lab__["a"]; });
14643/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_hcl__ = __webpack_require__(101);
14644/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHcl", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["a"]; });
14645/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHclLong", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["b"]; });
14646/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__ = __webpack_require__(102);
14647/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelix", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["b"]; });
14648/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelixLong", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["a"]; });
14649/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_quantize__ = __webpack_require__(103);
14650/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "quantize", function() { return __WEBPACK_IMPORTED_MODULE_16__src_quantize__["a"]; });
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669/***/ }),
14670/* 92 */
14671/***/ (function(module, __webpack_exports__, __webpack_require__) {
14672
14673"use strict";
14674/* unused harmony export gray */
14675/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
14676/* unused harmony export Lab */
14677/* unused harmony export lch */
14678/* harmony export (immutable) */ __webpack_exports__["b"] = hcl;
14679/* unused harmony export Hcl */
14680/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(19);
14681/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(18);
14682/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(33);
14683
14684
14685
14686
14687// https://beta.observablehq.com/@mbostock/lab-and-rgb
14688var K = 18,
14689 Xn = 0.96422,
14690 Yn = 1,
14691 Zn = 0.82521,
14692 t0 = 4 / 29,
14693 t1 = 6 / 29,
14694 t2 = 3 * t1 * t1,
14695 t3 = t1 * t1 * t1;
14696
14697function labConvert(o) {
14698 if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
14699 if (o instanceof Hcl) {
14700 if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
14701 var h = o.h * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */];
14702 return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
14703 }
14704 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
14705 var r = rgb2lrgb(o.r),
14706 g = rgb2lrgb(o.g),
14707 b = rgb2lrgb(o.b),
14708 y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn),
14709 x,
14710 z;
14711 if (r === g && g === b) x = z = y;else {
14712 x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
14713 z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
14714 }
14715 return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
14716}
14717
14718function gray(l, opacity) {
14719 return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
14720}
14721
14722function lab(l, a, b, opacity) {
14723 return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
14724}
14725
14726function Lab(l, a, b, opacity) {
14727 this.l = +l;
14728 this.a = +a;
14729 this.b = +b;
14730 this.opacity = +opacity;
14731}
14732
14733Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Lab, lab, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14734 brighter: function brighter(k) {
14735 return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
14736 },
14737 darker: function darker(k) {
14738 return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
14739 },
14740 rgb: function rgb() {
14741 var y = (this.l + 16) / 116,
14742 x = isNaN(this.a) ? y : y + this.a / 500,
14743 z = isNaN(this.b) ? y : y - this.b / 200;
14744 x = Xn * lab2xyz(x);
14745 y = Yn * lab2xyz(y);
14746 z = Zn * lab2xyz(z);
14747 return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](lrgb2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), lrgb2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity);
14748 }
14749}));
14750
14751function xyz2lab(t) {
14752 return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
14753}
14754
14755function lab2xyz(t) {
14756 return t > t1 ? t * t * t : t2 * (t - t0);
14757}
14758
14759function lrgb2rgb(x) {
14760 return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
14761}
14762
14763function rgb2lrgb(x) {
14764 return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
14765}
14766
14767function hclConvert(o) {
14768 if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
14769 if (!(o instanceof Lab)) o = labConvert(o);
14770 if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0, o.l, o.opacity);
14771 var h = Math.atan2(o.b, o.a) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */];
14772 return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
14773}
14774
14775function lch(l, c, h, opacity) {
14776 return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
14777}
14778
14779function hcl(h, c, l, opacity) {
14780 return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
14781}
14782
14783function Hcl(h, c, l, opacity) {
14784 this.h = +h;
14785 this.c = +c;
14786 this.l = +l;
14787 this.opacity = +opacity;
14788}
14789
14790Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hcl, hcl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14791 brighter: function brighter(k) {
14792 return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
14793 },
14794 darker: function darker(k) {
14795 return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
14796 },
14797 rgb: function rgb() {
14798 return labConvert(this).rgb();
14799 }
14800}));
14801
14802/***/ }),
14803/* 93 */
14804/***/ (function(module, __webpack_exports__, __webpack_require__) {
14805
14806"use strict";
14807/* harmony export (immutable) */ __webpack_exports__["a"] = cubehelix;
14808/* unused harmony export Cubehelix */
14809/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(19);
14810/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(18);
14811/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(33);
14812
14813
14814
14815
14816var A = -0.14861,
14817 B = +1.78277,
14818 C = -0.29227,
14819 D = -0.90649,
14820 E = +1.97294,
14821 ED = E * D,
14822 EB = E * B,
14823 BC_DA = B * C - D * A;
14824
14825function cubehelixConvert(o) {
14826 if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
14827 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
14828 var r = o.r / 255,
14829 g = o.g / 255,
14830 b = o.b / 255,
14831 l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
14832 bl = b - l,
14833 k = (E * (g - l) - C * bl) / D,
14834 s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)),
14835 // NaN if l=0 or l=1
14836 h = s ? Math.atan2(k, bl) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */] - 120 : NaN;
14837 return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
14838}
14839
14840function cubehelix(h, s, l, opacity) {
14841 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
14842}
14843
14844function Cubehelix(h, s, l, opacity) {
14845 this.h = +h;
14846 this.s = +s;
14847 this.l = +l;
14848 this.opacity = +opacity;
14849}
14850
14851Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Cubehelix, cubehelix, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14852 brighter: function brighter(k) {
14853 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */], k);
14854 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
14855 },
14856 darker: function darker(k) {
14857 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */], k);
14858 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
14859 },
14860 rgb: function rgb() {
14861 var h = isNaN(this.h) ? 0 : (this.h + 120) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */],
14862 l = +this.l,
14863 a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
14864 cosh = Math.cos(h),
14865 sinh = Math.sin(h);
14866 return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity);
14867 }
14868}));
14869
14870/***/ }),
14871/* 94 */
14872/***/ (function(module, __webpack_exports__, __webpack_require__) {
14873
14874"use strict";
14875/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
14876 return a = +a, b -= a, function (t) {
14877 return Math.round(a + b * t);
14878 };
14879});
14880
14881/***/ }),
14882/* 95 */
14883/***/ (function(module, __webpack_exports__, __webpack_require__) {
14884
14885"use strict";
14886/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return interpolateTransformCss; });
14887/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return interpolateTransformSvg; });
14888/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(11);
14889/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(96);
14890
14891
14892
14893function interpolateTransform(parse, pxComma, pxParen, degParen) {
14894
14895 function pop(s) {
14896 return s.length ? s.pop() + " " : "";
14897 }
14898
14899 function translate(xa, ya, xb, yb, s, q) {
14900 if (xa !== xb || ya !== yb) {
14901 var i = s.push("translate(", null, pxComma, null, pxParen);
14902 q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) });
14903 } else if (xb || yb) {
14904 s.push("translate(" + xb + pxComma + yb + pxParen);
14905 }
14906 }
14907
14908 function rotate(a, b, s, q) {
14909 if (a !== b) {
14910 if (a - b > 180) b += 360;else if (b - a > 180) a += 360; // shortest path
14911 q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
14912 } else if (b) {
14913 s.push(pop(s) + "rotate(" + b + degParen);
14914 }
14915 }
14916
14917 function skewX(a, b, s, q) {
14918 if (a !== b) {
14919 q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
14920 } else if (b) {
14921 s.push(pop(s) + "skewX(" + b + degParen);
14922 }
14923 }
14924
14925 function scale(xa, ya, xb, yb, s, q) {
14926 if (xa !== xb || ya !== yb) {
14927 var i = s.push(pop(s) + "scale(", null, ",", null, ")");
14928 q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) });
14929 } else if (xb !== 1 || yb !== 1) {
14930 s.push(pop(s) + "scale(" + xb + "," + yb + ")");
14931 }
14932 }
14933
14934 return function (a, b) {
14935 var s = [],
14936 // string constants and placeholders
14937 q = []; // number interpolators
14938 a = parse(a), b = parse(b);
14939 translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
14940 rotate(a.rotate, b.rotate, s, q);
14941 skewX(a.skewX, b.skewX, s, q);
14942 scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
14943 a = b = null; // gc
14944 return function (t) {
14945 var i = -1,
14946 n = q.length,
14947 o;
14948 while (++i < n) {
14949 s[(o = q[i]).i] = o.x(t);
14950 }return s.join("");
14951 };
14952 };
14953}
14954
14955var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)");
14956var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")");
14957
14958/***/ }),
14959/* 96 */
14960/***/ (function(module, __webpack_exports__, __webpack_require__) {
14961
14962"use strict";
14963/* harmony export (immutable) */ __webpack_exports__["a"] = parseCss;
14964/* harmony export (immutable) */ __webpack_exports__["b"] = parseSvg;
14965/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(97);
14966
14967
14968var cssNode, cssRoot, cssView, svgNode;
14969
14970function parseCss(value) {
14971 if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
14972 if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
14973 cssNode.style.transform = value;
14974 value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
14975 cssRoot.removeChild(cssNode);
14976 value = value.slice(7, -1).split(",");
14977 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
14978}
14979
14980function parseSvg(value) {
14981 if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
14982 if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
14983 svgNode.setAttribute("transform", value);
14984 if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
14985 value = value.matrix;
14986 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f);
14987}
14988
14989/***/ }),
14990/* 97 */
14991/***/ (function(module, __webpack_exports__, __webpack_require__) {
14992
14993"use strict";
14994/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return identity; });
14995var degrees = 180 / Math.PI;
14996
14997var identity = {
14998 translateX: 0,
14999 translateY: 0,
15000 rotate: 0,
15001 skewX: 0,
15002 scaleX: 1,
15003 scaleY: 1
15004};
15005
15006/* harmony default export */ __webpack_exports__["a"] = (function (a, b, c, d, e, f) {
15007 var scaleX, scaleY, skewX;
15008 if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
15009 if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
15010 if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
15011 if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
15012 return {
15013 translateX: e,
15014 translateY: f,
15015 rotate: Math.atan2(b, a) * degrees,
15016 skewX: Math.atan(skewX) * degrees,
15017 scaleX: scaleX,
15018 scaleY: scaleY
15019 };
15020});
15021
15022/***/ }),
15023/* 98 */
15024/***/ (function(module, __webpack_exports__, __webpack_require__) {
15025
15026"use strict";
15027var rho = Math.SQRT2,
15028 rho2 = 2,
15029 rho4 = 4,
15030 epsilon2 = 1e-12;
15031
15032function cosh(x) {
15033 return ((x = Math.exp(x)) + 1 / x) / 2;
15034}
15035
15036function sinh(x) {
15037 return ((x = Math.exp(x)) - 1 / x) / 2;
15038}
15039
15040function tanh(x) {
15041 return ((x = Math.exp(2 * x)) - 1) / (x + 1);
15042}
15043
15044// p0 = [ux0, uy0, w0]
15045// p1 = [ux1, uy1, w1]
15046/* harmony default export */ __webpack_exports__["a"] = (function (p0, p1) {
15047 var ux0 = p0[0],
15048 uy0 = p0[1],
15049 w0 = p0[2],
15050 ux1 = p1[0],
15051 uy1 = p1[1],
15052 w1 = p1[2],
15053 dx = ux1 - ux0,
15054 dy = uy1 - uy0,
15055 d2 = dx * dx + dy * dy,
15056 i,
15057 S;
15058
15059 // Special case for u0 ≅ u1.
15060 if (d2 < epsilon2) {
15061 S = Math.log(w1 / w0) / rho;
15062 i = function i(t) {
15063 return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
15064 };
15065 }
15066
15067 // General case.
15068 else {
15069 var d1 = Math.sqrt(d2),
15070 b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
15071 b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
15072 r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
15073 r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
15074 S = (r1 - r0) / rho;
15075 i = function i(t) {
15076 var s = t * S,
15077 coshr0 = cosh(r0),
15078 u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
15079 return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)];
15080 };
15081 }
15082
15083 i.duration = S * 1000;
15084
15085 return i;
15086});
15087
15088/***/ }),
15089/* 99 */
15090/***/ (function(module, __webpack_exports__, __webpack_require__) {
15091
15092"use strict";
15093/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hslLong; });
15094/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15095/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15096
15097
15098
15099function hsl(hue) {
15100 return function (start, end) {
15101 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(end)).h),
15102 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
15103 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15104 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15105 return function (t) {
15106 start.h = h(t);
15107 start.s = s(t);
15108 start.l = l(t);
15109 start.opacity = opacity(t);
15110 return start + "";
15111 };
15112 };
15113}
15114
15115/* harmony default export */ __webpack_exports__["a"] = (hsl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15116var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15117
15118/***/ }),
15119/* 100 */
15120/***/ (function(module, __webpack_exports__, __webpack_require__) {
15121
15122"use strict";
15123/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
15124/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15125/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15126
15127
15128
15129function lab(start, end) {
15130 var l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(start)).l, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(end)).l),
15131 a = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a),
15132 b = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b),
15133 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15134 return function (t) {
15135 start.l = l(t);
15136 start.a = a(t);
15137 start.b = b(t);
15138 start.opacity = opacity(t);
15139 return start + "";
15140 };
15141}
15142
15143/***/ }),
15144/* 101 */
15145/***/ (function(module, __webpack_exports__, __webpack_require__) {
15146
15147"use strict";
15148/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hclLong; });
15149/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15150/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15151
15152
15153
15154function hcl(hue) {
15155 return function (start, end) {
15156 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(end)).h),
15157 c = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c),
15158 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15159 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15160 return function (t) {
15161 start.h = h(t);
15162 start.c = c(t);
15163 start.l = l(t);
15164 start.opacity = opacity(t);
15165 return start + "";
15166 };
15167 };
15168}
15169
15170/* harmony default export */ __webpack_exports__["a"] = (hcl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15171var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15172
15173/***/ }),
15174/* 102 */
15175/***/ (function(module, __webpack_exports__, __webpack_require__) {
15176
15177"use strict";
15178/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cubehelixLong; });
15179/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15180/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15181
15182
15183
15184function cubehelix(hue) {
15185 return function cubehelixGamma(y) {
15186 y = +y;
15187
15188 function cubehelix(start, end) {
15189 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(end)).h),
15190 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
15191 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15192 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15193 return function (t) {
15194 start.h = h(t);
15195 start.s = s(t);
15196 start.l = l(Math.pow(t, y));
15197 start.opacity = opacity(t);
15198 return start + "";
15199 };
15200 }
15201
15202 cubehelix.gamma = cubehelixGamma;
15203
15204 return cubehelix;
15205 }(1);
15206}
15207
15208/* harmony default export */ __webpack_exports__["b"] = (cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15209var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15210
15211/***/ }),
15212/* 103 */
15213/***/ (function(module, __webpack_exports__, __webpack_require__) {
15214
15215"use strict";
15216/* harmony default export */ __webpack_exports__["a"] = (function (interpolator, n) {
15217 var samples = new Array(n);
15218 for (var i = 0; i < n; ++i) {
15219 samples[i] = interpolator(i / (n - 1));
15220 }return samples;
15221});
15222
15223/***/ }),
15224/* 104 */
15225/***/ (function(module, exports, __webpack_require__) {
15226
15227var Shape = __webpack_require__(4);
15228Shape.Rect = __webpack_require__(42);
15229Shape.Circle = __webpack_require__(43);
15230Shape.Ellipse = __webpack_require__(44);
15231Shape.Path = __webpack_require__(45);
15232Shape.Text = __webpack_require__(46);
15233Shape.Line = __webpack_require__(47);
15234Shape.Image = __webpack_require__(48);
15235Shape.Polygon = __webpack_require__(49);
15236Shape.Marker = __webpack_require__(50);
15237Shape.Dom = __webpack_require__(51);
15238Shape.Fa = __webpack_require__(52);
15239
15240module.exports = Shape;
15241
15242/***/ }),
15243/* 105 */
15244/***/ (function(module, exports, __webpack_require__) {
15245
15246/**
15247 * Created by Elaine on 2018/5/9.
15248 */
15249var Util = __webpack_require__(0);
15250var Element = __webpack_require__(13);
15251var Gradient = __webpack_require__(106);
15252var Shadow = __webpack_require__(107);
15253var Arrow = __webpack_require__(108);
15254var Clip = __webpack_require__(109);
15255
15256var Defs = function Defs(cfg) {
15257 Defs.superclass.constructor.call(this, cfg);
15258 this.set('children', []);
15259};
15260
15261Util.extend(Defs, Element);
15262
15263Util.augment(Defs, {
15264 isGroup: false,
15265 canFill: false,
15266 canStroke: false,
15267 capture: false,
15268 visible: false,
15269 init: function init() {
15270 var el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
15271 var id = Util.uniqueId('defs_');
15272 el.setAttribute('id', id);
15273 this.set('el', el);
15274 this.set('children', []);
15275 },
15276 find: function find(type, attr) {
15277 var children = this.get('children');
15278 var result = null;
15279 for (var i = 0; i < children.length; i++) {
15280 if (children[i].match(type, attr)) {
15281 result = children[i].__cfg.id;
15282 break;
15283 }
15284 }
15285 return result;
15286 },
15287 findById: function findById(id) {
15288 var children = this.get('children');
15289 var flag = null;
15290 for (var i = 0; i < children.length; i++) {
15291 if (children[i].__cfg.id === id) {
15292 flag = children[i];
15293 break;
15294 }
15295 }
15296 return flag;
15297 },
15298 add: function add(items) {
15299 var el = this.get('el');
15300 var self = this;
15301 var children = this.get('children');
15302 if (Util.isArray(items)) {
15303 Util.each(items, function (item) {
15304 var parent = item.get('parent');
15305 if (parent) {
15306 parent.removeChild(item, false);
15307 self._setContext(item);
15308 }
15309 el.appendChild(item.get('el'));
15310 });
15311 children.push.apply(children, items);
15312 return self;
15313 }
15314 if (self.findById(items.get('id'))) {
15315 return self;
15316 }
15317 var parent = items.get('parent');
15318 if (parent) {
15319 parent.removeChild(items, false);
15320 }
15321 self._add(items);
15322 el.appendChild(items.get('el'));
15323 return self;
15324 },
15325 _add: function _add(item) {
15326 this.get('el').appendChild(item.__cfg.el);
15327 this.get('children').push(item);
15328 item.__cfg.parent = this;
15329 item.__cfg.defs = this;
15330 item.__cfg.canvas = this.__cfg.canvas;
15331 },
15332 addGradient: function addGradient(cfg) {
15333 var gradient = new Gradient(cfg);
15334 this._add(gradient);
15335 return gradient.__cfg.id;
15336 },
15337 addShadow: function addShadow(cfg) {
15338 var shadow = new Shadow(cfg);
15339 this._add(shadow);
15340 return shadow.__cfg.id;
15341 },
15342 addArrow: function addArrow(name, cfg, stroke) {
15343 var arrow = new Arrow(name, cfg, stroke);
15344 this._add(arrow);
15345 return arrow.__cfg.id;
15346 },
15347 addClip: function addClip(cfg) {
15348 var clip = new Clip(cfg);
15349 this._add(clip);
15350 return clip.__cfg.id;
15351 }
15352});
15353
15354module.exports = Defs;
15355
15356/***/ }),
15357/* 106 */
15358/***/ (function(module, exports, __webpack_require__) {
15359
15360/**
15361 * Created by Elaine on 2018/5/9.
15362 */
15363var Util = __webpack_require__(0);
15364
15365var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
15366var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
15367var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
15368
15369function addStop(steps) {
15370 var arr = steps.match(regexColorStop);
15371 if (!arr) {
15372 return '';
15373 }
15374 var stops = '';
15375 arr.sort(function (a, b) {
15376 a = a.split(':');
15377 b = b.split(':');
15378 return Number(a[0]) - Number(b[0]);
15379 });
15380 Util.each(arr, function (item) {
15381 item = item.split(':');
15382 stops += '<stop offset="' + item[0] + '" stop-color="' + item[1] + '"></stop>';
15383 });
15384 return stops;
15385}
15386
15387function parseLineGradient(color, el) {
15388 var arr = regexLG.exec(color);
15389 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
15390 var steps = arr[2];
15391 var start = void 0;
15392 var end = void 0;
15393
15394 if (angle >= 0 && angle < 0.5 * Math.PI) {
15395 start = {
15396 x: 0,
15397 y: 0
15398 };
15399 end = {
15400 x: 1,
15401 y: 1
15402 };
15403 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
15404 start = {
15405 x: 1,
15406 y: 0
15407 };
15408 end = {
15409 x: 0,
15410 y: 1
15411 };
15412 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
15413 start = {
15414 x: 1,
15415 y: 1
15416 };
15417 end = {
15418 x: 0,
15419 y: 0
15420 };
15421 } else {
15422 start = {
15423 x: 0,
15424 y: 1
15425 };
15426 end = {
15427 x: 1,
15428 y: 0
15429 };
15430 }
15431
15432 var tanTheta = Math.tan(angle);
15433 var tanTheta2 = tanTheta * tanTheta;
15434
15435 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
15436 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
15437 el.setAttribute('x1', start.x);
15438 el.setAttribute('y1', start.y);
15439 el.setAttribute('x2', x);
15440 el.setAttribute('y2', y);
15441 el.innerHTML = addStop(steps);
15442}
15443
15444function parseRadialGradient(color, self) {
15445 var arr = regexRG.exec(color);
15446 var cx = parseFloat(arr[1]);
15447 var cy = parseFloat(arr[2]);
15448 var r = parseFloat(arr[3]);
15449 var steps = arr[4];
15450 self.setAttribute('cx', cx);
15451 self.setAttribute('cy', cy);
15452 self.setAttribute('r', r);
15453 self.innerHTML = addStop(steps);
15454}
15455
15456var Gradient = function Gradient(cfg) {
15457 var el = null;
15458 var id = Util.uniqueId('gradient_');
15459 if (cfg.toLowerCase().startsWith('l')) {
15460 el = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');
15461 parseLineGradient(cfg, el);
15462 } else {
15463 el = document.createElementNS('http://www.w3.org/2000/svg', 'radialGradient');
15464 parseRadialGradient(cfg, el);
15465 }
15466 el.setAttribute('id', id);
15467 this.__cfg = { el: el, id: id };
15468 this.__attrs = { config: cfg };
15469 return this;
15470};
15471
15472Util.augment(Gradient, {
15473 type: 'gradient',
15474 match: function match(type, attr) {
15475 return this.type === type && this.__attrs.config === attr;
15476 }
15477});
15478
15479module.exports = Gradient;
15480
15481/***/ }),
15482/* 107 */
15483/***/ (function(module, exports, __webpack_require__) {
15484
15485/**
15486 * Created by Elaine on 2018/5/10.
15487 */
15488var Util = __webpack_require__(0);
15489
15490var ATTR_MAP = {
15491 shadowColor: 'color',
15492 shadowOpacity: 'opacity',
15493 shadowBlur: 'blur',
15494 shadowOffsetX: 'dx',
15495 shadowOffsetY: 'dy'
15496};
15497
15498function parseShadow(config, el) {
15499 var child = '<feDropShadow \n dx="' + config.dx + '" \n dy="' + config.dy + '" \n stdDeviation="' + (config.blur ? config.blur / 10 : 0) + '"\n flood-color="' + (config.color ? config.color : '#000') + '"\n flood-opacity="' + (config.opacity ? config.opacity : 1) + '"\n />';
15500 el.innerHTML = child;
15501}
15502
15503var Shadow = function Shadow(cfg) {
15504 var el = document.createElementNS('http://www.w3.org/2000/svg', 'filter');
15505 var id = Util.uniqueId('filter_');
15506 el.setAttribute('id', id);
15507 parseShadow(cfg, el);
15508 this.__cfg = { el: el, id: id };
15509 this.__attrs = { config: cfg };
15510 return this;
15511};
15512Util.augment(Shadow, {
15513 type: 'filter',
15514 match: function match(type, cfg) {
15515 if (this.type !== type) {
15516 return false;
15517 }
15518 var flag = false;
15519 var config = this.__attrs.config;
15520 Util.each(Object.keys(config), function (attr) {
15521 if (!flag) {
15522 flag = config[attr] === cfg[attr];
15523 }
15524 });
15525 return flag;
15526 },
15527 update: function update(name, value) {
15528 var config = this.__attrs.config;
15529 config[ATTR_MAP[name]] = value;
15530 parseShadow(config, this.__cfg.el);
15531 return this;
15532 }
15533});
15534
15535module.exports = Shadow;
15536
15537/***/ }),
15538/* 108 */
15539/***/ (function(module, exports, __webpack_require__) {
15540
15541var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
15542
15543/**
15544 * Created by Elaine on 2018/5/11.
15545 */
15546var Util = __webpack_require__(0);
15547
15548var DEFAULT_PATH = {
15549 'marker-start': 'M6,0 L0,3 L6,6 L3,3Z',
15550 'marker-end': 'M0,0 L6,3 L0,6 L3,3Z'
15551};
15552
15553function setDefaultPath(parent, name, stroke) {
15554 var el = document.createElementNS('http://www.w3.org/2000/svg', 'path');
15555 el.setAttribute('d', DEFAULT_PATH[name]);
15556 el.setAttribute('stroke', 'none');
15557 el.setAttribute('fill', stroke || '#000');
15558 parent.appendChild(el);
15559 parent.setAttribute('refX', 3);
15560 parent.setAttribute('refY', 3);
15561 parent.setAttribute('markerWidth', 16);
15562 parent.setAttribute('markerHeight', 16);
15563 parent.setAttribute('orient', 'auto');
15564 return el;
15565}
15566
15567function setMarker(shape, parent, name, stroke) {
15568 if (!shape) {
15569 return setDefaultPath(parent, name);
15570 }
15571 if (shape.type !== 'marker') {
15572 throw new TypeError('the shape of an arrow should be an instance of Marker');
15573 }
15574 shape.attr({ stroke: 'none', fill: stroke });
15575 parent.append(shape.get('el'));
15576 var width = shape.__attrs.x;
15577 var height = shape.__attrs.y;
15578 parent.setAttribute('refX', width);
15579 parent.setAttribute('refY', height);
15580 parent.setAttribute('markerWidth', width * 2);
15581 parent.setAttribute('markerHeight', height * 2);
15582 parent.setAttribute('orient', 'auto');
15583 return shape;
15584}
15585
15586var Arrow = function Arrow(name, cfg, stroke) {
15587 var el = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
15588 var id = Util.uniqueId('marker_');
15589 el.setAttribute('id', id);
15590 this.__cfg = { el: el, id: id, stroke: stroke || '#000' };
15591 this.__cfg[name] = true;
15592 var child = null;
15593 if (typeof cfg === 'boolean' && cfg) {
15594 child = setDefaultPath(el, name, stroke);
15595 this._setChild(child, true);
15596 } else if ((typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) === 'object') {
15597 child = setMarker(cfg, el, name, stroke);
15598 this._setChild(child, false);
15599 }
15600 this.__attrs = { config: cfg };
15601 return this;
15602};
15603
15604Util.augment(Arrow, {
15605 type: 'arrow',
15606 match: function match(type, attr) {
15607 if (!this.__cfg[type]) {
15608 return false;
15609 }
15610 if (_typeof(attr.value) === 'object') {
15611 return false;
15612 }
15613 if (attr.stroke !== '#000') {
15614 return false;
15615 }
15616 if (typeof attr.value === 'boolean' && !this.__cfg.default) {
15617 return false;
15618 }
15619 return true;
15620 },
15621 _setChild: function _setChild(child, isDefault) {
15622 this.__cfg.child = child;
15623 this.__cfg.default = isDefault;
15624 },
15625 update: function update(fill) {
15626 var child = this.__cfg.child;
15627 this.__cfg.default = false;
15628 if (child.attr) {
15629 child.attr('fill', fill);
15630 } else {
15631 child.setAttribute('fill', fill);
15632 }
15633 }
15634});
15635
15636module.exports = Arrow;
15637
15638/***/ }),
15639/* 109 */
15640/***/ (function(module, exports, __webpack_require__) {
15641
15642/**
15643 * Created by Elaine on 2018/5/14.
15644 */
15645var Util = __webpack_require__(0);
15646
15647var Clip = function Clip(cfg) {
15648 var el = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
15649 var id = Util.uniqueId('clip_');
15650 if (cfg.get('el')) {
15651 el.appendChild(cfg.get('el'));
15652 } else if (Util.isString(cfg.nodeName)) {
15653 el.appendChild(cfg);
15654 } else {
15655 throw 'clip element should be a instance of Shape or a SVG node';
15656 }
15657 el.setAttribute('id', id);
15658 this.__cfg = { el: el, id: id };
15659 this.__attrs = { config: cfg };
15660 return this;
15661};
15662
15663Util.augment(Clip, {
15664 type: 'clip',
15665 match: function match() {
15666 return false;
15667 }
15668});
15669
15670module.exports = Clip;
15671
15672/***/ }),
15673/* 110 */
15674/***/ (function(module, exports, __webpack_require__) {
15675
15676module.exports = {
15677 Canvas: __webpack_require__(111),
15678 Group: __webpack_require__(54),
15679 Shape: __webpack_require__(1),
15680 Rect: __webpack_require__(25),
15681 Circle: __webpack_require__(56),
15682 Ellipse: __webpack_require__(57),
15683 Path: __webpack_require__(58),
15684 Text: __webpack_require__(59),
15685 Line: __webpack_require__(60),
15686 Image: __webpack_require__(61),
15687 Polygon: __webpack_require__(62),
15688 Polyline: __webpack_require__(63),
15689 Arc: __webpack_require__(64),
15690 Fan: __webpack_require__(65),
15691 Cubic: __webpack_require__(66),
15692 Quadratic: __webpack_require__(67),
15693 Marker: __webpack_require__(27),
15694 PathSegment: __webpack_require__(26),
15695 Event: __webpack_require__(53)
15696};
15697
15698/***/ }),
15699/* 111 */
15700/***/ (function(module, exports, __webpack_require__) {
15701
15702var Util = __webpack_require__(0);
15703var Event = __webpack_require__(53);
15704var Group = __webpack_require__(54);
15705
15706var Canvas = function Canvas(cfg) {
15707 Canvas.superclass.constructor.call(this, cfg);
15708};
15709
15710Canvas.CFG = {
15711 eventEnable: true,
15712 /**
15713 * 像素宽度
15714 * @type {Number}
15715 */
15716 width: null,
15717 /**
15718 * 像素高度
15719 * @type {Number}
15720 */
15721 height: null,
15722 /**
15723 * 画布宽度
15724 * @type {Number}
15725 */
15726 widthCanvas: null,
15727 /**
15728 * 画布高度
15729 * @type {Number}
15730 */
15731 heightCanvas: null,
15732 /**
15733 * CSS宽
15734 * @type {String}
15735 */
15736 widthStyle: null,
15737 /**
15738 * CSS高
15739 * @type {String}
15740 */
15741 heightStyle: null,
15742 /**
15743 * 容器DOM
15744 * @type {Object}
15745 */
15746 containerDOM: null,
15747 /**
15748 * 当前Canvas的DOM
15749 * @type {Object}
15750 */
15751 canvasDOM: null,
15752 /**
15753 * 屏幕像素比
15754 * @type {Number}
15755 */
15756 pixelRatio: null
15757};
15758
15759Util.extend(Canvas, Group);
15760
15761Util.augment(Canvas, {
15762 init: function init() {
15763 Canvas.superclass.init.call(this);
15764 this._setGlobalParam();
15765 this._setDOM();
15766 this._setInitSize();
15767 this._setCanvas();
15768 this._scale();
15769 if (this.get('eventEnable')) {
15770 this._registEvents();
15771 }
15772 },
15773 getEmitter: function getEmitter(element, event) {
15774 if (element) {
15775 if (Util.isEmpty(element._getEvents())) {
15776 var parent = element.get('parent');
15777 if (parent && !event.propagationStopped) {
15778 return this.getEmitter(parent, event);
15779 }
15780 } else {
15781 return element;
15782 }
15783 }
15784 },
15785 _getEventObj: function _getEventObj(type, e, point, target) {
15786 var event = new Event(type, e, true, true);
15787 event.x = point.x;
15788 event.y = point.y;
15789 event.clientX = e.clientX;
15790 event.clientY = e.clientY;
15791 event.currentTarget = target;
15792 event.target = target;
15793 return event;
15794 },
15795 _triggerEvent: function _triggerEvent(type, e) {
15796 var point = this.getPointByClient(e.clientX, e.clientY);
15797 var shape = this.getShape(point.x, point.y);
15798 var emitObj = void 0;
15799 if (type === 'mousemove') {
15800 var preShape = this.get('preShape');
15801 if (preShape && preShape !== shape) {
15802 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
15803 emitObj = this.getEmitter(preShape, e);
15804 emitObj && emitObj.emit('mouseleave', mouseleave);
15805 }
15806
15807 if (shape) {
15808 var mousemove = this._getEventObj('mousemove', e, point, shape);
15809 emitObj = this.getEmitter(shape, e);
15810 emitObj && emitObj.emit('mousemove', mousemove);
15811
15812 if (preShape !== shape) {
15813 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
15814 emitObj && emitObj.emit('mouseenter', mouseenter, e);
15815 }
15816 } else {
15817 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
15818 this.emit('mousemove', canvasmousemove);
15819 }
15820
15821 this.set('preShape', shape);
15822 } else {
15823 var event = this._getEventObj(type, e, point, shape || this);
15824 emitObj = this.getEmitter(shape, e);
15825 if (emitObj && emitObj !== this) {
15826 emitObj.emit(type, event);
15827 }
15828 this.emit(type, event);
15829 }
15830
15831 var el = this.get('el');
15832 if (shape && !shape.get('destroyed')) {
15833 el.style.cursor = shape.attr('cursor') || 'default';
15834 }
15835 },
15836 _registEvents: function _registEvents() {
15837 var self = this;
15838 var el = self.get('el');
15839 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
15840
15841 Util.each(events, function (event) {
15842 el.addEventListener(event, function (e) {
15843 self._triggerEvent(event, e);
15844 }, false);
15845 });
15846 el.addEventListener('touchstart', function (e) {
15847 if (!Util.isEmpty(e.touches)) {
15848 self._triggerEvent('touchstart', e.touches[0]);
15849 }
15850 }, false);
15851
15852 el.addEventListener('touchmove', function (e) {
15853 if (!Util.isEmpty(e.touches)) {
15854 self._triggerEvent('touchmove', e.touches[0]);
15855 }
15856 }, false);
15857
15858 el.addEventListener('touchend', function (e) {
15859 if (!Util.isEmpty(e.changedTouches)) {
15860 self._triggerEvent('touchend', e.changedTouches[0]);
15861 }
15862 }, false);
15863 },
15864 _scale: function _scale() {
15865 var pixelRatio = this.get('pixelRatio');
15866 this.scale(pixelRatio, pixelRatio);
15867 },
15868 _setCanvas: function _setCanvas() {
15869 var canvasDOM = this.get('canvasDOM');
15870 this.set('el', canvasDOM);
15871 this.set('context', canvasDOM.getContext('2d'));
15872 this.set('canvas', this);
15873 },
15874 _setGlobalParam: function _setGlobalParam() {
15875 var pixelRatio = this.get('pixelRatio');
15876 if (!pixelRatio) {
15877 this.set('pixelRatio', Util.getRatio());
15878 }
15879 return;
15880 },
15881 _setDOM: function _setDOM() {
15882 this._setContainer();
15883 this._setLayer();
15884 },
15885 _setContainer: function _setContainer() {
15886 var containerId = this.get('containerId');
15887 var containerDOM = this.get('containerDOM');
15888 if (!containerDOM) {
15889 containerDOM = document.getElementById(containerId);
15890 this.set('containerDOM', containerDOM);
15891 }
15892 Util.modifyCSS(containerDOM, {
15893 position: 'relative'
15894 });
15895 },
15896 _setLayer: function _setLayer() {
15897 var containerDOM = this.get('containerDOM');
15898 var canvasId = Util.uniqueId('canvas_');
15899 if (containerDOM) {
15900 var canvasDOM = Util.createDom('<canvas id="' + canvasId + '"></canvas>');
15901 containerDOM.appendChild(canvasDOM);
15902 this.set('canvasDOM', canvasDOM);
15903 }
15904 },
15905 _setInitSize: function _setInitSize() {
15906 this.changeSize(this.get('width'), this.get('height'));
15907 },
15908 _resize: function _resize() {
15909 var canvasDOM = this.get('canvasDOM');
15910 var widthCanvas = this.get('widthCanvas');
15911 var heightCanvas = this.get('heightCanvas');
15912 var widthStyle = this.get('widthStyle');
15913 var heightStyle = this.get('heightStyle');
15914
15915 canvasDOM.style.width = widthStyle;
15916 canvasDOM.style.height = heightStyle;
15917 canvasDOM.setAttribute('width', widthCanvas);
15918 canvasDOM.setAttribute('height', heightCanvas);
15919 },
15920 getWidth: function getWidth() {
15921 var pixelRatio = this.get('pixelRatio');
15922 var width = this.get('width');
15923 return width * pixelRatio;
15924 },
15925 getHeight: function getHeight() {
15926 var pixelRatio = this.get('pixelRatio');
15927 var height = this.get('height');
15928 return height * pixelRatio;
15929 },
15930 changeSize: function changeSize(width, height) {
15931 var pixelRatio = this.get('pixelRatio');
15932 var widthCanvas = width * pixelRatio;
15933 var heightCanvas = height * pixelRatio;
15934
15935 this.set('widthCanvas', widthCanvas);
15936 this.set('heightCanvas', heightCanvas);
15937 this.set('widthStyle', width + 'px');
15938 this.set('heightStyle', height + 'px');
15939 this.set('width', width);
15940 this.set('height', height);
15941 this._resize();
15942 },
15943
15944 /**
15945 * 将窗口坐标转变成 canvas 坐标
15946 * @param {Number} clientX 窗口x坐标
15947 * @param {Number} clientY 窗口y坐标
15948 * @return {Object} canvas坐标
15949 */
15950 getPointByClient: function getPointByClient(clientX, clientY) {
15951 var el = this.get('el');
15952 var bbox = el.getBoundingClientRect();
15953 var width = bbox.right - bbox.left;
15954 var height = bbox.bottom - bbox.top;
15955 return {
15956 x: (clientX - bbox.left) * (el.width / width),
15957 y: (clientY - bbox.top) * (el.height / height)
15958 };
15959 },
15960 getClientByPoint: function getClientByPoint(x, y) {
15961 var el = this.get('el');
15962 var bbox = el.getBoundingClientRect();
15963 var width = bbox.right - bbox.left;
15964 var height = bbox.bottom - bbox.top;
15965 return {
15966 clientX: x / (el.width / width) + bbox.left,
15967 clientY: y / (el.height / height) + bbox.top
15968 };
15969 },
15970 beforeDraw: function beforeDraw() {
15971 var context = this.get('context');
15972 var el = this.get('el');
15973 context && context.clearRect(0, 0, el.width, el.height);
15974 },
15975 _beginDraw: function _beginDraw() {
15976 this.setSilent('toDraw', true);
15977 },
15978 _endDraw: function _endDraw() {
15979 this.setSilent('toDraw', false);
15980 },
15981 draw: function draw() {
15982 var self = this;
15983 function drawInner() {
15984 self.setSilent('animateHandler', Util.requestAnimationFrame(function () {
15985 self.setSilent('animateHandler', undefined);
15986 if (self.get('toDraw')) {
15987 drawInner();
15988 }
15989 }));
15990 self.beforeDraw();
15991 try {
15992 var context = self.get('context');
15993 Canvas.superclass.draw.call(self, context);
15994 // self._drawCanvas();
15995 } catch (ev) {
15996 // 绘制时异常,中断重绘
15997 console.warn('error in draw canvas, detail as:');
15998 console.warn(ev);
15999 self._endDraw();
16000 }
16001 self._endDraw();
16002 }
16003
16004 if (self.get('destroyed')) {
16005 return;
16006 }
16007 if (self.get('animateHandler')) {
16008 this._beginDraw();
16009 } else {
16010 drawInner();
16011 }
16012 },
16013 destroy: function destroy() {
16014 var containerDOM = this.get('containerDOM');
16015 var canvasDOM = this.get('canvasDOM');
16016 if (canvasDOM && containerDOM) {
16017 containerDOM.removeChild(canvasDOM);
16018 }
16019 Canvas.superclass.destroy.call(this);
16020 }
16021});
16022
16023module.exports = Canvas;
16024
16025/***/ }),
16026/* 112 */
16027/***/ (function(module, exports, __webpack_require__) {
16028
16029var Util = __webpack_require__(0);
16030
16031var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
16032var CLIP_SHAPES = ['circle', 'ellipse', 'fan', 'polygon', 'rect', 'path'];
16033var CAPITALIZED_ATTRS_MAP = {
16034 r: 'R',
16035 opacity: 'Opacity',
16036 lineWidth: 'LineWidth',
16037 clip: 'Clip',
16038 stroke: 'Stroke',
16039 fill: 'Fill',
16040 strokeOpacity: 'Stroke',
16041 fillOpacity: 'Fill',
16042 x: 'X',
16043 y: 'Y',
16044 rx: 'Rx',
16045 ry: 'Ry',
16046 re: 'Re',
16047 rs: 'Rs',
16048 width: 'Width',
16049 height: 'Height',
16050 img: 'Img',
16051 x1: 'X1',
16052 x2: 'X2',
16053 y1: 'Y1',
16054 y2: 'Y2',
16055 points: 'Points',
16056 p1: 'P1',
16057 p2: 'P2',
16058 p3: 'P3',
16059 p4: 'P4',
16060 text: 'Text',
16061 radius: 'Radius',
16062 textAlign: 'TextAlign',
16063 textBaseline: 'TextBaseline',
16064 font: 'Font',
16065 fontSize: 'FontSize',
16066 fontStyle: 'FontStyle',
16067 fontVariant: 'FontVariant',
16068 fontWeight: 'FontWeight',
16069 fontFamily: 'FontFamily',
16070 clockwise: 'Clockwise',
16071 startAngle: 'StartAngle',
16072 endAngle: 'EndAngle',
16073 path: 'Path'
16074};
16075var ALIAS_ATTRS_MAP = {
16076 stroke: 'strokeStyle',
16077 fill: 'fillStyle',
16078 opacity: 'globalAlpha'
16079};
16080
16081module.exports = {
16082 canFill: false,
16083 canStroke: false,
16084 initAttrs: function initAttrs(attrs) {
16085 this.__attrs = {
16086 opacity: 1,
16087 fillOpacity: 1,
16088 strokeOpacity: 1
16089 };
16090 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
16091 return this;
16092 },
16093 getDefaultAttrs: function getDefaultAttrs() {
16094 return {};
16095 },
16096
16097 /**
16098 * 设置或者设置属性,有以下 4 种情形:
16099 * - name 不存在, 则返回属性集合
16100 * - name 为字符串,value 为空,获取属性值
16101 * - name 为字符串,value 不为空,设置属性值,返回 this
16102 * - name 为键值对,value 为空,设置属性值
16103 *
16104 * @param {String | Object} name 属性名
16105 * @param {*} value 属性值
16106 * @return {*} 属性值
16107 */
16108 attr: function attr(name, value) {
16109 var self = this;
16110 if (arguments.length === 0) {
16111 return self.__attrs;
16112 }
16113
16114 if (Util.isObject(name)) {
16115 for (var k in name) {
16116 if (ALIAS_ATTRS.indexOf(k) === -1) {
16117 var v = name[k];
16118 self._setAttr(k, v);
16119 }
16120 }
16121 if (self._afterSetAttrAll) {
16122 self._afterSetAttrAll(name);
16123 }
16124 // self.setSilent('box', null);
16125 self.clearBBox();
16126 return self;
16127 }
16128 if (arguments.length === 2) {
16129 if (self._setAttr(name, value) !== false) {
16130 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
16131 if (self[m]) {
16132 self[m](value);
16133 }
16134 }
16135 // self.setSilent('box', null);
16136 self.clearBBox();
16137 return self;
16138 }
16139 return self._getAttr(name);
16140 },
16141 clearBBox: function clearBBox() {
16142 this.setSilent('box', null);
16143 },
16144 _afterSetAttrAll: function _afterSetAttrAll() {},
16145
16146 // 属性获取触发函数
16147 _getAttr: function _getAttr(name) {
16148 return this.__attrs[name];
16149 },
16150
16151 // 属性设置触发函数
16152 _setAttr: function _setAttr(name, value) {
16153 var self = this;
16154 if (name === 'clip') {
16155 self._setAttrClip(value);
16156 self.__attrs.clip = value;
16157 } else if (name === 'transform') {
16158 self._setAttrTrans(value);
16159 } else {
16160 self.__attrs[name] = value;
16161 var alias = ALIAS_ATTRS_MAP[name];
16162 if (alias) {
16163 self.__attrs[alias] = value;
16164 }
16165 }
16166 return self;
16167 },
16168 hasFill: function hasFill() {
16169 return this.canFill && this.__attrs.fillStyle;
16170 },
16171 hasStroke: function hasStroke() {
16172 return this.canStroke && this.__attrs.strokeStyle;
16173 },
16174
16175 // 设置透明度
16176 _setAttrOpacity: function _setAttrOpacity(v) {
16177 this.__attrs.globalAlpha = v;
16178 return v;
16179 },
16180 _setAttrClip: function _setAttrClip(clip) {
16181 var self = this;
16182 if (clip && CLIP_SHAPES.indexOf(clip.type) > -1) {
16183 if (clip.get('canvas') === null) {
16184 clip = Util.clone(clip);
16185 }
16186 clip.set('parent', self.get('parent'));
16187 clip.set('canvas', self.get('canvas'));
16188 clip.set('context', self.get('context'));
16189 clip.inside = function (x, y) {
16190 var v = [x, y, 1];
16191 clip.invert(v, self.get('canvas')); // 已经在外面转换
16192 return clip._isPointInFill(v[0], v[1]);
16193 };
16194 return clip;
16195 }
16196 return null;
16197 },
16198 _setAttrTrans: function _setAttrTrans(value) {
16199 return this.transform(value);
16200 }
16201};
16202
16203/***/ }),
16204/* 113 */
16205/***/ (function(module, exports, __webpack_require__) {
16206
16207var Util = __webpack_require__(0);
16208var mat3 = __webpack_require__(2).mat3;
16209var vec3 = __webpack_require__(2).vec3;
16210
16211// 是否未改变
16212function isUnchanged(m) {
16213 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
16214}
16215
16216// 是否仅仅是scale
16217function isScale(m) {
16218 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
16219}
16220
16221function multiple(m1, m2) {
16222 if (!isUnchanged(m2)) {
16223 if (isScale(m2)) {
16224 m1[0] *= m2[0];
16225 m1[4] *= m2[4];
16226 } else {
16227 mat3.multiply(m1, m1, m2);
16228 }
16229 }
16230}
16231
16232module.exports = {
16233 initTransform: function initTransform() {
16234 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
16235 },
16236 translate: function translate(tx, ty) {
16237 var matrix = this.attr('matrix');
16238 mat3.translate(matrix, matrix, [tx, ty]);
16239 this.clearTotalMatrix();
16240 this.attr('matrix', matrix);
16241 return this;
16242 },
16243 rotate: function rotate(radian) {
16244 var matrix = this.attr('matrix');
16245 mat3.rotate(matrix, matrix, radian);
16246 this.clearTotalMatrix();
16247 this.attr('matrix', matrix);
16248 return this;
16249 },
16250 scale: function scale(s1, s2) {
16251 var matrix = this.attr('matrix');
16252 mat3.scale(matrix, matrix, [s1, s2]);
16253 this.clearTotalMatrix();
16254 this.attr('matrix', matrix);
16255 return this;
16256 },
16257
16258 /**
16259 * 绕起始点旋转
16260 * @param {Number} rotate 0~360
16261 */
16262 rotateAtStart: function rotateAtStart(rotate) {
16263 var x = this.attr('x');
16264 var y = this.attr('y');
16265 if (Math.abs(rotate) > Math.PI * 2) {
16266 rotate = rotate / 180 * Math.PI;
16267 }
16268 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
16269 },
16270
16271 /**
16272 * 移动的到位置
16273 * @param {Number} x 移动到x
16274 * @param {Number} y 移动到y
16275 */
16276 move: function move(x, y) {
16277 var cx = this.get('x') || 0; // 当前的x
16278 var cy = this.get('y') || 0; // 当前的y
16279 this.translate(x - cx, y - cy);
16280 this.set('x', x);
16281 this.set('y', y);
16282 },
16283 transform: function transform(ts) {
16284 var self = this;
16285 var matrix = self.attr('matrix');
16286
16287 Util.each(ts, function (t) {
16288 switch (t[0]) {
16289 case 't':
16290 self.translate(t[1], t[2]);
16291 break;
16292 case 's':
16293 self.scale(t[1], t[2]);
16294 break;
16295 case 'r':
16296 self.rotate(t[1]);
16297 break;
16298 case 'm':
16299 self.attr('matrix', mat3.multiply([], matrix, t[1]));
16300 self.clearTotalMatrix();
16301 break;
16302 default:
16303 break;
16304 }
16305 });
16306 return self;
16307 },
16308 setTransform: function setTransform(ts) {
16309 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
16310 return this.transform(ts);
16311 },
16312 getMatrix: function getMatrix() {
16313 return this.attr('matrix');
16314 },
16315 setMatrix: function setMatrix(m) {
16316 this.attr('matrix', m);
16317 this.clearTotalMatrix();
16318 return this;
16319 },
16320 apply: function apply(v, root) {
16321 var m = void 0;
16322 if (root) {
16323 m = this._getMatrixByRoot(root);
16324 } else {
16325 m = this.attr('matrix');
16326 }
16327 vec3.transformMat3(v, v, m);
16328 return this;
16329 },
16330
16331 // 获取到达指定根节点的矩阵
16332 _getMatrixByRoot: function _getMatrixByRoot(root) {
16333 var self = this;
16334 root = root || self;
16335 var parent = self;
16336 var parents = [];
16337
16338 while (parent !== root) {
16339 parents.unshift(parent);
16340 parent = parent.get('parent');
16341 }
16342 parents.unshift(parent);
16343
16344 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
16345 Util.each(parents, function (child) {
16346 mat3.multiply(m, child.attr('matrix'), m);
16347 });
16348 return m;
16349 },
16350
16351 /**
16352 * 应用到当前元素上的总的矩阵
16353 * @return {Matrix} 矩阵
16354 */
16355 getTotalMatrix: function getTotalMatrix() {
16356 var m = this.__cfg.totalMatrix;
16357 if (!m) {
16358 m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
16359 var parent = this.__cfg.parent;
16360 if (parent) {
16361 var pm = parent.getTotalMatrix();
16362 multiple(m, pm);
16363 }
16364
16365 multiple(m, this.attr('matrix'));
16366 this.__cfg.totalMatrix = m;
16367 }
16368 return m;
16369 },
16370
16371 // 清除当前的矩阵
16372 clearTotalMatrix: function clearTotalMatrix() {
16373 // this.__cfg.totalMatrix = null;
16374 },
16375 invert: function invert(v) {
16376 var m = this.getTotalMatrix();
16377 // 单精屏幕下大多数矩阵没变化
16378 if (isScale(m)) {
16379 v[0] /= m[0];
16380 v[1] /= m[4];
16381 } else {
16382 var inm = mat3.invert([], m);
16383 if (inm) {
16384 vec3.transformMat3(v, v, inm);
16385 }
16386 }
16387 return this;
16388 },
16389 resetTransform: function resetTransform(context) {
16390 var mo = this.attr('matrix');
16391 // 不改变时
16392 if (!isUnchanged(mo)) {
16393 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
16394 }
16395 }
16396};
16397
16398/***/ }),
16399/* 114 */
16400/***/ (function(module, exports, __webpack_require__) {
16401
16402var Shape = __webpack_require__(1);
16403Shape.Rect = __webpack_require__(25);
16404Shape.Rect = __webpack_require__(25);
16405Shape.Circle = __webpack_require__(56);
16406Shape.Ellipse = __webpack_require__(57);
16407Shape.Path = __webpack_require__(58);
16408Shape.Text = __webpack_require__(59);
16409Shape.Line = __webpack_require__(60);
16410Shape.Image = __webpack_require__(61);
16411Shape.Polygon = __webpack_require__(62);
16412Shape.Polyline = __webpack_require__(63);
16413Shape.Arc = __webpack_require__(64);
16414Shape.Fan = __webpack_require__(65);
16415Shape.Cubic = __webpack_require__(66);
16416Shape.Quadratic = __webpack_require__(67);
16417Shape.Marker = __webpack_require__(27);
16418
16419module.exports = Shape;
16420
16421/***/ }),
16422/* 115 */
16423/***/ (function(module, exports) {
16424
16425module.exports = {
16426 xAt: function xAt(psi, rx, ry, cx, t) {
16427 return rx * Math.cos(psi) * Math.cos(t) - ry * Math.sin(psi) * Math.sin(t) + cx;
16428 },
16429 yAt: function yAt(psi, rx, ry, cy, t) {
16430 return rx * Math.sin(psi) * Math.cos(t) + ry * Math.cos(psi) * Math.sin(t) + cy;
16431 },
16432 xExtrema: function xExtrema(psi, rx, ry) {
16433 return Math.atan(-ry / rx * Math.tan(psi));
16434 },
16435 yExtrema: function yExtrema(psi, rx, ry) {
16436 return Math.atan(ry / (rx * Math.tan(psi)));
16437 }
16438};
16439
16440/***/ }),
16441/* 116 */
16442/***/ (function(module, exports, __webpack_require__) {
16443
16444
16445module.exports = {
16446 getWrapBehavior: __webpack_require__(117),
16447 wrapBehavior: __webpack_require__(118)
16448};
16449
16450/***/ }),
16451/* 117 */
16452/***/ (function(module, exports) {
16453
16454/**
16455 * 获取封装的事件
16456 * @protected
16457 * @param {Object} obj 对象
16458 * @param {String} action 事件名称
16459 * @return {Function} 返回事件处理函数
16460 */
16461function getWrapBehavior(obj, action) {
16462 return obj['_wrap_' + action];
16463}
16464
16465module.exports = getWrapBehavior;
16466
16467/***/ }),
16468/* 118 */
16469/***/ (function(module, exports) {
16470
16471/**
16472 * 封装事件,便于使用上下文this,和便于解除事件时使用
16473 * @protected
16474 * @param {Object} obj 对象
16475 * @param {String} action 事件名称
16476 * @return {Function} 返回事件处理函数
16477 */
16478function wrapBehavior(obj, action) {
16479 if (obj['_wrap_' + action]) {
16480 return obj['_wrap_' + action];
16481 }
16482 var method = function method(e) {
16483 obj[action](e);
16484 };
16485 obj['_wrap_' + action] = method;
16486 return method;
16487}
16488
16489module.exports = wrapBehavior;
16490
16491/***/ }),
16492/* 119 */
16493/***/ (function(module, exports, __webpack_require__) {
16494
16495function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16496
16497function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
16498
16499function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
16500
16501var Util = __webpack_require__(10);
16502var Interaction = __webpack_require__(9);
16503// const G2 = require('../core.js');
16504
16505var BRUSH_TYPES = ['X', 'Y', 'XY', 'POLYGON'];
16506var DEFAULT_TYPE = 'XY';
16507
16508var Brush = function (_Interaction) {
16509 _inherits(Brush, _Interaction);
16510
16511 Brush.prototype.getDefaultCfg = function getDefaultCfg() {
16512 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
16513 return Util.mix({}, cfg, {
16514 type: DEFAULT_TYPE,
16515 startPoint: null,
16516 brushing: false,
16517 dragging: false,
16518 brushShape: null,
16519 container: null,
16520 polygonPath: null,
16521 style: {
16522 fill: '#C5D4EB',
16523 opacity: 0.3,
16524 lineWidth: 1,
16525 stroke: '#82A6DD'
16526 },
16527 draggable: false,
16528 dragOffX: 0,
16529 dragOffY: 0,
16530 inPlot: true,
16531 xField: null,
16532 yField: null
16533 });
16534 };
16535
16536 function Brush(cfg, view) {
16537 _classCallCheck(this, Brush);
16538
16539 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
16540
16541 var me = _this;
16542 me.filter = !me.draggable;
16543 me.type = me.type.toUpperCase();
16544 me.chart = view;
16545
16546 if (BRUSH_TYPES.indexOf(me.type) === -1) {
16547 me.type = DEFAULT_TYPE;
16548 }
16549 var canvas = me.canvas;
16550 if (canvas) {
16551 var plotRange = void 0;
16552 canvas.get('children').map(function (child) {
16553 if (child.get('type') === 'plotBack') {
16554 plotRange = child.get('plotRange');
16555 return false;
16556 }
16557 return child;
16558 });
16559 me.plot = {
16560 start: plotRange.bl,
16561 end: plotRange.tr
16562 };
16563 }
16564 if (view) {
16565 var coord = view.get('coord');
16566 me.plot = {
16567 start: coord.start,
16568 end: coord.end
16569 };
16570 var xScales = view._getScales('x');
16571 var yScales = view._getScales('y');
16572 me.xScale = me.xField ? xScales[me.xField] : view.getXScale();
16573 me.yScale = me.yField ? yScales[me.yField] : view.getYScales()[0];
16574 }
16575 return _this;
16576 }
16577
16578 // onBurshstart() { }
16579 // onBrushmove() { }
16580 // onBrushend() {}
16581 // onDragstart() {}
16582 // onDragmove() {}
16583 // onDragend() {}
16584
16585 Brush.prototype.start = function start(ev) {
16586 var me = this;
16587 var canvas = me.canvas,
16588 type = me.type,
16589 brushShape = me.brushShape;
16590
16591
16592 if (!type) return;
16593
16594 var startPoint = { x: ev.offsetX, y: ev.offsetY };
16595 if (!startPoint.x) return;
16596 var isInPlot = me.plot && me.inPlot;
16597 var canvasDOM = canvas.get('canvasDOM');
16598 var pixelRatio = canvas.get('pixelRatio');
16599
16600 if (me.selection) me.selection = null;
16601
16602 if (me.draggable && brushShape && !brushShape.get('destroyed')) {
16603 // allow drag the brushShape
16604 if (brushShape.isHit(startPoint.x * pixelRatio, startPoint.y * pixelRatio)) {
16605 canvasDOM.style.cursor = 'move';
16606 me.selection = brushShape;
16607 me.dragging = true;
16608 if (type === 'X') {
16609 me.dragoffX = startPoint.x - brushShape.attr('x');
16610 me.dragoffY = 0;
16611 } else if (type === 'Y') {
16612 me.dragoffX = 0;
16613 me.dragoffY = startPoint.y - brushShape.attr('y');
16614 } else if (type === 'XY') {
16615 me.dragoffX = startPoint.x - brushShape.attr('x');
16616 me.dragoffY = startPoint.y - brushShape.attr('y');
16617 } else if (type === 'POLYGON') {
16618 var box = brushShape.getBBox();
16619 me.dragoffX = startPoint.x - box.minX;
16620 me.dragoffY = startPoint.y - box.minY;
16621 }
16622
16623 if (isInPlot) {
16624 me.selection.attr('clip', canvas.addShape('rect', {
16625 attrs: {
16626 x: this.plot.start.x,
16627 y: this.plot.end.y,
16628 width: this.plot.end.x - this.plot.start.x,
16629 height: this.plot.start.y - this.plot.end.y,
16630 fill: '#fff',
16631 fillOpacity: 0
16632 }
16633 }));
16634 }
16635 me.onDragstart && me.onDragstart(ev);
16636 }
16637 me.prePoint = startPoint;
16638 }
16639
16640 if (!me.dragging) {
16641 // brush start
16642 me.onBrushstart && me.onBrushstart(startPoint);
16643 var container = me.container;
16644 if (isInPlot) {
16645 var _me$plot = me.plot,
16646 start = _me$plot.start,
16647 end = _me$plot.end;
16648
16649 if (startPoint.x < start.x || startPoint.x > end.x || startPoint.y < end.y || startPoint.y > start.y) return;
16650 }
16651 canvasDOM.style.cursor = 'crosshair';
16652 me.startPoint = startPoint;
16653 me.brushShape = null;
16654 me.brushing = true;
16655
16656 if (!container) {
16657 container = canvas.addGroup({
16658 zIndex: 5 // upper
16659 });
16660 container.initTransform();
16661 } else {
16662 container.clear();
16663 }
16664 me.container = container;
16665
16666 if (type === 'POLYGON') me.polygonPath = 'M ' + startPoint.x + ' ' + startPoint.y;
16667 }
16668 };
16669
16670 Brush.prototype.process = function process(ev) {
16671 var me = this;
16672 var brushing = me.brushing,
16673 dragging = me.dragging,
16674 type = me.type,
16675 plot = me.plot,
16676 startPoint = me.startPoint,
16677 xScale = me.xScale,
16678 yScale = me.yScale,
16679 canvas = me.canvas;
16680
16681
16682 if (!brushing && !dragging) {
16683 return;
16684 }
16685 var currentPoint = {
16686 x: ev.offsetX,
16687 y: ev.offsetY
16688 };
16689 var canvasDOM = canvas.get('canvasDOM');
16690
16691 if (brushing) {
16692 canvasDOM.style.cursor = 'crosshair';
16693 var start = plot.start,
16694 end = plot.end;
16695
16696 var polygonPath = me.polygonPath;
16697 var brushShape = me.brushShape;
16698 var container = me.container;
16699 if (me.plot && me.inPlot) {
16700 currentPoint = me._limitCoordScope(currentPoint);
16701 }
16702
16703 var rectStartX = void 0;
16704 var rectStartY = void 0;
16705 var rectWidth = void 0;
16706 var rectHeight = void 0;
16707
16708 if (type === 'Y') {
16709 rectStartX = start.x;
16710 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16711 rectWidth = Math.abs(start.x - end.x);
16712 rectHeight = Math.abs(startPoint.y - currentPoint.y);
16713 } else if (type === 'X') {
16714 rectStartX = currentPoint.x >= startPoint.x ? startPoint.x : currentPoint.x;
16715 rectStartY = end.y;
16716 rectWidth = Math.abs(startPoint.x - currentPoint.x);
16717 rectHeight = Math.abs(end.y - start.y);
16718 } else if (type === 'XY') {
16719 if (currentPoint.x >= startPoint.x) {
16720 rectStartX = startPoint.x;
16721 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16722 } else {
16723 rectStartX = currentPoint.x;
16724 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16725 }
16726 rectWidth = Math.abs(startPoint.x - currentPoint.x);
16727 rectHeight = Math.abs(startPoint.y - currentPoint.y);
16728 } else if (type === 'POLYGON') {
16729 polygonPath += 'L ' + currentPoint.x + ' ' + currentPoint.y;
16730 me.polygonPath = polygonPath;
16731 if (!brushShape) {
16732 brushShape = container.addShape('path', {
16733 attrs: Util.mix(me.style, {
16734 path: polygonPath
16735 })
16736 });
16737 } else {
16738 !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape.__attrs, {
16739 path: polygonPath
16740 }));
16741 }
16742 }
16743 if (type !== 'POLYGON') {
16744 if (!brushShape) {
16745 brushShape = container.addShape('rect', {
16746 attrs: Util.mix(me.style, {
16747 x: rectStartX,
16748 y: rectStartY,
16749 width: rectWidth,
16750 height: rectHeight
16751 })
16752 });
16753 } else {
16754 !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape.__attrs, {
16755 x: rectStartX,
16756 y: rectStartY,
16757 width: rectWidth,
16758 height: rectHeight
16759 }));
16760 }
16761 }
16762
16763 me.brushShape = brushShape;
16764 } else if (dragging) {
16765 canvasDOM.style.cursor = 'move';
16766 var selection = me.selection;
16767 if (selection && !selection.get('destroyed')) {
16768 if (type === 'POLYGON') {
16769 var prePoint = me.prePoint;
16770 me.selection.translate(currentPoint.x - prePoint.x, currentPoint.y - prePoint.y);
16771 } else {
16772 me.dragoffX && selection.attr('x', currentPoint.x - me.dragoffX);
16773 me.dragoffY && selection.attr('y', currentPoint.y - me.dragoffY);
16774 }
16775 }
16776 }
16777
16778 me.prePoint = currentPoint;
16779 canvas.draw();
16780
16781 var _me$_getSelected = me._getSelected(),
16782 data = _me$_getSelected.data,
16783 shapes = _me$_getSelected.shapes,
16784 xValues = _me$_getSelected.xValues,
16785 yValues = _me$_getSelected.yValues;
16786
16787 var eventObj = {
16788 data: data,
16789 shapes: shapes,
16790 x: currentPoint.x,
16791 y: currentPoint.y
16792 };
16793
16794 if (xScale) {
16795 eventObj[xScale.field] = xValues;
16796 }
16797 if (yScale) {
16798 eventObj[yScale.field] = yValues;
16799 }
16800 me.onDragmove && me.onDragmove(eventObj);
16801 me.onBrushmove && me.onBrushmove(eventObj);
16802 };
16803
16804 Brush.prototype.end = function end(ev) {
16805 var me = this;
16806 var data = me.data,
16807 shapes = me.shapes,
16808 xValues = me.xValues,
16809 yValues = me.yValues,
16810 canvas = me.canvas,
16811 type = me.type,
16812 startPoint = me.startPoint,
16813 chart = me.chart,
16814 container = me.container,
16815 xScale = me.xScale,
16816 yScale = me.yScale;
16817 var offsetX = ev.offsetX,
16818 offsetY = ev.offsetY;
16819
16820 var canvasDOM = canvas.get('canvasDOM');
16821 canvasDOM.style.cursor = 'default';
16822
16823 if (Math.abs(startPoint.x - offsetX) <= 1 && Math.abs(startPoint.y - offsetY) <= 1) {
16824 // 防止点击事件
16825 me.brushing = false;
16826 me.dragging = false;
16827 return;
16828 }
16829
16830 var eventObj = {
16831 data: data,
16832 shapes: shapes,
16833 x: offsetX,
16834 y: offsetY
16835 };
16836 if (xScale) {
16837 eventObj[xScale.field] = xValues;
16838 }
16839 if (yScale) {
16840 eventObj[yScale.field] = yValues;
16841 }
16842
16843 if (me.dragging) {
16844 me.dragging = false;
16845 me.onDragend && me.onDragend(eventObj);
16846 } else if (me.brushing) {
16847 me.brushing = false;
16848 var brushShape = me.brushShape;
16849 var polygonPath = me.polygonPath;
16850
16851 if (type === 'POLYGON') {
16852 polygonPath += 'z';
16853
16854 brushShape && !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape.__attrs, {
16855 path: polygonPath
16856 }));
16857 me.polygonPath = polygonPath;
16858 canvas.draw();
16859 }
16860
16861 if (me.onBrushend) {
16862 me.onBrushend(eventObj);
16863 } else if (chart && me.filter) {
16864 container.clear(); // clear the brush
16865 // filter data
16866 if (type === 'X') {
16867 xScale && chart.filter(xScale.field, function (val) {
16868 return xValues.indexOf(val) > -1;
16869 });
16870 } else if (type === 'Y') {
16871 yScale && chart.filter(yScale.field, function (val) {
16872 return yValues.indexOf(val) > -1;
16873 });
16874 } else {
16875 xScale && chart.filter(xScale.field, function (val) {
16876 return xValues.indexOf(val) > -1;
16877 });
16878 yScale && chart.filter(yScale.field, function (val) {
16879 return yValues.indexOf(val) > -1;
16880 });
16881 }
16882 chart.repaint();
16883 }
16884 }
16885 };
16886
16887 Brush.prototype.reset = function reset() {
16888 var me = this;
16889 var chart = me.chart,
16890 filter = me.filter;
16891
16892 if (chart && filter) {
16893 chart.get('options').filters = {};
16894 chart.repaint();
16895 }
16896 };
16897
16898 Brush.prototype._limitCoordScope = function _limitCoordScope(point) {
16899 var plot = this.plot;
16900 var start = plot.start,
16901 end = plot.end;
16902
16903
16904 if (point.x < start.x) {
16905 point.x = start.x;
16906 }
16907 if (point.x > end.x) {
16908 point.x = end.x;
16909 }
16910 if (point.y < end.y) {
16911 point.y = end.y;
16912 }
16913 if (point.y > start.y) {
16914 point.y = start.y;
16915 }
16916 return point;
16917 };
16918
16919 Brush.prototype._getSelected = function _getSelected() {
16920 var me = this;
16921 var chart = me.chart,
16922 xScale = me.xScale,
16923 yScale = me.yScale,
16924 brushShape = me.brushShape,
16925 canvas = me.canvas;
16926
16927 var pixelRatio = canvas.get('pixelRatio');
16928 var selectedShapes = [];
16929 var xValues = [];
16930 var yValues = [];
16931 var selectedData = [];
16932 if (chart) {
16933 var geoms = chart.get('geoms');
16934 geoms.map(function (geom) {
16935 var shapes = geom.getShapes();
16936 shapes.map(function (shape) {
16937 var shapeData = shape.get('origin');
16938 if (!Array.isArray(shapeData)) {
16939 // 线图、区域图等
16940 shapeData = [shapeData];
16941 }
16942
16943 shapeData.map(function (each) {
16944 if (brushShape.isHit(each.x * pixelRatio, each.y * pixelRatio)) {
16945 selectedShapes.push(shape);
16946 var origin = each._origin;
16947 selectedData.push(origin);
16948 xScale && xValues.push(origin[xScale.field]);
16949 yScale && yValues.push(origin[yScale.field]);
16950 }
16951 return each;
16952 });
16953
16954 return shape;
16955 });
16956 return geom;
16957 });
16958 }
16959 me.shapes = selectedShapes;
16960 me.xValues = xValues;
16961 me.yValues = yValues;
16962 me.data = selectedData;
16963 return {
16964 data: selectedData,
16965 xValues: xValues,
16966 yValues: yValues,
16967 shapes: selectedShapes
16968 };
16969 };
16970
16971 return Brush;
16972}(Interaction);
16973
16974// G2.registerInteraction('brush', Brush);
16975// G2.registerInteraction('Brush', Brush);
16976
16977module.exports = Brush;
16978
16979/***/ }),
16980/* 120 */
16981/***/ (function(module, exports, __webpack_require__) {
16982
16983function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16984
16985function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
16986
16987function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
16988
16989var Util = __webpack_require__(10);
16990var Interaction = __webpack_require__(9);
16991// const G2 = require('../core.js');
16992
16993var DRAGGING_TYPES = ['X', 'Y', 'XY'];
16994var DEFAULT_TYPE = 'X';
16995
16996var Drag = function (_Interaction) {
16997 _inherits(Drag, _Interaction);
16998
16999 Drag.prototype.getDefaultCfg = function getDefaultCfg() {
17000 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
17001 return Util.mix({}, cfg, {
17002 type: DEFAULT_TYPE,
17003 stepRatio: 0.05,
17004 stepByField: {},
17005 originScaleDefsByField: {},
17006 previousPoint: null,
17007 isDragging: false
17008 });
17009 };
17010
17011 function Drag(cfg, view) {
17012 _classCallCheck(this, Drag);
17013
17014 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
17015
17016 var me = _this;
17017 me.type = me.type.toUpperCase();
17018 me.chart = view;
17019
17020 var scales = view.getYScales();
17021 var xScale = view.getXScale();
17022 scales.push(xScale);
17023 var scaleController = view.get('scaleController');
17024 scales.forEach(function (scale) {
17025 var field = scale.field;
17026 var def = scaleController.defs[field];
17027 me.originScaleDefsByField[field] = Util.mix(def, {
17028 nice: !!def.nice
17029 });
17030 if (scale.isLinear) {
17031 me.stepByField[field] = (scale.max - scale.min) * me.stepRatio;
17032 }
17033 });
17034
17035 if (DRAGGING_TYPES.indexOf(me.type) === -1) {
17036 me.type = DEFAULT_TYPE;
17037 }
17038 return _this;
17039 }
17040
17041 // onDragstart() { }
17042 // onDrag() { }
17043 // onDragend() { }
17044
17045 Drag.prototype._applyTranslate = function _applyTranslate(scale) {
17046 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
17047
17048 var me = this;
17049 var chart = me.chart;
17050 var min = scale.min,
17051 max = scale.max,
17052 field = scale.field;
17053
17054 var range = max - min;
17055 chart.scale(field, {
17056 nice: false,
17057 min: min - offset * range,
17058 max: max - offset * range
17059 });
17060 };
17061
17062 Drag.prototype.start = function start(ev) {
17063 var me = this;
17064 var chart = me.chart,
17065 canvas = me.canvas;
17066
17067 var canvasDOM = canvas.get('canvasDOM');
17068 canvasDOM.style.cursor = 'pointer';
17069 var coord = chart.get('coord');
17070 me.isDragging = true;
17071 me.previousPoint = coord.invertPoint(ev);
17072 };
17073
17074 Drag.prototype.process = function process(ev) {
17075 var me = this;
17076 if (me.isDragging) {
17077 var chart = me.chart,
17078 type = me.type,
17079 canvas = me.canvas;
17080
17081 var canvasDOM = canvas.get('canvasDOM');
17082 canvasDOM.style.cursor = 'move';
17083 var coord = chart.get('coord');
17084 var previousPoint = me.previousPoint;
17085 var currentPoint = coord.invertPoint(ev);
17086 if (type.indexOf('X') > -1) {
17087 me._applyTranslate(chart.getXScale(), currentPoint.x - previousPoint.x);
17088 }
17089 if (type.indexOf('Y') > -1) {
17090 var yScales = chart.getYScales();
17091 yScales.forEach(function (yScale) {
17092 me._applyTranslate(yScale, currentPoint.y - previousPoint.y);
17093 });
17094 }
17095 me.previousPoint = currentPoint;
17096 chart.repaint();
17097 }
17098 };
17099
17100 Drag.prototype.end = function end() {
17101 var me = this;
17102 me.isDragging = false;
17103 var canvas = me.canvas;
17104
17105 var canvasDOM = canvas.get('canvasDOM');
17106 canvasDOM.style.cursor = 'default';
17107 };
17108
17109 Drag.prototype.reset = function reset() {
17110 var me = this;
17111 var view = me.view,
17112 originScaleDefsByField = me.originScaleDefsByField;
17113
17114 var scales = view.getYScales();
17115 var xScale = view.getXScale();
17116 scales.push(xScale);
17117 scales.forEach(function (scale) {
17118 if (scale.isLinear) {
17119 var field = scale.field;
17120 view.scale(field, originScaleDefsByField[field]);
17121 }
17122 });
17123 view.repaint();
17124 };
17125
17126 return Drag;
17127}(Interaction);
17128
17129// G2.registerInteraction('drag', Drag);
17130// G2.registerInteraction('Drag', Drag);
17131
17132module.exports = Drag;
17133
17134/***/ }),
17135/* 121 */
17136/***/ (function(module, exports, __webpack_require__) {
17137
17138function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17139
17140function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
17141
17142function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
17143
17144var Util = __webpack_require__(10);
17145var Interaction = __webpack_require__(9);
17146// const G2 = require('../core.js');
17147
17148var ZOOMING_TYPES = ['X', 'Y', 'XY'];
17149var DEFAULT_TYPE = 'X';
17150
17151// TODO zoom with center point
17152
17153var Zoom = function (_Interaction) {
17154 _inherits(Zoom, _Interaction);
17155
17156 Zoom.prototype.getDefaultCfg = function getDefaultCfg() {
17157 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
17158 return Util.mix({}, cfg, {
17159 processingEvent: 'mousewheel',
17160 type: DEFAULT_TYPE,
17161 stepRatio: 0.05,
17162 stepByField: {},
17163 originScaleDefsByField: {}
17164 });
17165 };
17166
17167 function Zoom(cfg, view) {
17168 _classCallCheck(this, Zoom);
17169
17170 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
17171
17172 var me = _this;
17173 me.chart = view;
17174 me.type = me.type.toUpperCase();
17175
17176 var scales = view.getYScales();
17177 var xScale = view.getXScale();
17178 scales.push(xScale);
17179 var scaleController = view.get('scaleController');
17180 scales.forEach(function (scale) {
17181 var field = scale.field;
17182 var def = scaleController.defs[field] || {};
17183 me.originScaleDefsByField[field] = Util.mix(def, {
17184 nice: !!def.nice
17185 });
17186 if (scale.isLinear) {
17187 me.stepByField[field] = (scale.max - scale.min) * me.stepRatio;
17188 }
17189 });
17190
17191 if (ZOOMING_TYPES.indexOf(me.type) === -1) {
17192 me.type = DEFAULT_TYPE;
17193 }
17194 return _this;
17195 }
17196
17197 // onZoom() { }
17198 // onZoomin() { }
17199 // onZoomout() { }
17200
17201 Zoom.prototype._applyScale = function _applyScale(scale, delta) {
17202 var minOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
17203
17204 var me = this;
17205 var chart = me.chart,
17206 stepByField = me.stepByField;
17207
17208 if (scale.isLinear) {
17209 var min = scale.min,
17210 max = scale.max,
17211 field = scale.field;
17212
17213 var maxOffset = 1 - minOffset;
17214 var step = stepByField[field] * delta;
17215 var newMin = min + step * minOffset;
17216 var newMax = max - step * maxOffset;
17217 if (newMax > newMin) {
17218 chart.scale(field, {
17219 nice: false,
17220 min: newMin,
17221 max: newMax
17222 });
17223 }
17224 }
17225 };
17226
17227 Zoom.prototype.process = function process(ev) {
17228 var me = this;
17229 var chart = me.chart,
17230 type = me.type;
17231
17232 var coord = chart.get('coord');
17233 var deltaY = ev.deltaY;
17234 var offsetPoint = coord.invertPoint(ev);
17235 if (deltaY) {
17236 me.onZoom && me.onZoom(deltaY, offsetPoint, me);
17237 if (deltaY > 0) {
17238 me.onZoomin && me.onZoomin(deltaY, offsetPoint, me);
17239 } else {
17240 me.onZoomout && me.onZoomout(deltaY, offsetPoint, me);
17241 }
17242 var delta = deltaY / Math.abs(deltaY);
17243 if (type.indexOf('X') > -1) {
17244 me._applyScale(chart.getXScale(), delta, offsetPoint.x);
17245 }
17246 if (type.indexOf('Y') > -1) {
17247 var yScales = chart.getYScales();
17248 yScales.forEach(function (yScale) {
17249 me._applyScale(yScale, delta, offsetPoint.y);
17250 });
17251 }
17252 }
17253 chart.repaint();
17254 };
17255
17256 Zoom.prototype.reset = function reset() {
17257 var me = this;
17258 var view = me.view,
17259 originScaleDefsByField = me.originScaleDefsByField;
17260
17261 var scales = view.getYScales();
17262 var xScale = view.getXScale();
17263 scales.push(xScale);
17264 scales.forEach(function (scale) {
17265 if (scale.isLinear) {
17266 var field = scale.field;
17267 view.scale(field, originScaleDefsByField[field]);
17268 }
17269 });
17270 view.repaint();
17271 };
17272
17273 return Zoom;
17274}(Interaction);
17275
17276// G2.registerInteraction('zoom', Zoom);
17277// G2.registerInteraction('Zoom', Zoom);
17278
17279module.exports = Zoom;
17280
17281/***/ }),
17282/* 122 */
17283/***/ (function(module, exports, __webpack_require__) {
17284
17285var G = __webpack_require__(123);
17286var CommonUtil = G.CommonUtil;
17287
17288function bindInteraction(Lib, View) {
17289 // binding on Library
17290 Lib._Interactions = {};
17291 Lib.registerInteraction = function (type, constructor) {
17292 Lib._Interactions[type] = constructor;
17293 };
17294 Lib.getInteraction = function (type) {
17295 return G2._Interactions[type];
17296 };
17297
17298 // binding on View
17299 View.prototype.getInteractions = function () {
17300 var me = this;
17301 if (!me._interactions) {
17302 me._interactions = {};
17303 }
17304 return me._interactions;
17305 };
17306 View.prototype._setInteraction = function (type, interaction) {
17307 var me = this;
17308 var interactions = me.getInteractions();
17309 if (interactions[type] && interactions[type] !== interaction) {
17310 // only one interaction for a key
17311 interactions[type].destroy();
17312 }
17313 interactions[type] = interaction;
17314 };
17315 View.prototype.clearInteraction = function (type) {
17316 var me = this;
17317 var interactions = me.getInteractions();
17318 if (type) {
17319 interactions[type] && interactions[type].destroy();
17320 delete interactions[type];
17321 } else {
17322 CommonUtil.each(interactions, function (interaction, key) {
17323 interaction.destroy();
17324 delete interactions[key];
17325 });
17326 }
17327 };
17328 View.prototype.interact = View.prototype.interaction = function (type, cfg) {
17329 var me = this;
17330 var Ctor = G2.getInteraction(type);
17331 var interaction = new Ctor(cfg, me);
17332 me._setInteraction(type, interaction);
17333 return me;
17334 };
17335}
17336
17337module.exports = bindInteraction;
17338
17339/***/ }),
17340/* 123 */
17341/***/ (function(module, exports, __webpack_require__) {
17342
17343/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof3 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
17344
17345(function webpackUniversalModuleDefinition(root, factory) {
17346 if (( false ? 'undefined' : _typeof3(exports)) === 'object' && ( false ? 'undefined' : _typeof3(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
17347 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
17348 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
17349 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else if ((typeof exports === 'undefined' ? 'undefined' : _typeof3(exports)) === 'object') exports["G"] = factory();else root["G"] = factory();
17350})(this, function () {
17351 return (/******/function (modules) {
17352 // webpackBootstrap
17353 /******/ // The module cache
17354 /******/var installedModules = {};
17355 /******/
17356 /******/ // The require function
17357 /******/function __webpack_require__(moduleId) {
17358 /******/
17359 /******/ // Check if module is in cache
17360 /******/if (installedModules[moduleId]) {
17361 /******/return installedModules[moduleId].exports;
17362 /******/
17363 }
17364 /******/ // Create a new module (and put it into the cache)
17365 /******/var module = installedModules[moduleId] = {
17366 /******/i: moduleId,
17367 /******/l: false,
17368 /******/exports: {}
17369 /******/ };
17370 /******/
17371 /******/ // Execute the module function
17372 /******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
17373 /******/
17374 /******/ // Flag the module as loaded
17375 /******/module.l = true;
17376 /******/
17377 /******/ // Return the exports of the module
17378 /******/return module.exports;
17379 /******/
17380 }
17381 /******/
17382 /******/
17383 /******/ // expose the modules object (__webpack_modules__)
17384 /******/__webpack_require__.m = modules;
17385 /******/
17386 /******/ // expose the module cache
17387 /******/__webpack_require__.c = installedModules;
17388 /******/
17389 /******/ // define getter function for harmony exports
17390 /******/__webpack_require__.d = function (exports, name, getter) {
17391 /******/if (!__webpack_require__.o(exports, name)) {
17392 /******/Object.defineProperty(exports, name, {
17393 /******/configurable: false,
17394 /******/enumerable: true,
17395 /******/get: getter
17396 /******/ });
17397 /******/
17398 }
17399 /******/
17400 };
17401 /******/
17402 /******/ // getDefaultExport function for compatibility with non-harmony modules
17403 /******/__webpack_require__.n = function (module) {
17404 /******/var getter = module && module.__esModule ?
17405 /******/function getDefault() {
17406 return module['default'];
17407 } :
17408 /******/function getModuleExports() {
17409 return module;
17410 };
17411 /******/__webpack_require__.d(getter, 'a', getter);
17412 /******/return getter;
17413 /******/
17414 };
17415 /******/
17416 /******/ // Object.prototype.hasOwnProperty.call
17417 /******/__webpack_require__.o = function (object, property) {
17418 return Object.prototype.hasOwnProperty.call(object, property);
17419 };
17420 /******/
17421 /******/ // __webpack_public_path__
17422 /******/__webpack_require__.p = "";
17423 /******/
17424 /******/ // Load entry module and return exports
17425 /******/return __webpack_require__(__webpack_require__.s = 65);
17426 /******/
17427 }(
17428 /************************************************************************/
17429 /******/[
17430 /* 0 */
17431 /***/function (module, exports, __webpack_require__) {
17432
17433 var CommonUtil = __webpack_require__(7);
17434 var DomUtil = __webpack_require__(26);
17435
17436 var Util = {};
17437
17438 CommonUtil.merge(Util, CommonUtil, DomUtil, {
17439 mixin: function mixin(c, mixins) {
17440 var Param = c.CFG ? 'CFG' : 'ATTRS';
17441 if (c && mixins) {
17442 c._mixins = mixins;
17443 c[Param] = c[Param] || {};
17444 var temp = {};
17445 Util.each(mixins, function (mixin) {
17446 Util.augment(c, mixin);
17447 var attrs = mixin[Param];
17448 if (attrs) {
17449 Util.merge(temp, attrs);
17450 }
17451 });
17452 c[Param] = Util.merge(temp, c[Param]);
17453 }
17454 }
17455 });
17456
17457 module.exports = Util;
17458
17459 /***/
17460 },
17461 /* 1 */
17462 /***/function (module, exports, __webpack_require__) {
17463
17464 var Util = __webpack_require__(0);
17465 var Element = __webpack_require__(52);
17466 var Inside = __webpack_require__(3);
17467
17468 var Shape = function Shape(cfg) {
17469 Shape.superclass.constructor.call(this, cfg);
17470 };
17471
17472 Shape.ATTRS = {};
17473
17474 Util.extend(Shape, Element);
17475
17476 Util.augment(Shape, {
17477 isShape: true,
17478 createPath: function createPath() {},
17479 afterPath: function afterPath() {},
17480 drawInner: function drawInner(context) {
17481 var self = this;
17482 var attrs = self.__attrs;
17483 self.createPath(context);
17484 var originOpacity = context.globalAlpha;
17485 if (self.hasFill()) {
17486 var fillOpacity = attrs.fillOpacity;
17487 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
17488 context.globalAlpha = fillOpacity;
17489 context.fill();
17490 context.globalAlpha = originOpacity;
17491 } else {
17492 context.fill();
17493 }
17494 }
17495 if (self.hasStroke()) {
17496 var lineWidth = self.__attrs.lineWidth;
17497 if (lineWidth > 0) {
17498 var strokeOpacity = attrs.strokeOpacity;
17499 if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
17500 context.globalAlpha = strokeOpacity;
17501 }
17502 context.stroke();
17503 }
17504 }
17505 self.afterPath(context);
17506 },
17507
17508 /**
17509 * 节点是否在图形中
17510 * @param {Number} x x 坐标
17511 * @param {Number} y y 坐标
17512 * @return {Boolean} 是否在图形中
17513 */
17514 isPointInPath: function isPointInPath() {
17515 return false;
17516 },
17517
17518 /**
17519 * 击中图形时是否进行包围盒判断
17520 * @return {Boolean} [description]
17521 */
17522 isHitBox: function isHitBox() {
17523 return true;
17524 },
17525
17526 /**
17527 * 节点是否能够被击中
17528 * @param {Number} x x坐标
17529 * @param {Number} y y坐标
17530 * @return {Boolean} 是否在图形中
17531 */
17532 isHit: function isHit(x, y) {
17533 var self = this;
17534 var v = [x, y, 1];
17535 self.invert(v); // canvas
17536
17537 if (self.isHitBox()) {
17538 var box = self.getBBox();
17539 if (box && !Inside.box(box.minX, box.maxX, box.minY, box.maxY, v[0], v[1])) {
17540 return false;
17541 }
17542 }
17543 var clip = self.__attrs.clip;
17544 if (clip) {
17545 if (clip.inside(x, y)) {
17546 return self.isPointInPath(v[0], v[1]);
17547 }
17548 } else {
17549 return self.isPointInPath(v[0], v[1]);
17550 }
17551 return false;
17552 },
17553
17554 /**
17555 * @protected
17556 * 计算包围盒
17557 * @return {Object} 包围盒
17558 */
17559 calculateBox: function calculateBox() {
17560 return null;
17561 },
17562
17563 // 获取拾取时线的宽度,需要考虑附加的线的宽度
17564 getHitLineWidth: function getHitLineWidth() {
17565 var attrs = this.__attrs;
17566 // if (!attrs.stroke) {
17567 // return 0;
17568 // }
17569 var lineAppendWidth = attrs.lineAppendWidth || 0;
17570 var lineWidth = attrs.lineWidth || 0;
17571 return lineWidth + lineAppendWidth;
17572 },
17573
17574 // 清除当前的矩阵
17575 clearTotalMatrix: function clearTotalMatrix() {
17576 this.__cfg.totalMatrix = null;
17577 this.__cfg.region = null;
17578 },
17579 clearBBox: function clearBBox() {
17580 this.__cfg.box = null;
17581 this.__cfg.region = null;
17582 },
17583 getBBox: function getBBox() {
17584 var box = this.__cfg.box;
17585 // 延迟计算
17586 if (!box) {
17587 box = this.calculateBox();
17588 if (box) {
17589 box.x = box.minX;
17590 box.y = box.minY;
17591 box.width = box.maxX - box.minX;
17592 box.height = box.maxY - box.minY;
17593 }
17594 this.__cfg.box = box;
17595 }
17596 return box;
17597 }
17598 });
17599
17600 module.exports = Shape;
17601
17602 /***/
17603 },
17604 /* 2 */
17605 /***/function (module, exports, __webpack_require__) {
17606
17607 var CommonUtil = __webpack_require__(7);
17608 var mat3 = __webpack_require__(72);
17609 var vec3 = __webpack_require__(73);
17610 var vec2 = __webpack_require__(74);
17611
17612 vec2.angle = function (v1, v2) {
17613 var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
17614 return Math.acos(CommonUtil.clamp(theta, -1, 1));
17615 };
17616 /**
17617 * 向量 v1 到 向量 v2 夹角的方向
17618 * @param {Array} v1 向量
17619 * @param {Array} v2 向量
17620 * @return {Boolean} >= 0 顺时针 < 0 逆时针
17621 */
17622 vec2.direction = function (v1, v2) {
17623 return v1[0] * v2[1] - v2[0] * v1[1];
17624 };
17625 vec2.angleTo = function (v1, v2, direct) {
17626 var angle = vec2.angle(v1, v2);
17627 var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
17628 if (direct) {
17629 if (angleLargeThanPI) {
17630 return Math.PI * 2 - angle;
17631 }
17632
17633 return angle;
17634 }
17635
17636 if (angleLargeThanPI) {
17637 return angle;
17638 }
17639 return Math.PI * 2 - angle;
17640 };
17641 vec2.vertical = function (out, v, flag) {
17642 if (flag) {
17643 out[0] = v[1];
17644 out[1] = -1 * v[0];
17645 } else {
17646 out[0] = -1 * v[1];
17647 out[1] = v[0];
17648 }
17649
17650 return out;
17651 };
17652
17653 mat3.translate = function (out, a, v) {
17654 var transMat = new Array(9);
17655 mat3.fromTranslation(transMat, v);
17656 return mat3.multiply(out, transMat, a);
17657 };
17658
17659 mat3.rotate = function (out, a, rad) {
17660 var rotateMat = new Array(9);
17661 mat3.fromRotation(rotateMat, rad);
17662 return mat3.multiply(out, rotateMat, a);
17663 };
17664
17665 mat3.scale = function (out, a, v) {
17666 var scaleMat = new Array(9);
17667 mat3.fromScaling(scaleMat, v);
17668 return mat3.multiply(out, scaleMat, a);
17669 };
17670
17671 module.exports = {
17672 mat3: mat3,
17673 vec2: vec2,
17674 vec3: vec3,
17675 transform: function transform(m, ts) {
17676 m = CommonUtil.clone(m);
17677 CommonUtil.each(ts, function (t) {
17678 switch (t[0]) {
17679 case 't':
17680 mat3.translate(m, m, [t[1], t[2]]);
17681 break;
17682 case 's':
17683 mat3.scale(m, m, [t[1], t[2]]);
17684 break;
17685 case 'r':
17686 mat3.rotate(m, m, t[1]);
17687 break;
17688 case 'm':
17689 mat3.multiply(m, m, t[1]);
17690 break;
17691 default:
17692 return false;
17693 }
17694 });
17695 return m;
17696 }
17697 };
17698
17699 /***/
17700 },
17701 /* 3 */
17702 /***/function (module, exports, __webpack_require__) {
17703
17704 var Line = __webpack_require__(20);
17705 var Quadratic = __webpack_require__(21);
17706 var Cubic = __webpack_require__(10);
17707 var Arc = __webpack_require__(22);
17708
17709 module.exports = {
17710 line: function line(x1, y1, x2, y2, lineWidth, x, y) {
17711 var box = Line.box(x1, y1, x2, y2, lineWidth);
17712
17713 if (!this.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
17714 return false;
17715 }
17716
17717 var d = Line.pointDistance(x1, y1, x2, y2, x, y);
17718 if (isNaN(d)) {
17719 return false;
17720 }
17721 return d <= lineWidth / 2;
17722 },
17723 polyline: function polyline(points, lineWidth, x, y) {
17724 var l = points.length - 1;
17725 if (l < 1) {
17726 return false;
17727 }
17728 for (var i = 0; i < l; i++) {
17729 var x1 = points[i][0];
17730 var y1 = points[i][1];
17731 var x2 = points[i + 1][0];
17732 var y2 = points[i + 1][1];
17733
17734 if (this.line(x1, y1, x2, y2, lineWidth, x, y)) {
17735 return true;
17736 }
17737 }
17738
17739 return false;
17740 },
17741 cubicline: function cubicline(x1, y1, x2, y2, x3, y3, x4, y4, lineWidth, x, y) {
17742 return Cubic.pointDistance(x1, y1, x2, y2, x3, y3, x4, y4, x, y) <= lineWidth / 2;
17743 },
17744 quadraticline: function quadraticline(x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
17745 return Quadratic.pointDistance(x1, y1, x2, y2, x3, y3, x, y) <= lineWidth / 2;
17746 },
17747 arcline: function arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y) {
17748 return Arc.pointDistance(cx, cy, r, startAngle, endAngle, clockwise, x, y) <= lineWidth / 2;
17749 },
17750 rect: function rect(rx, ry, width, height, x, y) {
17751 return rx <= x && x <= rx + width && ry <= y && y <= ry + height;
17752 },
17753 circle: function circle(cx, cy, r, x, y) {
17754 return Math.pow(x - cx, 2) + Math.pow(y - cy, 2) <= Math.pow(r, 2);
17755 },
17756 box: function box(minX, maxX, minY, maxY, x, y) {
17757 return minX <= x && x <= maxX && minY <= y && y <= maxY;
17758 }
17759 };
17760
17761 /***/
17762 },
17763 /* 4 */
17764 /***/function (module, exports, __webpack_require__) {
17765
17766 var Util = __webpack_require__(0);
17767 var Element = __webpack_require__(11);
17768
17769 var SHAPES = {
17770 rect: 'rect',
17771 circle: 'circle',
17772 line: 'line',
17773 path: 'path',
17774 marker: 'marker',
17775 text: 'text',
17776 polygon: 'polygon',
17777 image: 'image',
17778 ellipse: 'ellipse',
17779 dom: 'foreignObject',
17780 fan: 'path'
17781 };
17782
17783 var Shape = function Shape(cfg) {
17784 Shape.superclass.constructor.call(this, cfg);
17785 };
17786
17787 Shape.ATTRS = {};
17788
17789 Util.extend(Shape, Element);
17790
17791 Util.augment(Shape, {
17792 isShape: true,
17793 createPath: function createPath() {},
17794 init: function init(id) {
17795 Shape.superclass.init.call(this);
17796 var type = SHAPES[this.type];
17797 if (type) {
17798 var shape = document.createElementNS('http://www.w3.org/2000/svg', type);
17799 id = id || Util.uniqueId(this.type + '_');
17800 shape.setAttribute('id', id);
17801 this.setSilent('el', shape);
17802 this.setSilent('id', id);
17803 }
17804 },
17805
17806 /**
17807 * 节点是否在图形中
17808 * @param {Number} x x 坐标
17809 * @param {Number} y y 坐标
17810 * @return {Boolean} 是否在图形中
17811 */
17812 isPointInPath: function isPointInPath() {
17813 return false;
17814 },
17815
17816 /**
17817 * 击中图形时是否进行包围盒判断
17818 * @return {Boolean} [description]
17819 */
17820 isHitBox: function isHitBox() {
17821 return true;
17822 },
17823
17824 /**
17825 * 节点是否能够被击中
17826 * @return {Boolean} 是否在图形中
17827 */
17828 isHit: function isHit() {
17829 return false;
17830 },
17831
17832 /**
17833 * @protected
17834 * @protected
17835 * 计算包围盒
17836 * @return {Object} 包围盒
17837 */
17838 calculateBox: function calculateBox() {
17839 return null;
17840 },
17841
17842 // 获取拾取时线的宽度,需要考虑附加的线的宽度
17843 getHitLineWidth: function getHitLineWidth() {
17844 var attrs = this.__attrs;
17845 // if (!attrs.stroke) {
17846 // return 0;
17847 // }
17848 var lineAppendWidth = attrs.lineAppendWidth || 0;
17849 var lineWidth = attrs.lineWidth || 0;
17850 return lineWidth + lineAppendWidth;
17851 },
17852
17853 // 清除当前的矩阵
17854 clearTotalMatrix: function clearTotalMatrix() {
17855 this.__cfg.totalMatrix = null;
17856 this.__cfg.region = null;
17857 },
17858 clearBBox: function clearBBox() {
17859 this.__cfg.box = null;
17860 this.__cfg.region = null;
17861 }
17862 });
17863
17864 module.exports = Shape;
17865
17866 /***/
17867 },
17868 /* 5 */
17869 /***/function (module, __webpack_exports__, __webpack_require__) {
17870
17871 "use strict";
17872 /* harmony import */
17873 var __WEBPACK_IMPORTED_MODULE_0__src_color__ = __webpack_require__(16);
17874 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "a", function () {
17875 return __WEBPACK_IMPORTED_MODULE_0__src_color__["e"];
17876 });
17877 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "f", function () {
17878 return __WEBPACK_IMPORTED_MODULE_0__src_color__["g"];
17879 });
17880 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "d", function () {
17881 return __WEBPACK_IMPORTED_MODULE_0__src_color__["f"];
17882 });
17883 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_lab__ = __webpack_require__(90);
17884 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "e", function () {
17885 return __WEBPACK_IMPORTED_MODULE_1__src_lab__["a"];
17886 });
17887 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
17888 return __WEBPACK_IMPORTED_MODULE_1__src_lab__["b"];
17889 });
17890 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__ = __webpack_require__(91);
17891 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "b", function () {
17892 return __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__["a"];
17893 });
17894
17895 /***/
17896 },
17897 /* 6 */
17898 /***/function (module, exports, __webpack_require__) {
17899
17900 var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
17901 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
17902 } : function (obj) {
17903 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
17904 };
17905
17906 var Marker = __webpack_require__(25);
17907 var Util = __webpack_require__(0);
17908
17909 var PI = Math.PI;
17910 var sin = Math.sin;
17911 var cos = Math.cos;
17912 var atan2 = Math.atan2;
17913 var DEFAULT_LENGTH = 10;
17914 var DEFAULT_ANGLE = PI / 3;
17915
17916 function _addArrow(ctx, attrs, x1, y1, x2, y2) {
17917 var leftX = void 0;
17918 var leftY = void 0;
17919 var rightX = void 0;
17920 var rightY = void 0;
17921 var offsetX = void 0;
17922 var offsetY = void 0;
17923 var angle = void 0;
17924
17925 if (!attrs.fill) {
17926 // 闭合的不绘制箭头
17927 var arrowLength = attrs.arrowLength || DEFAULT_LENGTH;
17928 var arrowAngle = attrs.arrowAngle ? attrs.arrowAngle * PI / 180 : DEFAULT_ANGLE; // 转换为弧
17929 // Calculate angle
17930 angle = atan2(y2 - y1, x2 - x1);
17931 // Adjust angle correctly
17932 angle -= PI;
17933 // Calculate offset to place arrow at edge of path
17934 offsetX = attrs.lineWidth * cos(angle);
17935 offsetY = attrs.lineWidth * sin(angle);
17936
17937 // Calculate coordinates for left half of arrow
17938 leftX = x2 + arrowLength * cos(angle + arrowAngle / 2);
17939 leftY = y2 + arrowLength * sin(angle + arrowAngle / 2);
17940 // Calculate coordinates for right half of arrow
17941 rightX = x2 + arrowLength * cos(angle - arrowAngle / 2);
17942 rightY = y2 + arrowLength * sin(angle - arrowAngle / 2);
17943 ctx.beginPath();
17944 // Draw left half of arrow
17945 ctx.moveTo(leftX - offsetX, leftY - offsetY);
17946 ctx.lineTo(x2 - offsetX, y2 - offsetY);
17947 // Draw right half of arrow
17948 ctx.lineTo(rightX - offsetX, rightY - offsetY);
17949
17950 // Visually connect arrow to path
17951 ctx.moveTo(x2 - offsetX, y2 - offsetY);
17952 ctx.lineTo(x2 + offsetX, y2 + offsetY);
17953 // Move back to end of path
17954 ctx.moveTo(x2, y2);
17955 ctx.stroke();
17956 }
17957 }
17958
17959 function _addMarker(ctx, attrs, x1, y1, x2, y2, shape) {
17960 var marker = shape.__attrs;
17961 var method = marker.symbol;
17962 var markerX = marker.x || x2;
17963 var markerY = marker.y || y2;
17964 var markerR = marker.r || attrs.lineWidth;
17965 if (!Util.isFunction(method)) {
17966 method = Marker.Symbols[method || 'triangle'];
17967 }
17968 var deg = 0;
17969 var x = x1 - x2;
17970 var y = y1 - y2;
17971 if (y === 0) {
17972 if (x < 0) {
17973 deg = Math.PI / 2;
17974 } else {
17975 deg = 270 * Math.PI / 180;
17976 }
17977 } else if (x >= 0 && y > 0) {
17978 deg = -Math.atan(x / y);
17979 } else if (x <= 0 && y < 0) {
17980 deg = Math.PI - Math.atan(x / y);
17981 } else if (x > 0 && y < 0) {
17982 deg = Math.PI + Math.atan(-x / y);
17983 } else if (x < 0 && y > 0) {
17984 deg = Math.atan(x / -y);
17985 }
17986 ctx.save();
17987 ctx.beginPath();
17988 ctx.translate(markerX, markerY);
17989 ctx.rotate(deg);
17990 ctx.translate(-markerX, -markerY);
17991 method(markerX, markerY, markerR, ctx, shape);
17992 ctx.setTransform(1, 0, 0, 1, 0, 0);
17993 ctx.fillStyle = shape.attr('fill') || ctx.strokeStyle;
17994 ctx.fill();
17995 ctx.restore();
17996 }
17997
17998 module.exports = {
17999 addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) {
18000 if (_typeof(attrs.startArrow) === 'object') {
18001 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.startArrow);
18002 } else if (attrs.startArrow) {
18003 _addArrow(ctx, attrs, x1, y1, x2, y2);
18004 }
18005 },
18006 addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) {
18007 if (_typeof(attrs.endArrow) === 'object') {
18008 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.endArrow);
18009 } else if (attrs.endArrow) {
18010 _addArrow(ctx, attrs, x1, y1, x2, y2);
18011 }
18012 }
18013 };
18014
18015 /***/
18016 },
18017 /* 7 */
18018 /***/function (module, exports, __webpack_require__) {
18019
18020 var Util = __webpack_require__(68);
18021
18022 module.exports = {
18023 isFunction: Util.isFunction,
18024 isObject: Util.isObject,
18025 isBoolean: Util.isBoolean,
18026 isNil: Util.isNil,
18027 isString: Util.isString,
18028 isArray: Util.isArray,
18029 isNumber: Util.isNumber,
18030 isEmpty: Util.isEmpty, // isBlank
18031 uniqueId: Util.uniqueId,
18032 clone: Util.clone,
18033 assign: Util.mix, // simpleMix
18034 merge: Util.deepMix, // mix
18035 upperFirst: Util.upperFirst, // ucfirst
18036 each: Util.each,
18037 isEqual: Util.isEqual,
18038 toArray: Util.toArray,
18039 extend: Util.extend,
18040 augment: Util.augment,
18041 remove: Util.arrayUtil.pull,
18042 isNumberEqual: Util.isNumberEqual,
18043 toRadian: Util.toRadian,
18044 toDegree: Util.toDegree,
18045 mod: Util.mod,
18046 clamp: Util.clamp
18047 };
18048
18049 /***/
18050 },
18051 /* 8 */
18052 /***/function (module, __webpack_exports__, __webpack_require__) {
18053
18054 "use strict";
18055 /* harmony export (immutable) */
18056 __webpack_exports__["c"] = hue;
18057 /* harmony export (immutable) */__webpack_exports__["b"] = gamma;
18058 /* harmony export (immutable) */__webpack_exports__["a"] = nogamma;
18059 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(33);
18060
18061 function linear(a, d) {
18062 return function (t) {
18063 return a + t * d;
18064 };
18065 }
18066
18067 function exponential(a, b, y) {
18068 return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function (t) {
18069 return Math.pow(a + t * b, y);
18070 };
18071 }
18072
18073 function hue(a, b) {
18074 var d = b - a;
18075 return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
18076 }
18077
18078 function gamma(y) {
18079 return (y = +y) === 1 ? nogamma : function (a, b) {
18080 return b - a ? exponential(a, b, y) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
18081 };
18082 }
18083
18084 function nogamma(a, b) {
18085 var d = b - a;
18086 return d ? linear(a, d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
18087 }
18088
18089 /***/
18090 },
18091 /* 9 */
18092 /***/function (module, __webpack_exports__, __webpack_require__) {
18093
18094 "use strict";
18095 /* harmony default export */
18096 __webpack_exports__["a"] = function (a, b) {
18097 return a = +a, b -= a, function (t) {
18098 return a + b * t;
18099 };
18100 };
18101
18102 /***/
18103 },
18104 /* 10 */
18105 /***/function (module, exports, __webpack_require__) {
18106
18107 var Util = __webpack_require__(0);
18108 var vec2 = __webpack_require__(2).vec2;
18109
18110 function cubicAt(p0, p1, p2, p3, t) {
18111 var onet = 1 - t;
18112 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
18113 }
18114
18115 function cubicDerivativeAt(p0, p1, p2, p3, t) {
18116 var onet = 1 - t;
18117 return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
18118 }
18119
18120 function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) {
18121 var t = void 0;
18122 var interval = 0.005;
18123 var d = Infinity;
18124 var _t = void 0;
18125 var v1 = void 0;
18126 var d1 = void 0;
18127 var d2 = void 0;
18128 var v2 = void 0;
18129 var prev = void 0;
18130 var next = void 0;
18131 var EPSILON = 0.0001;
18132 var v0 = [x, y];
18133
18134 for (_t = 0; _t < 1; _t += 0.05) {
18135 v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)];
18136
18137 d1 = vec2.squaredDistance(v0, v1);
18138 if (d1 < d) {
18139 t = _t;
18140 d = d1;
18141 }
18142 }
18143 d = Infinity;
18144
18145 for (var i = 0; i < 32; i++) {
18146 if (interval < EPSILON) {
18147 break;
18148 }
18149
18150 prev = t - interval;
18151 next = t + interval;
18152
18153 v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)];
18154
18155 d1 = vec2.squaredDistance(v0, v1);
18156
18157 if (prev >= 0 && d1 < d) {
18158 t = prev;
18159 d = d1;
18160 } else {
18161 v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)];
18162
18163 d2 = vec2.squaredDistance(v0, v2);
18164
18165 if (next <= 1 && d2 < d) {
18166 t = next;
18167 d = d2;
18168 } else {
18169 interval *= 0.5;
18170 }
18171 }
18172 }
18173
18174 if (out) {
18175 out.x = cubicAt(x1, x2, x3, x4, t);
18176 out.y = cubicAt(y1, y2, y3, y4, t);
18177 }
18178
18179 return Math.sqrt(d);
18180 }
18181
18182 function cubicExtrema(p0, p1, p2, p3) {
18183 var a = 3 * p0 - 9 * p1 + 9 * p2 - 3 * p3;
18184 var b = 6 * p1 - 12 * p2 + 6 * p3;
18185 var c = 3 * p2 - 3 * p3;
18186 var extrema = [];
18187 var t1 = void 0;
18188 var t2 = void 0;
18189 var discSqrt = void 0;
18190
18191 if (Util.isNumberEqual(a, 0)) {
18192 if (!Util.isNumberEqual(b, 0)) {
18193 t1 = -c / b;
18194 if (t1 >= 0 && t1 <= 1) {
18195 extrema.push(t1);
18196 }
18197 }
18198 } else {
18199 var disc = b * b - 4 * a * c;
18200 if (Util.isNumberEqual(disc, 0)) {
18201 extrema.push(-b / (2 * a));
18202 } else if (disc > 0) {
18203 discSqrt = Math.sqrt(disc);
18204 t1 = (-b + discSqrt) / (2 * a);
18205 t2 = (-b - discSqrt) / (2 * a);
18206 if (t1 >= 0 && t1 <= 1) {
18207 extrema.push(t1);
18208 }
18209 if (t2 >= 0 && t2 <= 1) {
18210 extrema.push(t2);
18211 }
18212 }
18213 }
18214 return extrema;
18215 }
18216
18217 function base3(t, p1, p2, p3, p4) {
18218 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
18219 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
18220 return t * t2 - 3 * p1 + 3 * p2;
18221 }
18222
18223 function cubiclLen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
18224 if (Util.isNil(z)) {
18225 z = 1;
18226 }
18227 z = z > 1 ? 1 : z < 0 ? 0 : z;
18228 var z2 = z / 2;
18229 var n = 12;
18230 var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
18231 var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
18232 var sum = 0;
18233 for (var i = 0; i < n; i++) {
18234 var ct = z2 * Tvalues[i] + z2;
18235 var xbase = base3(ct, x1, x2, x3, x4);
18236 var ybase = base3(ct, y1, y2, y3, y4);
18237 var comb = xbase * xbase + ybase * ybase;
18238 sum += Cvalues[i] * Math.sqrt(comb);
18239 }
18240 return z2 * sum;
18241 }
18242
18243 module.exports = {
18244 at: cubicAt,
18245 derivativeAt: cubicDerivativeAt,
18246 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y) {
18247 var rst = {};
18248 cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, rst);
18249 return rst;
18250 },
18251
18252 pointDistance: cubicProjectPoint,
18253 extrema: cubicExtrema,
18254 len: cubiclLen
18255 };
18256
18257 /***/
18258 },
18259 /* 11 */
18260 /***/function (module, exports, __webpack_require__) {
18261
18262 var Util = __webpack_require__(0);
18263 var Attribute = __webpack_require__(70);
18264 var Transform = __webpack_require__(71);
18265 var Animate = __webpack_require__(29);
18266 var EventEmitter = __webpack_require__(38);
18267
18268 var Element = function Element(cfg) {
18269 this.__cfg = {
18270 zIndex: 0,
18271 capture: true,
18272 visible: true,
18273 destroyed: false
18274 }; // 配置存放地
18275
18276 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
18277 // 在子元素的init中创建新svg元素,然后设置属性和变换。在这边设置id而不是attr里,是考虑id一旦设置后应不能修改
18278 this.init(cfg ? cfg.id : null); // 类型初始化
18279 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
18280 this.initTransform(); // 初始化变换
18281 };
18282
18283 Element.CFG = {
18284 /**
18285 * 唯一标示
18286 * @type {Number}
18287 */
18288 id: null,
18289 /**
18290 * Z轴的层叠关系,Z值越大离用户越近
18291 * @type {Number}
18292 */
18293 zIndex: 0,
18294 /**
18295 * Canvas对象
18296 * @type: {Object}
18297 */
18298 canvas: null,
18299 /**
18300 * 父元素指针
18301 * @type {Object}
18302 */
18303 parent: null,
18304 /**
18305 * 用来设置当前对象是否能被捕捉
18306 * true 能
18307 * false 不能
18308 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
18309 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
18310 * @type {Boolean}
18311 **/
18312 capture: true,
18313 /**
18314 * 画布的上下文
18315 * @type {Object}
18316 */
18317 context: null,
18318 /**
18319 * 是否显示
18320 * @type {Boolean}
18321 */
18322 visible: true,
18323 /**
18324 * 是否被销毁
18325 * @type: {Boolean}
18326 */
18327 destroyed: false
18328 };
18329
18330 Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
18331 init: function init() {
18332 this.setSilent('animable', true);
18333 this.setSilent('animating', false); // 初始时不处于动画状态
18334 },
18335 getParent: function getParent() {
18336 return this.get('parent');
18337 },
18338
18339 /**
18340 * 获取默认的配置信息
18341 * @protected
18342 * @return {Object} 默认的属性
18343 */
18344 getDefaultCfg: function getDefaultCfg() {
18345 return {};
18346 },
18347 set: function set(name, value) {
18348 if (name === 'zIndex') {
18349 this._beforeSetZIndex(value);
18350 }
18351 this.__cfg[name] = value;
18352 return this;
18353 },
18354 setSilent: function setSilent(name, value) {
18355 this.__cfg[name] = value;
18356 },
18357 get: function get(name) {
18358 return this.__cfg[name];
18359 },
18360 draw: function draw() {},
18361 drawInner: function drawInner() {},
18362 show: function show() {
18363 this.set('visible', true);
18364 var el = this.get('el');
18365 if (el) {
18366 el.setAttribute('visibility', 'visible');
18367 }
18368 return this;
18369 },
18370 hide: function hide() {
18371 this.set('visible', false);
18372 var el = this.get('el');
18373 if (el) {
18374 el.setAttribute('visibility', 'hidden');
18375 }
18376 return this;
18377 },
18378 remove: function remove(destroy) {
18379 var el = this.get('el');
18380 if (destroy === undefined) {
18381 destroy = true;
18382 }
18383
18384 if (this.get('parent')) {
18385 var parent = this.get('parent');
18386 var children = parent.get('children');
18387 Util.remove(children, this);
18388 el.parentNode.removeChild(el);
18389 }
18390
18391 if (destroy) {
18392 this.destroy();
18393 }
18394
18395 return this;
18396 },
18397 destroy: function destroy() {
18398 var destroyed = this.get('destroyed');
18399 if (destroyed) {
18400 return;
18401 }
18402 // 如果正在执行动画,清理动画
18403 if (this.get('animating')) {
18404 var timer = this.get('animateTimer');
18405 timer && timer.stop();
18406 }
18407 this.__cfg = {};
18408 this.__attrs = null;
18409 this.removeEvent(); // 移除所有的事件
18410 this.set('destroyed', true);
18411 },
18412 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
18413 this.__cfg.zIndex = zIndex;
18414
18415 if (!Util.isNil(this.get('parent'))) {
18416 this.get('parent').sort();
18417 }
18418 return zIndex;
18419 },
18420 _setAttrs: function _setAttrs(attrs) {
18421 this.attr(attrs);
18422 return attrs;
18423 },
18424 setZIndex: function setZIndex(zIndex) {
18425 this.__cfg.zIndex = zIndex;
18426 return zIndex;
18427 },
18428 clone: function clone() {
18429 return Util.clone(this);
18430 },
18431 getBBox: function getBBox() {
18432 var el = this.get('el');
18433 if (!el) {
18434 return {
18435 minX: 0,
18436 minY: 0,
18437 maxX: 0,
18438 maxY: 0,
18439 width: 0,
18440 height: 0,
18441 x: 0,
18442 y: 0
18443 };
18444 }
18445 var bbox = el.getBBox();
18446 if (!el.parentNode || bbox.width === 0 && bbox.height === 0) {
18447 var node = el.cloneNode();
18448 node.innerHTML = el.innerHTML;
18449 node.setAttribute('visible', 'hidden');
18450 var svg = document.getElementsByTagName('svg')[0];
18451 svg.appendChild(node);
18452 bbox = node.getBBox();
18453 svg.removeChild(node);
18454 }
18455 bbox.minX = bbox.x;
18456 bbox.minY = bbox.y;
18457 bbox.maxX = bbox.x + bbox.width;
18458 bbox.maxY = bbox.y + bbox.height;
18459 return {
18460 minX: bbox.x,
18461 minY: bbox.y,
18462 maxX: bbox.x + bbox.width,
18463 maxY: bbox.y + bbox.height,
18464 width: bbox.width,
18465 height: bbox.height,
18466 x: bbox.x,
18467 y: bbox.y
18468 };
18469 }
18470 });
18471
18472 module.exports = Element;
18473
18474 /***/
18475 },
18476 /* 12 */
18477 /***/function (module, __webpack_exports__, __webpack_require__) {
18478
18479 "use strict";
18480 /* harmony export (binding) */
18481 __webpack_require__.d(__webpack_exports__, "b", function () {
18482 return EPSILON;
18483 });
18484 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "a", function () {
18485 return ARRAY_TYPE;
18486 });
18487 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
18488 return RANDOM;
18489 });
18490 /* unused harmony export setMatrixArrayType */
18491 /* unused harmony export toRadian */
18492 /* unused harmony export equals */
18493 /**
18494 * Common utilities
18495 * @module glMatrix
18496 */
18497
18498 // Configuration Constants
18499 var EPSILON = 0.000001;
18500 var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
18501 var RANDOM = Math.random;
18502
18503 /**
18504 * Sets the type of array used when creating new vectors and matrices
18505 *
18506 * @param {Type} type Array type, such as Float32Array or Array
18507 */
18508 function setMatrixArrayType(type) {
18509 ARRAY_TYPE = type;
18510 }
18511
18512 var degree = Math.PI / 180;
18513
18514 /**
18515 * Convert Degree To Radian
18516 *
18517 * @param {Number} a Angle in Degrees
18518 */
18519 function toRadian(a) {
18520 return a * degree;
18521 }
18522
18523 /**
18524 * Tests whether or not the arguments have approximately the same value, within an absolute
18525 * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
18526 * than or equal to 1.0, and a relative tolerance is used for larger values)
18527 *
18528 * @param {Number} a The first number to test.
18529 * @param {Number} b The second number to test.
18530 * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
18531 */
18532 function equals(a, b) {
18533 return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
18534 }
18535
18536 /***/
18537 },
18538 /* 13 */
18539 /***/function (module, exports, __webpack_require__) {
18540
18541 var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
18542 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
18543 } : function (obj) {
18544 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
18545 };
18546
18547 var Util = __webpack_require__(7);
18548 var SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029';
18549 var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
18550 var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
18551
18552 // Parses given path string into an array of arrays of path segments
18553 var parsePathString = function parsePathString(pathString) {
18554 if (!pathString) {
18555 return null;
18556 }
18557
18558 if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
18559 return pathString;
18560 }
18561 var paramCounts = {
18562 a: 7,
18563 c: 6,
18564 o: 2,
18565 h: 1,
18566 l: 2,
18567 m: 2,
18568 r: 4,
18569 q: 4,
18570 s: 4,
18571 t: 2,
18572 v: 1,
18573 u: 3,
18574 z: 0
18575 };
18576 var data = [];
18577
18578 String(pathString).replace(PATH_COMMAND, function (a, b, c) {
18579 var params = [];
18580 var name = b.toLowerCase();
18581 c.replace(PATH_VALUES, function (a, b) {
18582 b && params.push(+b);
18583 });
18584 if (name === 'm' && params.length > 2) {
18585 data.push([b].concat(params.splice(0, 2)));
18586 name = 'l';
18587 b = b === 'm' ? 'l' : 'L';
18588 }
18589 if (name === 'o' && params.length === 1) {
18590 data.push([b, params[0]]);
18591 }
18592 if (name === 'r') {
18593 data.push([b].concat(params));
18594 } else {
18595 while (params.length >= paramCounts[name]) {
18596 data.push([b].concat(params.splice(0, paramCounts[name])));
18597 if (!paramCounts[name]) {
18598 break;
18599 }
18600 }
18601 }
18602 });
18603
18604 return data;
18605 };
18606
18607 // http://schepers.cc/getting-to-the-point
18608 var catmullRom2bezier = function catmullRom2bezier(crp, z) {
18609 var d = [];
18610 for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
18611 var p = [{
18612 x: +crp[i - 2],
18613 y: +crp[i - 1]
18614 }, {
18615 x: +crp[i],
18616 y: +crp[i + 1]
18617 }, {
18618 x: +crp[i + 2],
18619 y: +crp[i + 3]
18620 }, {
18621 x: +crp[i + 4],
18622 y: +crp[i + 5]
18623 }];
18624 if (z) {
18625 if (!i) {
18626 p[0] = {
18627 x: +crp[iLen - 2],
18628 y: +crp[iLen - 1]
18629 };
18630 } else if (iLen - 4 === i) {
18631 p[3] = {
18632 x: +crp[0],
18633 y: +crp[1]
18634 };
18635 } else if (iLen - 2 === i) {
18636 p[2] = {
18637 x: +crp[0],
18638 y: +crp[1]
18639 };
18640 p[3] = {
18641 x: +crp[2],
18642 y: +crp[3]
18643 };
18644 }
18645 } else {
18646 if (iLen - 4 === i) {
18647 p[3] = p[2];
18648 } else if (!i) {
18649 p[0] = {
18650 x: +crp[i],
18651 y: +crp[i + 1]
18652 };
18653 }
18654 }
18655 d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]);
18656 }
18657
18658 return d;
18659 };
18660
18661 var ellipsePath = function ellipsePath(x, y, rx, ry, a) {
18662 var res = [];
18663 if (a === null && ry === null) {
18664 ry = rx;
18665 }
18666 x = +x;
18667 y = +y;
18668 rx = +rx;
18669 ry = +ry;
18670 if (a !== null) {
18671 var rad = Math.PI / 180;
18672 var x1 = x + rx * Math.cos(-ry * rad);
18673 var x2 = x + rx * Math.cos(-a * rad);
18674 var y1 = y + rx * Math.sin(-ry * rad);
18675 var y2 = y + rx * Math.sin(-a * rad);
18676 res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
18677 } else {
18678 res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
18679 }
18680 return res;
18681 };
18682
18683 var pathToAbsolute = function pathToAbsolute(pathArray) {
18684 pathArray = parsePathString(pathArray);
18685
18686 if (!pathArray || !pathArray.length) {
18687 return [['M', 0, 0]];
18688 }
18689 var res = [];
18690 var x = 0;
18691 var y = 0;
18692 var mx = 0;
18693 var my = 0;
18694 var start = 0;
18695 var pa0 = void 0;
18696 var dots = void 0;
18697 if (pathArray[0][0] === 'M') {
18698 x = +pathArray[0][1];
18699 y = +pathArray[0][2];
18700 mx = x;
18701 my = y;
18702 start++;
18703 res[0] = ['M', x, y];
18704 }
18705 var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
18706 for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
18707 res.push(r = []);
18708 pa = pathArray[i];
18709 pa0 = pa[0];
18710 if (pa0 !== pa0.toUpperCase()) {
18711 r[0] = pa0.toUpperCase();
18712 switch (r[0]) {
18713 case 'A':
18714 r[1] = pa[1];
18715 r[2] = pa[2];
18716 r[3] = pa[3];
18717 r[4] = pa[4];
18718 r[5] = pa[5];
18719 r[6] = +pa[6] + x;
18720 r[7] = +pa[7] + y;
18721 break;
18722 case 'V':
18723 r[1] = +pa[1] + y;
18724 break;
18725 case 'H':
18726 r[1] = +pa[1] + x;
18727 break;
18728 case 'R':
18729 dots = [x, y].concat(pa.slice(1));
18730 for (var j = 2, jj = dots.length; j < jj; j++) {
18731 dots[j] = +dots[j] + x;
18732 dots[++j] = +dots[j] + y;
18733 }
18734 res.pop();
18735 res = res.concat(catmullRom2bezier(dots, crz));
18736 break;
18737 case 'O':
18738 res.pop();
18739 dots = ellipsePath(x, y, pa[1], pa[2]);
18740 dots.push(dots[0]);
18741 res = res.concat(dots);
18742 break;
18743 case 'U':
18744 res.pop();
18745 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
18746 r = ['U'].concat(res[res.length - 1].slice(-2));
18747 break;
18748 case 'M':
18749 mx = +pa[1] + x;
18750 my = +pa[2] + y;
18751 break; // for lint
18752 default:
18753 for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
18754 r[_j] = +pa[_j] + (_j % 2 ? x : y);
18755 }
18756 }
18757 } else if (pa0 === 'R') {
18758 dots = [x, y].concat(pa.slice(1));
18759 res.pop();
18760 res = res.concat(catmullRom2bezier(dots, crz));
18761 r = ['R'].concat(pa.slice(-2));
18762 } else if (pa0 === 'O') {
18763 res.pop();
18764 dots = ellipsePath(x, y, pa[1], pa[2]);
18765 dots.push(dots[0]);
18766 res = res.concat(dots);
18767 } else if (pa0 === 'U') {
18768 res.pop();
18769 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
18770 r = ['U'].concat(res[res.length - 1].slice(-2));
18771 } else {
18772 for (var k = 0, kk = pa.length; k < kk; k++) {
18773 r[k] = pa[k];
18774 }
18775 }
18776 pa0 = pa0.toUpperCase();
18777 if (pa0 !== 'O') {
18778 switch (r[0]) {
18779 case 'Z':
18780 x = +mx;
18781 y = +my;
18782 break;
18783 case 'H':
18784 x = r[1];
18785 break;
18786 case 'V':
18787 y = r[1];
18788 break;
18789 case 'M':
18790 mx = r[r.length - 2];
18791 my = r[r.length - 1];
18792 break; // for lint
18793 default:
18794 x = r[r.length - 2];
18795 y = r[r.length - 1];
18796 }
18797 }
18798 }
18799
18800 return res;
18801 };
18802
18803 var l2c = function l2c(x1, y1, x2, y2) {
18804 return [x1, y1, x2, y2, x2, y2];
18805 };
18806
18807 var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
18808 var _13 = 1 / 3;
18809 var _23 = 2 / 3;
18810 return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
18811 };
18812
18813 var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
18814 // for more information of where this math came from visit:
18815 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
18816 if (rx === ry) {
18817 rx += 1;
18818 }
18819
18820 var _120 = Math.PI * 120 / 180;
18821 var rad = Math.PI / 180 * (+angle || 0);
18822 var res = [];
18823 var xy = void 0;
18824 var f1 = void 0;
18825 var f2 = void 0;
18826 var cx = void 0;
18827 var cy = void 0;
18828 var rotate = function rotate(x, y, rad) {
18829 var X = x * Math.cos(rad) - y * Math.sin(rad);
18830 var Y = x * Math.sin(rad) + y * Math.cos(rad);
18831 return {
18832 x: X,
18833 y: Y
18834 };
18835 };
18836 if (!recursive) {
18837 xy = rotate(x1, y1, -rad);
18838 x1 = xy.x;
18839 y1 = xy.y;
18840 xy = rotate(x2, y2, -rad);
18841 x2 = xy.x;
18842 y2 = xy.y;
18843 if (x1 === x2 && y1 === y2) {
18844 // 若弧的起始点和终点重叠则错开一点
18845 x2 += 1;
18846 y2 += 1;
18847 }
18848 // const cos = Math.cos(Math.PI / 180 * angle);
18849 // const sin = Math.sin(Math.PI / 180 * angle);
18850 var x = (x1 - x2) / 2;
18851 var y = (y1 - y2) / 2;
18852 var h = x * x / (rx * rx) + y * y / (ry * ry);
18853 if (h > 1) {
18854 h = Math.sqrt(h);
18855 rx = h * rx;
18856 ry = h * ry;
18857 }
18858 var rx2 = rx * rx;
18859 var ry2 = ry * ry;
18860 var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
18861 cx = k * rx * y / ry + (x1 + x2) / 2;
18862 cy = k * -ry * x / rx + (y1 + y2) / 2;
18863 f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
18864 f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
18865
18866 f1 = x1 < cx ? Math.PI - f1 : f1;
18867 f2 = x2 < cx ? Math.PI - f2 : f2;
18868 f1 < 0 && (f1 = Math.PI * 2 + f1);
18869 f2 < 0 && (f2 = Math.PI * 2 + f2);
18870 if (sweep_flag && f1 > f2) {
18871 f1 = f1 - Math.PI * 2;
18872 }
18873 if (!sweep_flag && f2 > f1) {
18874 f2 = f2 - Math.PI * 2;
18875 }
18876 } else {
18877 f1 = recursive[0];
18878 f2 = recursive[1];
18879 cx = recursive[2];
18880 cy = recursive[3];
18881 }
18882 var df = f2 - f1;
18883 if (Math.abs(df) > _120) {
18884 var f2old = f2;
18885 var x2old = x2;
18886 var y2old = y2;
18887 f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
18888 x2 = cx + rx * Math.cos(f2);
18889 y2 = cy + ry * Math.sin(f2);
18890 res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
18891 }
18892 df = f2 - f1;
18893 var c1 = Math.cos(f1);
18894 var s1 = Math.sin(f1);
18895 var c2 = Math.cos(f2);
18896 var s2 = Math.sin(f2);
18897 var t = Math.tan(df / 4);
18898 var hx = 4 / 3 * rx * t;
18899 var hy = 4 / 3 * ry * t;
18900 var m1 = [x1, y1];
18901 var m2 = [x1 + hx * s1, y1 - hy * c1];
18902 var m3 = [x2 + hx * s2, y2 - hy * c2];
18903 var m4 = [x2, y2];
18904 m2[0] = 2 * m1[0] - m2[0];
18905 m2[1] = 2 * m1[1] - m2[1];
18906 if (recursive) {
18907 return [m2, m3, m4].concat(res);
18908 }
18909 res = [m2, m3, m4].concat(res).join().split(',');
18910 var newres = [];
18911 for (var i = 0, ii = res.length; i < ii; i++) {
18912 newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
18913 }
18914 return newres;
18915 };
18916
18917 var pathTocurve = function pathTocurve(path, path2) {
18918 var p = pathToAbsolute(path);
18919 var p2 = path2 && pathToAbsolute(path2);
18920 var attrs = {
18921 x: 0,
18922 y: 0,
18923 bx: 0,
18924 by: 0,
18925 X: 0,
18926 Y: 0,
18927 qx: null,
18928 qy: null
18929 };
18930 var attrs2 = {
18931 x: 0,
18932 y: 0,
18933 bx: 0,
18934 by: 0,
18935 X: 0,
18936 Y: 0,
18937 qx: null,
18938 qy: null
18939 };
18940 var pcoms1 = []; // path commands of original path p
18941 var pcoms2 = []; // path commands of original path p2
18942 var pfirst = ''; // temporary holder for original path command
18943 var pcom = ''; // holder for previous path command of original path
18944 var ii = void 0;
18945 var processPath = function processPath(path, d, pcom) {
18946 var nx = void 0,
18947 ny = void 0;
18948 if (!path) {
18949 return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
18950 }!(path[0] in {
18951 T: 1,
18952 Q: 1
18953 }) && (d.qx = d.qy = null);
18954 switch (path[0]) {
18955 case 'M':
18956 d.X = path[1];
18957 d.Y = path[2];
18958 break;
18959 case 'A':
18960 path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
18961 break;
18962 case 'S':
18963 if (pcom === 'C' || pcom === 'S') {
18964 // In "S" case we have to take into account, if the previous command is C/S.
18965 nx = d.x * 2 - d.bx; // And reflect the previous
18966 ny = d.y * 2 - d.by; // command's control point relative to the current point.
18967 } else {
18968 // or some else or nothing
18969 nx = d.x;
18970 ny = d.y;
18971 }
18972 path = ['C', nx, ny].concat(path.slice(1));
18973 break;
18974 case 'T':
18975 if (pcom === 'Q' || pcom === 'T') {
18976 // In "T" case we have to take into account, if the previous command is Q/T.
18977 d.qx = d.x * 2 - d.qx; // And make a reflection similar
18978 d.qy = d.y * 2 - d.qy; // to case "S".
18979 } else {
18980 // or something else or nothing
18981 d.qx = d.x;
18982 d.qy = d.y;
18983 }
18984 path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
18985 break;
18986 case 'Q':
18987 d.qx = path[1];
18988 d.qy = path[2];
18989 path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
18990 break;
18991 case 'L':
18992 path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
18993 break;
18994 case 'H':
18995 path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
18996 break;
18997 case 'V':
18998 path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
18999 break;
19000 case 'Z':
19001 path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
19002 break;
19003 default:
19004 break;
19005 }
19006 return path;
19007 };
19008 var fixArc = function fixArc(pp, i) {
19009 if (pp[i].length > 7) {
19010 pp[i].shift();
19011 var pi = pp[i];
19012 while (pi.length) {
19013 pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
19014 p2 && (pcoms2[i] = 'A'); // the same as above
19015 pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
19016 }
19017 pp.splice(i, 1);
19018 ii = Math.max(p.length, p2 && p2.length || 0);
19019 }
19020 };
19021 var fixM = function fixM(path1, path2, a1, a2, i) {
19022 if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
19023 path2.splice(i, 0, ['M', a2.x, a2.y]);
19024 a1.bx = 0;
19025 a1.by = 0;
19026 a1.x = path1[i][1];
19027 a1.y = path1[i][2];
19028 ii = Math.max(p.length, p2 && p2.length || 0);
19029 }
19030 };
19031 ii = Math.max(p.length, p2 && p2.length || 0);
19032 for (var i = 0; i < ii; i++) {
19033
19034 p[i] && (pfirst = p[i][0]); // save current path command
19035
19036 if (pfirst !== 'C') {
19037 // C is not saved yet, because it may be result of conversion
19038 pcoms1[i] = pfirst; // Save current path command
19039 i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
19040 }
19041 p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
19042
19043 if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
19044 // which may produce multiple C:s
19045 // so we have to make sure that C is also C in original path
19046
19047 fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
19048
19049 if (p2) {
19050 // the same procedures is done to p2
19051 p2[i] && (pfirst = p2[i][0]);
19052 if (pfirst !== 'C') {
19053 pcoms2[i] = pfirst;
19054 i && (pcom = pcoms2[i - 1]);
19055 }
19056 p2[i] = processPath(p2[i], attrs2, pcom);
19057
19058 if (pcoms2[i] !== 'A' && pfirst === 'C') {
19059 pcoms2[i] = 'C';
19060 }
19061
19062 fixArc(p2, i);
19063 }
19064 fixM(p, p2, attrs, attrs2, i);
19065 fixM(p2, p, attrs2, attrs, i);
19066 var seg = p[i];
19067 var seg2 = p2 && p2[i];
19068 var seglen = seg.length;
19069 var seg2len = p2 && seg2.length;
19070 attrs.x = seg[seglen - 2];
19071 attrs.y = seg[seglen - 1];
19072 attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
19073 attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
19074 attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
19075 attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
19076 attrs2.x = p2 && seg2[seg2len - 2];
19077 attrs2.y = p2 && seg2[seg2len - 1];
19078 }
19079
19080 return p2 ? [p, p2] : p;
19081 };
19082
19083 var p2s = /,?([a-z]),?/gi;
19084 var parsePathArray = function parsePathArray(path) {
19085 return path.join(',').replace(p2s, '$1');
19086 };
19087
19088 var base3 = function base3(t, p1, p2, p3, p4) {
19089 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
19090 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
19091 return t * t2 - 3 * p1 + 3 * p2;
19092 };
19093
19094 var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
19095 if (z === null) {
19096 z = 1;
19097 }
19098 z = z > 1 ? 1 : z < 0 ? 0 : z;
19099 var z2 = z / 2;
19100 var n = 12;
19101 var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
19102 var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
19103 var sum = 0;
19104 for (var i = 0; i < n; i++) {
19105 var ct = z2 * Tvalues[i] + z2;
19106 var xbase = base3(ct, x1, x2, x3, x4);
19107 var ybase = base3(ct, y1, y2, y3, y4);
19108 var comb = xbase * xbase + ybase * ybase;
19109 sum += Cvalues[i] * Math.sqrt(comb);
19110 }
19111 return z2 * sum;
19112 };
19113
19114 var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
19115 var tvalues = [];
19116 var bounds = [[], []];
19117 var a = void 0;
19118 var b = void 0;
19119 var c = void 0;
19120 var t = void 0;
19121
19122 for (var i = 0; i < 2; ++i) {
19123 if (i === 0) {
19124 b = 6 * x0 - 12 * x1 + 6 * x2;
19125 a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
19126 c = 3 * x1 - 3 * x0;
19127 } else {
19128 b = 6 * y0 - 12 * y1 + 6 * y2;
19129 a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
19130 c = 3 * y1 - 3 * y0;
19131 }
19132 if (Math.abs(a) < 1e-12) {
19133 if (Math.abs(b) < 1e-12) {
19134 continue;
19135 }
19136 t = -c / b;
19137 if (t > 0 && t < 1) {
19138 tvalues.push(t);
19139 }
19140 continue;
19141 }
19142 var b2ac = b * b - 4 * c * a;
19143 var sqrtb2ac = Math.sqrt(b2ac);
19144 if (b2ac < 0) {
19145 continue;
19146 }
19147 var t1 = (-b + sqrtb2ac) / (2 * a);
19148 if (t1 > 0 && t1 < 1) {
19149 tvalues.push(t1);
19150 }
19151 var t2 = (-b - sqrtb2ac) / (2 * a);
19152 if (t2 > 0 && t2 < 1) {
19153 tvalues.push(t2);
19154 }
19155 }
19156
19157 var j = tvalues.length;
19158 var jlen = j;
19159 var mt = void 0;
19160 while (j--) {
19161 t = tvalues[j];
19162 mt = 1 - t;
19163 bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
19164 bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
19165 }
19166
19167 bounds[0][jlen] = x0;
19168 bounds[1][jlen] = y0;
19169 bounds[0][jlen + 1] = x3;
19170 bounds[1][jlen + 1] = y3;
19171 bounds[0].length = bounds[1].length = jlen + 2;
19172
19173 return {
19174 min: {
19175 x: Math.min.apply(0, bounds[0]),
19176 y: Math.min.apply(0, bounds[1])
19177 },
19178 max: {
19179 x: Math.max.apply(0, bounds[0]),
19180 y: Math.max.apply(0, bounds[1])
19181 }
19182 };
19183 };
19184
19185 var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
19186 if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) {
19187 return;
19188 }
19189 var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
19190 var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
19191 var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
19192
19193 if (!denominator) {
19194 return;
19195 }
19196 var px = nx / denominator;
19197 var py = ny / denominator;
19198 var px2 = +px.toFixed(2);
19199 var py2 = +py.toFixed(2);
19200 if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) {
19201 return;
19202 }
19203 return {
19204 x: px,
19205 y: py
19206 };
19207 };
19208
19209 var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
19210 return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
19211 };
19212
19213 var rectPath = function rectPath(x, y, w, h, r) {
19214 if (r) {
19215 return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']];
19216 }
19217 var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
19218 res.parsePathArray = parsePathArray;
19219 return res;
19220 };
19221
19222 var box = function box(x, y, width, height) {
19223 if (x === null) {
19224 x = y = width = height = 0;
19225 }
19226 if (y === null) {
19227 y = x.y;
19228 width = x.width;
19229 height = x.height;
19230 x = x.x;
19231 }
19232 return {
19233 x: x,
19234 y: y,
19235 width: width,
19236 w: width,
19237 height: height,
19238 h: height,
19239 x2: x + width,
19240 y2: y + height,
19241 cx: x + width / 2,
19242 cy: y + height / 2,
19243 r1: Math.min(width, height) / 2,
19244 r2: Math.max(width, height) / 2,
19245 r0: Math.sqrt(width * width + height * height) / 2,
19246 path: rectPath(x, y, width, height),
19247 vb: [x, y, width, height].join(' ')
19248 };
19249 };
19250
19251 var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
19252 bbox1 = box(bbox1);
19253 bbox2 = box(bbox2);
19254 return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
19255 };
19256
19257 var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
19258 if (!Util.isArray(p1x)) {
19259 p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
19260 }
19261 var bbox = curveDim.apply(null, p1x);
19262 return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
19263 };
19264
19265 var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
19266 var t1 = 1 - t;
19267 var t13 = Math.pow(t1, 3);
19268 var t12 = Math.pow(t1, 2);
19269 var t2 = t * t;
19270 var t3 = t2 * t;
19271 var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
19272 var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
19273 var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
19274 var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
19275 var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
19276 var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
19277 var ax = t1 * p1x + t * c1x;
19278 var ay = t1 * p1y + t * c1y;
19279 var cx = t1 * c2x + t * p2x;
19280 var cy = t1 * c2y + t * p2y;
19281 var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
19282 // (mx > nx || my < ny) && (alpha += 180);
19283 return {
19284 x: x,
19285 y: y,
19286 m: {
19287 x: mx,
19288 y: my
19289 },
19290 n: {
19291 x: nx,
19292 y: ny
19293 },
19294 start: {
19295 x: ax,
19296 y: ay
19297 },
19298 end: {
19299 x: cx,
19300 y: cy
19301 },
19302 alpha: alpha
19303 };
19304 };
19305
19306 var interHelper = function interHelper(bez1, bez2, justCount) {
19307 var bbox1 = bezierBBox(bez1);
19308 var bbox2 = bezierBBox(bez2);
19309 if (!isBBoxIntersect(bbox1, bbox2)) {
19310 return justCount ? 0 : [];
19311 }
19312 var l1 = bezlen.apply(0, bez1);
19313 var l2 = bezlen.apply(0, bez2);
19314 var n1 = ~~(l1 / 8);
19315 var n2 = ~~(l2 / 8);
19316 var dots1 = [];
19317 var dots2 = [];
19318 var xy = {};
19319 var res = justCount ? 0 : [];
19320 for (var i = 0; i < n1 + 1; i++) {
19321 var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
19322 dots1.push({
19323 x: d.x,
19324 y: d.y,
19325 t: i / n1
19326 });
19327 }
19328 for (var _i = 0; _i < n2 + 1; _i++) {
19329 var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
19330 dots2.push({
19331 x: _d.x,
19332 y: _d.y,
19333 t: _i / n2
19334 });
19335 }
19336 for (var _i2 = 0; _i2 < n1; _i2++) {
19337 for (var j = 0; j < n2; j++) {
19338 var di = dots1[_i2];
19339 var di1 = dots1[_i2 + 1];
19340 var dj = dots2[j];
19341 var dj1 = dots2[j + 1];
19342 var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
19343 var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
19344 var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
19345 if (is) {
19346 if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
19347 continue;
19348 }
19349 xy[is.x.toFixed(4)] = is.y.toFixed(4);
19350 var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
19351 var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
19352 if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
19353 if (justCount) {
19354 res++;
19355 } else {
19356 res.push({
19357 x: is.x,
19358 y: is.y,
19359 t1: t1,
19360 t2: t2
19361 });
19362 }
19363 }
19364 }
19365 }
19366 }
19367 return res;
19368 };
19369
19370 var interPathHelper = function interPathHelper(path1, path2, justCount) {
19371 path1 = pathTocurve(path1);
19372 path2 = pathTocurve(path2);
19373 var x1 = void 0;
19374 var y1 = void 0;
19375 var x2 = void 0;
19376 var y2 = void 0;
19377 var x1m = void 0;
19378 var y1m = void 0;
19379 var x2m = void 0;
19380 var y2m = void 0;
19381 var bez1 = void 0;
19382 var bez2 = void 0;
19383 var res = justCount ? 0 : [];
19384 for (var i = 0, ii = path1.length; i < ii; i++) {
19385 var pi = path1[i];
19386 if (pi[0] === 'M') {
19387 x1 = x1m = pi[1];
19388 y1 = y1m = pi[2];
19389 } else {
19390 if (pi[0] === 'C') {
19391 bez1 = [x1, y1].concat(pi.slice(1));
19392 x1 = bez1[6];
19393 y1 = bez1[7];
19394 } else {
19395 bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
19396 x1 = x1m;
19397 y1 = y1m;
19398 }
19399 for (var j = 0, jj = path2.length; j < jj; j++) {
19400 var pj = path2[j];
19401 if (pj[0] === 'M') {
19402 x2 = x2m = pj[1];
19403 y2 = y2m = pj[2];
19404 } else {
19405 if (pj[0] === 'C') {
19406 bez2 = [x2, y2].concat(pj.slice(1));
19407 x2 = bez2[6];
19408 y2 = bez2[7];
19409 } else {
19410 bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
19411 x2 = x2m;
19412 y2 = y2m;
19413 }
19414 var intr = interHelper(bez1, bez2, justCount);
19415 if (justCount) {
19416 res += intr;
19417 } else {
19418 for (var k = 0, kk = intr.length; k < kk; k++) {
19419 intr[k].segment1 = i;
19420 intr[k].segment2 = j;
19421 intr[k].bez1 = bez1;
19422 intr[k].bez2 = bez2;
19423 }
19424 res = res.concat(intr);
19425 }
19426 }
19427 }
19428 }
19429 }
19430 return res;
19431 };
19432
19433 var pathIntersection = function pathIntersection(path1, path2) {
19434 return interPathHelper(path1, path2);
19435 };
19436
19437 module.exports = {
19438 parsePathString: parsePathString,
19439 parsePathArray: parsePathArray,
19440 pathTocurve: pathTocurve,
19441 pathToAbsolute: pathToAbsolute,
19442 catmullRomToBezier: catmullRom2bezier,
19443 rectPath: rectPath,
19444 intersection: pathIntersection
19445 };
19446
19447 /***/
19448 },
19449 /* 14 */
19450 /***/function (module, __webpack_exports__, __webpack_require__) {
19451
19452 "use strict";
19453 /* harmony export (immutable) */
19454 __webpack_exports__["b"] = now;
19455 /* harmony export (immutable) */__webpack_exports__["a"] = Timer;
19456 /* harmony export (immutable) */__webpack_exports__["c"] = timer;
19457 /* harmony export (immutable) */__webpack_exports__["d"] = timerFlush;
19458 var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
19459 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
19460 } : function (obj) {
19461 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
19462 };
19463
19464 var frame = 0,
19465
19466 // is an animation frame pending?
19467 timeout = 0,
19468
19469 // is a timeout pending?
19470 interval = 0,
19471
19472 // are any timers active?
19473 pokeDelay = 1000,
19474
19475 // how frequently we check for clock skew
19476 taskHead,
19477 taskTail,
19478 clockLast = 0,
19479 clockNow = 0,
19480 clockSkew = 0,
19481 clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === "object" && performance.now ? performance : Date,
19482 setFrame = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function (f) {
19483 setTimeout(f, 17);
19484 };
19485
19486 function now() {
19487 return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
19488 }
19489
19490 function clearNow() {
19491 clockNow = 0;
19492 }
19493
19494 function Timer() {
19495 this._call = this._time = this._next = null;
19496 }
19497
19498 Timer.prototype = timer.prototype = {
19499 constructor: Timer,
19500 restart: function restart(callback, delay, time) {
19501 if (typeof callback !== "function") throw new TypeError("callback is not a function");
19502 time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
19503 if (!this._next && taskTail !== this) {
19504 if (taskTail) taskTail._next = this;else taskHead = this;
19505 taskTail = this;
19506 }
19507 this._call = callback;
19508 this._time = time;
19509 sleep();
19510 },
19511 stop: function stop() {
19512 if (this._call) {
19513 this._call = null;
19514 this._time = Infinity;
19515 sleep();
19516 }
19517 }
19518 };
19519
19520 function timer(callback, delay, time) {
19521 var t = new Timer();
19522 t.restart(callback, delay, time);
19523 return t;
19524 }
19525
19526 function timerFlush() {
19527 now(); // Get the current time, if not already set.
19528 ++frame; // Pretend we’ve set an alarm, if we haven’t already.
19529 var t = taskHead,
19530 e;
19531 while (t) {
19532 if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
19533 t = t._next;
19534 }
19535 --frame;
19536 }
19537
19538 function wake() {
19539 clockNow = (clockLast = clock.now()) + clockSkew;
19540 frame = timeout = 0;
19541 try {
19542 timerFlush();
19543 } finally {
19544 frame = 0;
19545 nap();
19546 clockNow = 0;
19547 }
19548 }
19549
19550 function poke() {
19551 var now = clock.now(),
19552 delay = now - clockLast;
19553 if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
19554 }
19555
19556 function nap() {
19557 var t0,
19558 t1 = taskHead,
19559 t2,
19560 time = Infinity;
19561 while (t1) {
19562 if (t1._call) {
19563 if (time > t1._time) time = t1._time;
19564 t0 = t1, t1 = t1._next;
19565 } else {
19566 t2 = t1._next, t1._next = null;
19567 t1 = t0 ? t0._next = t2 : taskHead = t2;
19568 }
19569 }
19570 taskTail = t0;
19571 sleep(time);
19572 }
19573
19574 function sleep(time) {
19575 if (frame) return; // Soonest alarm already set, or will be.
19576 if (timeout) timeout = clearTimeout(timeout);
19577 var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
19578 if (delay > 24) {
19579 if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
19580 if (interval) interval = clearInterval(interval);
19581 } else {
19582 if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
19583 frame = 1, setFrame(wake);
19584 }
19585 }
19586
19587 /***/
19588 },
19589 /* 15 */
19590 /***/function (module, __webpack_exports__, __webpack_require__) {
19591
19592 "use strict";
19593 /* harmony import */
19594 var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
19595 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(31);
19596 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(34);
19597 /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(35);
19598 /* harmony import */var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(9);
19599 /* harmony import */var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(36);
19600 /* harmony import */var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(37);
19601 /* harmony import */var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(33);
19602 var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
19603 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
19604 } : function (obj) {
19605 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
19606 };
19607
19608 /* harmony default export */__webpack_exports__["a"] = function (a, b) {
19609 var t = typeof b === "undefined" ? "undefined" : _typeof(b),
19610 c;
19611 return b == null || t === "boolean" ? Object(__WEBPACK_IMPORTED_MODULE_7__constant__["a" /* default */])(b) : (t === "number" ? __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */] : t === "string" ? (c = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]) : __WEBPACK_IMPORTED_MODULE_6__string__["a" /* default */] : b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */] ? __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */] : b instanceof Date ? __WEBPACK_IMPORTED_MODULE_3__date__["a" /* default */] : Array.isArray(b) ? __WEBPACK_IMPORTED_MODULE_2__array__["a" /* default */] : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? __WEBPACK_IMPORTED_MODULE_5__object__["a" /* default */] : __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */])(a, b);
19612 };
19613
19614 /***/
19615 },
19616 /* 16 */
19617 /***/function (module, __webpack_exports__, __webpack_require__) {
19618
19619 "use strict";
19620 /* harmony export (immutable) */
19621 __webpack_exports__["a"] = Color;
19622 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "d", function () {
19623 return _darker;
19624 });
19625 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
19626 return _brighter;
19627 });
19628 /* harmony export (immutable) */__webpack_exports__["e"] = color;
19629 /* harmony export (immutable) */__webpack_exports__["h"] = rgbConvert;
19630 /* harmony export (immutable) */__webpack_exports__["g"] = rgb;
19631 /* harmony export (immutable) */__webpack_exports__["b"] = Rgb;
19632 /* unused harmony export hslConvert */
19633 /* harmony export (immutable) */__webpack_exports__["f"] = hsl;
19634 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(17);
19635
19636 function Color() {}
19637
19638 var _darker = 0.7;
19639
19640 var _brighter = 1 / _darker;
19641
19642 var reI = "\\s*([+-]?\\d+)\\s*",
19643 reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
19644 reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
19645 reHex3 = /^#([0-9a-f]{3})$/,
19646 reHex6 = /^#([0-9a-f]{6})$/,
19647 reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
19648 reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
19649 reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
19650 reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
19651 reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
19652 reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
19653
19654 var named = {
19655 aliceblue: 0xf0f8ff,
19656 antiquewhite: 0xfaebd7,
19657 aqua: 0x00ffff,
19658 aquamarine: 0x7fffd4,
19659 azure: 0xf0ffff,
19660 beige: 0xf5f5dc,
19661 bisque: 0xffe4c4,
19662 black: 0x000000,
19663 blanchedalmond: 0xffebcd,
19664 blue: 0x0000ff,
19665 blueviolet: 0x8a2be2,
19666 brown: 0xa52a2a,
19667 burlywood: 0xdeb887,
19668 cadetblue: 0x5f9ea0,
19669 chartreuse: 0x7fff00,
19670 chocolate: 0xd2691e,
19671 coral: 0xff7f50,
19672 cornflowerblue: 0x6495ed,
19673 cornsilk: 0xfff8dc,
19674 crimson: 0xdc143c,
19675 cyan: 0x00ffff,
19676 darkblue: 0x00008b,
19677 darkcyan: 0x008b8b,
19678 darkgoldenrod: 0xb8860b,
19679 darkgray: 0xa9a9a9,
19680 darkgreen: 0x006400,
19681 darkgrey: 0xa9a9a9,
19682 darkkhaki: 0xbdb76b,
19683 darkmagenta: 0x8b008b,
19684 darkolivegreen: 0x556b2f,
19685 darkorange: 0xff8c00,
19686 darkorchid: 0x9932cc,
19687 darkred: 0x8b0000,
19688 darksalmon: 0xe9967a,
19689 darkseagreen: 0x8fbc8f,
19690 darkslateblue: 0x483d8b,
19691 darkslategray: 0x2f4f4f,
19692 darkslategrey: 0x2f4f4f,
19693 darkturquoise: 0x00ced1,
19694 darkviolet: 0x9400d3,
19695 deeppink: 0xff1493,
19696 deepskyblue: 0x00bfff,
19697 dimgray: 0x696969,
19698 dimgrey: 0x696969,
19699 dodgerblue: 0x1e90ff,
19700 firebrick: 0xb22222,
19701 floralwhite: 0xfffaf0,
19702 forestgreen: 0x228b22,
19703 fuchsia: 0xff00ff,
19704 gainsboro: 0xdcdcdc,
19705 ghostwhite: 0xf8f8ff,
19706 gold: 0xffd700,
19707 goldenrod: 0xdaa520,
19708 gray: 0x808080,
19709 green: 0x008000,
19710 greenyellow: 0xadff2f,
19711 grey: 0x808080,
19712 honeydew: 0xf0fff0,
19713 hotpink: 0xff69b4,
19714 indianred: 0xcd5c5c,
19715 indigo: 0x4b0082,
19716 ivory: 0xfffff0,
19717 khaki: 0xf0e68c,
19718 lavender: 0xe6e6fa,
19719 lavenderblush: 0xfff0f5,
19720 lawngreen: 0x7cfc00,
19721 lemonchiffon: 0xfffacd,
19722 lightblue: 0xadd8e6,
19723 lightcoral: 0xf08080,
19724 lightcyan: 0xe0ffff,
19725 lightgoldenrodyellow: 0xfafad2,
19726 lightgray: 0xd3d3d3,
19727 lightgreen: 0x90ee90,
19728 lightgrey: 0xd3d3d3,
19729 lightpink: 0xffb6c1,
19730 lightsalmon: 0xffa07a,
19731 lightseagreen: 0x20b2aa,
19732 lightskyblue: 0x87cefa,
19733 lightslategray: 0x778899,
19734 lightslategrey: 0x778899,
19735 lightsteelblue: 0xb0c4de,
19736 lightyellow: 0xffffe0,
19737 lime: 0x00ff00,
19738 limegreen: 0x32cd32,
19739 linen: 0xfaf0e6,
19740 magenta: 0xff00ff,
19741 maroon: 0x800000,
19742 mediumaquamarine: 0x66cdaa,
19743 mediumblue: 0x0000cd,
19744 mediumorchid: 0xba55d3,
19745 mediumpurple: 0x9370db,
19746 mediumseagreen: 0x3cb371,
19747 mediumslateblue: 0x7b68ee,
19748 mediumspringgreen: 0x00fa9a,
19749 mediumturquoise: 0x48d1cc,
19750 mediumvioletred: 0xc71585,
19751 midnightblue: 0x191970,
19752 mintcream: 0xf5fffa,
19753 mistyrose: 0xffe4e1,
19754 moccasin: 0xffe4b5,
19755 navajowhite: 0xffdead,
19756 navy: 0x000080,
19757 oldlace: 0xfdf5e6,
19758 olive: 0x808000,
19759 olivedrab: 0x6b8e23,
19760 orange: 0xffa500,
19761 orangered: 0xff4500,
19762 orchid: 0xda70d6,
19763 palegoldenrod: 0xeee8aa,
19764 palegreen: 0x98fb98,
19765 paleturquoise: 0xafeeee,
19766 palevioletred: 0xdb7093,
19767 papayawhip: 0xffefd5,
19768 peachpuff: 0xffdab9,
19769 peru: 0xcd853f,
19770 pink: 0xffc0cb,
19771 plum: 0xdda0dd,
19772 powderblue: 0xb0e0e6,
19773 purple: 0x800080,
19774 rebeccapurple: 0x663399,
19775 red: 0xff0000,
19776 rosybrown: 0xbc8f8f,
19777 royalblue: 0x4169e1,
19778 saddlebrown: 0x8b4513,
19779 salmon: 0xfa8072,
19780 sandybrown: 0xf4a460,
19781 seagreen: 0x2e8b57,
19782 seashell: 0xfff5ee,
19783 sienna: 0xa0522d,
19784 silver: 0xc0c0c0,
19785 skyblue: 0x87ceeb,
19786 slateblue: 0x6a5acd,
19787 slategray: 0x708090,
19788 slategrey: 0x708090,
19789 snow: 0xfffafa,
19790 springgreen: 0x00ff7f,
19791 steelblue: 0x4682b4,
19792 tan: 0xd2b48c,
19793 teal: 0x008080,
19794 thistle: 0xd8bfd8,
19795 tomato: 0xff6347,
19796 turquoise: 0x40e0d0,
19797 violet: 0xee82ee,
19798 wheat: 0xf5deb3,
19799 white: 0xffffff,
19800 whitesmoke: 0xf5f5f5,
19801 yellow: 0xffff00,
19802 yellowgreen: 0x9acd32
19803 };
19804
19805 Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Color, color, {
19806 displayable: function displayable() {
19807 return this.rgb().displayable();
19808 },
19809 toString: function toString() {
19810 return this.rgb() + "";
19811 }
19812 });
19813
19814 function color(format) {
19815 var m;
19816 format = (format + "").trim().toLowerCase();
19817 return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb(m >> 8 & 0xf | m >> 4 & 0x0f0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00
19818 ) : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
19819 : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
19820 : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
19821 : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
19822 : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
19823 : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
19824 : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
19825 : named.hasOwnProperty(format) ? rgbn(named[format]) : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
19826 }
19827
19828 function rgbn(n) {
19829 return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
19830 }
19831
19832 function rgba(r, g, b, a) {
19833 if (a <= 0) r = g = b = NaN;
19834 return new Rgb(r, g, b, a);
19835 }
19836
19837 function rgbConvert(o) {
19838 if (!(o instanceof Color)) o = color(o);
19839 if (!o) return new Rgb();
19840 o = o.rgb();
19841 return new Rgb(o.r, o.g, o.b, o.opacity);
19842 }
19843
19844 function rgb(r, g, b, opacity) {
19845 return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
19846 }
19847
19848 function Rgb(r, g, b, opacity) {
19849 this.r = +r;
19850 this.g = +g;
19851 this.b = +b;
19852 this.opacity = +opacity;
19853 }
19854
19855 Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Rgb, rgb, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
19856 brighter: function brighter(k) {
19857 k = k == null ? _brighter : Math.pow(_brighter, k);
19858 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
19859 },
19860 darker: function darker(k) {
19861 k = k == null ? _darker : Math.pow(_darker, k);
19862 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
19863 },
19864 rgb: function rgb() {
19865 return this;
19866 },
19867 displayable: function displayable() {
19868 return 0 <= this.r && this.r <= 255 && 0 <= this.g && this.g <= 255 && 0 <= this.b && this.b <= 255 && 0 <= this.opacity && this.opacity <= 1;
19869 },
19870 toString: function toString() {
19871 var a = this.opacity;a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
19872 return (a === 1 ? "rgb(" : "rgba(") + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.b) || 0)) + (a === 1 ? ")" : ", " + a + ")");
19873 }
19874 }));
19875
19876 function hsla(h, s, l, a) {
19877 if (a <= 0) h = s = l = NaN;else if (l <= 0 || l >= 1) h = s = NaN;else if (s <= 0) h = NaN;
19878 return new Hsl(h, s, l, a);
19879 }
19880
19881 function hslConvert(o) {
19882 if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
19883 if (!(o instanceof Color)) o = color(o);
19884 if (!o) return new Hsl();
19885 if (o instanceof Hsl) return o;
19886 o = o.rgb();
19887 var r = o.r / 255,
19888 g = o.g / 255,
19889 b = o.b / 255,
19890 min = Math.min(r, g, b),
19891 max = Math.max(r, g, b),
19892 h = NaN,
19893 s = max - min,
19894 l = (max + min) / 2;
19895 if (s) {
19896 if (r === max) h = (g - b) / s + (g < b) * 6;else if (g === max) h = (b - r) / s + 2;else h = (r - g) / s + 4;
19897 s /= l < 0.5 ? max + min : 2 - max - min;
19898 h *= 60;
19899 } else {
19900 s = l > 0 && l < 1 ? 0 : h;
19901 }
19902 return new Hsl(h, s, l, o.opacity);
19903 }
19904
19905 function hsl(h, s, l, opacity) {
19906 return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
19907 }
19908
19909 function Hsl(h, s, l, opacity) {
19910 this.h = +h;
19911 this.s = +s;
19912 this.l = +l;
19913 this.opacity = +opacity;
19914 }
19915
19916 Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hsl, hsl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
19917 brighter: function brighter(k) {
19918 k = k == null ? _brighter : Math.pow(_brighter, k);
19919 return new Hsl(this.h, this.s, this.l * k, this.opacity);
19920 },
19921 darker: function darker(k) {
19922 k = k == null ? _darker : Math.pow(_darker, k);
19923 return new Hsl(this.h, this.s, this.l * k, this.opacity);
19924 },
19925 rgb: function rgb() {
19926 var h = this.h % 360 + (this.h < 0) * 360,
19927 s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
19928 l = this.l,
19929 m2 = l + (l < 0.5 ? l : 1 - l) * s,
19930 m1 = 2 * l - m2;
19931 return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity);
19932 },
19933 displayable: function displayable() {
19934 return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
19935 }
19936 }));
19937
19938 /* From FvD 13.37, CSS Color Module Level 3 */
19939 function hsl2rgb(h, m1, m2) {
19940 return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
19941 }
19942
19943 /***/
19944 },
19945 /* 17 */
19946 /***/function (module, __webpack_exports__, __webpack_require__) {
19947
19948 "use strict";
19949 /* harmony export (immutable) */
19950 __webpack_exports__["b"] = extend;
19951 /* harmony default export */__webpack_exports__["a"] = function (constructor, factory, prototype) {
19952 constructor.prototype = factory.prototype = prototype;
19953 prototype.constructor = constructor;
19954 };
19955
19956 function extend(parent, definition) {
19957 var prototype = Object.create(parent.prototype);
19958 for (var key in definition) {
19959 prototype[key] = definition[key];
19960 }return prototype;
19961 }
19962
19963 /***/
19964 },
19965 /* 18 */
19966 /***/function (module, __webpack_exports__, __webpack_require__) {
19967
19968 "use strict";
19969 /* harmony export (immutable) */
19970 __webpack_exports__["a"] = basis;
19971 function basis(t1, v0, v1, v2, v3) {
19972 var t2 = t1 * t1,
19973 t3 = t2 * t1;
19974 return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
19975 }
19976
19977 /* harmony default export */__webpack_exports__["b"] = function (values) {
19978 var n = values.length - 1;
19979 return function (t) {
19980 var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
19981 v1 = values[i],
19982 v2 = values[i + 1],
19983 v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
19984 v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
19985 return basis((t - i / n) * n, v0, v1, v2, v3);
19986 };
19987 };
19988
19989 /***/
19990 },
19991 /* 19 */
19992 /***/function (module, exports, __webpack_require__) {
19993
19994 var Util = __webpack_require__(0);
19995
19996 var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
19997 var regexDot = /[^\s\,]+/ig;
19998 var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
19999 var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
20000 var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
20001 var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
20002 var numColorCache = {};
20003
20004 function addStop(steps, gradient) {
20005 var arr = steps.match(regexColorStop);
20006 Util.each(arr, function (item) {
20007 item = item.split(':');
20008 gradient.addColorStop(item[0], item[1]);
20009 });
20010 }
20011
20012 function parseLineGradient(color, self) {
20013 var arr = regexLG.exec(color);
20014 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
20015 var steps = arr[2];
20016 var box = self.getBBox();
20017 var start = void 0;
20018 var end = void 0;
20019
20020 if (angle >= 0 && angle < 0.5 * Math.PI) {
20021 start = {
20022 x: box.minX,
20023 y: box.minY
20024 };
20025 end = {
20026 x: box.maxX,
20027 y: box.maxY
20028 };
20029 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
20030 start = {
20031 x: box.maxX,
20032 y: box.minY
20033 };
20034 end = {
20035 x: box.minX,
20036 y: box.maxY
20037 };
20038 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
20039 start = {
20040 x: box.maxX,
20041 y: box.maxY
20042 };
20043 end = {
20044 x: box.minX,
20045 y: box.minY
20046 };
20047 } else {
20048 start = {
20049 x: box.minX,
20050 y: box.maxY
20051 };
20052 end = {
20053 x: box.maxX,
20054 y: box.minY
20055 };
20056 }
20057
20058 var tanTheta = Math.tan(angle);
20059 var tanTheta2 = tanTheta * tanTheta;
20060
20061 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
20062 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
20063 var context = self.get('context');
20064 var gradient = context.createLinearGradient(start.x, start.y, x, y);
20065 addStop(steps, gradient);
20066 return gradient;
20067 }
20068
20069 function parseRadialGradient(color, self) {
20070 var arr = regexRG.exec(color);
20071 var fx = parseFloat(arr[1]);
20072 var fy = parseFloat(arr[2]);
20073 var fr = parseFloat(arr[3]);
20074 var steps = arr[4];
20075 // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
20076 if (fr === 0) {
20077 var colors = steps.match(regexColorStop);
20078 return colors[colors.length - 1].split(':')[1];
20079 }
20080 var box = self.getBBox();
20081 var context = self.get('context');
20082 var width = box.maxX - box.minX;
20083 var height = box.maxY - box.minY;
20084 var r = Math.sqrt(width * width + height * height) / 2;
20085 var gradient = context.createRadialGradient(box.minX + width * fx, box.minY + height * fy, fr * r, box.minX + width / 2, box.minY + height / 2, r);
20086 addStop(steps, gradient);
20087 return gradient;
20088 }
20089
20090 function parsePattern(color, self) {
20091 if (self.get('patternSource') && self.get('patternSource') === color) {
20092 return self.get('pattern');
20093 }
20094 var pattern = void 0;
20095 var img = void 0;
20096 var arr = regexPR.exec(color);
20097 var repeat = arr[1];
20098 var source = arr[2];
20099
20100 // Function to be called when pattern loads
20101 function onload() {
20102 // Create pattern
20103 var context = self.get('context');
20104 pattern = context.createPattern(img, repeat);
20105 self.setSilent('pattern', pattern); // be a cache
20106 self.setSilent('patternSource', color);
20107 }
20108
20109 switch (repeat) {
20110 case 'a':
20111 repeat = 'repeat';
20112 break;
20113 case 'x':
20114 repeat = 'repeat-x';
20115 break;
20116 case 'y':
20117 repeat = 'repeat-y';
20118 break;
20119 case 'n':
20120 repeat = 'no-repeat';
20121 break;
20122 default:
20123 repeat = 'no-repeat';
20124 }
20125
20126 img = new Image();
20127 // If source URL is not a data URL
20128 if (!source.match(/^data:/i)) {
20129 // Set crossOrigin for this image
20130 img.crossOrigin = 'Anonymous';
20131 }
20132 img.src = source;
20133
20134 if (img.complete) {
20135 onload();
20136 } else {
20137 img.onload = onload;
20138 // Fix onload() bug in IE9
20139 img.src = img.src;
20140 }
20141
20142 return pattern;
20143 }
20144
20145 module.exports = {
20146 parsePath: function parsePath(path) {
20147 path = path || [];
20148 if (Util.isArray(path)) {
20149 return path;
20150 }
20151
20152 if (Util.isString(path)) {
20153 path = path.match(regexTags);
20154 Util.each(path, function (item, index) {
20155 item = item.match(regexDot);
20156 if (item[0].length > 1) {
20157 var tag = item[0].charAt(0);
20158 item.splice(1, 0, item[0].substr(1));
20159 item[0] = tag;
20160 }
20161 Util.each(item, function (sub, i) {
20162 if (!isNaN(sub)) {
20163 item[i] = +sub;
20164 }
20165 });
20166 path[index] = item;
20167 });
20168 return path;
20169 }
20170 },
20171 parseStyle: function parseStyle(color, self) {
20172 if (Util.isString(color)) {
20173 if (color[1] === '(' || color[2] === '(') {
20174 if (color[0] === 'l') {
20175 // regexLG.test(color)
20176 return parseLineGradient(color, self);
20177 } else if (color[0] === 'r') {
20178 // regexRG.test(color)
20179 return parseRadialGradient(color, self);
20180 } else if (color[0] === 'p') {
20181 // regexPR.test(color)
20182 return parsePattern(color, self);
20183 }
20184 }
20185 return color;
20186 }
20187 },
20188 numberToColor: function numberToColor(num) {
20189 // 增加缓存
20190 var color = numColorCache[num];
20191 if (!color) {
20192 var str = num.toString(16);
20193 for (var i = str.length; i < 6; i++) {
20194 str = '0' + str;
20195 }
20196 color = '#' + str;
20197 numColorCache[num] = color;
20198 }
20199 return color;
20200 }
20201 };
20202
20203 /***/
20204 },
20205 /* 20 */
20206 /***/function (module, exports, __webpack_require__) {
20207
20208 var vec2 = __webpack_require__(2).vec2;
20209
20210 module.exports = {
20211 at: function at(p1, p2, t) {
20212 return (p2 - p1) * t + p1;
20213 },
20214 pointDistance: function pointDistance(x1, y1, x2, y2, x, y) {
20215 var d = [x2 - x1, y2 - y1];
20216 if (vec2.exactEquals(d, [0, 0])) {
20217 return NaN;
20218 }
20219
20220 var u = [-d[1], d[0]];
20221 vec2.normalize(u, u);
20222 var a = [x - x1, y - y1];
20223 return Math.abs(vec2.dot(a, u));
20224 },
20225 box: function box(x1, y1, x2, y2, lineWidth) {
20226 var halfWidth = lineWidth / 2;
20227 var minX = Math.min(x1, x2);
20228 var maxX = Math.max(x1, x2);
20229 var minY = Math.min(y1, y2);
20230 var maxY = Math.max(y1, y2);
20231
20232 return {
20233 minX: minX - halfWidth,
20234 minY: minY - halfWidth,
20235 maxX: maxX + halfWidth,
20236 maxY: maxY + halfWidth
20237 };
20238 },
20239 len: function len(x1, y1, x2, y2) {
20240 return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
20241 }
20242 };
20243
20244 /***/
20245 },
20246 /* 21 */
20247 /***/function (module, exports, __webpack_require__) {
20248
20249 var Util = __webpack_require__(0);
20250 var vec2 = __webpack_require__(2).vec2;
20251
20252 function quadraticAt(p0, p1, p2, t) {
20253 var onet = 1 - t;
20254 return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
20255 }
20256
20257 function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) {
20258 var t = void 0;
20259 var interval = 0.005;
20260 var d = Infinity;
20261 var d1 = void 0;
20262 var v1 = void 0;
20263 var v2 = void 0;
20264 var _t = void 0;
20265 var d2 = void 0;
20266 var i = void 0;
20267 var EPSILON = 0.0001;
20268 var v0 = [x, y];
20269
20270 for (_t = 0; _t < 1; _t += 0.05) {
20271 v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)];
20272
20273 d1 = vec2.squaredDistance(v0, v1);
20274 if (d1 < d) {
20275 t = _t;
20276 d = d1;
20277 }
20278 }
20279 d = Infinity;
20280
20281 for (i = 0; i < 32; i++) {
20282 if (interval < EPSILON) {
20283 break;
20284 }
20285
20286 var prev = t - interval;
20287 var next = t + interval;
20288
20289 v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)];
20290
20291 d1 = vec2.squaredDistance(v0, v1);
20292
20293 if (prev >= 0 && d1 < d) {
20294 t = prev;
20295 d = d1;
20296 } else {
20297 v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)];
20298
20299 d2 = vec2.squaredDistance(v0, v2);
20300
20301 if (next <= 1 && d2 < d) {
20302 t = next;
20303 d = d2;
20304 } else {
20305 interval *= 0.5;
20306 }
20307 }
20308 }
20309
20310 if (out) {
20311 out.x = quadraticAt(x1, x2, x3, t);
20312 out.y = quadraticAt(y1, y2, y3, t);
20313 }
20314
20315 return Math.sqrt(d);
20316 }
20317
20318 function quadraticExtrema(p0, p1, p2) {
20319 var a = p0 + p2 - 2 * p1;
20320 if (Util.isNumberEqual(a, 0)) {
20321 return [0.5];
20322 }
20323 var rst = (p0 - p1) / a;
20324 if (rst <= 1 && rst >= 0) {
20325 return [rst];
20326 }
20327 return [];
20328 }
20329
20330 module.exports = {
20331 at: quadraticAt,
20332 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x, y) {
20333 var rst = {};
20334 quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, rst);
20335 return rst;
20336 },
20337
20338 pointDistance: quadraticProjectPoint,
20339 extrema: quadraticExtrema
20340 };
20341
20342 /***/
20343 },
20344 /* 22 */
20345 /***/function (module, exports, __webpack_require__) {
20346
20347 var Util = __webpack_require__(0);
20348 var vec2 = __webpack_require__(2).vec2;
20349
20350 function circlePoint(cx, cy, r, angle) {
20351 return {
20352 x: Math.cos(angle) * r + cx,
20353 y: Math.sin(angle) * r + cy
20354 };
20355 }
20356
20357 function angleNearTo(angle, min, max, out) {
20358 var v1 = void 0;
20359 var v2 = void 0;
20360 if (out) {
20361 if (angle < min) {
20362 v1 = min - angle;
20363 v2 = Math.PI * 2 - max + angle;
20364 } else if (angle > max) {
20365 v1 = Math.PI * 2 - angle + min;
20366 v2 = angle - max;
20367 }
20368 } else {
20369 v1 = angle - min;
20370 v2 = max - angle;
20371 }
20372
20373 return v1 > v2 ? max : min;
20374 }
20375
20376 function nearAngle(angle, startAngle, endAngle, clockwise) {
20377 var plus = 0;
20378 if (endAngle - startAngle >= Math.PI * 2) {
20379 plus = Math.PI * 2;
20380 }
20381 startAngle = Util.mod(startAngle, Math.PI * 2);
20382 endAngle = Util.mod(endAngle, Math.PI * 2) + plus;
20383 angle = Util.mod(angle, Math.PI * 2);
20384 if (clockwise) {
20385 if (startAngle >= endAngle) {
20386 if (angle > endAngle && angle < startAngle) {
20387 return angle;
20388 }
20389 return angleNearTo(angle, endAngle, startAngle, true);
20390 }
20391 if (angle < startAngle || angle > endAngle) {
20392 return angle;
20393 }
20394 return angleNearTo(angle, startAngle, endAngle);
20395 }
20396 if (startAngle <= endAngle) {
20397 if (startAngle < angle && angle < endAngle) {
20398 return angle;
20399 }
20400 return angleNearTo(angle, startAngle, endAngle, true);
20401 }
20402 if (angle > startAngle || angle < endAngle) {
20403 return angle;
20404 }
20405 return angleNearTo(angle, endAngle, startAngle);
20406 }
20407
20408 function arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, out) {
20409 var v = [x, y];
20410 var v0 = [cx, cy];
20411 var v1 = [1, 0];
20412 var subv = vec2.subtract([], v, v0);
20413 var angle = vec2.angleTo(v1, subv);
20414
20415 angle = nearAngle(angle, startAngle, endAngle, clockwise);
20416 var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy];
20417 if (out) {
20418 out.x = vpoint[0];
20419 out.y = vpoint[1];
20420 }
20421 var d = vec2.distance(vpoint, v);
20422 return d;
20423 }
20424
20425 function arcBox(cx, cy, r, startAngle, endAngle, clockwise) {
20426 var angleRight = 0;
20427 var angleBottom = Math.PI / 2;
20428 var angleLeft = Math.PI;
20429 var angleTop = Math.PI * 3 / 2;
20430 var points = [];
20431 var angle = nearAngle(angleRight, startAngle, endAngle, clockwise);
20432 if (angle === angleRight) {
20433 points.push(circlePoint(cx, cy, r, angleRight));
20434 }
20435
20436 angle = nearAngle(angleBottom, startAngle, endAngle, clockwise);
20437 if (angle === angleBottom) {
20438 points.push(circlePoint(cx, cy, r, angleBottom));
20439 }
20440
20441 angle = nearAngle(angleLeft, startAngle, endAngle, clockwise);
20442 if (angle === angleLeft) {
20443 points.push(circlePoint(cx, cy, r, angleLeft));
20444 }
20445
20446 angle = nearAngle(angleTop, startAngle, endAngle, clockwise);
20447 if (angle === angleTop) {
20448 points.push(circlePoint(cx, cy, r, angleTop));
20449 }
20450
20451 points.push(circlePoint(cx, cy, r, startAngle));
20452 points.push(circlePoint(cx, cy, r, endAngle));
20453 var minX = Infinity;
20454 var maxX = -Infinity;
20455 var minY = Infinity;
20456 var maxY = -Infinity;
20457 Util.each(points, function (point) {
20458 if (minX > point.x) {
20459 minX = point.x;
20460 }
20461 if (maxX < point.x) {
20462 maxX = point.x;
20463 }
20464 if (minY > point.y) {
20465 minY = point.y;
20466 }
20467 if (maxY < point.y) {
20468 maxY = point.y;
20469 }
20470 });
20471
20472 return {
20473 minX: minX,
20474 minY: minY,
20475 maxX: maxX,
20476 maxY: maxY
20477 };
20478 }
20479
20480 module.exports = {
20481 nearAngle: nearAngle,
20482 projectPoint: function projectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y) {
20483 var rst = {};
20484 arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, rst);
20485 return rst;
20486 },
20487
20488 pointDistance: arcProjectPoint,
20489 box: arcBox
20490 };
20491
20492 /***/
20493 },
20494 /* 23 */
20495 /***/function (module, exports, __webpack_require__) {
20496
20497 var Util = __webpack_require__(0);
20498 var Shape = __webpack_require__(1);
20499 var Inside = __webpack_require__(3);
20500
20501 var Rect = function Rect(cfg) {
20502 Rect.superclass.constructor.call(this, cfg);
20503 };
20504
20505 Rect.ATTRS = {
20506 x: 0,
20507 y: 0,
20508 width: 0,
20509 height: 0,
20510 radius: 0,
20511 lineWidth: 1
20512 };
20513
20514 Util.extend(Rect, Shape);
20515
20516 Util.augment(Rect, {
20517 canFill: true,
20518 canStroke: true,
20519 type: 'rect',
20520 getDefaultAttrs: function getDefaultAttrs() {
20521 return {
20522 lineWidth: 1,
20523 radius: 0
20524 };
20525 },
20526 calculateBox: function calculateBox() {
20527 var self = this;
20528 var attrs = self.__attrs;
20529 var x = attrs.x;
20530 var y = attrs.y;
20531 var width = attrs.width;
20532 var height = attrs.height;
20533 var lineWidth = this.getHitLineWidth();
20534
20535 var halfWidth = lineWidth / 2;
20536 return {
20537 minX: x - halfWidth,
20538 minY: y - halfWidth,
20539 maxX: x + width + halfWidth,
20540 maxY: y + height + halfWidth
20541 };
20542 },
20543 isPointInPath: function isPointInPath(x, y) {
20544 var self = this;
20545 var fill = self.hasFill();
20546 var stroke = self.hasStroke();
20547
20548 if (fill && stroke) {
20549 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
20550 }
20551
20552 if (fill) {
20553 return self._isPointInFill(x, y);
20554 }
20555
20556 if (stroke) {
20557 return self._isPointInStroke(x, y);
20558 }
20559
20560 return false;
20561 },
20562 _isPointInFill: function _isPointInFill(x, y) {
20563 var context = this.get('context');
20564
20565 if (!context) return false;
20566 this.createPath();
20567 return context.isPointInPath(x, y);
20568 },
20569 _isPointInStroke: function _isPointInStroke(x, y) {
20570 var self = this;
20571 var attrs = self.__attrs;
20572 var rx = attrs.x;
20573 var ry = attrs.y;
20574 var width = attrs.width;
20575 var height = attrs.height;
20576 var radius = attrs.radius;
20577 var lineWidth = this.getHitLineWidth();
20578
20579 if (radius === 0) {
20580 var halfWidth = lineWidth / 2;
20581 return Inside.line(rx - halfWidth, ry, rx + width + halfWidth, ry, lineWidth, x, y) || Inside.line(rx + width, ry - halfWidth, rx + width, ry + height + halfWidth, lineWidth, x, y) || Inside.line(rx + width + halfWidth, ry + height, rx - halfWidth, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height + halfWidth, rx, ry - halfWidth, lineWidth, x, y);
20582 }
20583
20584 return Inside.line(rx + radius, ry, rx + width - radius, ry, lineWidth, x, y) || Inside.line(rx + width, ry + radius, rx + width, ry + height - radius, lineWidth, x, y) || Inside.line(rx + width - radius, ry + height, rx + radius, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height - radius, rx, ry + radius, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + radius, radius, 1.5 * Math.PI, 2 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + height - radius, radius, 0, 0.5 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + height - radius, radius, 0.5 * Math.PI, Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + radius, radius, Math.PI, 1.5 * Math.PI, false, lineWidth, x, y);
20585 },
20586 createPath: function createPath(context) {
20587 var self = this;
20588 var attrs = self.__attrs;
20589 var x = attrs.x;
20590 var y = attrs.y;
20591 var width = attrs.width;
20592 var height = attrs.height;
20593 var radius = attrs.radius;
20594 context = context || self.get('context');
20595
20596 context.beginPath();
20597 if (radius === 0) {
20598 // 改成原生的rect方法
20599 context.rect(x, y, width, height);
20600 } else {
20601 context.moveTo(x + radius, y);
20602 context.lineTo(x + width - radius, y);
20603 context.arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0, false);
20604 context.lineTo(x + width, y + height - radius);
20605 context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2, false);
20606 context.lineTo(x + radius, y + height);
20607 context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI, false);
20608 context.lineTo(x, y + radius);
20609 context.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2, false);
20610 context.closePath();
20611 }
20612 }
20613 });
20614
20615 module.exports = Rect;
20616
20617 /***/
20618 },
20619 /* 24 */
20620 /***/function (module, exports, __webpack_require__) {
20621
20622 var Util = __webpack_require__(0);
20623 var Inside = __webpack_require__(3);
20624 var Cubic = __webpack_require__(10);
20625 var Quadratic = __webpack_require__(21);
20626 var Ellipse = __webpack_require__(113);
20627 var vec3 = __webpack_require__(2).vec3;
20628 var mat3 = __webpack_require__(2).mat3;
20629
20630 var ARR_CMD = ['m', 'l', 'c', 'a', 'q', 'h', 'v', 't', 's', 'z'];
20631
20632 function toAbsolute(x, y, curPoint) {
20633 // 获取绝对坐标
20634 return {
20635 x: curPoint.x + x,
20636 y: curPoint.y + y
20637 };
20638 }
20639
20640 function toSymmetry(point, center) {
20641 // 点对称
20642 return {
20643 x: center.x + (center.x - point.x),
20644 y: center.y + (center.y - point.y)
20645 };
20646 }
20647
20648 function vMag(v) {
20649 return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
20650 }
20651
20652 function vRatio(u, v) {
20653 return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
20654 }
20655
20656 function vAngle(u, v) {
20657 return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
20658 }
20659
20660 function getArcParams(point1, point2, fa, fs, rx, ry, psiDeg) {
20661 var psi = Util.mod(Util.toRadian(psiDeg), Math.PI * 2);
20662 var x1 = point1.x;
20663 var y1 = point1.y;
20664 var x2 = point2.x;
20665 var y2 = point2.y;
20666 var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
20667 var yp = -1 * Math.sin(psi) * (x1 - x2) / 2.0 + Math.cos(psi) * (y1 - y2) / 2.0;
20668 var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
20669 if (lambda > 1) {
20670 rx *= Math.sqrt(lambda);
20671 ry *= Math.sqrt(lambda);
20672 }
20673 var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);
20674 var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff);
20675
20676 if (fa === fs) {
20677 f *= -1;
20678 }
20679 if (isNaN(f)) {
20680 f = 0;
20681 }
20682
20683 var cxp = f * rx * yp / ry;
20684 var cyp = f * -ry * xp / rx;
20685
20686 var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
20687 var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
20688
20689 var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
20690 var u = [(xp - cxp) / rx, (yp - cyp) / ry];
20691 var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
20692 var dTheta = vAngle(u, v);
20693 if (fs === 0 && dTheta > 0) {
20694 dTheta = dTheta - 2 * Math.PI;
20695 }
20696 if (fs === 1 && dTheta < 0) {
20697 dTheta = dTheta + 2 * Math.PI;
20698 }
20699 return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs];
20700 }
20701
20702 var PathSegment = function PathSegment(item, preSegment, isLast) {
20703 this.preSegment = preSegment;
20704 this.isLast = isLast;
20705 this.init(item, preSegment);
20706 };
20707
20708 Util.augment(PathSegment, {
20709 init: function init(item, preSegment) {
20710 var command = item[0];
20711 preSegment = preSegment || {
20712 endPoint: {
20713 x: 0,
20714 y: 0
20715 }
20716 };
20717 var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command);
20718 var cmd = relative ? command.toUpperCase() : command;
20719 var p = item;
20720 var point1 = void 0;
20721 var point2 = void 0;
20722 var point3 = void 0;
20723 var point = void 0;
20724 var preEndPoint = preSegment.endPoint;
20725
20726 var p1 = p[1];
20727 var p2 = p[2];
20728 switch (cmd) {
20729 default:
20730 break;
20731 case 'M':
20732 if (relative) {
20733 point = toAbsolute(p1, p2, preEndPoint);
20734 } else {
20735 point = {
20736 x: p1,
20737 y: p2
20738 };
20739 }
20740 this.command = 'M';
20741 this.params = [preEndPoint, point];
20742 this.subStart = point;
20743 this.endPoint = point;
20744 break;
20745 case 'L':
20746 if (relative) {
20747 point = toAbsolute(p1, p2, preEndPoint);
20748 } else {
20749 point = {
20750 x: p1,
20751 y: p2
20752 };
20753 }
20754 this.command = 'L';
20755 this.params = [preEndPoint, point];
20756 this.subStart = preSegment.subStart;
20757 this.endPoint = point;
20758 this.endTangent = function () {
20759 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
20760 };
20761 this.startTangent = function () {
20762 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
20763 };
20764 break;
20765 case 'H':
20766 if (relative) {
20767 point = toAbsolute(p1, 0, preEndPoint);
20768 } else {
20769 point = {
20770 x: p1,
20771 y: preEndPoint.y
20772 };
20773 }
20774 this.command = 'L';
20775 this.params = [preEndPoint, point];
20776 this.subStart = preSegment.subStart;
20777 this.endPoint = point;
20778 this.endTangent = function () {
20779 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
20780 };
20781 this.startTangent = function () {
20782 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
20783 };
20784 break;
20785 case 'V':
20786 if (relative) {
20787 point = toAbsolute(0, p1, preEndPoint);
20788 } else {
20789 point = {
20790 x: preEndPoint.x,
20791 y: p1
20792 };
20793 }
20794 this.command = 'L';
20795 this.params = [preEndPoint, point];
20796 this.subStart = preSegment.subStart;
20797 this.endPoint = point;
20798 this.endTangent = function () {
20799 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
20800 };
20801 this.startTangent = function () {
20802 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
20803 };
20804 break;
20805 case 'Q':
20806 if (relative) {
20807 point1 = toAbsolute(p1, p2, preEndPoint);
20808 point2 = toAbsolute(p[3], p[4], preEndPoint);
20809 } else {
20810 point1 = {
20811 x: p1,
20812 y: p2
20813 };
20814 point2 = {
20815 x: p[3],
20816 y: p[4]
20817 };
20818 }
20819 this.command = 'Q';
20820 this.params = [preEndPoint, point1, point2];
20821 this.subStart = preSegment.subStart;
20822 this.endPoint = point2;
20823 this.endTangent = function () {
20824 return [point2.x - point1.x, point2.y - point1.y];
20825 };
20826 this.startTangent = function () {
20827 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
20828 };
20829 break;
20830 case 'T':
20831 if (relative) {
20832 point2 = toAbsolute(p1, p2, preEndPoint);
20833 } else {
20834 point2 = {
20835 x: p1,
20836 y: p2
20837 };
20838 }
20839 if (preSegment.command === 'Q') {
20840 point1 = toSymmetry(preSegment.params[1], preEndPoint);
20841 this.command = 'Q';
20842 this.params = [preEndPoint, point1, point2];
20843 this.subStart = preSegment.subStart;
20844 this.endPoint = point2;
20845 this.endTangent = function () {
20846 return [point2.x - point1.x, point2.y - point1.y];
20847 };
20848 this.startTangent = function () {
20849 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
20850 };
20851 } else {
20852 this.command = 'TL';
20853 this.params = [preEndPoint, point2];
20854 this.subStart = preSegment.subStart;
20855 this.endPoint = point2;
20856 this.endTangent = function () {
20857 return [point2.x - preEndPoint.x, point2.y - preEndPoint.y];
20858 };
20859 this.startTangent = function () {
20860 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
20861 };
20862 }
20863
20864 break;
20865 case 'C':
20866 if (relative) {
20867 point1 = toAbsolute(p1, p2, preEndPoint);
20868 point2 = toAbsolute(p[3], p[4], preEndPoint);
20869 point3 = toAbsolute(p[5], p[6], preEndPoint);
20870 } else {
20871 point1 = {
20872 x: p1,
20873 y: p2
20874 };
20875 point2 = {
20876 x: p[3],
20877 y: p[4]
20878 };
20879 point3 = {
20880 x: p[5],
20881 y: p[6]
20882 };
20883 }
20884 this.command = 'C';
20885 this.params = [preEndPoint, point1, point2, point3];
20886 this.subStart = preSegment.subStart;
20887 this.endPoint = point3;
20888 this.endTangent = function () {
20889 return [point3.x - point2.x, point3.y - point2.y];
20890 };
20891 this.startTangent = function () {
20892 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
20893 };
20894 break;
20895 case 'S':
20896 if (relative) {
20897 point2 = toAbsolute(p1, p2, preEndPoint);
20898 point3 = toAbsolute(p[3], p[4], preEndPoint);
20899 } else {
20900 point2 = {
20901 x: p1,
20902 y: p2
20903 };
20904 point3 = {
20905 x: p[3],
20906 y: p[4]
20907 };
20908 }
20909 if (preSegment.command === 'C') {
20910 point1 = toSymmetry(preSegment.params[2], preEndPoint);
20911 this.command = 'C';
20912 this.params = [preEndPoint, point1, point2, point3];
20913 this.subStart = preSegment.subStart;
20914 this.endPoint = point3;
20915 this.endTangent = function () {
20916 return [point3.x - point2.x, point3.y - point2.y];
20917 };
20918 this.startTangent = function () {
20919 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
20920 };
20921 } else {
20922 this.command = 'SQ';
20923 this.params = [preEndPoint, point2, point3];
20924 this.subStart = preSegment.subStart;
20925 this.endPoint = point3;
20926 this.endTangent = function () {
20927 return [point3.x - point2.x, point3.y - point2.y];
20928 };
20929 this.startTangent = function () {
20930 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
20931 };
20932 }
20933 break;
20934 case 'A':
20935 {
20936 var rx = p1;
20937 var ry = p2;
20938 var psi = p[3];
20939 var fa = p[4];
20940 var fs = p[5];
20941 if (relative) {
20942 point = toAbsolute(p[6], p[7], preEndPoint);
20943 } else {
20944 point = {
20945 x: p[6],
20946 y: p[7]
20947 };
20948 }
20949
20950 this.command = 'A';
20951 var params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi);
20952 this.params = params;
20953 var start = preSegment.subStart;
20954 this.subStart = start;
20955 this.endPoint = point;
20956 var startAngle = params[5] % (Math.PI * 2);
20957 if (Util.isNumberEqual(startAngle, Math.PI * 2)) {
20958 startAngle = 0;
20959 }
20960 var endAngle = params[6] % (Math.PI * 2);
20961 if (Util.isNumberEqual(endAngle, Math.PI * 2)) {
20962 endAngle = 0;
20963 }
20964 var d = 0.001;
20965 this.startTangent = function () {
20966 if (fs === 0) {
20967 d *= -1;
20968 }
20969 var dx = params[3] * Math.cos(startAngle - d) + params[1];
20970 var dy = params[4] * Math.sin(startAngle - d) + params[2];
20971 return [dx - start.x, dy - start.y];
20972 };
20973 this.endTangent = function () {
20974 var endAngle = params[6];
20975 if (endAngle - Math.PI * 2 < 0.0001) {
20976 endAngle = 0;
20977 }
20978 var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1];
20979 var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2];
20980 return [preEndPoint.x - dx, preEndPoint.y - dy];
20981 };
20982 break;
20983 }
20984 case 'Z':
20985 {
20986 this.command = 'Z';
20987 this.params = [preEndPoint, preSegment.subStart];
20988 this.subStart = preSegment.subStart;
20989 this.endPoint = preSegment.subStart;
20990 }
20991 }
20992 },
20993 isInside: function isInside(x, y, lineWidth) {
20994 var self = this;
20995 var command = self.command;
20996 var params = self.params;
20997 var box = self.box;
20998 if (box) {
20999 if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
21000 return false;
21001 }
21002 }
21003 switch (command) {
21004 default:
21005 break;
21006 case 'M':
21007 return false;
21008 case 'TL':
21009 case 'L':
21010 case 'Z':
21011 return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y);
21012 case 'SQ':
21013 case 'Q':
21014 return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y);
21015 case 'C':
21016 {
21017 return Inside.cubicline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, params[3].x, params[3].y, lineWidth, x, y);
21018 }
21019 case 'A':
21020 {
21021 var p = params;
21022 var cx = p[1];
21023 var cy = p[2];
21024 var rx = p[3];
21025 var ry = p[4];
21026 var theta = p[5];
21027 var dTheta = p[6];
21028 var psi = p[7];
21029 var fs = p[8];
21030
21031 var r = rx > ry ? rx : ry;
21032 var scaleX = rx > ry ? 1 : rx / ry;
21033 var scaleY = rx > ry ? ry / rx : 1;
21034
21035 p = [x, y, 1];
21036 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
21037 mat3.translate(m, m, [-cx, -cy]);
21038 mat3.rotate(m, m, -psi);
21039 mat3.scale(m, m, [1 / scaleX, 1 / scaleY]);
21040 vec3.transformMat3(p, p, m);
21041 return Inside.arcline(0, 0, r, theta, theta + dTheta, 1 - fs, lineWidth, p[0], p[1]);
21042 }
21043 }
21044 return false;
21045 },
21046 draw: function draw(context) {
21047 var command = this.command;
21048 var params = this.params;
21049 var point1 = void 0;
21050 var point2 = void 0;
21051 var point3 = void 0;
21052
21053 switch (command) {
21054 default:
21055 break;
21056 case 'M':
21057 context.moveTo(params[1].x, params[1].y);
21058 break;
21059 case 'TL':
21060 case 'L':
21061 context.lineTo(params[1].x, params[1].y);
21062 break;
21063 case 'SQ':
21064 case 'Q':
21065 point1 = params[1];
21066 point2 = params[2];
21067 context.quadraticCurveTo(point1.x, point1.y, point2.x, point2.y);
21068 break;
21069 case 'C':
21070 point1 = params[1];
21071 point2 = params[2];
21072 point3 = params[3];
21073 context.bezierCurveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
21074 break;
21075 case 'A':
21076 {
21077 var p = params;
21078 var p1 = p[1];
21079 var p2 = p[2];
21080 var cx = p1;
21081 var cy = p2;
21082 var rx = p[3];
21083 var ry = p[4];
21084 var theta = p[5];
21085 var dTheta = p[6];
21086 var psi = p[7];
21087 var fs = p[8];
21088
21089 var r = rx > ry ? rx : ry;
21090 var scaleX = rx > ry ? 1 : rx / ry;
21091 var scaleY = rx > ry ? ry / rx : 1;
21092
21093 context.translate(cx, cy);
21094 context.rotate(psi);
21095 context.scale(scaleX, scaleY);
21096 context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);
21097 context.scale(1 / scaleX, 1 / scaleY);
21098 context.rotate(-psi);
21099 context.translate(-cx, -cy);
21100 break;
21101 }
21102 case 'Z':
21103 context.closePath();
21104 break;
21105 }
21106 },
21107 getBBox: function getBBox(lineWidth) {
21108 var halfWidth = lineWidth / 2;
21109 var params = this.params;
21110 var yDims = void 0;
21111 var xDims = void 0;
21112 var i = void 0;
21113 var l = void 0;
21114
21115 switch (this.command) {
21116 default:
21117 case 'M':
21118 case 'Z':
21119 break;
21120 case 'TL':
21121 case 'L':
21122 this.box = {
21123 minX: Math.min(params[0].x, params[1].x) - halfWidth,
21124 maxX: Math.max(params[0].x, params[1].x) + halfWidth,
21125 minY: Math.min(params[0].y, params[1].y) - halfWidth,
21126 maxY: Math.max(params[0].y, params[1].y) + halfWidth
21127 };
21128 break;
21129 case 'SQ':
21130 case 'Q':
21131 xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x);
21132 for (i = 0, l = xDims.length; i < l; i++) {
21133 xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]);
21134 }
21135 xDims.push(params[0].x, params[2].x);
21136 yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y);
21137 for (i = 0, l = yDims.length; i < l; i++) {
21138 yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims);
21139 }
21140 yDims.push(params[0].y, params[2].y);
21141 this.box = {
21142 minX: Math.min.apply(Math, xDims) - halfWidth,
21143 maxX: Math.max.apply(Math, xDims) + halfWidth,
21144 minY: Math.min.apply(Math, yDims) - halfWidth,
21145 maxY: Math.max.apply(Math, yDims) + halfWidth
21146 };
21147 break;
21148 case 'C':
21149 xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x);
21150 for (i = 0, l = xDims.length; i < l; i++) {
21151 xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]);
21152 }
21153 yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y);
21154 for (i = 0, l = yDims.length; i < l; i++) {
21155 yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]);
21156 }
21157 xDims.push(params[0].x, params[3].x);
21158 yDims.push(params[0].y, params[3].y);
21159 this.box = {
21160 minX: Math.min.apply(Math, xDims) - halfWidth,
21161 maxX: Math.max.apply(Math, xDims) + halfWidth,
21162 minY: Math.min.apply(Math, yDims) - halfWidth,
21163 maxY: Math.max.apply(Math, yDims) + halfWidth
21164 };
21165 break;
21166 case 'A':
21167 {
21168 // todo 待优化
21169 var p = params;
21170 var cx = p[1];
21171 var cy = p[2];
21172 var rx = p[3];
21173 var ry = p[4];
21174 var theta = p[5];
21175 var dTheta = p[6];
21176 var psi = p[7];
21177 var fs = p[8];
21178 var start = theta;
21179 var end = theta + dTheta;
21180
21181 var xDim = Ellipse.xExtrema(psi, rx, ry);
21182 var minX = Infinity;
21183 var maxX = -Infinity;
21184 var xs = [start, end];
21185 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
21186 var xAngle = xDim + i;
21187 if (fs === 1) {
21188 if (start < xAngle && xAngle < end) {
21189 xs.push(xAngle);
21190 }
21191 } else {
21192 if (end < xAngle && xAngle < start) {
21193 xs.push(xAngle);
21194 }
21195 }
21196 }
21197
21198 for (i = 0, l = xs.length; i < l; i++) {
21199 var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]);
21200 if (x < minX) {
21201 minX = x;
21202 }
21203 if (x > maxX) {
21204 maxX = x;
21205 }
21206 }
21207
21208 var yDim = Ellipse.yExtrema(psi, rx, ry);
21209 var minY = Infinity;
21210 var maxY = -Infinity;
21211 var ys = [start, end];
21212 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
21213 var yAngle = yDim + i;
21214 if (fs === 1) {
21215 if (start < yAngle && yAngle < end) {
21216 ys.push(yAngle);
21217 }
21218 } else {
21219 if (end < yAngle && yAngle < start) {
21220 ys.push(yAngle);
21221 }
21222 }
21223 }
21224
21225 for (i = 0, l = ys.length; i < l; i++) {
21226 var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]);
21227 if (y < minY) {
21228 minY = y;
21229 }
21230 if (y > maxY) {
21231 maxY = y;
21232 }
21233 }
21234 this.box = {
21235 minX: minX - halfWidth,
21236 maxX: maxX + halfWidth,
21237 minY: minY - halfWidth,
21238 maxY: maxY + halfWidth
21239 };
21240 break;
21241 }
21242 }
21243 }
21244 });
21245
21246 module.exports = PathSegment;
21247
21248 /***/
21249 },
21250 /* 25 */
21251 /***/function (module, exports, __webpack_require__) {
21252
21253 var Util = __webpack_require__(0);
21254 var Shape = __webpack_require__(1);
21255 var Inside = __webpack_require__(3);
21256 var Format = __webpack_require__(19);
21257 var PathSegment = __webpack_require__(24);
21258
21259 var Marker = function Marker(cfg) {
21260 Marker.superclass.constructor.call(this, cfg);
21261 };
21262
21263 Marker.Symbols = {
21264 // 圆
21265 circle: function circle(x, y, r) {
21266 return [['M', x, y], ['m', -r, 0], ['a', r, r, 0, 1, 0, r * 2, 0], ['a', r, r, 0, 1, 0, -r * 2, 0]];
21267 },
21268
21269 // 正方形
21270 square: function square(x, y, r) {
21271 return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];
21272 },
21273
21274 // 菱形
21275 diamond: function diamond(x, y, r) {
21276 return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];
21277 },
21278
21279 // 三角形
21280 triangle: function triangle(x, y, r) {
21281 var diffY = r * Math.sin(1 / 3 * Math.PI);
21282 return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['z']];
21283 },
21284
21285 // 倒三角形
21286 'triangle-down': function triangleDown(x, y, r) {
21287 var diffY = r * Math.sin(1 / 3 * Math.PI);
21288 return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];
21289 }
21290 };
21291
21292 Marker.ATTRS = {
21293 path: null,
21294 lineWidth: 1
21295 };
21296
21297 Util.extend(Marker, Shape);
21298
21299 Util.augment(Marker, {
21300 type: 'marker',
21301 canFill: true,
21302 canStroke: true,
21303 getDefaultAttrs: function getDefaultAttrs() {
21304 return {
21305 x: 0,
21306 y: 0,
21307 lineWidth: 1
21308 };
21309 },
21310 calculateBox: function calculateBox() {
21311 var attrs = this.__attrs;
21312 var cx = attrs.x;
21313 var cy = attrs.y;
21314 var r = attrs.radius;
21315 var lineWidth = this.getHitLineWidth();
21316 var halfWidth = lineWidth / 2 + r;
21317 return {
21318 minX: cx - halfWidth,
21319 minY: cy - halfWidth,
21320 maxX: cx + halfWidth,
21321 maxY: cy + halfWidth
21322 };
21323 },
21324 isPointInPath: function isPointInPath(x, y) {
21325 var attrs = this.__attrs;
21326 var cx = attrs.x;
21327 var cy = attrs.y;
21328 var r = attrs.radius || attrs.r;
21329 var lineWidth = this.getHitLineWidth();
21330 return Inside.circle(cx, cy, r + lineWidth / 2, x, y);
21331 },
21332 createPath: function createPath(context) {
21333 var attrs = this.__attrs;
21334 var x = attrs.x;
21335 var y = attrs.y;
21336 var r = attrs.radius || attrs.r;
21337 var symbol = attrs.symbol || 'circle';
21338 var method = void 0;
21339 if (Util.isFunction(symbol)) {
21340 method = symbol;
21341 } else {
21342 method = Marker.Symbols[symbol];
21343 }
21344 var path = method(x, y, r);
21345 path = Format.parsePath(path);
21346 context.beginPath();
21347 var preSegment = void 0;
21348 for (var i = 0; i < path.length; i++) {
21349 var item = path[i];
21350 preSegment = new PathSegment(item, preSegment, i === path.length - 1);
21351 preSegment.draw(context);
21352 }
21353 }
21354 });
21355
21356 module.exports = Marker;
21357
21358 /***/
21359 },
21360 /* 26 */
21361 /***/function (module, exports, __webpack_require__) {
21362
21363 var Util = __webpack_require__(7);
21364
21365 var TABLE = document.createElement('table');
21366 var TABLE_TR = document.createElement('tr');
21367 var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
21368 var CONTAINERS = {
21369 tr: document.createElement('tbody'),
21370 tbody: TABLE,
21371 thead: TABLE,
21372 tfoot: TABLE,
21373 td: TABLE_TR,
21374 th: TABLE_TR,
21375 '*': document.createElement('div')
21376 };
21377
21378 module.exports = {
21379 getBoundingClientRect: function getBoundingClientRect(node, defaultValue) {
21380 if (node && node.getBoundingClientRect) {
21381 var rect = node.getBoundingClientRect();
21382 var top = document.documentElement.clientTop;
21383 var left = document.documentElement.clientLeft;
21384 return {
21385 top: rect.top - top,
21386 bottom: rect.bottom - top,
21387 left: rect.left - left,
21388 right: rect.right - left
21389 };
21390 }
21391 return defaultValue || null;
21392 },
21393
21394 /**
21395 * 获取样式
21396 * @param {Object} dom DOM节点
21397 * @param {String} name 样式名
21398 * @param {Any} defaultValue 默认值
21399 * @return {String} 属性值
21400 */
21401 getStyle: function getStyle(dom, name, defaultValue) {
21402 try {
21403 if (window.getComputedStyle) {
21404 return window.getComputedStyle(dom, null)[name];
21405 }
21406 return dom.currentStyle[name];
21407 } catch (e) {
21408 if (!Util.isNil(defaultValue)) {
21409 return defaultValue;
21410 }
21411 return null;
21412 }
21413 },
21414 modifyCSS: function modifyCSS(dom, css) {
21415 if (dom) {
21416 for (var key in css) {
21417 if (css.hasOwnProperty(key)) {
21418 dom.style[key] = css[key];
21419 }
21420 }
21421 }
21422 return dom;
21423 },
21424
21425 /**
21426 * 创建DOM 节点
21427 * @param {String} str Dom 字符串
21428 * @return {HTMLElement} DOM 节点
21429 */
21430 createDom: function createDom(str) {
21431 var name = FRAGMENT_REG.test(str) && RegExp.$1;
21432 if (!(name in CONTAINERS)) {
21433 name = '*';
21434 }
21435 var container = CONTAINERS[name];
21436 str = str.replace(/(^\s*)|(\s*$)/g, '');
21437 container.innerHTML = '' + str;
21438 var dom = container.childNodes[0];
21439 container.removeChild(dom);
21440 return dom;
21441 },
21442 getRatio: function getRatio() {
21443 return window.devicePixelRatio ? window.devicePixelRatio : 2;
21444 },
21445
21446 /**
21447 * 获取宽度
21448 * @param {HTMLElement} el dom节点
21449 * @param {Number} defaultValue 默认值
21450 * @return {Number} 宽度
21451 */
21452 getWidth: function getWidth(el, defaultValue) {
21453 var width = this.getStyle(el, 'width', defaultValue);
21454 if (width === 'auto') {
21455 width = el.offsetWidth;
21456 }
21457 return parseFloat(width);
21458 },
21459
21460 /**
21461 * 获取高度
21462 * @param {HTMLElement} el dom节点
21463 * @param {Number} defaultValue 默认值
21464 * @return {Number} 高度
21465 */
21466 getHeight: function getHeight(el, defaultValue) {
21467 var height = this.getStyle(el, 'height', defaultValue);
21468 if (height === 'auto') {
21469 height = el.offsetHeight;
21470 }
21471 return parseFloat(height);
21472 },
21473
21474 /**
21475 * 获取外层高度
21476 * @param {HTMLElement} el dom节点
21477 * @param {Number} defaultValue 默认值
21478 * @return {Number} 高度
21479 */
21480 getOuterHeight: function getOuterHeight(el, defaultValue) {
21481 var height = this.getHeight(el, defaultValue);
21482 var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
21483 var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
21484 var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
21485 var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
21486 return height + bTop + bBottom + pTop + pBottom;
21487 },
21488
21489 /**
21490 * 获取外层宽度
21491 * @param {HTMLElement} el dom节点
21492 * @param {Number} defaultValue 默认值
21493 * @return {Number} 宽度
21494 */
21495 getOuterWidth: function getOuterWidth(el, defaultValue) {
21496 var width = this.getWidth(el, defaultValue);
21497 var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
21498 var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
21499 var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
21500 var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
21501 return width + bLeft + bRight + pLeft + pRight;
21502 },
21503
21504 /**
21505 * 添加事件监听器
21506 * @param {Object} target DOM对象
21507 * @param {String} eventType 事件名
21508 * @param {Funtion} callback 回调函数
21509 * @return {Object} 返回对象
21510 */
21511 addEventListener: function addEventListener(target, eventType, callback) {
21512 if (target) {
21513 if (target.addEventListener) {
21514 target.addEventListener(eventType, callback, false);
21515 return {
21516 remove: function remove() {
21517 target.removeEventListener(eventType, callback, false);
21518 }
21519 };
21520 } else if (target.attachEvent) {
21521 target.attachEvent('on' + eventType, callback);
21522 return {
21523 remove: function remove() {
21524 target.detachEvent('on' + eventType, callback);
21525 }
21526 };
21527 }
21528 }
21529 },
21530 requestAnimationFrame: function requestAnimationFrame(fn) {
21531 var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
21532 return setTimeout(fn, 16);
21533 };
21534
21535 return method(fn);
21536 }
21537 };
21538
21539 /***/
21540 },
21541 /* 27 */
21542 /***/function (module, exports, __webpack_require__) {
21543
21544 var Util = __webpack_require__(0);
21545
21546 var Event = function Event(type, event, bubbles, cancelable) {
21547 this.type = type; // 事件类型
21548 this.target = null; // 目标
21549 this.currentTarget = null; // 当前目标
21550 this.bubbles = bubbles; // 冒泡
21551 this.cancelable = cancelable; // 是否能够阻止
21552 this.timeStamp = new Date().getTime(); // 时间戳
21553 this.defaultPrevented = false; // 阻止默认
21554 this.propagationStopped = false; // 阻止冒泡
21555 this.removed = false; // 是否被移除
21556 this.event = event; // 触发的原生事件
21557 };
21558
21559 Util.augment(Event, {
21560 preventDefault: function preventDefault() {
21561 this.defaultPrevented = this.cancelable && true;
21562 },
21563 stopPropagation: function stopPropagation() {
21564 this.propagationStopped = true;
21565 },
21566 remove: function remove() {
21567 this.remove = true;
21568 },
21569 clone: function clone() {
21570 return Util.clone(this);
21571 },
21572 toString: function toString() {
21573 return '[Event (type=' + this.type + ')]';
21574 }
21575 });
21576
21577 module.exports = Event;
21578
21579 /***/
21580 },
21581 /* 28 */
21582 /***/function (module, exports, __webpack_require__) {
21583
21584 var Util = __webpack_require__(0);
21585 var Element = __webpack_require__(11);
21586 var Shape = __webpack_require__(102);
21587
21588 var SHAPE_MAP = {}; // 缓存图形类型
21589 var INDEX = '_INDEX';
21590
21591 function getComparer(compare) {
21592 return function (left, right) {
21593 var result = compare(left, right);
21594 return result === 0 ? left[INDEX] - right[INDEX] : result;
21595 };
21596 }
21597
21598 var Group = function Group(cfg) {
21599 Group.superclass.constructor.call(this, cfg);
21600 this.set('children', []);
21601
21602 this._beforeRenderUI();
21603 this._renderUI();
21604 this._bindUI();
21605 };
21606
21607 function initClassCfgs(c) {
21608 if (c.__cfg || c === Group) {
21609 return;
21610 }
21611 var superCon = c.superclass.constructor;
21612 if (superCon && !superCon.__cfg) {
21613 initClassCfgs(superCon);
21614 }
21615 c.__cfg = {};
21616
21617 Util.merge(c.__cfg, superCon.__cfg);
21618 Util.merge(c.__cfg, c.CFG);
21619 }
21620
21621 Util.extend(Group, Element);
21622
21623 Util.augment(Group, {
21624 isGroup: true,
21625 canFill: true,
21626 canStroke: true,
21627 init: function init(id) {
21628 Group.superclass.init.call(this);
21629 var shape = document.createElementNS('http://www.w3.org/2000/svg', 'g');
21630 id = id || Util.uniqueId('g_');
21631 shape.setAttribute('id', id);
21632 this.setSilent('el', shape);
21633 this.setSilent('id', id);
21634 },
21635 getDefaultCfg: function getDefaultCfg() {
21636 initClassCfgs(this.constructor);
21637 return Util.merge({}, this.constructor.__cfg);
21638 },
21639 _beforeRenderUI: function _beforeRenderUI() {},
21640 _renderUI: function _renderUI() {},
21641 _bindUI: function _bindUI() {},
21642 addShape: function addShape(type, cfg) {
21643 var canvas = this.get('canvas');
21644 cfg = cfg || {};
21645 var shapeType = SHAPE_MAP[type];
21646 if (!shapeType) {
21647 shapeType = Util.upperFirst(type);
21648 SHAPE_MAP[type] = shapeType;
21649 }
21650 if (cfg.attrs) {
21651 var attrs = cfg.attrs;
21652 if (type === 'text') {
21653 // 临时解决
21654 var topFontFamily = canvas.get('fontFamily');
21655 if (topFontFamily) {
21656 attrs.fontFamily = attrs.fontFamily || topFontFamily;
21657 }
21658 }
21659 }
21660 cfg.canvas = canvas;
21661 cfg.defs = this.get('defs');
21662 cfg.type = type;
21663 var shape = Shape[shapeType];
21664 if (!shape) {
21665 throw new TypeError('the shape ' + shapeType + ' is not supported by svg version, use canvas instead');
21666 }
21667 var rst = new shape(cfg);
21668 this.add(rst);
21669 return rst;
21670 },
21671
21672 /** 添加图组
21673 * @param {Function|Object|undefined} param 图组类
21674 * @param {Object} cfg 配置项
21675 * @return {Object} rst 图组
21676 */
21677 addGroup: function addGroup(param, cfg) {
21678 var canvas = this.get('canvas');
21679 var rst = void 0;
21680 cfg = Util.merge({}, cfg);
21681 if (Util.isFunction(param)) {
21682 if (cfg) {
21683 cfg.canvas = canvas;
21684 cfg.parent = this;
21685 rst = new param(cfg);
21686 } else {
21687 rst = new param({
21688 canvas: canvas,
21689 parent: this
21690 });
21691 }
21692 this.add(rst);
21693 } else if (Util.isObject(param)) {
21694 param.canvas = canvas;
21695 rst = new Group(param);
21696 this.add(rst);
21697 } else if (param === undefined) {
21698 rst = new Group();
21699 this.add(rst);
21700 } else {
21701 return false;
21702 }
21703 return rst;
21704 },
21705
21706 /** 绘制背景
21707 * @param {Array} padding 内边距
21708 * @param {Attrs} attrs 图形属性
21709 * @param {Shape} backShape 背景图形
21710 * @return {Object} 背景层对象
21711 */
21712 renderBack: function renderBack(padding, attrs) {
21713 var backShape = this.get('backShape');
21714 var innerBox = this.getBBox();
21715 // const parent = this.get('parent'); // getParent
21716 Util.merge(attrs, {
21717 x: innerBox.minX - padding[3],
21718 y: innerBox.minY - padding[0],
21719 width: innerBox.width + padding[1] + padding[3],
21720 height: innerBox.height + padding[0] + padding[2]
21721 });
21722 if (backShape) {
21723 backShape.attr(attrs);
21724 } else {
21725 backShape = this.addShape('rect', {
21726 zIndex: -1,
21727 attrs: attrs
21728 });
21729 }
21730 this.set('backShape', backShape);
21731 this.sort();
21732 return backShape;
21733 },
21734 removeChild: function removeChild(item, destroy) {
21735 if (arguments.length >= 2) {
21736 if (this.contain(item)) {
21737 item.remove(destroy);
21738 }
21739 } else {
21740 if (arguments.length === 1) {
21741 if (Util.isBoolean(item)) {
21742 destroy = item;
21743 } else {
21744 if (this.contain(item)) {
21745 item.remove(true);
21746 }
21747 return this;
21748 }
21749 }
21750 if (arguments.length === 0) {
21751 destroy = true;
21752 }
21753
21754 Group.superclass.remove.call(this, destroy);
21755 }
21756 return this;
21757 },
21758
21759 /**
21760 * 向组中添加shape或者group
21761 * @param {Object} items 图形或者分组
21762 * @return {Object} group 本尊
21763 */
21764 add: function add(items) {
21765 var self = this;
21766 var children = self.get('children');
21767 var el = self.get('el');
21768 if (Util.isArray(items)) {
21769 Util.each(items, function (item) {
21770 var parent = item.get('parent');
21771 if (parent) {
21772 parent.removeChild(item, false);
21773 }
21774 if (item.get('dependencies')) {
21775 self._addDependency(item);
21776 }
21777 self._setEvn(item);
21778 el.appendChild(item.get('el'));
21779 });
21780 children.push.apply(children, items);
21781 } else {
21782 var item = items;
21783 var parent = item.get('parent');
21784 if (parent) {
21785 parent.removeChild(item, false);
21786 }
21787 self._setEvn(item);
21788 if (item.get('dependencies')) {
21789 self._addDependency(item);
21790 }
21791 el.appendChild(item.get('el'));
21792 children.push(item);
21793 }
21794 return self;
21795 },
21796 contain: function contain(item) {
21797 var children = this.get('children');
21798 return children.indexOf(item) > -1;
21799 },
21800 getChildByIndex: function getChildByIndex(index) {
21801 var children = this.get('children');
21802 return children[index];
21803 },
21804 getFirst: function getFirst() {
21805 return this.getChildByIndex(0);
21806 },
21807 getLast: function getLast() {
21808 var lastIndex = this.get('children').length - 1;
21809 return this.getChildByIndex(lastIndex);
21810 },
21811 _addDependency: function _addDependency(item) {
21812 var dependencies = item.get('dependencies');
21813 item.attr(dependencies);
21814 item.__cfg.dependencies = {};
21815 },
21816 _setEvn: function _setEvn(item) {
21817 var self = this;
21818 item.__cfg.parent = self;
21819 item.__cfg.parent = self;
21820 item.__cfg.canvas = self.__cfg.canvas;
21821 item.__cfg.defs = self.__cfg.defs;
21822 var clip = item.__attrs.clip;
21823 if (clip) {
21824 clip.setSilent('parent', self);
21825 clip.setSilent('context', self.get('context'));
21826 }
21827 var children = item.__cfg.children;
21828 if (children) {
21829 Util.each(children, function (child) {
21830 item._setEvn(child);
21831 });
21832 }
21833 },
21834 getCount: function getCount() {
21835 return this.get('children').length;
21836 },
21837 sort: function sort() {
21838 var children = this.get('children');
21839 // 稳定排序
21840 Util.each(children, function (child, index) {
21841 child[INDEX] = index;
21842 return child;
21843 });
21844
21845 children.sort(getComparer(function (obj1, obj2) {
21846 return obj1.get('zIndex') - obj2.get('zIndex');
21847 }));
21848
21849 return this;
21850 },
21851 findById: function findById(id) {
21852 return this.find(function (item) {
21853 return item.get('id') === id;
21854 });
21855 },
21856
21857 /**
21858 * 根据查找函数查找分组或者图形
21859 * @param {Function} fn 匹配函数
21860 * @return {Canvas.Base} 分组或者图形
21861 */
21862 find: function find(fn) {
21863 if (Util.isString(fn)) {
21864 return this.findById(fn);
21865 }
21866 var children = this.get('children');
21867 var rst = null;
21868
21869 Util.each(children, function (item) {
21870 if (fn(item)) {
21871 rst = item;
21872 } else if (item.find) {
21873 rst = item.find(fn);
21874 }
21875 if (rst) {
21876 return false;
21877 }
21878 });
21879 return rst;
21880 },
21881
21882 /**
21883 * @param {Function} fn filter mathod
21884 * @return {Array} all the matching shapes and groups
21885 */
21886 findAll: function findAll(fn) {
21887 var children = this.get('children');
21888 var rst = [];
21889 var childRst = [];
21890 Util.each(children, function (item) {
21891 if (fn(item)) {
21892 rst.push(item);
21893 }
21894 if (item.findAllBy) {
21895 childRst = item.findAllBy(fn);
21896 rst = rst.concat(childRst);
21897 }
21898 });
21899 return rst;
21900 },
21901
21902 /**
21903 * @Deprecated
21904 * @param {Function} fn filter method
21905 * @return {Object} found shape or group
21906 */
21907 findBy: function findBy(fn) {
21908 var children = this.get('children');
21909 var rst = null;
21910
21911 Util.each(children, function (item) {
21912 if (fn(item)) {
21913 rst = item;
21914 } else if (item.findBy) {
21915 rst = item.findBy(fn);
21916 }
21917 if (rst) {
21918 return false;
21919 }
21920 });
21921 return rst;
21922 },
21923
21924 /**
21925 * @Deprecated
21926 * @param {Function} fn filter mathod
21927 * @return {Array} all the matching shapes and groups
21928 */
21929 findAllBy: function findAllBy(fn) {
21930 var children = this.get('children');
21931 var rst = [];
21932 var childRst = [];
21933 Util.each(children, function (item) {
21934 if (fn(item)) {
21935 rst.push(item);
21936 }
21937 if (item.findAllBy) {
21938 childRst = item.findAllBy(fn);
21939 rst = rst.concat(childRst);
21940 }
21941 });
21942 return rst;
21943 },
21944
21945 // svg不进行拾取,仅保留接口
21946 getShape: function getShape() {
21947 return null;
21948 },
21949
21950 /**
21951 * 根据点击事件的element获取对应的图形对象
21952 * @param {Object} el 点击的dom元素
21953 * @return {Object} 对应图形对象
21954 */
21955 findShape: function findShape(el) {
21956 if (this.__cfg.visible && this.__cfg.capture && this.get('el') === el) {
21957 return this;
21958 }
21959 var children = this.__cfg.children;
21960 var shape = null;
21961 for (var i = children.length - 1; i >= 0; i--) {
21962 var child = children[i];
21963 if (child.isGroup) {
21964 shape = child.findShape(el);
21965 shape = child.findShape(el);
21966 } else if (child.get('visible') && child.get('el') === el) {
21967 shape = child;
21968 }
21969 if (shape) {
21970 break;
21971 }
21972 }
21973 return shape;
21974 },
21975 clearTotalMatrix: function clearTotalMatrix() {
21976 var m = this.get('totalMatrix');
21977 if (m) {
21978 this.setSilent('totalMatrix', null);
21979 var children = this.__cfg.children;
21980 for (var i = 0; i < children.length; i++) {
21981 var child = children[i];
21982 child.clearTotalMatrix();
21983 }
21984 }
21985 },
21986 clear: function clear() {
21987 var children = this.get('children');
21988
21989 while (children.length !== 0) {
21990 children[children.length - 1].remove();
21991 }
21992 return this;
21993 },
21994 destroy: function destroy() {
21995 if (this.get('destroyed')) {
21996 return;
21997 }
21998 this.clear();
21999 Group.superclass.destroy.call(this);
22000 }
22001 });
22002
22003 module.exports = Group;
22004
22005 /***/
22006 },
22007 /* 29 */
22008 /***/function (module, exports, __webpack_require__) {
22009
22010 var MatrixUtil = __webpack_require__(2);
22011 var PathUtil = __webpack_require__(13);
22012 var Util = __webpack_require__(0);
22013 var d3Ease = __webpack_require__(75);
22014 var d3Timer = __webpack_require__(86);
22015
22016 var _require = __webpack_require__(89),
22017 interpolate = _require.interpolate,
22018 interpolateArray = _require.interpolateArray; // 目前整体动画只需要数值和数组的差值计算
22019
22020
22021 var ReservedProps = {
22022 delay: 'delay'
22023 };
22024 module.exports = {
22025 stopAnimate: function stopAnimate() {
22026 var self = this;
22027 var canvas = self.get('canvas');
22028 if (self.get('destroyed')) {
22029 return;
22030 }
22031 if (self.get('animating')) {
22032 var clip = self.attr('clip');
22033 // 如果 clip 在执行动画
22034 if (clip && clip.get('animating')) {
22035 clip.stopAnimate();
22036 }
22037 var timer = self.get('animateTimer');
22038 if (timer) {
22039 timer.stop();
22040 self.setSilent('animateTimer', null);
22041 }
22042 var animateCfg = self.get('animateCfg');
22043 if (animateCfg) {
22044 self.attr(animateCfg.toAttrs);
22045 if (animateCfg.toM) {
22046 self.setMatrix(animateCfg.toM);
22047 }
22048 if (animateCfg.callback) {
22049 animateCfg.callback();
22050 }
22051 self.setSilent('animateCfg', null);
22052 }
22053 self.setSilent('animating', false); // 动画停止
22054 canvas.draw();
22055 }
22056 },
22057
22058 /**
22059 * 执行动画
22060 * @param {Object} toProps 动画最终状态
22061 * @param {Number} duration 动画执行时间
22062 * @param {String} easing 动画缓动效果
22063 * @param {Function} callback 动画执行后的回调
22064 * @param {Number} delay 动画延迟时间
22065 */
22066 animate: function animate(toProps, duration, easing, callback) {
22067 var delay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
22068
22069 var self = this;
22070 var canvas = self.get('canvas');
22071 var formatProps = getFormatProps(toProps);
22072 var toAttrs = formatProps.attrs;
22073 var toM = formatProps.M;
22074 var fromAttrs = getfromAttrs(toAttrs);
22075 var fromM = Util.clone(self.getMatrix());
22076 var repeat = toProps.repeat;
22077 var timer = self.get('animateTimer');
22078 timer && timer.stop();
22079 // 可能不设置 easing
22080 if (Util.isNumber(callback)) {
22081 delay = callback;
22082 callback = null;
22083 }
22084 if (Util.isFunction(easing)) {
22085 callback = easing;
22086 easing = 'easeLinear';
22087 } else {
22088 easing = easing ? easing : 'easeLinear';
22089 }
22090
22091 self.setSilent('animating', true); // 处于动画状态
22092 self.setSilent('animateCfg', {
22093 toAttrs: toAttrs,
22094 toM: toM,
22095 callback: callback
22096 });
22097
22098 // 执行动画
22099 timer = d3Timer.timer(function (elapsed) {
22100 if (repeat) {
22101 excuteRepeat(elapsed);
22102 } else {
22103 excuteOnce(elapsed);
22104 }
22105 }, delay);
22106
22107 self.setSilent('animateTimer', timer);
22108
22109 function excuteRepeat(elapsed) {
22110 var ratio = elapsed % duration / duration;
22111 ratio = d3Ease[easing](ratio);
22112 update(ratio);
22113 }
22114
22115 function excuteOnce(elapsed) {
22116 var ratio = elapsed / duration;
22117 if (ratio < 1) {
22118 ratio = d3Ease[easing](ratio);
22119 update(ratio);
22120 } else {
22121 update(1); // 保证最后一帧的绘制
22122 callback && callback();
22123 self.setSilent('animating', false); // 动画停止
22124 self.setSilent('animateCfg', null);
22125 self.setSilent('animateTimer', null);
22126 timer.stop();
22127 }
22128 }
22129
22130 function update(ratio) {
22131 var cProps = {}; // 此刻属性
22132 if (self.get('destroyed')) {
22133 return;
22134 }
22135 var interf = void 0; // 差值函数
22136
22137 for (var k in toAttrs) {
22138 if (!Util.isEqual(fromAttrs[k], toAttrs[k])) {
22139 if (k === 'path') {
22140 var toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态
22141 var fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态
22142 cProps[k] = [];
22143 for (var i = 0; i < toPath.length; i++) {
22144 var toPathPoint = toPath[i];
22145 var fromPathPoint = fromPath[i];
22146 var cPathPoint = [];
22147 for (var j = 0; j < toPathPoint.length; j++) {
22148 if (Util.isNumber(toPathPoint[j]) && fromPathPoint) {
22149 interf = interpolate(fromPathPoint[j], toPathPoint[j]);
22150 cPathPoint.push(interf(ratio));
22151 } else {
22152 cPathPoint.push(toPathPoint[j]);
22153 }
22154 }
22155 cProps[k].push(cPathPoint);
22156 }
22157 } else {
22158 interf = interpolate(fromAttrs[k], toAttrs[k]);
22159 cProps[k] = interf(ratio);
22160 }
22161 }
22162 }
22163 if (toM) {
22164 var mf = interpolateArray(fromM, toM);
22165 var cM = mf(ratio);
22166 self.setMatrix(cM);
22167 }
22168 self.attr(cProps);
22169 canvas.draw();
22170 }
22171
22172 function getFormatProps(props) {
22173 var rst = {
22174 M: null,
22175 attrs: {}
22176 };
22177 for (var k in props) {
22178 if (k === 'transform') {
22179 rst.M = MatrixUtil.transform(self.getMatrix(), props[k]);
22180 } else if (k === 'matrix') {
22181 rst.M = props[k];
22182 } else if (!ReservedProps[k]) {
22183 rst.attrs[k] = props[k];
22184 }
22185 }
22186 return rst;
22187 }
22188
22189 function getfromAttrs(toAttrs) {
22190 var rst = {};
22191 for (var k in toAttrs) {
22192 rst[k] = self.attr(k);
22193 }
22194 return rst;
22195 }
22196 }
22197 };
22198
22199 /***/
22200 },
22201 /* 30 */
22202 /***/function (module, __webpack_exports__, __webpack_require__) {
22203
22204 "use strict";
22205 /* harmony export (binding) */
22206 __webpack_require__.d(__webpack_exports__, "a", function () {
22207 return deg2rad;
22208 });
22209 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () {
22210 return rad2deg;
22211 });
22212 var deg2rad = Math.PI / 180;
22213 var rad2deg = 180 / Math.PI;
22214
22215 /***/
22216 },
22217 /* 31 */
22218 /***/function (module, __webpack_exports__, __webpack_require__) {
22219
22220 "use strict";
22221 /* harmony export (binding) */
22222 __webpack_require__.d(__webpack_exports__, "b", function () {
22223 return rgbBasis;
22224 });
22225 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
22226 return rgbBasisClosed;
22227 });
22228 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
22229 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(18);
22230 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(32);
22231 /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(8);
22232
22233 /* harmony default export */__webpack_exports__["a"] = function rgbGamma(y) {
22234 var color = Object(__WEBPACK_IMPORTED_MODULE_3__color__["b" /* gamma */])(y);
22235
22236 function rgb(start, end) {
22237 var r = color((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(start)).r, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(end)).r),
22238 g = color(start.g, end.g),
22239 b = color(start.b, end.b),
22240 opacity = Object(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity);
22241 return function (t) {
22242 start.r = r(t);
22243 start.g = g(t);
22244 start.b = b(t);
22245 start.opacity = opacity(t);
22246 return start + "";
22247 };
22248 }
22249
22250 rgb.gamma = rgbGamma;
22251
22252 return rgb;
22253 }(1);
22254
22255 function rgbSpline(spline) {
22256 return function (colors) {
22257 var n = colors.length,
22258 r = new Array(n),
22259 g = new Array(n),
22260 b = new Array(n),
22261 i,
22262 color;
22263 for (i = 0; i < n; ++i) {
22264 color = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(colors[i]);
22265 r[i] = color.r || 0;
22266 g[i] = color.g || 0;
22267 b[i] = color.b || 0;
22268 }
22269 r = spline(r);
22270 g = spline(g);
22271 b = spline(b);
22272 color.opacity = 1;
22273 return function (t) {
22274 color.r = r(t);
22275 color.g = g(t);
22276 color.b = b(t);
22277 return color + "";
22278 };
22279 };
22280 }
22281
22282 var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["b" /* default */]);
22283 var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]);
22284
22285 /***/
22286 },
22287 /* 32 */
22288 /***/function (module, __webpack_exports__, __webpack_require__) {
22289
22290 "use strict";
22291 /* harmony import */
22292 var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(18);
22293
22294 /* harmony default export */__webpack_exports__["a"] = function (values) {
22295 var n = values.length;
22296 return function (t) {
22297 var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
22298 v0 = values[(i + n - 1) % n],
22299 v1 = values[i % n],
22300 v2 = values[(i + 1) % n],
22301 v3 = values[(i + 2) % n];
22302 return Object(__WEBPACK_IMPORTED_MODULE_0__basis__["a" /* basis */])((t - i / n) * n, v0, v1, v2, v3);
22303 };
22304 };
22305
22306 /***/
22307 },
22308 /* 33 */
22309 /***/function (module, __webpack_exports__, __webpack_require__) {
22310
22311 "use strict";
22312 /* harmony default export */
22313 __webpack_exports__["a"] = function (x) {
22314 return function () {
22315 return x;
22316 };
22317 };
22318
22319 /***/
22320 },
22321 /* 34 */
22322 /***/function (module, __webpack_exports__, __webpack_require__) {
22323
22324 "use strict";
22325 /* harmony import */
22326 var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(15);
22327
22328 /* harmony default export */__webpack_exports__["a"] = function (a, b) {
22329 var nb = b ? b.length : 0,
22330 na = a ? Math.min(nb, a.length) : 0,
22331 x = new Array(na),
22332 c = new Array(nb),
22333 i;
22334
22335 for (i = 0; i < na; ++i) {
22336 x[i] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[i], b[i]);
22337 }for (; i < nb; ++i) {
22338 c[i] = b[i];
22339 }return function (t) {
22340 for (i = 0; i < na; ++i) {
22341 c[i] = x[i](t);
22342 }return c;
22343 };
22344 };
22345
22346 /***/
22347 },
22348 /* 35 */
22349 /***/function (module, __webpack_exports__, __webpack_require__) {
22350
22351 "use strict";
22352 /* harmony default export */
22353 __webpack_exports__["a"] = function (a, b) {
22354 var d = new Date();
22355 return a = +a, b -= a, function (t) {
22356 return d.setTime(a + b * t), d;
22357 };
22358 };
22359
22360 /***/
22361 },
22362 /* 36 */
22363 /***/function (module, __webpack_exports__, __webpack_require__) {
22364
22365 "use strict";
22366 /* harmony import */
22367 var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(15);
22368 var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
22369 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
22370 } : function (obj) {
22371 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
22372 };
22373
22374 /* harmony default export */__webpack_exports__["a"] = function (a, b) {
22375 var i = {},
22376 c = {},
22377 k;
22378
22379 if (a === null || (typeof a === "undefined" ? "undefined" : _typeof(a)) !== "object") a = {};
22380 if (b === null || (typeof b === "undefined" ? "undefined" : _typeof(b)) !== "object") b = {};
22381
22382 for (k in b) {
22383 if (k in a) {
22384 i[k] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]);
22385 } else {
22386 c[k] = b[k];
22387 }
22388 }
22389
22390 return function (t) {
22391 for (k in i) {
22392 c[k] = i[k](t);
22393 }return c;
22394 };
22395 };
22396
22397 /***/
22398 },
22399 /* 37 */
22400 /***/function (module, __webpack_exports__, __webpack_require__) {
22401
22402 "use strict";
22403 /* harmony import */
22404 var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(9);
22405
22406 var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
22407 reB = new RegExp(reA.source, "g");
22408
22409 function zero(b) {
22410 return function () {
22411 return b;
22412 };
22413 }
22414
22415 function one(b) {
22416 return function (t) {
22417 return b(t) + "";
22418 };
22419 }
22420
22421 /* harmony default export */__webpack_exports__["a"] = function (a, b) {
22422 var bi = reA.lastIndex = reB.lastIndex = 0,
22423
22424 // scan index for next number in b
22425 am,
22426
22427 // current match in a
22428 bm,
22429
22430 // current match in b
22431 bs,
22432
22433 // string preceding current number in b, if any
22434 i = -1,
22435
22436 // index in s
22437 s = [],
22438
22439 // string constants and placeholders
22440 q = []; // number interpolators
22441
22442 // Coerce inputs to strings.
22443 a = a + "", b = b + "";
22444
22445 // Interpolate pairs of numbers in a & b.
22446 while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
22447 if ((bs = bm.index) > bi) {
22448 // a string precedes the next number in b
22449 bs = b.slice(bi, bs);
22450 if (s[i]) s[i] += bs; // coalesce with previous string
22451 else s[++i] = bs;
22452 }
22453 if ((am = am[0]) === (bm = bm[0])) {
22454 // numbers in a & b match
22455 if (s[i]) s[i] += bm; // coalesce with previous string
22456 else s[++i] = bm;
22457 } else {
22458 // interpolate non-matching numbers
22459 s[++i] = null;
22460 q.push({ i: i, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm) });
22461 }
22462 bi = reB.lastIndex;
22463 }
22464
22465 // Add remains of b.
22466 if (bi < b.length) {
22467 bs = b.slice(bi);
22468 if (s[i]) s[i] += bs; // coalesce with previous string
22469 else s[++i] = bs;
22470 }
22471
22472 // Special optimization for only a single match.
22473 // Otherwise, interpolate each of the numbers and rejoin the string.
22474 return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) {
22475 for (var i = 0, o; i < b; ++i) {
22476 s[(o = q[i]).i] = o.x(t);
22477 }return s.join("");
22478 });
22479 };
22480
22481 /***/
22482 },
22483 /* 38 */
22484 /***/function (module, exports, __webpack_require__) {
22485
22486 var __WEBPACK_AMD_DEFINE_RESULT__;var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
22487 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
22488 } : function (obj) {
22489 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
22490 };
22491
22492 /*!
22493 * EventEmitter v5.1.0 - git.io/ee
22494 * Unlicense - http://unlicense.org/
22495 * Oliver Caldwell - http://oli.me.uk/
22496 * @preserve
22497 */
22498
22499 ;(function (exports) {
22500 'use strict';
22501
22502 /**
22503 * Class for managing events.
22504 * Can be extended to provide event functionality in other classes.
22505 *
22506 * @class EventEmitter Manages event registering and emitting.
22507 */
22508
22509 function EventEmitter() {}
22510
22511 // Shortcuts to improve speed and size
22512 var proto = EventEmitter.prototype;
22513 var originalGlobalValue = exports.EventEmitter;
22514
22515 /**
22516 * Finds the index of the listener for the event in its storage array.
22517 *
22518 * @param {Function[]} listeners Array of listeners to search through.
22519 * @param {Function} listener Method to look for.
22520 * @return {Number} Index of the specified listener, -1 if not found
22521 * @api private
22522 */
22523 function indexOfListener(listeners, listener) {
22524 var i = listeners.length;
22525 while (i--) {
22526 if (listeners[i].listener === listener) {
22527 return i;
22528 }
22529 }
22530
22531 return -1;
22532 }
22533
22534 /**
22535 * Alias a method while keeping the context correct, to allow for overwriting of target method.
22536 *
22537 * @param {String} name The name of the target method.
22538 * @return {Function} The aliased method
22539 * @api private
22540 */
22541 function alias(name) {
22542 return function aliasClosure() {
22543 return this[name].apply(this, arguments);
22544 };
22545 }
22546
22547 /**
22548 * Returns the listener array for the specified event.
22549 * Will initialise the event object and listener arrays if required.
22550 * Will return an object if you use a regex search. The object contains keys for each matched event. So /ba[rz]/ might return an object containing bar and baz. But only if you have either defined them with defineEvent or added some listeners to them.
22551 * Each property in the object response is an array of listener functions.
22552 *
22553 * @param {String|RegExp} evt Name of the event to return the listeners from.
22554 * @return {Function[]|Object} All listener functions for the event.
22555 */
22556 proto.getListeners = function getListeners(evt) {
22557 var events = this._getEvents();
22558 var response;
22559 var key;
22560
22561 // Return a concatenated array of all matching events if
22562 // the selector is a regular expression.
22563 if (evt instanceof RegExp) {
22564 response = {};
22565 for (key in events) {
22566 if (events.hasOwnProperty(key) && evt.test(key)) {
22567 response[key] = events[key];
22568 }
22569 }
22570 } else {
22571 response = events[evt] || (events[evt] = []);
22572 }
22573
22574 return response;
22575 };
22576
22577 /**
22578 * Takes a list of listener objects and flattens it into a list of listener functions.
22579 *
22580 * @param {Object[]} listeners Raw listener objects.
22581 * @return {Function[]} Just the listener functions.
22582 */
22583 proto.flattenListeners = function flattenListeners(listeners) {
22584 var flatListeners = [];
22585 var i;
22586
22587 for (i = 0; i < listeners.length; i += 1) {
22588 flatListeners.push(listeners[i].listener);
22589 }
22590
22591 return flatListeners;
22592 };
22593
22594 /**
22595 * Fetches the requested listeners via getListeners but will always return the results inside an object. This is mainly for internal use but others may find it useful.
22596 *
22597 * @param {String|RegExp} evt Name of the event to return the listeners from.
22598 * @return {Object} All listener functions for an event in an object.
22599 */
22600 proto.getListenersAsObject = function getListenersAsObject(evt) {
22601 var listeners = this.getListeners(evt);
22602 var response;
22603
22604 if (listeners instanceof Array) {
22605 response = {};
22606 response[evt] = listeners;
22607 }
22608
22609 return response || listeners;
22610 };
22611
22612 function isValidListener(listener) {
22613 if (typeof listener === 'function' || listener instanceof RegExp) {
22614 return true;
22615 } else if (listener && (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object') {
22616 return isValidListener(listener.listener);
22617 } else {
22618 return false;
22619 }
22620 }
22621
22622 /**
22623 * Adds a listener function to the specified event.
22624 * The listener will not be added if it is a duplicate.
22625 * If the listener returns true then it will be removed after it is called.
22626 * If you pass a regular expression as the event name then the listener will be added to all events that match it.
22627 *
22628 * @param {String|RegExp} evt Name of the event to attach the listener to.
22629 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
22630 * @return {Object} Current instance of EventEmitter for chaining.
22631 */
22632 proto.addListener = function addListener(evt, listener) {
22633 if (!isValidListener(listener)) {
22634 throw new TypeError('listener must be a function');
22635 }
22636
22637 var listeners = this.getListenersAsObject(evt);
22638 var listenerIsWrapped = (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object';
22639 var key;
22640
22641 for (key in listeners) {
22642 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
22643 listeners[key].push(listenerIsWrapped ? listener : {
22644 listener: listener,
22645 once: false
22646 });
22647 }
22648 }
22649
22650 return this;
22651 };
22652
22653 /**
22654 * Alias of addListener
22655 */
22656 proto.on = alias('addListener');
22657
22658 /**
22659 * Semi-alias of addListener. It will add a listener that will be
22660 * automatically removed after its first execution.
22661 *
22662 * @param {String|RegExp} evt Name of the event to attach the listener to.
22663 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
22664 * @return {Object} Current instance of EventEmitter for chaining.
22665 */
22666 proto.addOnceListener = function addOnceListener(evt, listener) {
22667 return this.addListener(evt, {
22668 listener: listener,
22669 once: true
22670 });
22671 };
22672
22673 /**
22674 * Alias of addOnceListener.
22675 */
22676 proto.once = alias('addOnceListener');
22677
22678 /**
22679 * Defines an event name. This is required if you want to use a regex to add a listener to multiple events at once. If you don't do this then how do you expect it to know what event to add to? Should it just add to every possible match for a regex? No. That is scary and bad.
22680 * You need to tell it what event names should be matched by a regex.
22681 *
22682 * @param {String} evt Name of the event to create.
22683 * @return {Object} Current instance of EventEmitter for chaining.
22684 */
22685 proto.defineEvent = function defineEvent(evt) {
22686 this.getListeners(evt);
22687 return this;
22688 };
22689
22690 /**
22691 * Uses defineEvent to define multiple events.
22692 *
22693 * @param {String[]} evts An array of event names to define.
22694 * @return {Object} Current instance of EventEmitter for chaining.
22695 */
22696 proto.defineEvents = function defineEvents(evts) {
22697 for (var i = 0; i < evts.length; i += 1) {
22698 this.defineEvent(evts[i]);
22699 }
22700 return this;
22701 };
22702
22703 /**
22704 * Removes a listener function from the specified event.
22705 * When passed a regular expression as the event name, it will remove the listener from all events that match it.
22706 *
22707 * @param {String|RegExp} evt Name of the event to remove the listener from.
22708 * @param {Function} listener Method to remove from the event.
22709 * @return {Object} Current instance of EventEmitter for chaining.
22710 */
22711 proto.removeListener = function removeListener(evt, listener) {
22712 var listeners = this.getListenersAsObject(evt);
22713 var index;
22714 var key;
22715
22716 for (key in listeners) {
22717 if (listeners.hasOwnProperty(key)) {
22718 index = indexOfListener(listeners[key], listener);
22719
22720 if (index !== -1) {
22721 listeners[key].splice(index, 1);
22722 }
22723 }
22724 }
22725
22726 return this;
22727 };
22728
22729 /**
22730 * Alias of removeListener
22731 */
22732 proto.off = alias('removeListener');
22733
22734 /**
22735 * Adds listeners in bulk using the manipulateListeners method.
22736 * If you pass an object as the second argument you can add to multiple events at once. The object should contain key value pairs of events and listeners or listener arrays. You can also pass it an event name and an array of listeners to be added.
22737 * You can also pass it a regular expression to add the array of listeners to all events that match it.
22738 * Yeah, this function does quite a bit. That's probably a bad thing.
22739 *
22740 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add to multiple events at once.
22741 * @param {Function[]} [listeners] An optional array of listener functions to add.
22742 * @return {Object} Current instance of EventEmitter for chaining.
22743 */
22744 proto.addListeners = function addListeners(evt, listeners) {
22745 // Pass through to manipulateListeners
22746 return this.manipulateListeners(false, evt, listeners);
22747 };
22748
22749 /**
22750 * Removes listeners in bulk using the manipulateListeners method.
22751 * If you pass an object as the second argument you can remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
22752 * You can also pass it an event name and an array of listeners to be removed.
22753 * You can also pass it a regular expression to remove the listeners from all events that match it.
22754 *
22755 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to remove from multiple events at once.
22756 * @param {Function[]} [listeners] An optional array of listener functions to remove.
22757 * @return {Object} Current instance of EventEmitter for chaining.
22758 */
22759 proto.removeListeners = function removeListeners(evt, listeners) {
22760 // Pass through to manipulateListeners
22761 return this.manipulateListeners(true, evt, listeners);
22762 };
22763
22764 /**
22765 * Edits listeners in bulk. The addListeners and removeListeners methods both use this to do their job. You should really use those instead, this is a little lower level.
22766 * The first argument will determine if the listeners are removed (true) or added (false).
22767 * If you pass an object as the second argument you can add/remove from multiple events at once. The object should contain key value pairs of events and listeners or listener arrays.
22768 * You can also pass it an event name and an array of listeners to be added/removed.
22769 * You can also pass it a regular expression to manipulate the listeners of all events that match it.
22770 *
22771 * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
22772 * @param {String|Object|RegExp} evt An event name if you will pass an array of listeners next. An object if you wish to add/remove from multiple events at once.
22773 * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
22774 * @return {Object} Current instance of EventEmitter for chaining.
22775 */
22776 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
22777 var i;
22778 var value;
22779 var single = remove ? this.removeListener : this.addListener;
22780 var multiple = remove ? this.removeListeners : this.addListeners;
22781
22782 // If evt is an object then pass each of its properties to this method
22783 if ((typeof evt === 'undefined' ? 'undefined' : _typeof(evt)) === 'object' && !(evt instanceof RegExp)) {
22784 for (i in evt) {
22785 if (evt.hasOwnProperty(i) && (value = evt[i])) {
22786 // Pass the single listener straight through to the singular method
22787 if (typeof value === 'function') {
22788 single.call(this, i, value);
22789 } else {
22790 // Otherwise pass back to the multiple function
22791 multiple.call(this, i, value);
22792 }
22793 }
22794 }
22795 } else {
22796 // So evt must be a string
22797 // And listeners must be an array of listeners
22798 // Loop over it and pass each one to the multiple method
22799 i = listeners.length;
22800 while (i--) {
22801 single.call(this, evt, listeners[i]);
22802 }
22803 }
22804
22805 return this;
22806 };
22807
22808 /**
22809 * Removes all listeners from a specified event.
22810 * If you do not specify an event then all listeners will be removed.
22811 * That means every event will be emptied.
22812 * You can also pass a regex to remove all events that match it.
22813 *
22814 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
22815 * @return {Object} Current instance of EventEmitter for chaining.
22816 */
22817 proto.removeEvent = function removeEvent(evt) {
22818 var type = typeof evt === 'undefined' ? 'undefined' : _typeof(evt);
22819 var events = this._getEvents();
22820 var key;
22821
22822 // Remove different things depending on the state of evt
22823 if (type === 'string') {
22824 // Remove all listeners for the specified event
22825 delete events[evt];
22826 } else if (evt instanceof RegExp) {
22827 // Remove all events matching the regex.
22828 for (key in events) {
22829 if (events.hasOwnProperty(key) && evt.test(key)) {
22830 delete events[key];
22831 }
22832 }
22833 } else {
22834 // Remove all listeners in all events
22835 delete this._events;
22836 }
22837
22838 return this;
22839 };
22840
22841 /**
22842 * Alias of removeEvent.
22843 *
22844 * Added to mirror the node API.
22845 */
22846 proto.removeAllListeners = alias('removeEvent');
22847
22848 /**
22849 * Emits an event of your choice.
22850 * When emitted, every listener attached to that event will be executed.
22851 * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
22852 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
22853 * So they will not arrive within the array on the other side, they will be separate.
22854 * You can also pass a regular expression to emit to all events that match it.
22855 *
22856 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
22857 * @param {Array} [args] Optional array of arguments to be passed to each listener.
22858 * @return {Object} Current instance of EventEmitter for chaining.
22859 */
22860 proto.emitEvent = function emitEvent(evt, args) {
22861 var listenersMap = this.getListenersAsObject(evt);
22862 var listeners;
22863 var listener;
22864 var i;
22865 var key;
22866 var response;
22867
22868 for (key in listenersMap) {
22869 if (listenersMap.hasOwnProperty(key)) {
22870 listeners = listenersMap[key].slice(0);
22871
22872 for (i = 0; i < listeners.length; i++) {
22873 // If the listener returns true then it shall be removed from the event
22874 // The function is executed either with a basic call or an apply if there is an args array
22875 listener = listeners[i];
22876
22877 if (listener.once === true) {
22878 this.removeListener(evt, listener.listener);
22879 }
22880
22881 response = listener.listener.apply(this, args || []);
22882
22883 if (response === this._getOnceReturnValue()) {
22884 this.removeListener(evt, listener.listener);
22885 }
22886 }
22887 }
22888 }
22889
22890 return this;
22891 };
22892
22893 /**
22894 * Alias of emitEvent
22895 */
22896 proto.trigger = alias('emitEvent');
22897
22898 /**
22899 * Subtly different from emitEvent in that it will pass its arguments on to the listeners, as opposed to taking a single array of arguments to pass on.
22900 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
22901 *
22902 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
22903 * @param {...*} Optional additional arguments to be passed to each listener.
22904 * @return {Object} Current instance of EventEmitter for chaining.
22905 */
22906 proto.emit = function emit(evt) {
22907 var args = Array.prototype.slice.call(arguments, 1);
22908 return this.emitEvent(evt, args);
22909 };
22910
22911 /**
22912 * Sets the current value to check against when executing listeners. If a
22913 * listeners return value matches the one set here then it will be removed
22914 * after execution. This value defaults to true.
22915 *
22916 * @param {*} value The new value to check for when executing listeners.
22917 * @return {Object} Current instance of EventEmitter for chaining.
22918 */
22919 proto.setOnceReturnValue = function setOnceReturnValue(value) {
22920 this._onceReturnValue = value;
22921 return this;
22922 };
22923
22924 /**
22925 * Fetches the current value to check against when executing listeners. If
22926 * the listeners return value matches this one then it should be removed
22927 * automatically. It will return true by default.
22928 *
22929 * @return {*|Boolean} The current value to check for or the default, true.
22930 * @api private
22931 */
22932 proto._getOnceReturnValue = function _getOnceReturnValue() {
22933 if (this.hasOwnProperty('_onceReturnValue')) {
22934 return this._onceReturnValue;
22935 } else {
22936 return true;
22937 }
22938 };
22939
22940 /**
22941 * Fetches the events object and creates one if required.
22942 *
22943 * @return {Object} The events storage object.
22944 * @api private
22945 */
22946 proto._getEvents = function _getEvents() {
22947 return this._events || (this._events = {});
22948 };
22949
22950 /**
22951 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
22952 *
22953 * @return {Function} Non conflicting EventEmitter class.
22954 */
22955 EventEmitter.noConflict = function noConflict() {
22956 exports.EventEmitter = originalGlobalValue;
22957 return EventEmitter;
22958 };
22959
22960 // Expose the class either via AMD, CommonJS or the global object
22961 if (true) {
22962 !(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
22963 return EventEmitter;
22964 }.call(exports, __webpack_require__, exports, module), __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
22965 } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports) {
22966 module.exports = EventEmitter;
22967 } else {
22968 exports.EventEmitter = EventEmitter;
22969 }
22970 })(this || {});
22971
22972 /***/
22973 },
22974 /* 39 */
22975 /***/function (module, exports, __webpack_require__) {
22976
22977 var Util = __webpack_require__(0);
22978 var Shape = __webpack_require__(4);
22979
22980 var Rect = function Rect(cfg) {
22981 Rect.superclass.constructor.call(this, cfg);
22982 };
22983
22984 Rect.ATTRS = {
22985 x: 0,
22986 y: 0,
22987 width: 0,
22988 height: 0,
22989 radius: 0,
22990 lineWidth: 1,
22991 fill: 'none'
22992 };
22993
22994 Util.extend(Rect, Shape);
22995
22996 Util.augment(Rect, {
22997 canFill: true,
22998 canStroke: true,
22999 type: 'rect',
23000 getDefaultAttrs: function getDefaultAttrs() {
23001 return {
23002 lineWidth: 1,
23003 fill: 'none'
23004 };
23005 },
23006 _afterSetRadius: function _afterSetRadius() {
23007 var el = this.get('el');
23008 el.setAttribute('rx', this.__attrs.radius);
23009 el.setAttribute('ry', this.__attrs.radius);
23010 },
23011 _afterSetAttrAll: function _afterSetAttrAll(objs) {
23012 if ('radius' in objs) {
23013 this._afterSetRadius();
23014 }
23015 }
23016 });
23017
23018 module.exports = Rect;
23019
23020 /***/
23021 },
23022 /* 40 */
23023 /***/function (module, exports, __webpack_require__) {
23024
23025 var Util = __webpack_require__(0);
23026 var Shape = __webpack_require__(4);
23027
23028 var Circle = function Circle(cfg) {
23029 Circle.superclass.constructor.call(this, cfg);
23030 };
23031
23032 Circle.ATTRS = {
23033 x: 0,
23034 y: 0,
23035 r: 0,
23036 lineWidth: 1
23037 };
23038
23039 Util.extend(Circle, Shape);
23040
23041 Util.augment(Circle, {
23042 canFill: true,
23043 canStroke: true,
23044 type: 'circle',
23045 getDefaultAttrs: function getDefaultAttrs() {
23046 return {
23047 lineWidth: 1,
23048 fill: 'none'
23049 };
23050 }
23051 });
23052
23053 module.exports = Circle;
23054
23055 /***/
23056 },
23057 /* 41 */
23058 /***/function (module, exports, __webpack_require__) {
23059
23060 var Util = __webpack_require__(0);
23061 var Shape = __webpack_require__(4);
23062
23063 var Ellipse = function Ellipse(cfg) {
23064 Ellipse.superclass.constructor.call(this, cfg);
23065 };
23066
23067 Ellipse.ATTRS = {
23068 x: 0,
23069 y: 0,
23070 rx: 1,
23071 ry: 1,
23072 lineWidth: 1
23073 };
23074
23075 Util.extend(Ellipse, Shape);
23076
23077 Util.augment(Ellipse, {
23078 canFill: true,
23079 canStroke: true,
23080 type: 'ellipse',
23081 getDefaultAttrs: function getDefaultAttrs() {
23082 return {
23083 lineWidth: 1
23084 };
23085 }
23086 });
23087
23088 module.exports = Ellipse;
23089
23090 /***/
23091 },
23092 /* 42 */
23093 /***/function (module, exports, __webpack_require__) {
23094
23095 var Util = __webpack_require__(0);
23096 var Shape = __webpack_require__(4);
23097
23098 var Path = function Path(cfg) {
23099 Path.superclass.constructor.call(this, cfg);
23100 };
23101
23102 function at(p0, p1, p2, p3, t) {
23103 var onet = 1 - t;
23104 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
23105 }
23106
23107 Path.ATTRS = {
23108 path: null,
23109 lineWidth: 1,
23110 curve: null, // 曲线path
23111 tCache: null,
23112 startArrow: false,
23113 endArrow: false
23114 };
23115
23116 Util.extend(Path, Shape);
23117
23118 Util.augment(Path, {
23119 canFill: true,
23120 canStroke: true,
23121 type: 'path',
23122 getDefaultAttrs: function getDefaultAttrs() {
23123 return {
23124 lineWidth: 1,
23125 fill: 'none',
23126 startArrow: false,
23127 endArrow: false
23128 };
23129 },
23130 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
23131 var start = this.get('marker-start');
23132 var end = this.get('marker-end');
23133 if (start) {
23134 this.get('defs').findById(start).update(null, value);
23135 }
23136 if (end) {
23137 this.get('defs').findById(end).update(null, value);
23138 }
23139 },
23140 _afterSetAttrPath: function _afterSetAttrPath(value) {
23141 var el = this.get('el');
23142 var d = value;
23143 if (Util.isArray(d)) {
23144 d = d.map(function (path) {
23145 return path.join(' ');
23146 }).join('');
23147 }
23148 if (~d.indexOf('NaN')) {
23149 el.setAttribute('d', '');
23150 } else {
23151 el.setAttribute('d', d);
23152 }
23153 },
23154 _afterSetAttrAll: function _afterSetAttrAll(objs) {
23155 if (objs.path) {
23156 this._afterSetAttrPath(objs.path);
23157 }
23158 if (objs.stroke) {
23159 this._afterSetAttrStroke(objs.stroke);
23160 }
23161 },
23162 getPoint: function getPoint(t) {
23163 var tCache = this.tCache;
23164 var subt = void 0;
23165 var index = void 0;
23166
23167 if (!tCache) {
23168 this._calculateCurve();
23169 this._setTcache();
23170 tCache = this.tCache;
23171 }
23172
23173 var curve = this.curve;
23174
23175 if (!tCache) {
23176 if (curve) {
23177 return {
23178 x: curve[0][1],
23179 y: curve[0][2]
23180 };
23181 }
23182 return null;
23183 }
23184 Util.each(tCache, function (v, i) {
23185 if (t >= v[0] && t <= v[1]) {
23186 subt = (t - v[0]) / (v[1] - v[0]);
23187 index = i;
23188 }
23189 });
23190 var seg = curve[index];
23191 if (Util.isNil(seg) || Util.isNil(index)) {
23192 return null;
23193 }
23194 var l = seg.length;
23195 var nextSeg = curve[index + 1];
23196
23197 return {
23198 x: at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
23199 y: at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
23200 };
23201 },
23202 createPath: function createPath() {}
23203 });
23204
23205 module.exports = Path;
23206
23207 /***/
23208 },
23209 /* 43 */
23210 /***/function (module, exports, __webpack_require__) {
23211
23212 var Util = __webpack_require__(0);
23213 var Shape = __webpack_require__(4);
23214
23215 var CText = function CText(cfg) {
23216 CText.superclass.constructor.call(this, cfg);
23217 };
23218
23219 var BASELINE_MAP = {
23220 top: 'before-edge',
23221 middle: 'central',
23222 bottom: 'after-edge',
23223 alphabetic: 'baseline',
23224 hanging: 'hanging'
23225 };
23226
23227 var ANCHOR_MAP = {
23228 left: 'left',
23229 start: 'left',
23230 center: 'middle',
23231 right: 'end',
23232 end: 'end'
23233 };
23234
23235 CText.ATTRS = {
23236 x: 0,
23237 y: 0,
23238 text: null,
23239 fontSize: 12,
23240 fontFamily: 'sans-serif',
23241 fontStyle: 'normal',
23242 fontWeight: 'normal',
23243 fontVariant: 'normal',
23244 textAlign: 'start',
23245 textBaseline: 'bottom',
23246 lineHeight: null,
23247 textArr: null
23248 };
23249
23250 Util.extend(CText, Shape);
23251
23252 Util.augment(CText, {
23253 canFill: true,
23254 canStroke: true,
23255 type: 'text',
23256 getDefaultAttrs: function getDefaultAttrs() {
23257 return {
23258 lineWidth: 1,
23259 lineCount: 1,
23260 fontSize: 12,
23261 fill: '#000',
23262 fontFamily: 'sans-serif',
23263 fontStyle: 'normal',
23264 fontWeight: 'normal',
23265 fontVariant: 'normal',
23266 textAlign: 'start',
23267 textBaseline: 'bottom'
23268 };
23269 },
23270 initTransform: function initTransform() {
23271 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
23272 var fontSize = this.__attrs.fontSize;
23273 if (fontSize && +fontSize < 12) {
23274 // 小于 12 像素的文本进行 scale 处理
23275 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
23276 }
23277 },
23278 _assembleFont: function _assembleFont() {
23279 var el = this.get('el');
23280 var attrs = this.__attrs;
23281 var fontSize = attrs.fontSize;
23282 var fontFamily = attrs.fontFamily;
23283 var fontWeight = attrs.fontWeight;
23284 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
23285 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
23286 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
23287 var font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
23288 attrs.font = font;
23289 el.setAttribute('font', attrs.font);
23290 },
23291 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
23292 /* this.attr({
23293 height: this._getTextHeight()
23294 }); */
23295 this._assembleFont();
23296 },
23297 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
23298 this._assembleFont();
23299 },
23300 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
23301 this._assembleFont();
23302 },
23303 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
23304 this._assembleFont();
23305 },
23306 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
23307 this._assembleFont();
23308 },
23309 _afterSetAttrTextAlign: function _afterSetAttrTextAlign() {
23310 // 由于本身不支持设置direction,所以left = start, right = end。之后看是否需要根据direction判断
23311 var attr = this.__attrs.textAlign;
23312 var el = this.get('el');
23313 el.setAttribute('text-anchor', ANCHOR_MAP[attr]);
23314 },
23315 _afterSetAttrTextBaseLine: function _afterSetAttrTextBaseLine() {
23316 var attr = this.__attrs.textBaseline;
23317 this.get('el').setAttribute('alignment-baseline', BASELINE_MAP[attr] || 'baseline');
23318 },
23319 _afterSetAttrText: function _afterSetAttrText(text) {
23320 var attrs = this.__attrs;
23321 var textArr = void 0;
23322 if (Util.isString(text) && text.indexOf('\n') !== -1) {
23323 textArr = text.split('\n');
23324 var lineCount = textArr.length;
23325 attrs.lineCount = lineCount;
23326 attrs.textArr = textArr;
23327 }
23328 var el = this.get('el');
23329 if (~['undefined', 'null', 'NaN'].indexOf(String(text)) && el) {
23330 el.innerHTML = '';
23331 } else if (~text.indexOf('\n')) {
23332 textArr = text.split('\n');
23333 attrs.lineCount = textArr.length;
23334 attrs.textArr = textArr;
23335 var arr = '';
23336 Util.each(textArr, function (segment, i) {
23337 arr += '<tspan x="0" y="' + (i + 1) + 'em">' + segment + '</tspan>';
23338 });
23339 el.innerHTML = arr;
23340 } else {
23341 el.innerHTML = text;
23342 }
23343 },
23344 _afterSetAttrOutline: function _afterSetAttrOutline(val) {
23345 var el = this.get('el');
23346 if (!val) {
23347 el.setAttribute('paint-order', 'normal');
23348 }
23349 var stroke = val.stroke || '#000';
23350 var fill = val.fill || this.__attrs.stroke;
23351 var lineWidth = val.lineWidth || this.__attrs.lineWidth * 2;
23352 el.setAttribute('paint-order', 'stroke');
23353 el.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');
23354 el.setAttribute('stroke', stroke);
23355 el.setAttribute('fill', fill);
23356 el.setAttribute('stroke-width', lineWidth);
23357 },
23358
23359 // 计算浪费,效率低,待优化
23360 _afterSetAttrAll: function _afterSetAttrAll(objs) {
23361 var self = this;
23362 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
23363 self._assembleFont();
23364 }
23365 if ('textAlign' in objs) {
23366 this._afterSetAttrTextAlign();
23367 }
23368 if ('textBaseline' in objs) {
23369 this._afterSetAttrTextBaseLine();
23370 }
23371 if ('text' in objs) {
23372 self._afterSetAttrText(objs.text);
23373 }
23374 if ('outline' in objs) {
23375 self._afterSetAttrOutline(objs.outline);
23376 }
23377 }
23378 });
23379
23380 module.exports = CText;
23381
23382 /***/
23383 },
23384 /* 44 */
23385 /***/function (module, exports, __webpack_require__) {
23386
23387 var Util = __webpack_require__(0);
23388 var Shape = __webpack_require__(4);
23389
23390 var Line = function Line(cfg) {
23391 Line.superclass.constructor.call(this, cfg);
23392 };
23393
23394 Line.ATTRS = {
23395 x1: 0,
23396 y1: 0,
23397 x2: 0,
23398 y2: 0,
23399 lineWidth: 1,
23400 startArrow: false,
23401 endArrow: false
23402 };
23403
23404 Util.extend(Line, Shape);
23405
23406 Util.augment(Line, {
23407 canStroke: true,
23408 type: 'line',
23409 getDefaultAttrs: function getDefaultAttrs() {
23410 return {
23411 lineWidth: 1,
23412 stroke: '#000',
23413 startArrow: false,
23414 endArrow: false
23415 };
23416 },
23417 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
23418 var start = this.get('marker-start');
23419 var end = this.get('marker-end');
23420 if (start) {
23421 this.get('defs').findById(start).update(value);
23422 }
23423 if (end) {
23424 this.get('defs').findById(end).update(value);
23425 }
23426 },
23427 _afterSetAttrAll: function _afterSetAttrAll(objs) {
23428 if (objs.stroke) {
23429 this._afterSetAttrStroke(objs.stroke);
23430 }
23431 },
23432 createPath: function createPath() {},
23433 getPoint: function getPoint(t) {
23434 var attrs = this.__attrs;
23435 return {
23436 x: (attrs.x2 - attrs.x1) * t + attrs.x1,
23437 y: (attrs.y2 - attrs.y1) * t + attrs.y1
23438 };
23439 }
23440 });
23441
23442 module.exports = Line;
23443
23444 /***/
23445 },
23446 /* 45 */
23447 /***/function (module, exports, __webpack_require__) {
23448
23449 var Util = __webpack_require__(0);
23450 var Shape = __webpack_require__(4);
23451
23452 var CImage = function CImage(cfg) {
23453 CImage.superclass.constructor.call(this, cfg);
23454 };
23455
23456 CImage.ATTRS = {
23457 x: 0,
23458 y: 0,
23459 img: undefined,
23460 width: 0,
23461 height: 0,
23462 sx: null,
23463 sy: null,
23464 swidth: null,
23465 sheight: null
23466 };
23467
23468 Util.extend(CImage, Shape);
23469
23470 Util.augment(CImage, {
23471 type: 'image',
23472 _afterSetAttrImg: function _afterSetAttrImg(img) {
23473 this._setAttrImg(img);
23474 },
23475 _afterSetAttrAll: function _afterSetAttrAll(params) {
23476 if (params.img) {
23477 this._setAttrImg(params.img);
23478 }
23479 },
23480 _setAttrImg: function _setAttrImg(image) {
23481 var self = this;
23482 var el = this.get('el');
23483 var attrs = self.__attrs;
23484 var img = image;
23485
23486 if (Util.isString(img)) {
23487 // 如果传入的
23488 el.setAttribute('href', img);
23489 } else if (img instanceof Image) {
23490 if (!attrs.width) {
23491 self.attr('width', img.width);
23492 }
23493 if (!attrs.height) {
23494 self.attr('height', img.height);
23495 }
23496 el.setAttribute('href', img.src);
23497 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
23498 el.setAttribute('href', img.toDataURL());
23499 } else if (img instanceof ImageData) {
23500 var canvas = document.createElement('canvas');
23501 canvas.setAttribute('width', img.width);
23502 canvas.setAttribute('height', img.height);
23503 canvas.getContext('2d').putImageData(img, 0, 0);
23504 if (!attrs.width) {
23505 self.attr('width', img.width);
23506 }
23507
23508 if (!attrs.height) {
23509 self.attr('height', img.height);
23510 }
23511 el.setAttribute('href', canvas.toDataURL());
23512 }
23513 },
23514 drawInner: function drawInner() {}
23515 });
23516
23517 module.exports = CImage;
23518
23519 /***/
23520 },
23521 /* 46 */
23522 /***/function (module, exports, __webpack_require__) {
23523
23524 var Util = __webpack_require__(0);
23525 var Shape = __webpack_require__(4);
23526
23527 var Polygon = function Polygon(cfg) {
23528 Polygon.superclass.constructor.call(this, cfg);
23529 };
23530
23531 Polygon.ATTRS = {
23532 points: null,
23533 lineWidth: 1
23534 };
23535
23536 Util.extend(Polygon, Shape);
23537
23538 Util.augment(Polygon, {
23539 canFill: true,
23540 canStroke: true,
23541 type: 'polygon',
23542 getDefaultAttrs: function getDefaultAttrs() {
23543 return {
23544 lineWidth: 1,
23545 fill: 'none'
23546 };
23547 },
23548 _afterSetAttrPoints: function _afterSetAttrPoints() {
23549 var value = this.__attrs.points;
23550 var el = this.get('el');
23551 var points = value;
23552 if (!value || value.length === 0) {
23553 points = '';
23554 } else if (Util.isArray(value)) {
23555 points = points.map(function (point) {
23556 return point[0] + ',' + point[1];
23557 });
23558 points = points.join(' ');
23559 }
23560 el.setAttribute('points', points);
23561 },
23562 _afterSetAttrAll: function _afterSetAttrAll(obj) {
23563 if ('points' in obj) {
23564 this._afterSetAttrPoints();
23565 }
23566 },
23567 createPath: function createPath() {}
23568 });
23569
23570 module.exports = Polygon;
23571
23572 /***/
23573 },
23574 /* 47 */
23575 /***/function (module, exports, __webpack_require__) {
23576
23577 var Util = __webpack_require__(0);
23578 var Shape = __webpack_require__(4);
23579
23580 var Marker = function Marker(cfg) {
23581 Marker.superclass.constructor.call(this, cfg);
23582 };
23583
23584 Marker.Symbols = {
23585 // 圆
23586 circle: function circle(x, y, r) {
23587 return 'M' + x + ',' + y + '\n m' + -r + ',0\n a ' + r + ',' + r + ',0,1,0,' + r * 2 + ',0\n a ' + r + ',' + r + ',0,1,0,' + -r * 2 + ',0';
23588 },
23589
23590 // 正方形
23591 square: function square(x, y, r) {
23592 return 'M' + (x - r) + ',' + (y - r) + '\n H' + (x + r) + 'V' + (y + r) + '\n H' + (x - r) + 'Z';
23593 },
23594
23595 // 菱形
23596 diamond: function diamond(x, y, r) {
23597 return 'M' + (x - r) + ',' + y + '\n L' + x + ',' + (y - r) + '\n L' + (x + r) + ',' + y + ',\n L' + x + ',' + (y + r) + 'Z';
23598 },
23599
23600 // 三角形
23601 triangle: function triangle(x, y, r) {
23602 var diff = r * Math.sin(1 / 3 * Math.PI);
23603 return 'M' + (x - r) + ',' + (y + diff) + '\n L' + x + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y + diff) + 'Z';
23604 },
23605
23606 // 倒三角形
23607 'triangle-down': function triangleDown(x, y, r) {
23608 var diff = r * Math.sin(1 / 3 * Math.PI);
23609 return 'M' + (x - r) + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y - diff) + '\n L' + x + ',' + (y + diff) + 'Z';
23610 }
23611 };
23612
23613 Marker.ATTRS = {
23614 path: null,
23615 lineWidth: 1
23616 };
23617
23618 Util.extend(Marker, Shape);
23619
23620 Util.augment(Marker, {
23621 type: 'marker',
23622 canFill: true,
23623 canStroke: true,
23624 init: function init(id) {
23625 Marker.superclass.init.call(this);
23626 var marker = document.createElementNS('http://www.w3.org/2000/svg', 'path');
23627 id = id || Util.uniqueId(this.type + '_');
23628 marker.setAttribute('id', id);
23629 this.setSilent('el', marker);
23630 },
23631 getDefaultAttrs: function getDefaultAttrs() {
23632 return {
23633 x: 0,
23634 y: 0,
23635 lineWidth: 1,
23636 fill: 'none'
23637 };
23638 },
23639 _afterSetX: function _afterSetX() {
23640 this._assembleShape();
23641 },
23642 _afterSetY: function _afterSetY() {
23643 this._assembleShape();
23644 },
23645 _afterSetRadius: function _afterSetRadius() {
23646 this._assembleShape();
23647 },
23648 _afterSetR: function _afterSetR() {
23649 this._assembleShape();
23650 },
23651 _afterSetAttrAll: function _afterSetAttrAll(objs) {
23652 if ('x' in objs || 'y' in objs || 'radius' in objs) {
23653 this._assembleShape();
23654 }
23655 },
23656 _assembleShape: function _assembleShape() {
23657 var attrs = this.__attrs;
23658 var r = attrs.r;
23659 if (typeof attrs.r === 'undefined') {
23660 r = attrs.radius;
23661 }
23662 if (isNaN(Number(attrs.x)) || isNaN(Number(attrs.y)) || isNaN(Number(r))) {
23663 return;
23664 }
23665 var d = '';
23666 if (typeof attrs.symbol === 'function') {
23667 d = attrs.symbol(attrs.x, attrs.y, r);
23668 } else {
23669 d = Marker.Symbols[attrs.symbol || 'circle'](attrs.x, attrs.y, r);
23670 }
23671 if (Util.isArray(d)) {
23672 d = d.map(function (path) {
23673 return path.join(' ');
23674 }).join('');
23675 }
23676 this.get('el').setAttribute('d', d);
23677 }
23678 });
23679
23680 module.exports = Marker;
23681
23682 /***/
23683 },
23684 /* 48 */
23685 /***/function (module, exports, __webpack_require__) {
23686
23687 var Util = __webpack_require__(0);
23688 var Shape = __webpack_require__(4);
23689
23690 var Dom = function Dom(cfg) {
23691 Dom.superclass.constructor.call(this, cfg);
23692 };
23693
23694 Util.extend(Dom, Shape);
23695
23696 Util.augment(Dom, {
23697 canFill: true,
23698 canStroke: true,
23699 type: 'dom',
23700 _afterSetAttrHtml: function _afterSetAttrHtml() {
23701 var html = this.__attrs.html;
23702 var el = this.get('el');
23703 if (typeof html === 'string') {
23704 el.innerHTML = html;
23705 } else {
23706 el.innerHTML = '';
23707 el.appendChild(html);
23708 }
23709 },
23710 _afterSetAttrAll: function _afterSetAttrAll(objs) {
23711 if ('html' in objs) {
23712 this._afterSetAttrHtml();
23713 }
23714 }
23715 });
23716
23717 module.exports = Dom;
23718
23719 /***/
23720 },
23721 /* 49 */
23722 /***/function (module, exports, __webpack_require__) {
23723
23724 var Util = __webpack_require__(0);
23725 var Shape = __webpack_require__(4);
23726
23727 var Fan = function Fan(cfg) {
23728 Fan.superclass.constructor.call(this, cfg);
23729 };
23730
23731 function getPoint(angle, radius, center) {
23732 return {
23733 x: radius * Math.cos(angle) + center.x,
23734 y: radius * Math.sin(angle) + center.y
23735 };
23736 }
23737
23738 Fan.ATTRS = {
23739 x: 0,
23740 y: 0,
23741 rs: 0,
23742 re: 0,
23743 startAngle: 0,
23744 endAngle: 0,
23745 clockwise: false,
23746 lineWidth: 1
23747 };
23748
23749 Util.extend(Fan, Shape);
23750
23751 Util.augment(Fan, {
23752 canFill: true,
23753 canStroke: true,
23754 type: 'fan',
23755 getDefaultAttrs: function getDefaultAttrs() {
23756 return {
23757 clockwise: false,
23758 lineWidth: 1,
23759 rs: 0,
23760 re: 0,
23761 fill: 'none'
23762 };
23763 },
23764 _afterSetAttrX: function _afterSetAttrX() {
23765 this._calculatePath();
23766 },
23767 _afterSetAttrY: function _afterSetAttrY() {
23768 this._calculatePath();
23769 },
23770 _afterSetAttrRs: function _afterSetAttrRs() {
23771 this._calculatePath();
23772 },
23773 _afterSetAttrRe: function _afterSetAttrRe() {
23774 this._calculatePath();
23775 },
23776 _afterSetAttrStartAngle: function _afterSetAttrStartAngle() {
23777 this._calculatePath();
23778 },
23779 _afterSetAttrEndAngle: function _afterSetAttrEndAngle() {
23780 this._calculatePath();
23781 },
23782 _afterSetAttrClockwise: function _afterSetAttrClockwise() {
23783 this._calculatePath();
23784 },
23785 _afterSetAttrAll: function _afterSetAttrAll(obj) {
23786 if ('x' in obj || 'y' in obj || 'rs' in obj || 're' in obj || 'startAngle' in obj || 'endAngle' in obj || 'clockwise' in obj) {
23787 this._calculatePath();
23788 }
23789 },
23790 _calculatePath: function _calculatePath() {
23791 var self = this;
23792 var attrs = self.__attrs;
23793 var center = {
23794 x: attrs.x,
23795 y: attrs.y
23796 };
23797 var d = [];
23798 var startAngle = attrs.startAngle;
23799 var endAngle = attrs.endAngle;
23800 if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
23801 endAngle -= 0.00001;
23802 }
23803 var outerStart = getPoint(startAngle, attrs.re, center);
23804 var outerEnd = getPoint(endAngle, attrs.re, center);
23805 var fa = endAngle > startAngle ? 1 : 0;
23806 var fs = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
23807 var rs = attrs.rs;
23808 var re = attrs.re;
23809 var innerStart = getPoint(startAngle, attrs.rs, center);
23810 var innerEnd = getPoint(endAngle, attrs.rs, center);
23811 if (attrs.rs > 0) {
23812 d.push('M ' + outerEnd.x + ',' + outerEnd.y);
23813 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
23814 /* if (endAngle - startAngle >= Math.PI) {
23815 const endPoint = getSymmetricalPoint(innerStart, center);
23816 d.push(`A ${rs},${rs},0,0,${fa},${endPoint.x},${endPoint.y}`);
23817 d.push(`M ${endPoint.x},${endPoint.y}`);
23818 }*/
23819 d.push('A ' + rs + ',' + rs + ',0,' + fs + ',' + (fa === 1 ? 0 : 1) + ',' + innerStart.x + ',' + innerStart.y);
23820 d.push('L ' + outerStart.x + ' ' + outerStart.y);
23821 } else {
23822 d.push('M ' + center.x + ',' + center.y);
23823 d.push('L ' + outerStart.x + ',' + outerStart.y);
23824 }
23825 /* if (endAngle - startAngle >= Math.PI) {
23826 const endPoint = getSymmetricalPoint(outerStart, center);
23827 d.push(`A ${re},${re},0,0,${fa},${endPoint.x},${endPoint.y}`);
23828 }*/
23829 d.push('A ' + re + ',' + re + ',0,' + fs + ',' + fa + ',' + outerEnd.x + ',' + outerEnd.y);
23830 if (attrs.rs > 0) {
23831 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
23832 } else {
23833 d.push('Z');
23834 }
23835 self.get('el').setAttribute('d', d.join(' '));
23836 }
23837 });
23838
23839 module.exports = Fan;
23840
23841 /***/
23842 },
23843 /* 50 */
23844 /***/function (module, exports, __webpack_require__) {
23845
23846 var Util = __webpack_require__(0);
23847
23848 var Event = function Event(type, event, bubbles, cancelable) {
23849 this.type = type; // 事件类型
23850 this.target = null; // 目标
23851 this.currentTarget = null; // 当前目标
23852 this.bubbles = bubbles; // 冒泡
23853 this.cancelable = cancelable; // 是否能够阻止
23854 this.timeStamp = new Date().getTime(); // 时间戳
23855 this.defaultPrevented = false; // 阻止默认
23856 this.propagationStopped = false; // 阻止冒泡
23857 this.removed = false; // 是否被移除
23858 this.event = event; // 触发的原生事件
23859 };
23860
23861 Util.augment(Event, {
23862 preventDefault: function preventDefault() {
23863 this.defaultPrevented = this.cancelable && true;
23864 },
23865 stopPropagation: function stopPropagation() {
23866 this.propagationStopped = true;
23867 },
23868 remove: function remove() {
23869 this.remove = true;
23870 },
23871 clone: function clone() {
23872 return Util.clone(this);
23873 },
23874 toString: function toString() {
23875 return '[Event (type=' + this.type + ')]';
23876 }
23877 });
23878
23879 module.exports = Event;
23880
23881 /***/
23882 },
23883 /* 51 */
23884 /***/function (module, exports, __webpack_require__) {
23885
23886 var Util = __webpack_require__(0);
23887 var Element = __webpack_require__(52);
23888 var Shape = __webpack_require__(112);
23889 var SHAPE_MAP = {}; // 缓存图形类型
23890 var INDEX = '_INDEX';
23891
23892 function find(children, x, y) {
23893 var rst = void 0;
23894 for (var i = children.length - 1; i >= 0; i--) {
23895 var child = children[i];
23896 if (child.__cfg.visible && child.__cfg.capture) {
23897 if (child.isGroup) {
23898 rst = child.getShape(x, y);
23899 } else if (child.isHit(x, y)) {
23900 rst = child;
23901 }
23902 }
23903 if (rst) {
23904 break;
23905 }
23906 }
23907 return rst;
23908 }
23909
23910 function getComparer(compare) {
23911 return function (left, right) {
23912 var result = compare(left, right);
23913 return result === 0 ? left[INDEX] - right[INDEX] : result;
23914 };
23915 }
23916
23917 var Group = function Group(cfg) {
23918 Group.superclass.constructor.call(this, cfg);
23919 this.set('children', []);
23920
23921 this._beforeRenderUI();
23922 this._renderUI();
23923 this._bindUI();
23924 };
23925
23926 function initClassCfgs(c) {
23927 if (c.__cfg || c === Group) {
23928 return;
23929 }
23930 var superCon = c.superclass.constructor;
23931 if (superCon && !superCon.__cfg) {
23932 initClassCfgs(superCon);
23933 }
23934 c.__cfg = {};
23935
23936 Util.merge(c.__cfg, superCon.__cfg);
23937 Util.merge(c.__cfg, c.CFG);
23938 }
23939
23940 Util.extend(Group, Element);
23941
23942 Util.augment(Group, {
23943 isGroup: true,
23944 canFill: true,
23945 canStroke: true,
23946 getDefaultCfg: function getDefaultCfg() {
23947 initClassCfgs(this.constructor);
23948 return Util.merge({}, this.constructor.__cfg);
23949 },
23950 _beforeRenderUI: function _beforeRenderUI() {},
23951 _renderUI: function _renderUI() {},
23952 _bindUI: function _bindUI() {},
23953 addShape: function addShape(type, cfg) {
23954 var canvas = this.get('canvas');
23955 cfg = cfg || {};
23956 var shapeType = SHAPE_MAP[type];
23957 if (!shapeType) {
23958 shapeType = Util.upperFirst(type);
23959 SHAPE_MAP[type] = shapeType;
23960 }
23961 if (cfg.attrs) {
23962 var attrs = cfg.attrs;
23963 if (type === 'text') {
23964 // 临时解决
23965 var topFontFamily = canvas.get('fontFamily');
23966 if (topFontFamily) {
23967 attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily;
23968 }
23969 }
23970 }
23971 cfg.canvas = canvas;
23972 cfg.type = type;
23973 var rst = new Shape[shapeType](cfg);
23974 this.add(rst);
23975 return rst;
23976 },
23977
23978 /** 添加图组
23979 * @param {Function|Object|undefined} param 图组类
23980 * @param {Object} cfg 配置项
23981 * @return {Object} rst 图组
23982 */
23983 addGroup: function addGroup(param, cfg) {
23984 var canvas = this.get('canvas');
23985 var rst = void 0;
23986 cfg = Util.merge({}, cfg);
23987 if (Util.isFunction(param)) {
23988 if (cfg) {
23989 cfg.canvas = canvas;
23990 cfg.parent = this;
23991 rst = new param(cfg);
23992 } else {
23993 rst = new param({
23994 canvas: canvas,
23995 parent: this
23996 });
23997 }
23998 this.add(rst);
23999 } else if (Util.isObject(param)) {
24000 param.canvas = canvas;
24001 rst = new Group(param);
24002 this.add(rst);
24003 } else if (param === undefined) {
24004 rst = new Group();
24005 this.add(rst);
24006 } else {
24007 return false;
24008 }
24009 return rst;
24010 },
24011
24012 /** 绘制背景
24013 * @param {Array} padding 内边距
24014 * @param {Attrs} attrs 图形属性
24015 * @param {Shape} backShape 背景图形
24016 * @return {Object} 背景层对象
24017 */
24018 renderBack: function renderBack(padding, attrs) {
24019 var backShape = this.get('backShape');
24020 var innerBox = this.getBBox();
24021 // const parent = this.get('parent'); // getParent
24022 Util.merge(attrs, {
24023 x: innerBox.minX - padding[3],
24024 y: innerBox.minY - padding[0],
24025 width: innerBox.width + padding[1] + padding[3],
24026 height: innerBox.height + padding[0] + padding[2]
24027 });
24028 if (backShape) {
24029 backShape.attr(attrs);
24030 } else {
24031 backShape = this.addShape('rect', {
24032 zIndex: -1,
24033 attrs: attrs
24034 });
24035 }
24036 this.set('backShape', backShape);
24037 this.sort();
24038 return backShape;
24039 },
24040 removeChild: function removeChild(item, destroy) {
24041 if (arguments.length >= 2) {
24042 if (this.contain(item)) {
24043 item.remove(destroy);
24044 }
24045 } else {
24046 if (arguments.length === 1) {
24047 if (Util.isBoolean(item)) {
24048 destroy = item;
24049 } else {
24050 if (this.contain(item)) {
24051 item.remove(true);
24052 }
24053 return this;
24054 }
24055 }
24056 if (arguments.length === 0) {
24057 destroy = true;
24058 }
24059
24060 Group.superclass.remove.call(this, destroy);
24061 }
24062 return this;
24063 },
24064
24065 /**
24066 * 向组中添加shape或者group
24067 * @param {Object} items 图形或者分组
24068 * @return {Object} group 本尊
24069 */
24070 add: function add(items) {
24071 var self = this;
24072 var children = self.get('children');
24073 if (Util.isArray(items)) {
24074 Util.each(items, function (item) {
24075 var parent = item.get('parent');
24076 if (parent) {
24077 parent.removeChild(item, false);
24078 }
24079 self._setEvn(item);
24080 });
24081 children.push.apply(children, items);
24082 } else {
24083 var item = items;
24084 var parent = item.get('parent');
24085 if (parent) {
24086 parent.removeChild(item, false);
24087 }
24088 self._setEvn(item);
24089 children.push(item);
24090 }
24091 return self;
24092 },
24093 contain: function contain(item) {
24094 var children = this.get('children');
24095 return children.indexOf(item) > -1;
24096 },
24097 getChildByIndex: function getChildByIndex(index) {
24098 var children = this.get('children');
24099 return children[index];
24100 },
24101 getFirst: function getFirst() {
24102 return this.getChildByIndex(0);
24103 },
24104 getLast: function getLast() {
24105 var lastIndex = this.get('children').length - 1;
24106 return this.getChildByIndex(lastIndex);
24107 },
24108 _setEvn: function _setEvn(item) {
24109 var self = this;
24110 item.__cfg.parent = self;
24111 item.__cfg.context = self.__cfg.context;
24112 item.__cfg.canvas = self.__cfg.canvas;
24113 var clip = item.__attrs.clip;
24114 if (clip) {
24115 clip.setSilent('parent', self);
24116 clip.setSilent('context', self.get('context'));
24117 }
24118 var children = item.__cfg.children;
24119 if (children) {
24120 Util.each(children, function (child) {
24121 item._setEvn(child);
24122 });
24123 }
24124 },
24125 getBBox: function getBBox() {
24126 var self = this;
24127 var minX = Infinity;
24128 var maxX = -Infinity;
24129 var minY = Infinity;
24130 var maxY = -Infinity;
24131 var children = self.get('children');
24132 if (children.length > 0) {
24133 Util.each(children, function (child) {
24134 if (child.get('visible')) {
24135 var _box = child.getBBox();
24136 if (!_box) {
24137 return true;
24138 }
24139
24140 var leftTop = [_box.minX, _box.minY, 1];
24141 var leftBottom = [_box.minX, _box.maxY, 1];
24142 var rightTop = [_box.maxX, _box.minY, 1];
24143 var rightBottom = [_box.maxX, _box.maxY, 1];
24144
24145 child.apply(leftTop);
24146 child.apply(leftBottom);
24147 child.apply(rightTop);
24148 child.apply(rightBottom);
24149
24150 var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
24151 var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
24152 var boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
24153 var boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
24154
24155 if (boxMinX < minX) {
24156 minX = boxMinX;
24157 }
24158
24159 if (boxMaxX > maxX) {
24160 maxX = boxMaxX;
24161 }
24162
24163 if (boxMinY < minY) {
24164 minY = boxMinY;
24165 }
24166
24167 if (boxMaxY > maxY) {
24168 maxY = boxMaxY;
24169 }
24170 }
24171 });
24172 } else {
24173 minX = 0;
24174 maxX = 0;
24175 minY = 0;
24176 maxY = 0;
24177 }
24178
24179 var box = {
24180 minX: minX,
24181 minY: minY,
24182 maxX: maxX,
24183 maxY: maxY
24184 };
24185 box.x = box.minX;
24186 box.y = box.minY;
24187 box.width = box.maxX - box.minX;
24188 box.height = box.maxY - box.minY;
24189 return box;
24190 },
24191 drawInner: function drawInner(context) {
24192 var children = this.get('children');
24193 for (var i = 0; i < children.length; i++) {
24194 var child = children[i];
24195 child.draw(context);
24196 }
24197 return this;
24198 },
24199 getCount: function getCount() {
24200 return this.get('children').length;
24201 },
24202 sort: function sort() {
24203 var children = this.get('children');
24204 // 稳定排序
24205 Util.each(children, function (child, index) {
24206 child[INDEX] = index;
24207 return child;
24208 });
24209
24210 children.sort(getComparer(function (obj1, obj2) {
24211 return obj1.get('zIndex') - obj2.get('zIndex');
24212 }));
24213
24214 return this;
24215 },
24216 findById: function findById(id) {
24217 return this.find(function (item) {
24218 return item.get('id') === id;
24219 });
24220 },
24221
24222 /**
24223 * 根据查找函数查找分组或者图形
24224 * @param {Function} fn 匹配函数
24225 * @return {Canvas.Base} 分组或者图形
24226 */
24227 find: function find(fn) {
24228 if (Util.isString(fn)) {
24229 return this.findById(fn);
24230 }
24231 var children = this.get('children');
24232 var rst = null;
24233
24234 Util.each(children, function (item) {
24235 if (fn(item)) {
24236 rst = item;
24237 } else if (item.find) {
24238 rst = item.find(fn);
24239 }
24240 if (rst) {
24241 return false;
24242 }
24243 });
24244 return rst;
24245 },
24246
24247 /**
24248 * @param {Function} fn filter mathod
24249 * @return {Array} all the matching shapes and groups
24250 */
24251 findAll: function findAll(fn) {
24252 var children = this.get('children');
24253 var rst = [];
24254 var childRst = [];
24255 Util.each(children, function (item) {
24256 if (fn(item)) {
24257 rst.push(item);
24258 }
24259 if (item.findAllBy) {
24260 childRst = item.findAllBy(fn);
24261 rst = rst.concat(childRst);
24262 }
24263 });
24264 return rst;
24265 },
24266
24267 /**
24268 * @Deprecated
24269 * @param {Function} fn filter method
24270 * @return {Object} found shape or group
24271 */
24272 findBy: function findBy(fn) {
24273 var children = this.get('children');
24274 var rst = null;
24275
24276 Util.each(children, function (item) {
24277 if (fn(item)) {
24278 rst = item;
24279 } else if (item.findBy) {
24280 rst = item.findBy(fn);
24281 }
24282 if (rst) {
24283 return false;
24284 }
24285 });
24286 return rst;
24287 },
24288
24289 /**
24290 * @Deprecated
24291 * @param {Function} fn filter mathod
24292 * @return {Array} all the matching shapes and groups
24293 */
24294 findAllBy: function findAllBy(fn) {
24295 var children = this.get('children');
24296 var rst = [];
24297 var childRst = [];
24298 Util.each(children, function (item) {
24299 if (fn(item)) {
24300 rst.push(item);
24301 }
24302 if (item.findAllBy) {
24303 childRst = item.findAllBy(fn);
24304 rst = rst.concat(childRst);
24305 }
24306 });
24307 return rst;
24308 },
24309
24310 /**
24311 * 根据x,y轴坐标获取对应的图形
24312 * @param {Number} x x坐标
24313 * @param {Number} y y坐标
24314 * @return {Object} 最上面的图形
24315 */
24316 getShape: function getShape(x, y) {
24317 var self = this;
24318 var clip = self.__attrs.clip;
24319 var children = self.__cfg.children;
24320 var rst = void 0;
24321 if (clip) {
24322 if (clip.inside(x, y)) {
24323 rst = find(children, x, y);
24324 }
24325 } else {
24326 rst = find(children, x, y);
24327 }
24328 return rst;
24329 },
24330 clearTotalMatrix: function clearTotalMatrix() {
24331 var m = this.get('totalMatrix');
24332 if (m) {
24333 this.setSilent('totalMatrix', null);
24334 var children = this.__cfg.children;
24335 for (var i = 0; i < children.length; i++) {
24336 var child = children[i];
24337 child.clearTotalMatrix();
24338 }
24339 }
24340 },
24341 clear: function clear() {
24342 var children = this.get('children');
24343
24344 while (children.length !== 0) {
24345 children[children.length - 1].remove();
24346 }
24347 return this;
24348 },
24349 destroy: function destroy() {
24350 if (this.get('destroyed')) {
24351 return;
24352 }
24353 this.clear();
24354 Group.superclass.destroy.call(this);
24355 }
24356 });
24357
24358 module.exports = Group;
24359
24360 /***/
24361 },
24362 /* 52 */
24363 /***/function (module, exports, __webpack_require__) {
24364
24365 var Util = __webpack_require__(0);
24366 var Attribute = __webpack_require__(110);
24367 var Transform = __webpack_require__(111);
24368 var Animate = __webpack_require__(29);
24369 var Format = __webpack_require__(19);
24370 var EventEmitter = __webpack_require__(38);
24371
24372 var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'lineDashOffset'];
24373
24374 var Element = function Element(cfg) {
24375 this.__cfg = {
24376 zIndex: 0,
24377 capture: true,
24378 visible: true,
24379 destroyed: false
24380 }; // 配置存放地
24381
24382 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
24383 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
24384 this.initTransform(); // 初始化变换
24385 this.init(); // 类型初始化
24386 };
24387
24388 Element.CFG = {
24389 /**
24390 * 唯一标示
24391 * @type {Number}
24392 */
24393 id: null,
24394 /**
24395 * Z轴的层叠关系,Z值越大离用户越近
24396 * @type {Number}
24397 */
24398 zIndex: 0,
24399 /**
24400 * Canvas对象
24401 * @type: {Object}
24402 */
24403 canvas: null,
24404 /**
24405 * 父元素指针
24406 * @type {Object}
24407 */
24408 parent: null,
24409 /**
24410 * 用来设置当前对象是否能被捕捉
24411 * true 能
24412 * false 不能
24413 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
24414 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
24415 * @type {Boolean}
24416 **/
24417 capture: true,
24418 /**
24419 * 画布的上下文
24420 * @type {Object}
24421 */
24422 context: null,
24423 /**
24424 * 是否显示
24425 * @type {Boolean}
24426 */
24427 visible: true,
24428 /**
24429 * 是否被销毁
24430 * @type: {Boolean}
24431 */
24432 destroyed: false
24433 };
24434
24435 Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
24436 init: function init() {
24437 this.setSilent('animable', true);
24438 this.setSilent('animating', false); // 初始时不处于动画状态
24439 var attrs = this.__attrs;
24440 if (attrs && attrs.rotate) {
24441 this.rotateAtStart(attrs.rotate);
24442 }
24443 },
24444 getParent: function getParent() {
24445 return this.get('parent');
24446 },
24447
24448 /**
24449 * 获取默认的配置信息
24450 * @protected
24451 * @return {Object} 默认的属性
24452 */
24453 getDefaultCfg: function getDefaultCfg() {
24454 return {};
24455 },
24456 set: function set(name, value) {
24457 if (name === 'zIndex' && this._beforeSetZIndex) {
24458 this._beforeSetZIndex(value);
24459 }
24460 if (name === 'loading' && this._beforeSetLoading) {
24461 this._beforeSetLoading(value);
24462 }
24463 this.__cfg[name] = value;
24464 return this;
24465 },
24466 setSilent: function setSilent(name, value) {
24467 this.__cfg[name] = value;
24468 },
24469 get: function get(name) {
24470 return this.__cfg[name];
24471 },
24472 draw: function draw(context) {
24473 if (this.get('destroyed')) {
24474 return;
24475 }
24476 if (this.get('visible')) {
24477 this.setContext(context);
24478 this.drawInner(context);
24479 this.restoreContext(context);
24480 }
24481 },
24482 setContext: function setContext(context) {
24483 var clip = this.__attrs.clip;
24484 context.save();
24485 if (clip) {
24486 // context.save();
24487 clip.resetTransform(context);
24488 clip.createPath(context);
24489 context.clip();
24490 // context.restore();
24491 }
24492 this.resetContext(context);
24493 this.resetTransform(context);
24494 },
24495 restoreContext: function restoreContext(context) {
24496 context.restore();
24497 },
24498 resetContext: function resetContext(context) {
24499 var elAttrs = this.__attrs;
24500 // var canvas = this.get('canvas');
24501 if (!this.isGroup) {
24502 // canvas.registShape(this); // 快速拾取方案暂时不执行
24503 for (var k in elAttrs) {
24504 if (SHAPE_ATTRS.indexOf(k) > -1) {
24505 // 非canvas属性不附加
24506 var v = elAttrs[k];
24507 if (k === 'fillStyle') {
24508 v = Format.parseStyle(v, this);
24509 }
24510 if (k === 'strokeStyle') {
24511 v = Format.parseStyle(v, this);
24512 }
24513 if (k === 'lineDash' && context.setLineDash) {
24514 if (Util.isArray(v)) {
24515 context.setLineDash(v);
24516 } else if (Util.isString(v)) {
24517 context.setLineDash(v.split(' '));
24518 }
24519 } else {
24520 context[k] = v;
24521 }
24522 }
24523 }
24524 }
24525 },
24526 drawInner: function drawInner() /* context */{},
24527 show: function show() {
24528 this.set('visible', true);
24529 return this;
24530 },
24531 hide: function hide() {
24532 this.set('visible', false);
24533 return this;
24534 },
24535 remove: function remove(destroy) {
24536 if (destroy === undefined) {
24537 destroy = true;
24538 }
24539
24540 if (this.get('parent')) {
24541 var parent = this.get('parent');
24542 var children = parent.get('children');
24543 Util.remove(children, this);
24544 }
24545
24546 if (destroy) {
24547 this.destroy();
24548 }
24549
24550 return this;
24551 },
24552 destroy: function destroy() {
24553 var destroyed = this.get('destroyed');
24554 if (destroyed) {
24555 return;
24556 }
24557 // 如果正在执行动画,清理动画
24558 if (this.get('animating')) {
24559 var timer = this.get('animateTimer');
24560 timer && timer.stop();
24561 }
24562 this.__cfg = {};
24563 this.__attrs = null;
24564 this.removeEvent(); // 移除所有的事件
24565 this.set('destroyed', true);
24566 },
24567 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
24568 this.__cfg.zIndex = zIndex;
24569
24570 if (!Util.isNil(this.get('parent'))) {
24571 this.get('parent').sort();
24572 }
24573 return zIndex;
24574 },
24575 _setAttrs: function _setAttrs(attrs) {
24576 this.attr(attrs);
24577 return attrs;
24578 },
24579 setZIndex: function setZIndex(zIndex) {
24580 this.__cfg.zIndex = zIndex;
24581 return zIndex;
24582 },
24583 clone: function clone() {
24584 return Util.clone(this);
24585 },
24586 getBBox: function getBBox() {
24587 return {
24588 minX: 0,
24589 maxX: 0,
24590 minY: 0,
24591 maxY: 0
24592 };
24593 }
24594 });
24595
24596 module.exports = Element;
24597
24598 /***/
24599 },
24600 /* 53 */
24601 /***/function (module, exports, __webpack_require__) {
24602
24603 var Util = __webpack_require__(0);
24604 var Shape = __webpack_require__(1);
24605 var Inside = __webpack_require__(3);
24606
24607 var Circle = function Circle(cfg) {
24608 Circle.superclass.constructor.call(this, cfg);
24609 };
24610
24611 Circle.ATTRS = {
24612 x: 0,
24613 y: 0,
24614 r: 0,
24615 lineWidth: 1
24616 };
24617
24618 Util.extend(Circle, Shape);
24619
24620 Util.augment(Circle, {
24621 canFill: true,
24622 canStroke: true,
24623 type: 'circle',
24624 getDefaultAttrs: function getDefaultAttrs() {
24625 return {
24626 lineWidth: 1
24627 };
24628 },
24629 calculateBox: function calculateBox() {
24630 var attrs = this.__attrs;
24631 var cx = attrs.x;
24632 var cy = attrs.y;
24633 var r = attrs.r;
24634 var lineWidth = this.getHitLineWidth();
24635 var halfWidth = lineWidth / 2 + r;
24636 return {
24637 minX: cx - halfWidth,
24638 minY: cy - halfWidth,
24639 maxX: cx + halfWidth,
24640 maxY: cy + halfWidth
24641 };
24642 },
24643 isPointInPath: function isPointInPath(x, y) {
24644 var fill = this.hasFill();
24645 var stroke = this.hasStroke();
24646 if (fill && stroke) {
24647 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
24648 }
24649
24650 if (fill) {
24651 return this._isPointInFill(x, y);
24652 }
24653
24654 if (stroke) {
24655 return this._isPointInStroke(x, y);
24656 }
24657
24658 return false;
24659 },
24660 _isPointInFill: function _isPointInFill(x, y) {
24661 var attrs = this.__attrs;
24662 var cx = attrs.x;
24663 var cy = attrs.y;
24664 var r = attrs.r;
24665
24666 return Inside.circle(cx, cy, r, x, y);
24667 },
24668 _isPointInStroke: function _isPointInStroke(x, y) {
24669 var attrs = this.__attrs;
24670 var cx = attrs.x;
24671 var cy = attrs.y;
24672 var r = attrs.r;
24673 var lineWidth = this.getHitLineWidth();
24674
24675 return Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y);
24676 },
24677 createPath: function createPath(context) {
24678 var attrs = this.__attrs;
24679 var cx = attrs.x;
24680 var cy = attrs.y;
24681 var r = attrs.r;
24682 context = context || self.get('context');
24683
24684 context.beginPath();
24685 context.arc(cx, cy, r, 0, Math.PI * 2, false);
24686 }
24687 });
24688
24689 module.exports = Circle;
24690
24691 /***/
24692 },
24693 /* 54 */
24694 /***/function (module, exports, __webpack_require__) {
24695
24696 var Util = __webpack_require__(0);
24697 var Shape = __webpack_require__(1);
24698 var Inside = __webpack_require__(3);
24699 var mat3 = __webpack_require__(2).mat3;
24700 var vec3 = __webpack_require__(2).vec3;
24701
24702 var Ellipse = function Ellipse(cfg) {
24703 Ellipse.superclass.constructor.call(this, cfg);
24704 };
24705
24706 Ellipse.ATTRS = {
24707 x: 0,
24708 y: 0,
24709 rx: 1,
24710 ry: 1,
24711 lineWidth: 1
24712 };
24713
24714 Util.extend(Ellipse, Shape);
24715
24716 Util.augment(Ellipse, {
24717 canFill: true,
24718 canStroke: true,
24719 type: 'ellipse',
24720 getDefaultAttrs: function getDefaultAttrs() {
24721 return {
24722 lineWidth: 1
24723 };
24724 },
24725 calculateBox: function calculateBox() {
24726 var attrs = this.__attrs;
24727 var cx = attrs.x;
24728 var cy = attrs.y;
24729 var rx = attrs.rx;
24730 var ry = attrs.ry;
24731 var lineWidth = this.getHitLineWidth();
24732 var halfXWidth = rx + lineWidth / 2;
24733 var halfYWidth = ry + lineWidth / 2;
24734
24735 return {
24736 minX: cx - halfXWidth,
24737 minY: cy - halfYWidth,
24738 maxX: cx + halfXWidth,
24739 maxY: cy + halfYWidth
24740 };
24741 },
24742 isPointInPath: function isPointInPath(x, y) {
24743 var fill = this.hasFill();
24744 var stroke = this.hasStroke();
24745
24746 if (fill && stroke) {
24747 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
24748 }
24749
24750 if (fill) {
24751 return this._isPointInFill(x, y);
24752 }
24753
24754 if (stroke) {
24755 return this._isPointInStroke(x, y);
24756 }
24757
24758 return false;
24759 },
24760 _isPointInFill: function _isPointInFill(x, y) {
24761 var attrs = this.__attrs;
24762 var cx = attrs.x;
24763 var cy = attrs.y;
24764 var rx = attrs.rx;
24765 var ry = attrs.ry;
24766
24767 var r = rx > ry ? rx : ry;
24768 var scaleX = rx > ry ? 1 : rx / ry;
24769 var scaleY = rx > ry ? ry / rx : 1;
24770
24771 var p = [x, y, 1];
24772 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
24773 mat3.scale(m, m, [scaleX, scaleY]);
24774 mat3.translate(m, m, [cx, cy]);
24775 var inm = mat3.invert([], m);
24776 vec3.transformMat3(p, p, inm);
24777
24778 return Inside.circle(0, 0, r, p[0], p[1]);
24779 },
24780 _isPointInStroke: function _isPointInStroke(x, y) {
24781 var attrs = this.__attrs;
24782 var cx = attrs.x;
24783 var cy = attrs.y;
24784 var rx = attrs.rx;
24785 var ry = attrs.ry;
24786 var lineWidth = this.getHitLineWidth();
24787
24788 var r = rx > ry ? rx : ry;
24789 var scaleX = rx > ry ? 1 : rx / ry;
24790 var scaleY = rx > ry ? ry / rx : 1;
24791 var p = [x, y, 1];
24792 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
24793 mat3.scale(m, m, [scaleX, scaleY]);
24794 mat3.translate(m, m, [cx, cy]);
24795 var inm = mat3.invert([], m);
24796 vec3.transformMat3(p, p, inm);
24797
24798 return Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]);
24799 },
24800 createPath: function createPath(context) {
24801 var attrs = this.__attrs;
24802 var cx = attrs.x;
24803 var cy = attrs.y;
24804 var rx = attrs.rx;
24805 var ry = attrs.ry;
24806
24807 context = context || self.get('context');
24808 var r = rx > ry ? rx : ry;
24809 var scaleX = rx > ry ? 1 : rx / ry;
24810 var scaleY = rx > ry ? ry / rx : 1;
24811
24812 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
24813 mat3.scale(m, m, [scaleX, scaleY]);
24814 mat3.translate(m, m, [cx, cy]);
24815 context.beginPath();
24816 context.save();
24817 context.transform(m[0], m[1], m[3], m[4], m[6], m[7]);
24818 context.arc(0, 0, r, 0, Math.PI * 2);
24819 context.restore();
24820 context.closePath();
24821 }
24822 });
24823
24824 module.exports = Ellipse;
24825
24826 /***/
24827 },
24828 /* 55 */
24829 /***/function (module, exports, __webpack_require__) {
24830
24831 var Util = __webpack_require__(0);
24832 var Shape = __webpack_require__(1);
24833 var PathSegment = __webpack_require__(24);
24834 var Format = __webpack_require__(19);
24835 var Arrow = __webpack_require__(6);
24836 var PathUtil = __webpack_require__(13);
24837 var CubicMath = __webpack_require__(10);
24838
24839 var Path = function Path(cfg) {
24840 Path.superclass.constructor.call(this, cfg);
24841 };
24842
24843 Path.ATTRS = {
24844 path: null,
24845 lineWidth: 1,
24846 curve: null, // 曲线path
24847 tCache: null,
24848 startArrow: false,
24849 endArrow: false
24850 };
24851
24852 Util.extend(Path, Shape);
24853
24854 Util.augment(Path, {
24855 canFill: true,
24856 canStroke: true,
24857 type: 'path',
24858 getDefaultAttrs: function getDefaultAttrs() {
24859 return {
24860 lineWidth: 1,
24861 startArrow: false,
24862 endArrow: false
24863 };
24864 },
24865 _afterSetAttrPath: function _afterSetAttrPath(path) {
24866 var self = this;
24867 if (Util.isNil(path)) {
24868 self.setSilent('segments', null);
24869 self.setSilent('box', undefined);
24870 return;
24871 }
24872 var pathArray = Format.parsePath(path);
24873 var preSegment = void 0;
24874 var segments = [];
24875
24876 if (!Util.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {
24877 return;
24878 }
24879 var count = pathArray.length;
24880 for (var i = 0; i < pathArray.length; i++) {
24881 var item = pathArray[i];
24882 preSegment = new PathSegment(item, preSegment, i === count - 1);
24883 segments.push(preSegment);
24884 }
24885 self.setSilent('segments', segments);
24886 self.set('tCache', null);
24887 this.setSilent('box', null);
24888 },
24889 _afterSetAttrAll: function _afterSetAttrAll(objs) {
24890 if (objs.path) {
24891 this._afterSetAttrPath(objs.path);
24892 }
24893 },
24894 calculateBox: function calculateBox() {
24895 var self = this;
24896 var segments = self.get('segments');
24897
24898 if (!segments) {
24899 return null;
24900 }
24901 var lineWidth = this.getHitLineWidth();
24902 var minX = Infinity;
24903 var maxX = -Infinity;
24904 var minY = Infinity;
24905 var maxY = -Infinity;
24906 Util.each(segments, function (segment) {
24907 segment.getBBox(lineWidth);
24908 var box = segment.box;
24909 if (box) {
24910 if (box.minX < minX) {
24911 minX = box.minX;
24912 }
24913
24914 if (box.maxX > maxX) {
24915 maxX = box.maxX;
24916 }
24917
24918 if (box.minY < minY) {
24919 minY = box.minY;
24920 }
24921
24922 if (box.maxY > maxY) {
24923 maxY = box.maxY;
24924 }
24925 }
24926 });
24927 return {
24928 minX: minX,
24929 minY: minY,
24930 maxX: maxX,
24931 maxY: maxY
24932 };
24933 },
24934 isPointInPath: function isPointInPath(x, y) {
24935 var self = this;
24936 var fill = self.hasFill();
24937 var stroke = self.hasStroke();
24938
24939 if (fill && stroke) {
24940 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
24941 }
24942
24943 if (fill) {
24944 return self._isPointInFill(x, y);
24945 }
24946
24947 if (stroke) {
24948 return self._isPointInStroke(x, y);
24949 }
24950
24951 return false;
24952 },
24953 _isPointInFill: function _isPointInFill(x, y) {
24954 var self = this;
24955 var context = self.get('context');
24956 if (!context) return undefined;
24957 self.createPath();
24958 return context.isPointInPath(x, y);
24959 },
24960 _isPointInStroke: function _isPointInStroke(x, y) {
24961 var self = this;
24962 var segments = self.get('segments');
24963 if (!Util.isEmpty(segments)) {
24964 var lineWidth = self.getHitLineWidth();
24965 for (var i = 0, l = segments.length; i < l; i++) {
24966 if (segments[i].isInside(x, y, lineWidth)) {
24967 return true;
24968 }
24969 }
24970 }
24971
24972 return false;
24973 },
24974 _setTcache: function _setTcache() {
24975 var totalLength = 0;
24976 var tempLength = 0;
24977 var tCache = [];
24978 var segmentT = void 0;
24979 var segmentL = void 0;
24980 var segmentN = void 0;
24981 var l = void 0;
24982 var curve = this.curve;
24983
24984 if (!curve) {
24985 return;
24986 }
24987
24988 Util.each(curve, function (segment, i) {
24989 segmentN = curve[i + 1];
24990 l = segment.length;
24991 if (segmentN) {
24992 totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
24993 }
24994 });
24995
24996 Util.each(curve, function (segment, i) {
24997 segmentN = curve[i + 1];
24998 l = segment.length;
24999 if (segmentN) {
25000 segmentT = [];
25001 segmentT[0] = tempLength / totalLength;
25002 segmentL = CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
25003 tempLength += segmentL;
25004 segmentT[1] = tempLength / totalLength;
25005 tCache.push(segmentT);
25006 }
25007 });
25008
25009 this.tCache = tCache;
25010 },
25011 _calculateCurve: function _calculateCurve() {
25012 var self = this;
25013 var attrs = self.__attrs;
25014 var path = attrs.path;
25015 this.curve = PathUtil.pathTocurve(path);
25016 },
25017 getPoint: function getPoint(t) {
25018 var tCache = this.tCache;
25019 var subt = void 0;
25020 var index = void 0;
25021
25022 if (!tCache) {
25023 this._calculateCurve();
25024 this._setTcache();
25025 tCache = this.tCache;
25026 }
25027
25028 var curve = this.curve;
25029
25030 if (!tCache) {
25031 if (curve) {
25032 return {
25033 x: curve[0][1],
25034 y: curve[0][2]
25035 };
25036 }
25037 return null;
25038 }
25039 Util.each(tCache, function (v, i) {
25040 if (t >= v[0] && t <= v[1]) {
25041 subt = (t - v[0]) / (v[1] - v[0]);
25042 index = i;
25043 }
25044 });
25045 var seg = curve[index];
25046 if (Util.isNil(seg) || Util.isNil(index)) {
25047 return null;
25048 }
25049 var l = seg.length;
25050 var nextSeg = curve[index + 1];
25051 return {
25052 x: CubicMath.at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
25053 y: CubicMath.at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
25054 };
25055 },
25056 createPath: function createPath(context) {
25057 var self = this;
25058 var segments = self.get('segments');
25059 if (!Util.isArray(segments)) return;
25060
25061 context = context || self.get('context');
25062
25063 context.beginPath();
25064 var segmentsLen = segments.length;
25065
25066 for (var i = 0; i < segmentsLen; i++) {
25067 segments[i].draw(context);
25068 }
25069 },
25070 afterPath: function afterPath(context) {
25071 var self = this;
25072 var attrs = self.__attrs;
25073 var segments = self.get('segments');
25074 var path = attrs.path;
25075 var startPoint = void 0,
25076 endPoint = void 0,
25077 tangent = void 0;
25078 context = context || self.get('context');
25079 if (!Util.isArray(segments)) return;
25080 if (!attrs.startArrow && !attrs.endArrow) {
25081 return;
25082 }
25083 if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) {
25084 // 闭合路径不绘制箭头
25085 return;
25086 }
25087 var segmentsLen = segments.length;
25088 if (segmentsLen > 1) {
25089 startPoint = segments[0].endPoint;
25090 endPoint = segments[1].endPoint;
25091 tangent = segments[1].startTangent;
25092 if (Util.isFunction(tangent)) {
25093 var v = tangent();
25094 Arrow.addStartArrow(context, attrs, startPoint.x - v[0], startPoint.y - v[1], startPoint.x, startPoint.y);
25095 } else {
25096 Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y);
25097 }
25098 }
25099
25100 if (segmentsLen > 1 && !closed) {
25101 startPoint = segments[segmentsLen - 2].endPoint;
25102 endPoint = segments[segmentsLen - 1].endPoint;
25103 tangent = segments[segmentsLen - 1].endTangent;
25104 if (Util.isFunction(tangent)) {
25105 var _v = tangent();
25106 Arrow.addEndArrow(context, attrs, endPoint.x - _v[0], endPoint.y - _v[1], endPoint.x, endPoint.y, tangent());
25107 } else {
25108 Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y);
25109 }
25110 }
25111 }
25112 });
25113
25114 module.exports = Path;
25115
25116 /***/
25117 },
25118 /* 56 */
25119 /***/function (module, exports, __webpack_require__) {
25120
25121 var Util = __webpack_require__(0);
25122 var Shape = __webpack_require__(1);
25123 var Inside = __webpack_require__(3);
25124
25125 var CText = function CText(cfg) {
25126 CText.superclass.constructor.call(this, cfg);
25127 };
25128
25129 CText.ATTRS = {
25130 x: 0,
25131 y: 0,
25132 text: null,
25133 fontSize: 12,
25134 fontFamily: 'sans-serif',
25135 fontStyle: 'normal',
25136 fontWeight: 'normal',
25137 fontVariant: 'normal',
25138 textAlign: 'start',
25139 textBaseline: 'bottom',
25140 lineHeight: null,
25141 textArr: null
25142 };
25143
25144 Util.extend(CText, Shape);
25145
25146 Util.augment(CText, {
25147 canFill: true,
25148 canStroke: true,
25149 type: 'text',
25150 getDefaultAttrs: function getDefaultAttrs() {
25151 return {
25152 lineWidth: 1,
25153 lineCount: 1,
25154 fontSize: 12,
25155 fontFamily: 'sans-serif',
25156 fontStyle: 'normal',
25157 fontWeight: 'normal',
25158 fontVariant: 'normal',
25159 textAlign: 'start',
25160 textBaseline: 'bottom'
25161 };
25162 },
25163 initTransform: function initTransform() {
25164 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
25165 var fontSize = this.__attrs.fontSize;
25166 if (fontSize && +fontSize < 12) {
25167 // 小于 12 像素的文本进行 scale 处理
25168 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
25169 }
25170 },
25171 _assembleFont: function _assembleFont() {
25172 // var self = this;
25173 var attrs = this.__attrs;
25174 var fontSize = attrs.fontSize;
25175 var fontFamily = attrs.fontFamily;
25176 var fontWeight = attrs.fontWeight;
25177 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
25178 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
25179 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
25180 attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
25181 },
25182 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
25183 /* this.attr({
25184 height: this.__getTextHeight()
25185 }); */
25186 this._assembleFont();
25187 },
25188 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
25189 this._assembleFont();
25190 },
25191 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
25192 this._assembleFont();
25193 },
25194 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
25195 this._assembleFont();
25196 },
25197 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
25198 this._assembleFont();
25199 },
25200 _afterSetAttrFont: function _afterSetAttrFont() {
25201 // this.attr('width', this.measureText());
25202 },
25203 _afterSetAttrText: function _afterSetAttrText() {
25204 var attrs = this.__attrs;
25205 var text = attrs.text;
25206 var textArr = void 0;
25207 if (Util.isString(text) && text.indexOf('\n') !== -1) {
25208 textArr = text.split('\n');
25209 var lineCount = textArr.length;
25210 attrs.lineCount = lineCount;
25211 attrs.textArr = textArr;
25212 }
25213 // attrs.height = this.__getTextHeight();
25214 // attrs.width = this.measureText();
25215 },
25216 _getTextHeight: function _getTextHeight() {
25217 var attrs = this.__attrs;
25218 var lineCount = attrs.lineCount;
25219 var fontSize = attrs.fontSize * 1;
25220 if (lineCount > 1) {
25221 var spaceingY = this._getSpaceingY();
25222 return fontSize * lineCount + spaceingY * (lineCount - 1);
25223 }
25224 return fontSize;
25225 },
25226
25227 // 计算浪费,效率低,待优化
25228 _afterSetAttrAll: function _afterSetAttrAll(objs) {
25229 var self = this;
25230 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
25231 self._assembleFont();
25232 }
25233
25234 if ('text' in objs) {
25235 self._afterSetAttrText(objs.text);
25236 }
25237 },
25238 isHitBox: function isHitBox() {
25239 return false;
25240 },
25241 calculateBox: function calculateBox() {
25242 var self = this;
25243 var attrs = self.__attrs;
25244 var x = attrs.x;
25245 var y = attrs.y;
25246 var width = self.measureText(); // attrs.width
25247 if (!width) {
25248 // 如果width不存在,四点共其实点
25249 return {
25250 minX: x,
25251 minY: y,
25252 maxX: x,
25253 maxY: y
25254 };
25255 }
25256 var height = self._getTextHeight(); // attrs.height
25257 var textAlign = attrs.textAlign;
25258 var textBaseline = attrs.textBaseline;
25259 var lineWidth = self.getHitLineWidth();
25260 var point = {
25261 x: x,
25262 y: y - height
25263 };
25264
25265 if (textAlign) {
25266 if (textAlign === 'end' || textAlign === 'right') {
25267 point.x -= width;
25268 } else if (textAlign === 'center') {
25269 point.x -= width / 2;
25270 }
25271 }
25272
25273 if (textBaseline) {
25274 if (textBaseline === 'top') {
25275 point.y += height;
25276 } else if (textBaseline === 'middle') {
25277 point.y += height / 2;
25278 }
25279 }
25280
25281 this.set('startPoint', point);
25282 var halfWidth = lineWidth / 2;
25283 return {
25284 minX: point.x - halfWidth,
25285 minY: point.y - halfWidth,
25286 maxX: point.x + width + halfWidth,
25287 maxY: point.y + height + halfWidth
25288 };
25289 },
25290 _getSpaceingY: function _getSpaceingY() {
25291 var attrs = this.__attrs;
25292 var lineHeight = attrs.lineHeight;
25293 var fontSize = attrs.fontSize * 1;
25294 return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
25295 },
25296 isPointInPath: function isPointInPath(x, y) {
25297 var self = this;
25298 var box = self.getBBox();
25299 if (self.hasFill() || self.hasStroke()) {
25300 return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y);
25301 }
25302 },
25303 drawInner: function drawInner(context) {
25304 var self = this;
25305 var attrs = self.__attrs;
25306 var text = attrs.text;
25307 if (!text) {
25308 return;
25309 }
25310 var textArr = attrs.textArr;
25311 var x = attrs.x;
25312 var y = attrs.y;
25313
25314 context.beginPath();
25315 if (self.hasStroke()) {
25316 if (textArr) {
25317 self._drawTextArr(context, false);
25318 } else {
25319 context.strokeText(text, x, y);
25320 }
25321 }
25322 if (self.hasFill()) {
25323 var fillOpacity = attrs.fillOpacity;
25324 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
25325 context.globalAlpha = fillOpacity;
25326 }
25327 if (textArr) {
25328 self._drawTextArr(context, true);
25329 } else {
25330 context.fillText(text, x, y);
25331 }
25332 }
25333 },
25334 _drawTextArr: function _drawTextArr(context, fill) {
25335 var textArr = this.__attrs.textArr;
25336 var textBaseline = this.__attrs.textBaseline;
25337 var fontSize = this.__attrs.fontSize * 1;
25338 var spaceingY = this._getSpaceingY();
25339 var x = this.__attrs.x;
25340 var y = this.__attrs.y;
25341 var box = this.getBBox();
25342 var height = box.maxY - box.minY;
25343 var subY = void 0;
25344
25345 Util.each(textArr, function (subText, index) {
25346 subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;
25347 if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;
25348 if (textBaseline === 'top') subY += height - fontSize;
25349 if (fill) {
25350 context.fillText(subText, x, subY);
25351 } else {
25352 context.strokeText(subText, x, subY);
25353 }
25354 });
25355 },
25356 measureText: function measureText() {
25357 var self = this;
25358 var attrs = self.__attrs;
25359 var text = attrs.text;
25360 var font = attrs.font;
25361 var textArr = attrs.textArr;
25362 var measureWidth = void 0;
25363 var width = 0;
25364
25365 if (Util.isNil(text)) return undefined;
25366 var context = document.createElement('canvas').getContext('2d');
25367 context.save();
25368 context.font = font;
25369 if (textArr) {
25370 Util.each(textArr, function (subText) {
25371 measureWidth = context.measureText(subText).width;
25372 if (width < measureWidth) {
25373 width = measureWidth;
25374 }
25375 context.restore();
25376 });
25377 } else {
25378 width = context.measureText(text).width;
25379 context.restore();
25380 }
25381 return width;
25382 }
25383 });
25384
25385 module.exports = CText;
25386
25387 /***/
25388 },
25389 /* 57 */
25390 /***/function (module, exports, __webpack_require__) {
25391
25392 var Util = __webpack_require__(0);
25393 var Shape = __webpack_require__(1);
25394 var Inside = __webpack_require__(3);
25395 var Arrow = __webpack_require__(6);
25396 var LineMath = __webpack_require__(20);
25397
25398 var Line = function Line(cfg) {
25399 Line.superclass.constructor.call(this, cfg);
25400 };
25401
25402 Line.ATTRS = {
25403 x1: 0,
25404 y1: 0,
25405 x2: 0,
25406 y2: 0,
25407 lineWidth: 1,
25408 startArrow: false,
25409 endArrow: false
25410 };
25411
25412 Util.extend(Line, Shape);
25413
25414 Util.augment(Line, {
25415 canStroke: true,
25416 type: 'line',
25417 getDefaultAttrs: function getDefaultAttrs() {
25418 return {
25419 lineWidth: 1,
25420 startArrow: false,
25421 endArrow: false
25422 };
25423 },
25424 calculateBox: function calculateBox() {
25425 var attrs = this.__attrs;
25426 var x1 = attrs.x1,
25427 y1 = attrs.y1,
25428 x2 = attrs.x2,
25429 y2 = attrs.y2;
25430
25431 var lineWidth = this.getHitLineWidth();
25432 return LineMath.box(x1, y1, x2, y2, lineWidth);
25433 },
25434 isPointInPath: function isPointInPath(x, y) {
25435 var attrs = this.__attrs;
25436 var x1 = attrs.x1,
25437 y1 = attrs.y1,
25438 x2 = attrs.x2,
25439 y2 = attrs.y2;
25440
25441 var lineWidth = this.getHitLineWidth();
25442
25443 if (this.hasStroke()) {
25444 return Inside.line(x1, y1, x2, y2, lineWidth, x, y);
25445 }
25446
25447 return false;
25448 },
25449 createPath: function createPath(context) {
25450 var attrs = this.__attrs;
25451 var x1 = attrs.x1,
25452 y1 = attrs.y1,
25453 x2 = attrs.x2,
25454 y2 = attrs.y2;
25455
25456 context = context || self.get('context');
25457 context.beginPath();
25458 context.moveTo(x1, y1);
25459 context.lineTo(x2, y2);
25460 },
25461 afterPath: function afterPath(context) {
25462 var attrs = this.__attrs;
25463 var x1 = attrs.x1,
25464 y1 = attrs.y1,
25465 x2 = attrs.x2,
25466 y2 = attrs.y2;
25467
25468 context = context || this.get('context');
25469 if (attrs.startArrow) {
25470 Arrow.addStartArrow(context, attrs, x2, y2, x1, y1);
25471 }
25472 if (attrs.endArrow) {
25473 Arrow.addEndArrow(context, attrs, x1, y1, x2, y2);
25474 }
25475 },
25476 getPoint: function getPoint(t) {
25477 var attrs = this.__attrs;
25478 return {
25479 x: LineMath.at(attrs.x1, attrs.x2, t),
25480 y: LineMath.at(attrs.y1, attrs.y2, t)
25481 };
25482 }
25483 });
25484
25485 module.exports = Line;
25486
25487 /***/
25488 },
25489 /* 58 */
25490 /***/function (module, exports, __webpack_require__) {
25491
25492 var Util = __webpack_require__(0);
25493 var Shape = __webpack_require__(1);
25494 var Inside = __webpack_require__(3);
25495
25496 var CImage = function CImage(cfg) {
25497 CImage.superclass.constructor.call(this, cfg);
25498 };
25499
25500 CImage.ATTRS = {
25501 x: 0,
25502 y: 0,
25503 img: undefined,
25504 width: 0,
25505 height: 0,
25506 sx: null,
25507 sy: null,
25508 swidth: null,
25509 sheight: null
25510 };
25511
25512 Util.extend(CImage, Shape);
25513
25514 Util.augment(CImage, {
25515 type: 'image',
25516 _afterSetAttrImg: function _afterSetAttrImg(img) {
25517 this._setAttrImg(img);
25518 },
25519 _afterSetAttrAll: function _afterSetAttrAll(params) {
25520 if (params.img) {
25521 this._setAttrImg(params.img);
25522 }
25523 },
25524 isHitBox: function isHitBox() {
25525 return false;
25526 },
25527 calculateBox: function calculateBox() {
25528 var attrs = this.__attrs;
25529 var x = attrs.x;
25530 var y = attrs.y;
25531 var width = attrs.width;
25532 var height = attrs.height;
25533
25534 return {
25535 minX: x,
25536 minY: y,
25537 maxX: x + width,
25538 maxY: y + height
25539 };
25540 },
25541 isPointInPath: function isPointInPath(x, y) {
25542 var attrs = this.__attrs;
25543 if (this.get('toDraw') || !attrs.img) {
25544 return false;
25545 }
25546 var rx = attrs.x;
25547 var ry = attrs.y;
25548 var width = attrs.width;
25549 var height = attrs.height;
25550 return Inside.rect(rx, ry, width, height, x, y);
25551 },
25552 _beforeSetLoading: function _beforeSetLoading(loading) {
25553 var canvas = this.get('canvas');
25554 if (loading === false && this.get('toDraw') === true) {
25555 this.__cfg.loading = false;
25556 canvas.draw();
25557 }
25558 return loading;
25559 },
25560 _setAttrImg: function _setAttrImg(img) {
25561 var self = this;
25562 var attrs = self.__attrs;
25563 if (Util.isString(img)) {
25564 var image = new Image();
25565 image.onload = function () {
25566 if (self.get('destroyed')) return false;
25567 self.attr('imgSrc', img);
25568 self.attr('img', image);
25569 var callback = self.get('callback');
25570 if (callback) {
25571 callback.call(self);
25572 }
25573 self.set('loading', false);
25574 };
25575 image.src = img;
25576 self.set('loading', true);
25577 } else if (img instanceof Image) {
25578 if (!attrs.width) {
25579 self.attr('width', img.width);
25580 }
25581
25582 if (!attrs.height) {
25583 self.attr('height', img.height);
25584 }
25585 return img;
25586 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
25587 if (!attrs.width) {
25588 self.attr('width', Number(img.getAttribute('width')));
25589 }
25590
25591 if (!attrs.height) {
25592 self.attr('height', Number(img.getAttribute('height')));
25593 }
25594 return img;
25595 } else if (img instanceof ImageData) {
25596 if (!attrs.width) {
25597 self.attr('width', img.width);
25598 }
25599
25600 if (!attrs.height) {
25601 self.attr('height', img.height);
25602 }
25603 return img;
25604 } else {
25605 return null;
25606 }
25607 },
25608 drawInner: function drawInner(context) {
25609 if (this.get('loading')) {
25610 this.set('toDraw', true);
25611 return;
25612 }
25613 this._drawImage(context);
25614 },
25615 _drawImage: function _drawImage(context) {
25616 var attrs = this.__attrs;
25617 var x = attrs.x;
25618 var y = attrs.y;
25619 var image = attrs.img;
25620 var width = attrs.width;
25621 var height = attrs.height;
25622 var sx = attrs.sx;
25623 var sy = attrs.sy;
25624 var swidth = attrs.swidth;
25625 var sheight = attrs.sheight;
25626 this.set('toDraw', false);
25627
25628 var img = image;
25629 if (img instanceof ImageData) {
25630 img = new Image();
25631 img.src = image;
25632 }
25633 if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
25634 if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) {
25635 context.drawImage(img, x, y, width, height);
25636 return;
25637 }
25638 if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) {
25639 context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);
25640 return;
25641 }
25642 }
25643 return;
25644 }
25645 });
25646
25647 module.exports = CImage;
25648
25649 /***/
25650 },
25651 /* 59 */
25652 /***/function (module, exports, __webpack_require__) {
25653
25654 var Util = __webpack_require__(0);
25655 var Shape = __webpack_require__(1);
25656 var Inside = __webpack_require__(3);
25657
25658 var Polygon = function Polygon(cfg) {
25659 Polygon.superclass.constructor.call(this, cfg);
25660 };
25661
25662 Polygon.ATTRS = {
25663 points: null,
25664 lineWidth: 1
25665 };
25666
25667 Util.extend(Polygon, Shape);
25668
25669 Util.augment(Polygon, {
25670 canFill: true,
25671 canStroke: true,
25672 type: 'polygon',
25673 getDefaultAttrs: function getDefaultAttrs() {
25674 return {
25675 lineWidth: 1
25676 };
25677 },
25678 calculateBox: function calculateBox() {
25679 var self = this;
25680 var attrs = self.__attrs;
25681 var points = attrs.points;
25682 var lineWidth = this.getHitLineWidth();
25683 if (!points || points.length === 0) {
25684 return null;
25685 }
25686 var minX = Infinity;
25687 var minY = Infinity;
25688 var maxX = -Infinity;
25689 var maxY = -Infinity;
25690
25691 Util.each(points, function (point) {
25692 var x = point[0];
25693 var y = point[1];
25694 if (x < minX) {
25695 minX = x;
25696 }
25697 if (x > maxX) {
25698 maxX = x;
25699 }
25700
25701 if (y < minY) {
25702 minY = y;
25703 }
25704
25705 if (y > maxY) {
25706 maxY = y;
25707 }
25708 });
25709
25710 var halfWidth = lineWidth / 2;
25711 return {
25712 minX: minX - halfWidth,
25713 minY: minY - halfWidth,
25714 maxX: maxX + halfWidth,
25715 maxY: maxY + halfWidth
25716 };
25717 },
25718 isPointInPath: function isPointInPath(x, y) {
25719 var self = this;
25720 var fill = self.hasFill();
25721 var stroke = self.hasStroke();
25722
25723 if (fill && stroke) {
25724 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
25725 }
25726
25727 if (fill) {
25728 return self._isPointInFill(x, y);
25729 }
25730
25731 if (stroke) {
25732 return self._isPointInStroke(x, y);
25733 }
25734
25735 return false;
25736 },
25737 _isPointInFill: function _isPointInFill(x, y) {
25738 var self = this;
25739 var context = self.get('context');
25740 self.createPath();
25741 return context.isPointInPath(x, y);
25742 },
25743 _isPointInStroke: function _isPointInStroke(x, y) {
25744 var self = this;
25745 var attrs = self.__attrs;
25746 var points = attrs.points;
25747 if (points.length < 2) {
25748 return false;
25749 }
25750 var lineWidth = this.getHitLineWidth();
25751 var outPoints = points.slice(0);
25752 if (points.length >= 3) {
25753 outPoints.push(points[0]);
25754 }
25755
25756 return Inside.polyline(outPoints, lineWidth, x, y);
25757 },
25758 createPath: function createPath(context) {
25759 var self = this;
25760 var attrs = self.__attrs;
25761 var points = attrs.points;
25762 if (points.length < 2) {
25763 return;
25764 }
25765 context = context || self.get('context');
25766 context.beginPath();
25767 Util.each(points, function (point, index) {
25768 if (index === 0) {
25769 context.moveTo(point[0], point[1]);
25770 } else {
25771 context.lineTo(point[0], point[1]);
25772 }
25773 });
25774 context.closePath();
25775 }
25776 });
25777
25778 module.exports = Polygon;
25779
25780 /***/
25781 },
25782 /* 60 */
25783 /***/function (module, exports, __webpack_require__) {
25784
25785 var Util = __webpack_require__(0);
25786 var Shape = __webpack_require__(1);
25787 var Inside = __webpack_require__(3);
25788 var Arrow = __webpack_require__(6);
25789 var LineMath = __webpack_require__(20);
25790
25791 var Polyline = function Polyline(cfg) {
25792 Polyline.superclass.constructor.call(this, cfg);
25793 };
25794
25795 Polyline.ATTRS = {
25796 points: null,
25797 lineWidth: 1,
25798 startArrow: false,
25799 endArrow: false,
25800 tCache: null
25801 };
25802
25803 Util.extend(Polyline, Shape);
25804
25805 Util.augment(Polyline, {
25806 canStroke: true,
25807 type: 'polyline',
25808 tCache: null, // 缓存各点的t
25809 getDefaultAttrs: function getDefaultAttrs() {
25810 return {
25811 lineWidth: 1,
25812 startArrow: false,
25813 endArrow: false
25814 };
25815 },
25816 calculateBox: function calculateBox() {
25817 var self = this;
25818 var attrs = self.__attrs;
25819 var lineWidth = this.getHitLineWidth();
25820 var points = attrs.points;
25821 if (!points || points.length === 0) {
25822 return null;
25823 }
25824 var minX = Infinity;
25825 var minY = Infinity;
25826 var maxX = -Infinity;
25827 var maxY = -Infinity;
25828
25829 Util.each(points, function (point) {
25830 var x = point[0];
25831 var y = point[1];
25832 if (x < minX) {
25833 minX = x;
25834 }
25835 if (x > maxX) {
25836 maxX = x;
25837 }
25838
25839 if (y < minY) {
25840 minY = y;
25841 }
25842
25843 if (y > maxY) {
25844 maxY = y;
25845 }
25846 });
25847
25848 var halfWidth = lineWidth / 2;
25849 return {
25850 minX: minX - halfWidth,
25851 minY: minY - halfWidth,
25852 maxX: maxX + halfWidth,
25853 maxY: maxY + halfWidth
25854 };
25855 },
25856 _setTcache: function _setTcache() {
25857 var self = this;
25858 var attrs = self.__attrs;
25859 var points = attrs.points;
25860 var totalLength = 0;
25861 var tempLength = 0;
25862 var tCache = [];
25863 var segmentT = void 0;
25864 var segmentL = void 0;
25865 if (!points || points.length === 0) {
25866 return;
25867 }
25868
25869 Util.each(points, function (p, i) {
25870 if (points[i + 1]) {
25871 totalLength += LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
25872 }
25873 });
25874 if (totalLength <= 0) {
25875 return;
25876 }
25877 Util.each(points, function (p, i) {
25878 if (points[i + 1]) {
25879 segmentT = [];
25880 segmentT[0] = tempLength / totalLength;
25881 segmentL = LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
25882 tempLength += segmentL;
25883 segmentT[1] = tempLength / totalLength;
25884 tCache.push(segmentT);
25885 }
25886 });
25887 this.tCache = tCache;
25888 },
25889 isPointInPath: function isPointInPath(x, y) {
25890 var self = this;
25891 var attrs = self.__attrs;
25892 if (self.hasStroke()) {
25893 var points = attrs.points;
25894 if (points.length < 2) {
25895 return false;
25896 }
25897 var lineWidth = attrs.lineWidth;
25898 return Inside.polyline(points, lineWidth, x, y);
25899 }
25900 return false;
25901 },
25902 createPath: function createPath(context) {
25903 var self = this;
25904 var attrs = self.__attrs;
25905 var points = attrs.points;
25906 var l = void 0;
25907 var i = void 0;
25908
25909 if (points.length < 2) {
25910 return;
25911 }
25912 context = context || self.get('context');
25913 context.beginPath();
25914
25915 context.moveTo(points[0][0], points[0][1]);
25916 for (i = 1, l = points.length - 1; i < l; i++) {
25917 context.lineTo(points[i][0], points[i][1]);
25918 }
25919 context.lineTo(points[l][0], points[l][1]);
25920 },
25921 afterPath: function afterPath(context) {
25922 var self = this;
25923 var attrs = self.__attrs;
25924 var points = attrs.points;
25925 var l = points.length - 1;
25926 context = context || self.get('context');
25927
25928 if (attrs.startArrow) {
25929 Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]);
25930 }
25931 if (attrs.endArrow) {
25932 Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]);
25933 }
25934 },
25935 getPoint: function getPoint(t) {
25936 var attrs = this.__attrs;
25937 var points = attrs.points;
25938 var tCache = this.tCache;
25939 var subt = void 0;
25940 var index = void 0;
25941 if (!tCache) {
25942 this._setTcache();
25943 tCache = this.tCache;
25944 }
25945 Util.each(tCache, function (v, i) {
25946 if (t >= v[0] && t <= v[1]) {
25947 subt = (t - v[0]) / (v[1] - v[0]);
25948 index = i;
25949 }
25950 });
25951 return {
25952 x: LineMath.at(points[index][0], points[index + 1][0], subt),
25953 y: LineMath.at(points[index][1], points[index + 1][1], subt)
25954 };
25955 }
25956 });
25957
25958 module.exports = Polyline;
25959
25960 /***/
25961 },
25962 /* 61 */
25963 /***/function (module, exports, __webpack_require__) {
25964
25965 var Util = __webpack_require__(0);
25966 var Shape = __webpack_require__(1);
25967 var Inside = __webpack_require__(3);
25968 var ArcMath = __webpack_require__(22);
25969 var Arrow = __webpack_require__(6);
25970
25971 function _getArcX(x, radius, angle) {
25972 return x + radius * Math.cos(angle);
25973 }
25974 function _getArcY(y, radius, angle) {
25975 return y + radius * Math.sin(angle);
25976 }
25977
25978 var Arc = function Arc(cfg) {
25979 Arc.superclass.constructor.call(this, cfg);
25980 };
25981
25982 Arc.ATTRS = {
25983 x: 0,
25984 y: 0,
25985 r: 0,
25986 startAngle: 0,
25987 endAngle: 0,
25988 clockwise: false,
25989 lineWidth: 1,
25990 startArrow: false,
25991 endArrow: false
25992 };
25993
25994 Util.extend(Arc, Shape);
25995
25996 Util.augment(Arc, {
25997 canStroke: true,
25998 type: 'arc',
25999 getDefaultAttrs: function getDefaultAttrs() {
26000 return {
26001 x: 0,
26002 y: 0,
26003 r: 0,
26004 startAngle: 0,
26005 endAngle: 0,
26006 clockwise: false,
26007 lineWidth: 1,
26008 startArrow: false,
26009 endArrow: false
26010 };
26011 },
26012 calculateBox: function calculateBox() {
26013 var attrs = this.__attrs;
26014 var x = attrs.x,
26015 y = attrs.y,
26016 r = attrs.r,
26017 startAngle = attrs.startAngle,
26018 endAngle = attrs.endAngle,
26019 clockwise = attrs.clockwise;
26020
26021 var lineWidth = this.getHitLineWidth();
26022 var halfWidth = lineWidth / 2;
26023 var box = ArcMath.box(x, y, r, startAngle, endAngle, clockwise);
26024 box.minX -= halfWidth;
26025 box.minY -= halfWidth;
26026 box.maxX += halfWidth;
26027 box.maxY += halfWidth;
26028 return box;
26029 },
26030 isPointInPath: function isPointInPath(x, y) {
26031 var attrs = this.__attrs;
26032 var cx = attrs.x;
26033 var cy = attrs.y;
26034 var r = attrs.r,
26035 startAngle = attrs.startAngle,
26036 endAngle = attrs.endAngle,
26037 clockwise = attrs.clockwise;
26038
26039 var lineWidth = this.getHitLineWidth();
26040 if (this.hasStroke()) {
26041 return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y);
26042 }
26043 return false;
26044 },
26045 createPath: function createPath(context) {
26046 var attrs = this.__attrs;
26047 var x = attrs.x,
26048 y = attrs.y,
26049 r = attrs.r,
26050 startAngle = attrs.startAngle,
26051 endAngle = attrs.endAngle,
26052 clockwise = attrs.clockwise;
26053
26054 context = context || self.get('context');
26055
26056 context.beginPath();
26057 context.arc(x, y, r, startAngle, endAngle, clockwise);
26058 },
26059 afterPath: function afterPath(context) {
26060 var attrs = this.__attrs;
26061 var x = attrs.x,
26062 y = attrs.y,
26063 r = attrs.r,
26064 startAngle = attrs.startAngle,
26065 endAngle = attrs.endAngle,
26066 clockwise = attrs.clockwise;
26067
26068 context = context || this.get('context');
26069 var diff = void 0;
26070 var x1 = void 0;
26071 var y1 = void 0;
26072 var x2 = void 0;
26073 var y2 = void 0;
26074
26075 if (attrs.startArrow) {
26076 diff = Math.PI / 180;
26077 if (clockwise) {
26078 diff *= -1;
26079 }
26080 x1 = _getArcX(x, r, startAngle + diff);
26081 y1 = _getArcY(y, r, startAngle + diff);
26082 x2 = _getArcX(x, r, startAngle);
26083 y2 = _getArcY(y, r, startAngle);
26084 Arrow.addStartArrow(context, attrs, x1, y1, x2, y2);
26085 }
26086
26087 if (attrs.endArrow) {
26088 diff = Math.PI / 180;
26089 if (clockwise) {
26090 diff *= -1;
26091 }
26092 x1 = _getArcX(x, r, endAngle + diff);
26093 y1 = _getArcY(y, r, endAngle + diff);
26094 x2 = _getArcX(x, r, endAngle);
26095 y2 = _getArcY(y, r, endAngle);
26096 Arrow.addEndArrow(context, attrs, x2, y2, x1, y1);
26097 }
26098 }
26099 });
26100
26101 module.exports = Arc;
26102
26103 /***/
26104 },
26105 /* 62 */
26106 /***/function (module, exports, __webpack_require__) {
26107
26108 var Util = __webpack_require__(0);
26109 var Shape = __webpack_require__(1);
26110 var Inside = __webpack_require__(3);
26111 var ArcMath = __webpack_require__(22);
26112 var vec2 = __webpack_require__(2).vec2;
26113
26114 var Fan = function Fan(cfg) {
26115 Fan.superclass.constructor.call(this, cfg);
26116 };
26117
26118 Fan.ATTRS = {
26119 x: 0,
26120 y: 0,
26121 rs: 0,
26122 re: 0,
26123 startAngle: 0,
26124 endAngle: 0,
26125 clockwise: false,
26126 lineWidth: 1
26127 };
26128
26129 Util.extend(Fan, Shape);
26130
26131 Util.augment(Fan, {
26132 canFill: true,
26133 canStroke: true,
26134 type: 'fan',
26135 getDefaultAttrs: function getDefaultAttrs() {
26136 return {
26137 clockwise: false,
26138 lineWidth: 1,
26139 rs: 0,
26140 re: 0
26141 };
26142 },
26143 calculateBox: function calculateBox() {
26144 var self = this;
26145 var attrs = self.__attrs;
26146 var cx = attrs.x;
26147 var cy = attrs.y;
26148 var rs = attrs.rs;
26149 var re = attrs.re;
26150 var startAngle = attrs.startAngle;
26151 var endAngle = attrs.endAngle;
26152 var clockwise = attrs.clockwise;
26153 var lineWidth = this.getHitLineWidth();
26154
26155 var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise);
26156 var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise);
26157 var minX = Math.min(boxs.minX, boxe.minX);
26158 var minY = Math.min(boxs.minY, boxe.minY);
26159 var maxX = Math.max(boxs.maxX, boxe.maxX);
26160 var maxY = Math.max(boxs.maxY, boxe.maxY);
26161
26162 var halfWidth = lineWidth / 2;
26163 return {
26164 minX: minX - halfWidth,
26165 minY: minY - halfWidth,
26166 maxX: maxX + halfWidth,
26167 maxY: maxY + halfWidth
26168 };
26169 },
26170 isPointInPath: function isPointInPath(x, y) {
26171 var fill = this.hasFill();
26172 var stroke = this.hasStroke();
26173
26174 if (fill && stroke) {
26175 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
26176 }
26177
26178 if (fill) {
26179 return this._isPointInFill(x, y);
26180 }
26181
26182 if (stroke) {
26183 return this._isPointInStroke(x, y);
26184 }
26185 return false;
26186 },
26187 _isPointInFill: function _isPointInFill(x, y) {
26188 var attrs = this.__attrs;
26189 var cx = attrs.x;
26190 var cy = attrs.y;
26191 var rs = attrs.rs;
26192 var re = attrs.re;
26193 var startAngle = attrs.startAngle;
26194 var endAngle = attrs.endAngle;
26195 var clockwise = attrs.clockwise;
26196 var v1 = [1, 0];
26197 var subv = [x - cx, y - cy];
26198 var angle = vec2.angleTo(v1, subv);
26199
26200 var angle1 = ArcMath.nearAngle(angle, startAngle, endAngle, clockwise);
26201
26202 if (Util.isNumberEqual(angle, angle1)) {
26203 var ls = vec2.squaredLength(subv);
26204 if (rs * rs <= ls && ls <= re * re) {
26205 return true;
26206 }
26207 }
26208 return false;
26209 },
26210 _isPointInStroke: function _isPointInStroke(x, y) {
26211 var attrs = this.__attrs;
26212 var cx = attrs.x;
26213 var cy = attrs.y;
26214 var rs = attrs.rs;
26215 var re = attrs.re;
26216 var startAngle = attrs.startAngle;
26217 var endAngle = attrs.endAngle;
26218 var clockwise = attrs.clockwise;
26219 var lineWidth = this.getHitLineWidth();
26220
26221 var ssp = {
26222 x: Math.cos(startAngle) * rs + cx,
26223 y: Math.sin(startAngle) * rs + cy
26224 };
26225 var sep = {
26226 x: Math.cos(startAngle) * re + cx,
26227 y: Math.sin(startAngle) * re + cy
26228 };
26229 var esp = {
26230 x: Math.cos(endAngle) * rs + cx,
26231 y: Math.sin(endAngle) * rs + cy
26232 };
26233 var eep = {
26234 x: Math.cos(endAngle) * re + cx,
26235 y: Math.sin(endAngle) * re + cy
26236 };
26237
26238 if (Inside.line(ssp.x, ssp.y, sep.x, sep.y, lineWidth, x, y)) {
26239 return true;
26240 }
26241
26242 if (Inside.line(esp.x, esp.y, eep.x, eep.y, lineWidth, x, y)) {
26243 return true;
26244 }
26245
26246 if (Inside.arcline(cx, cy, rs, startAngle, endAngle, clockwise, lineWidth, x, y)) {
26247 return true;
26248 }
26249
26250 if (Inside.arcline(cx, cy, re, startAngle, endAngle, clockwise, lineWidth, x, y)) {
26251 return true;
26252 }
26253
26254 return false;
26255 },
26256 createPath: function createPath(context) {
26257 var attrs = this.__attrs;
26258 var cx = attrs.x;
26259 var cy = attrs.y;
26260 var rs = attrs.rs;
26261 var re = attrs.re;
26262 var startAngle = attrs.startAngle;
26263 var endAngle = attrs.endAngle;
26264 var clockwise = attrs.clockwise;
26265
26266 var ssp = {
26267 x: Math.cos(startAngle) * rs + cx,
26268 y: Math.sin(startAngle) * rs + cy
26269 };
26270 var sep = {
26271 x: Math.cos(startAngle) * re + cx,
26272 y: Math.sin(startAngle) * re + cy
26273 };
26274 var esp = {
26275 x: Math.cos(endAngle) * rs + cx,
26276 y: Math.sin(endAngle) * rs + cy
26277 };
26278
26279 context = context || self.get('context');
26280 context.beginPath();
26281 context.moveTo(ssp.x, ssp.y);
26282 context.lineTo(sep.x, sep.y);
26283 context.arc(cx, cy, re, startAngle, endAngle, clockwise);
26284 context.lineTo(esp.x, esp.y);
26285 context.arc(cx, cy, rs, endAngle, startAngle, !clockwise);
26286 context.closePath();
26287 }
26288 });
26289
26290 module.exports = Fan;
26291
26292 /***/
26293 },
26294 /* 63 */
26295 /***/function (module, exports, __webpack_require__) {
26296
26297 var Util = __webpack_require__(0);
26298 var Shape = __webpack_require__(1);
26299 var Inside = __webpack_require__(3);
26300 var Arrow = __webpack_require__(6);
26301 var CubicMath = __webpack_require__(10);
26302
26303 var Cubic = function Cubic(cfg) {
26304 Cubic.superclass.constructor.call(this, cfg);
26305 };
26306
26307 Cubic.ATTRS = {
26308 p1: null, // 起始点
26309 p2: null, // 第一个控制点
26310 p3: null, // 第二个控制点
26311 p4: null, // 终点
26312 lineWidth: 1,
26313 startArrow: false,
26314 endArrow: false
26315 };
26316
26317 Util.extend(Cubic, Shape);
26318
26319 Util.augment(Cubic, {
26320 canStroke: true,
26321 type: 'cubic',
26322 getDefaultAttrs: function getDefaultAttrs() {
26323 return {
26324 lineWidth: 1,
26325 startArrow: false,
26326 endArrow: false
26327 };
26328 },
26329 calculateBox: function calculateBox() {
26330 var attrs = this.__attrs;
26331 var p1 = attrs.p1,
26332 p2 = attrs.p2,
26333 p3 = attrs.p3,
26334 p4 = attrs.p4;
26335
26336 var lineWidth = this.getHitLineWidth();
26337 var i = void 0;
26338 var l = void 0;
26339
26340 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
26341 return null;
26342 }
26343 var halfWidth = lineWidth / 2;
26344
26345 var xDim = CubicMath.extrema(p1[0], p2[0], p3[0], p4[0]);
26346 for (i = 0, l = xDim.length; i < l; i++) {
26347 xDim[i] = CubicMath.at(p1[0], p2[0], p3[0], p4[0], xDim[i]);
26348 }
26349 var yDim = CubicMath.extrema(p1[1], p2[1], p3[1], p4[1]);
26350 for (i = 0, l = yDim.length; i < l; i++) {
26351 yDim[i] = CubicMath.at(p1[1], p2[1], p3[1], p4[1], yDim[i]);
26352 }
26353 xDim.push(p1[0], p4[0]);
26354 yDim.push(p1[1], p4[1]);
26355
26356 return {
26357 minX: Math.min.apply(Math, xDim) - halfWidth,
26358 maxX: Math.max.apply(Math, xDim) + halfWidth,
26359 minY: Math.min.apply(Math, yDim) - halfWidth,
26360 maxY: Math.max.apply(Math, yDim) + halfWidth
26361 };
26362 },
26363 isPointInPath: function isPointInPath(x, y) {
26364 var attrs = this.__attrs;
26365 var p1 = attrs.p1,
26366 p2 = attrs.p2,
26367 p3 = attrs.p3,
26368 p4 = attrs.p4;
26369
26370 var lineWidth = this.getHitLineWidth();
26371 return Inside.cubicline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], p4[0], p4[1], lineWidth, x, y);
26372 },
26373 createPath: function createPath(context) {
26374 var attrs = this.__attrs;
26375 var p1 = attrs.p1,
26376 p2 = attrs.p2,
26377 p3 = attrs.p3,
26378 p4 = attrs.p4;
26379
26380 context = context || self.get('context');
26381 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
26382 return;
26383 }
26384 context.beginPath();
26385 context.moveTo(p1[0], p1[1]);
26386 context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]);
26387 },
26388 afterPath: function afterPath(context) {
26389 var attrs = this.__attrs;
26390 var p1 = attrs.p1,
26391 p2 = attrs.p2,
26392 p3 = attrs.p3,
26393 p4 = attrs.p4;
26394
26395 context = context || this.get('context');
26396 if (attrs.startArrow) {
26397 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
26398 }
26399 if (attrs.endArrow) {
26400 Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]);
26401 }
26402 },
26403 getPoint: function getPoint(t) {
26404 var attrs = this.__attrs;
26405 return {
26406 x: CubicMath.at(attrs.p4[0], attrs.p3[0], attrs.p2[0], attrs.p1[0], t),
26407 y: CubicMath.at(attrs.p4[1], attrs.p3[1], attrs.p2[1], attrs.p1[1], t)
26408 };
26409 }
26410 });
26411
26412 module.exports = Cubic;
26413
26414 /***/
26415 },
26416 /* 64 */
26417 /***/function (module, exports, __webpack_require__) {
26418
26419 var Util = __webpack_require__(0);
26420 var Shape = __webpack_require__(1);
26421 var Inside = __webpack_require__(3);
26422 var Arrow = __webpack_require__(6);
26423 var QuadraticMath = __webpack_require__(21);
26424
26425 var Quadratic = function Quadratic(cfg) {
26426 Quadratic.superclass.constructor.call(this, cfg);
26427 };
26428
26429 Quadratic.ATTRS = {
26430 p1: null, // 起始点
26431 p2: null, // 控制点
26432 p3: null, // 结束点
26433 lineWidth: 1,
26434 startArrow: false,
26435 endArrow: false
26436 };
26437
26438 Util.extend(Quadratic, Shape);
26439
26440 Util.augment(Quadratic, {
26441 canStroke: true,
26442 type: 'quadratic',
26443 getDefaultAttrs: function getDefaultAttrs() {
26444 return {
26445 lineWidth: 1,
26446 startArrow: false,
26447 endArrow: false
26448 };
26449 },
26450 calculateBox: function calculateBox() {
26451 var self = this;
26452 var attrs = self.__attrs;
26453 var p1 = attrs.p1,
26454 p2 = attrs.p2,
26455 p3 = attrs.p3;
26456
26457 var lineWidth = this.getHitLineWidth();
26458 var i = void 0;
26459 var l = void 0;
26460
26461 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
26462 return null;
26463 }
26464 var halfWidth = lineWidth / 2;
26465 var xDims = QuadraticMath.extrema(p1[0], p2[0], p3[0]);
26466 for (i = 0, l = xDims.length; i < l; i++) {
26467 xDims[i] = QuadraticMath.at(p1[0], p2[0], p3[0], xDims[i]);
26468 }
26469 xDims.push(p1[0], p3[0]);
26470 var yDims = QuadraticMath.extrema(p1[1], p2[1], p3[1]);
26471 for (i = 0, l = yDims.length; i < l; i++) {
26472 yDims[i] = QuadraticMath.at(p1[1], p2[1], p3[1], yDims[i]);
26473 }
26474 yDims.push(p1[1], p3[1]);
26475
26476 return {
26477 minX: Math.min.apply(Math, xDims) - halfWidth,
26478 maxX: Math.max.apply(Math, xDims) + halfWidth,
26479 minY: Math.min.apply(Math, yDims) - halfWidth,
26480 maxY: Math.max.apply(Math, yDims) + halfWidth
26481 };
26482 },
26483 isPointInPath: function isPointInPath(x, y) {
26484 var self = this;
26485 var attrs = self.__attrs;
26486 var p1 = attrs.p1,
26487 p2 = attrs.p2,
26488 p3 = attrs.p3;
26489
26490 var lineWidth = this.getHitLineWidth();
26491
26492 return Inside.quadraticline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], lineWidth, x, y);
26493 },
26494 createPath: function createPath(context) {
26495 var self = this;
26496 var attrs = self.__attrs;
26497 var p1 = attrs.p1,
26498 p2 = attrs.p2,
26499 p3 = attrs.p3;
26500
26501 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
26502 return;
26503 }
26504 context = context || self.get('context');
26505 context.beginPath();
26506 context.moveTo(p1[0], p1[1]);
26507 context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]);
26508 },
26509 afterPath: function afterPath(context) {
26510 var self = this;
26511 var attrs = self.__attrs;
26512 var p1 = attrs.p1,
26513 p2 = attrs.p2,
26514 p3 = attrs.p3;
26515
26516 context = context || self.get('context');
26517
26518 if (attrs.startArrow) {
26519 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
26520 }
26521
26522 if (attrs.endArrow) {
26523 Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]);
26524 }
26525 },
26526 getPoint: function getPoint(t) {
26527 var attrs = this.__attrs;
26528 return {
26529 x: QuadraticMath.at(attrs.p1[0], attrs.p2[0], attrs.p3[0], t),
26530 y: QuadraticMath.at(attrs.p1[1], attrs.p2[1], attrs.p3[1], t)
26531 };
26532 }
26533 });
26534
26535 module.exports = Quadratic;
26536
26537 /***/
26538 },
26539 /* 65 */
26540 /***/function (module, exports, __webpack_require__) {
26541
26542 module.exports = {
26543 // renderers
26544 svg: __webpack_require__(66),
26545 canvas: __webpack_require__(108),
26546 // utils
26547 CommonUtil: __webpack_require__(7),
26548 DomUtil: __webpack_require__(26),
26549 MatrixUtil: __webpack_require__(2),
26550 PathUtil: __webpack_require__(13),
26551 // version, etc.
26552 version: '3.0.0-beta.4'
26553 };
26554
26555 /***/
26556 },
26557 /* 66 */
26558 /***/function (module, exports, __webpack_require__) {
26559
26560 module.exports = {
26561 Canvas: __webpack_require__(67),
26562 Group: __webpack_require__(28),
26563 Shape: __webpack_require__(4),
26564 Rect: __webpack_require__(39),
26565 Circle: __webpack_require__(40),
26566 Ellipse: __webpack_require__(41),
26567 Path: __webpack_require__(42),
26568 Text: __webpack_require__(43),
26569 Line: __webpack_require__(44),
26570 Image: __webpack_require__(45),
26571 Polygon: __webpack_require__(46),
26572 Marker: __webpack_require__(47),
26573 Dom: __webpack_require__(48),
26574 Fan: __webpack_require__(49),
26575 Event: __webpack_require__(27)
26576 };
26577
26578 /***/
26579 },
26580 /* 67 */
26581 /***/function (module, exports, __webpack_require__) {
26582
26583 var Util = __webpack_require__(0);
26584 var Event = __webpack_require__(27);
26585 var Group = __webpack_require__(28);
26586 var Defs = __webpack_require__(103);
26587
26588 var Canvas = function Canvas(cfg) {
26589 Canvas.superclass.constructor.call(this, cfg);
26590 };
26591
26592 var defs = new Defs();
26593
26594 Canvas.CFG = {
26595 eventEnable: true,
26596 /**
26597 * 像素宽度
26598 * @type {Number}
26599 */
26600 width: null,
26601 /**
26602 * 像素高度
26603 * @type {Number}
26604 */
26605 height: null,
26606 /**
26607 * 画布宽度
26608 * @type {Number}
26609 */
26610 widthCanvas: null,
26611 /**
26612 * 画布高度
26613 * @type {Number}
26614 */
26615 heightCanvas: null,
26616 /**
26617 * CSS宽
26618 * CSS宽
26619 * @type {String}
26620 */
26621 widthStyle: null,
26622 /**
26623 * CSS高
26624 * @type {String}
26625 */
26626 heightStyle: null,
26627 /**
26628 * 容器DOM
26629 * @type {Object}
26630 */
26631 containerDOM: null,
26632 /**
26633 * 当前Canvas的DOM
26634 * @type {Object}
26635 */
26636 canvasDOM: null,
26637 /**
26638 * 屏幕像素比
26639 * @type {Number}
26640 */
26641 pixelRatio: Util.getRatio()
26642 };
26643
26644 Util.extend(Canvas, Group);
26645
26646 Util.augment(Canvas, {
26647 init: function init() {
26648 Canvas.superclass.init.call(this);
26649 this._setDOM();
26650 this._setInitSize();
26651 // this._scale();
26652 if (this.get('eventEnable')) {
26653 this._registEvents();
26654 }
26655 },
26656 getEmitter: function getEmitter(element, event) {
26657 if (element) {
26658 if (Util.isEmpty(element._getEvents())) {
26659 var parent = element.get('parent');
26660 if (parent && !event.propagationStopped) {
26661 return this.getEmitter(parent, event);
26662 }
26663 } else {
26664 return element;
26665 }
26666 }
26667 },
26668 _getEventObj: function _getEventObj(type, e, point, target) {
26669 var event = new Event(type, e, true, true);
26670 event.x = point.x;
26671 event.y = point.y;
26672 event.clientX = e.clientX;
26673 event.clientY = e.clientY;
26674 event.currentTarget = target;
26675 event.target = target;
26676 return event;
26677 },
26678 _triggerEvent: function _triggerEvent(type, e) {
26679 var point = this.getPointByClient(e.clientX, e.clientY);
26680 var shape = this.findShape(e.srcElement);
26681 var emitObj = void 0;
26682 if (type === 'mousemove') {
26683 var preShape = this.get('preShape');
26684 if (preShape && preShape !== shape) {
26685 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
26686 emitObj = this.getEmitter(preShape, e);
26687 emitObj && emitObj.emit('mouseleave', mouseleave);
26688 }
26689
26690 if (shape) {
26691 var mousemove = this._getEventObj('mousemove', e, point, shape);
26692 emitObj = this.getEmitter(shape, e);
26693 emitObj && emitObj.emit('mousemove', mousemove);
26694
26695 if (preShape !== shape) {
26696 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
26697 emitObj && emitObj.emit('mouseenter', mouseenter, e);
26698 }
26699 } else {
26700 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
26701 this.emit('mousemove', canvasmousemove);
26702 }
26703 this.set('preShape', shape);
26704 } else {
26705 var event = this._getEventObj(type, e, point, shape || this);
26706 emitObj = this.getEmitter(shape, e);
26707 if (emitObj && emitObj !== this) {
26708 emitObj.emit(type, event);
26709 }
26710 this.emit(type, event);
26711 }
26712
26713 var el = this.get('el');
26714 if (shape && !shape.get('destroyed')) {
26715 el.style.cursor = shape.attr('cursor') || 'default';
26716 }
26717 },
26718 _registEvents: function _registEvents() {
26719 var self = this;
26720 var el = self.get('el');
26721 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
26722
26723 Util.each(events, function (event) {
26724 el.addEventListener(event, function (e) {
26725 self._triggerEvent(event, e);
26726 }, false);
26727 });
26728 el.addEventListener('touchstart', function (e) {
26729 if (!Util.isEmpty(e.touches)) {
26730 self._triggerEvent('touchstart', e.touches[0]);
26731 }
26732 }, false);
26733
26734 el.addEventListener('touchmove', function (e) {
26735 if (!Util.isEmpty(e.touches)) {
26736 self._triggerEvent('touchmove', e.touches[0]);
26737 }
26738 }, false);
26739
26740 el.addEventListener('touchend', function (e) {
26741 if (!Util.isEmpty(e.changedTouches)) {
26742 self._triggerEvent('touchend', e.changedTouches[0]);
26743 }
26744 }, false);
26745 },
26746 _setDOM: function _setDOM() {
26747 this._setContainer();
26748 this._setLayer();
26749 },
26750 _setContainer: function _setContainer() {
26751 var containerId = this.get('containerId');
26752 var containerDOM = this.get('containerDOM');
26753 if (!containerDOM) {
26754 containerDOM = document.getElementById(containerId);
26755 this.set('containerDOM', containerDOM);
26756 }
26757 Util.modifyCSS(containerDOM, {
26758 position: 'relative'
26759 });
26760 },
26761 _setLayer: function _setLayer() {
26762 var containerDOM = this.get('containerDOM');
26763 var canvasId = Util.uniqueId('svg_');
26764 if (containerDOM) {
26765 var _canvasDOM = Util.createDom('<svg id="' + canvasId + '"></svg>');
26766 containerDOM.appendChild(_canvasDOM);
26767 _canvasDOM.appendChild(defs.get('el'));
26768 this.set('canvasDOM', _canvasDOM);
26769 this.set('el', _canvasDOM);
26770 this.set('defs', defs);
26771 this.set('canvas', this);
26772 }
26773 var canvasDOM = this.get('canvasDOM');
26774 this.set('context', canvasDOM);
26775 },
26776 _setInitSize: function _setInitSize() {
26777 this.changeSize(this.get('width'), this.get('height'));
26778 this.set('pixelRatio', 1);
26779 },
26780 _resize: function _resize() {
26781 var canvasDOM = this.get('canvasDOM');
26782 var widthCanvas = this.get('widthCanvas');
26783 var heightCanvas = this.get('heightCanvas');
26784 var widthStyle = this.get('widthStyle');
26785 var heightStyle = this.get('heightStyle');
26786
26787 canvasDOM.style.width = widthStyle;
26788 canvasDOM.style.height = heightStyle;
26789 canvasDOM.setAttribute('width', widthCanvas);
26790 canvasDOM.setAttribute('height', heightCanvas);
26791 },
26792 getWidth: function getWidth() {
26793 return this.get('width');
26794 },
26795 getHeight: function getHeight() {
26796 return this.get('height');
26797 },
26798 changeSize: function changeSize(width, height) {
26799 this.set('widthCanvas', width);
26800 this.set('heightCanvas', height);
26801 this.set('widthStyle', width + 'px');
26802 this.set('heightStyle', height + 'px');
26803 this.set('width', width);
26804 this.set('height', height);
26805 this._resize();
26806 },
26807
26808 /**
26809 * 将窗口坐标转变成 canvas 坐标
26810 * @param {Number} clientX 窗口x坐标
26811 * @param {Number} clientY 窗口y坐标
26812 * @return {Object} canvas坐标
26813 */
26814 getPointByClient: function getPointByClient(clientX, clientY) {
26815 var el = this.get('el');
26816 var bbox = el.getBoundingClientRect();
26817 return {
26818 x: clientX - bbox.left,
26819 y: clientY - bbox.top
26820 };
26821 },
26822 getClientByPoint: function getClientByPoint(x, y) {
26823 var el = this.get('el');
26824 var bbox = el.getBoundingClientRect();
26825 return {
26826 clientX: x + bbox.left,
26827 clientY: y + bbox.top
26828 };
26829 },
26830 beforeDraw: function beforeDraw() {
26831 var el = this.get('el');
26832 // canvas版本用盖一个canvas大小的矩阵清空画布,svg换成清空html
26833 el.innerHTML = '';
26834 },
26835 _beginDraw: function _beginDraw() {
26836 this.setSilent('toDraw', true);
26837 },
26838 _endDraw: function _endDraw() {
26839 this.setSilent('toDraw', false);
26840 },
26841
26842 // svg实时渲染,兼容canvas版本留个空接口
26843 draw: function draw() {},
26844 destroy: function destroy() {
26845 var containerDOM = this.get('containerDOM');
26846 var canvasDOM = this.get('canvasDOM');
26847 if (canvasDOM && containerDOM) {
26848 containerDOM.removeChild(canvasDOM);
26849 }
26850 Canvas.superclass.destroy.call(this);
26851 }
26852 });
26853
26854 module.exports = Canvas;
26855
26856 /***/
26857 },
26858 /* 68 */
26859 /***/function (module, exports, __webpack_require__) {
26860
26861 /* WEBPACK VAR INJECTION */(function (module) {
26862 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof2 = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
26863 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
26864 } : function (obj) {
26865 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
26866 };
26867
26868 (function webpackUniversalModuleDefinition(root, factory) {
26869 if ((false ? 'undefined' : _typeof2(exports)) === 'object' && (false ? 'undefined' : _typeof2(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = factory, __WEBPACK_AMD_DEFINE_RESULT__ = typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? __WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__) : __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else if ((typeof exports === 'undefined' ? 'undefined' : _typeof2(exports)) === 'object') exports["Util"] = factory();else root["Util"] = factory();
26870 })(this, function () {
26871 return (/******/function (modules) {
26872 // webpackBootstrap
26873 /******/ // The module cache
26874 /******/var installedModules = {};
26875 /******/
26876 /******/ // The require function
26877 /******/function __webpack_require__(moduleId) {
26878 /******/
26879 /******/ // Check if module is in cache
26880 /******/if (installedModules[moduleId]) {
26881 /******/return installedModules[moduleId].exports;
26882 /******/
26883 }
26884 /******/ // Create a new module (and put it into the cache)
26885 /******/var module = installedModules[moduleId] = {
26886 /******/i: moduleId,
26887 /******/l: false,
26888 /******/exports: {}
26889 /******/ };
26890 /******/
26891 /******/ // Execute the module function
26892 /******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
26893 /******/
26894 /******/ // Flag the module as loaded
26895 /******/module.l = true;
26896 /******/
26897 /******/ // Return the exports of the module
26898 /******/return module.exports;
26899 /******/
26900 }
26901 /******/
26902 /******/
26903 /******/ // expose the modules object (__webpack_modules__)
26904 /******/__webpack_require__.m = modules;
26905 /******/
26906 /******/ // expose the module cache
26907 /******/__webpack_require__.c = installedModules;
26908 /******/
26909 /******/ // define getter function for harmony exports
26910 /******/__webpack_require__.d = function (exports, name, getter) {
26911 /******/if (!__webpack_require__.o(exports, name)) {
26912 /******/Object.defineProperty(exports, name, {
26913 /******/configurable: false,
26914 /******/enumerable: true,
26915 /******/get: getter
26916 /******/ });
26917 /******/
26918 }
26919 /******/
26920 };
26921 /******/
26922 /******/ // getDefaultExport function for compatibility with non-harmony modules
26923 /******/__webpack_require__.n = function (module) {
26924 /******/var getter = module && module.__esModule ?
26925 /******/function getDefault() {
26926 return module['default'];
26927 } :
26928 /******/function getModuleExports() {
26929 return module;
26930 };
26931 /******/__webpack_require__.d(getter, 'a', getter);
26932 /******/return getter;
26933 /******/
26934 };
26935 /******/
26936 /******/ // Object.prototype.hasOwnProperty.call
26937 /******/__webpack_require__.o = function (object, property) {
26938 return Object.prototype.hasOwnProperty.call(object, property);
26939 };
26940 /******/
26941 /******/ // __webpack_public_path__
26942 /******/__webpack_require__.p = "";
26943 /******/
26944 /******/ // Load entry module and return exports
26945 /******/return __webpack_require__(__webpack_require__.s = 27);
26946 /******/
26947 }(
26948 /************************************************************************/
26949 /******/[
26950 /* 0 */
26951 /***/function (module, exports) {
26952
26953 var isArrayLike = function isArrayLike(value) {
26954 /**
26955 * isArrayLike([1, 2, 3]) => true
26956 * isArrayLike(document.body.children) => true
26957 * isArrayLike('abc') => true
26958 * isArrayLike(Function) => false
26959 */
26960 return value !== null && typeof value !== 'function' && isFinite(value.length);
26961 };
26962
26963 module.exports = isArrayLike;
26964
26965 /***/
26966 },
26967 /* 1 */
26968 /***/function (module, exports) {
26969
26970 var toString = {}.toString;
26971 var isType = function isType(value, type) {
26972 return toString.call(value) === '[object ' + type + ']';
26973 };
26974
26975 module.exports = isType;
26976
26977 /***/
26978 },
26979 /* 2 */
26980 /***/function (module, exports, __webpack_require__) {
26981
26982 var isType = __webpack_require__(1);
26983
26984 var isArray = Array.isArray ? Array.isArray : function (value) {
26985 return isType(value, 'Array');
26986 };
26987
26988 module.exports = isArray;
26989
26990 /***/
26991 },
26992 /* 3 */
26993 /***/function (module, exports, __webpack_require__) {
26994
26995 /**
26996 * 判断是否数字
26997 * @return {Boolean} 是否数字
26998 */
26999 var isType = __webpack_require__(1);
27000
27001 var isNumber = function isNumber(value) {
27002 return isType(value, 'Number');
27003 };
27004 module.exports = isNumber;
27005
27006 /***/
27007 },
27008 /* 4 */
27009 /***/function (module, exports, __webpack_require__) {
27010
27011 var isType = __webpack_require__(1);
27012
27013 var isString = function isString(str) {
27014 return isType(str, 'String');
27015 };
27016
27017 module.exports = isString;
27018
27019 /***/
27020 },
27021 /* 5 */
27022 /***/function (module, exports) {
27023
27024 function isNull(value) {
27025 return value === null;
27026 }
27027
27028 function isUndefined(value) {
27029 return value === undefined;
27030 }
27031
27032 // isFinite,
27033 var isNil = function isNil(value) {
27034 /**
27035 * isNil(null) => true
27036 * isNil() => true
27037 */
27038 return isUndefined(value) || isNull(value);
27039 };
27040
27041 module.exports = isNil;
27042
27043 /***/
27044 },
27045 /* 6 */
27046 /***/function (module, exports, __webpack_require__) {
27047
27048 var isObject = __webpack_require__(16);
27049 var isArray = __webpack_require__(2);
27050
27051 var each = function each(elements, func) {
27052 if (!elements) {
27053 return;
27054 }
27055 var rst = void 0;
27056 if (isArray(elements)) {
27057 for (var i = 0; i < elements.length; i++) {
27058 rst = func(elements[i], i);
27059 if (rst === false) {
27060 break;
27061 }
27062 }
27063 } else if (isObject(elements)) {
27064 for (var k in elements) {
27065 if (elements.hasOwnProperty(k)) {
27066 rst = func(elements[k], k);
27067 if (rst === false) {
27068 break;
27069 }
27070 }
27071 }
27072 }
27073 };
27074
27075 module.exports = each;
27076
27077 /***/
27078 },
27079 /* 7 */
27080 /***/function (module, exports, __webpack_require__) {
27081
27082 var isArrayLike = __webpack_require__(0);
27083
27084 var indexOf = Array.prototype.indexOf;
27085
27086 var contains = function contains(arr, value) {
27087 if (!isArrayLike(arr)) {
27088 return false;
27089 }
27090 return indexOf.call(arr, value) > -1;
27091 };
27092
27093 module.exports = contains;
27094
27095 /***/
27096 },
27097 /* 8 */
27098 /***/function (module, exports, __webpack_require__) {
27099
27100 var isArrayLike = __webpack_require__(0);
27101
27102 var splice = Array.prototype.splice;
27103
27104 var pullAt = function pullAt(arr, indexes) {
27105 if (!isArrayLike(arr)) {
27106 return [];
27107 }
27108 var length = arr ? indexes.length : 0;
27109 var last = length - 1;
27110
27111 while (length--) {
27112 var previous = void 0;
27113 var index = indexes[length];
27114 if (length === last || index !== previous) {
27115 previous = index;
27116 splice.call(arr, index, 1);
27117 }
27118 }
27119 return arr;
27120 };
27121
27122 module.exports = pullAt;
27123
27124 /***/
27125 },
27126 /* 9 */
27127 /***/function (module, exports) {
27128
27129 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
27130 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
27131 } : function (obj) {
27132 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
27133 };
27134
27135 var isObjectLike = function isObjectLike(value) {
27136 /**
27137 * isObjectLike({}) => true
27138 * isObjectLike([1, 2, 3]) => true
27139 * isObjectLike(Function) => false
27140 * isObjectLike(null) => false
27141 */
27142 return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
27143 };
27144
27145 module.exports = isObjectLike;
27146
27147 /***/
27148 },
27149 /* 10 */
27150 /***/function (module, exports, __webpack_require__) {
27151
27152 var isArrayLike = __webpack_require__(0);
27153
27154 function toArray(value) {
27155 return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
27156 }
27157
27158 module.exports = toArray;
27159
27160 /***/
27161 },
27162 /* 11 */
27163 /***/function (module, exports, __webpack_require__) {
27164
27165 /**
27166 * 是否为函数
27167 * @param {*} fn 对象
27168 * @return {Boolean} 是否函数
27169 */
27170 var isType = __webpack_require__(1);
27171
27172 var isFunction = function isFunction(value) {
27173 return isType(value, 'Function');
27174 };
27175
27176 module.exports = isFunction;
27177
27178 /***/
27179 },
27180 /* 12 */
27181 /***/function (module, exports) {
27182
27183 function _mix(dist, obj) {
27184 for (var key in obj) {
27185 if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
27186 dist[key] = obj[key];
27187 }
27188 }
27189 }
27190
27191 var mix = function mix(dist, src1, src2, src3) {
27192 if (src1) _mix(dist, src1);
27193 if (src2) _mix(dist, src2);
27194 if (src3) _mix(dist, src3);
27195 return dist;
27196 };
27197
27198 module.exports = mix;
27199
27200 /***/
27201 },
27202 /* 13 */
27203 /***/function (module, exports, __webpack_require__) {
27204
27205 var isNil = __webpack_require__(5);
27206 var isArray = __webpack_require__(2);
27207
27208 var firstValue = function firstValue(data, name) {
27209 var rst = null;
27210 for (var i = 0; i < data.length; i++) {
27211 var obj = data[i];
27212 var value = obj[name];
27213 if (!isNil(value)) {
27214 if (isArray(value)) {
27215 rst = value[0];
27216 } else {
27217 rst = value;
27218 }
27219 break;
27220 }
27221 }
27222 return rst;
27223 };
27224
27225 module.exports = firstValue;
27226
27227 /***/
27228 },
27229 /* 14 */
27230 /***/function (module, exports, __webpack_require__) {
27231
27232 var filter = __webpack_require__(15);
27233 var isArray = __webpack_require__(2);
27234
27235 var getRange = function getRange(values) {
27236 // 存在 NaN 时,min,max 判定会出问题
27237 values = filter(values, function (v) {
27238 return !isNaN(v);
27239 });
27240 if (!values.length) {
27241 // 如果没有数值则直接返回0
27242 return {
27243 min: 0,
27244 max: 0
27245 };
27246 }
27247 if (isArray(values[0])) {
27248 var tmp = [];
27249 for (var i = 0; i < values.length; i++) {
27250 tmp = tmp.concat(values[i]);
27251 }
27252 values = tmp;
27253 }
27254 var max = Math.max.apply(null, values);
27255 var min = Math.min.apply(null, values);
27256 return {
27257 min: min,
27258 max: max
27259 };
27260 };
27261
27262 module.exports = getRange;
27263
27264 /***/
27265 },
27266 /* 15 */
27267 /***/function (module, exports, __webpack_require__) {
27268
27269 var each = __webpack_require__(6);
27270 var isArrayLike = __webpack_require__(0);
27271
27272 var filter = function filter(arr, func) {
27273 if (!isArrayLike(arr)) {
27274 return arr;
27275 }
27276 var result = [];
27277 each(arr, function (value, index) {
27278 if (func(value, index)) {
27279 result.push(value);
27280 }
27281 });
27282 return result;
27283 };
27284
27285 module.exports = filter;
27286
27287 /***/
27288 },
27289 /* 16 */
27290 /***/function (module, exports) {
27291
27292 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
27293 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
27294 } : function (obj) {
27295 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
27296 };
27297
27298 var isObject = function isObject(value) {
27299 /**
27300 * isObject({}) => true
27301 * isObject([1, 2, 3]) => true
27302 * isObject(Function) => true
27303 * isObject(null) => false
27304 */
27305 var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
27306 return value !== null && type === 'object' || type === 'function';
27307 };
27308
27309 module.exports = isObject;
27310
27311 /***/
27312 },
27313 /* 17 */
27314 /***/function (module, exports) {
27315
27316 var arrPrototype = Array.prototype;
27317 var splice = arrPrototype.splice;
27318 var indexOf = arrPrototype.indexOf;
27319 var slice = arrPrototype.slice;
27320
27321 var pull = function pull(arr) {
27322 var values = slice.call(arguments, 1);
27323 for (var i = 0; i < values.length; i++) {
27324 var value = values[i];
27325 var fromIndex = -1;
27326 while ((fromIndex = indexOf.call(arr, value)) > -1) {
27327 splice.call(arr, fromIndex, 1);
27328 }
27329 }
27330 return arr;
27331 };
27332
27333 module.exports = pull;
27334
27335 /***/
27336 },
27337 /* 18 */
27338 /***/function (module, exports, __webpack_require__) {
27339
27340 var isArrayLike = __webpack_require__(0);
27341 var pullAt = __webpack_require__(8);
27342
27343 var remove = function remove(arr, predicate) {
27344 /**
27345 * const arr = [1, 2, 3, 4]
27346 * const evens = remove(arr, n => n % 2 == 0)
27347 * console.log(arr) // => [1, 3]
27348 * console.log(evens) // => [2, 4]
27349 */
27350 var result = [];
27351 if (!isArrayLike(arr)) {
27352 return result;
27353 }
27354 var i = -1;
27355 var indexes = [];
27356 var length = arr.length;
27357
27358 while (++i < length) {
27359 var value = arr[i];
27360 if (predicate(value, i, arr)) {
27361 result.push(value);
27362 indexes.push(i);
27363 }
27364 }
27365 pullAt(arr, indexes);
27366 return result;
27367 };
27368
27369 module.exports = remove;
27370
27371 /***/
27372 },
27373 /* 19 */
27374 /***/function (module, exports, __webpack_require__) {
27375
27376 var contains = __webpack_require__(7);
27377
27378 var uniq = function uniq(arr) {
27379 var resultArr = [];
27380 arr.forEach(function (item) {
27381 if (!contains(resultArr, item)) {
27382 resultArr.push(item);
27383 }
27384 });
27385 return resultArr;
27386 };
27387
27388 module.exports = uniq;
27389
27390 /***/
27391 },
27392 /* 20 */
27393 /***/function (module, exports, __webpack_require__) {
27394
27395 var each = __webpack_require__(6);
27396 var isNil = __webpack_require__(5);
27397 var isArray = __webpack_require__(2);
27398
27399 var values = function values(data, name) {
27400 var rst = [];
27401 var tmpMap = {};
27402 for (var i = 0; i < data.length; i++) {
27403 var obj = data[i];
27404 var value = obj[name];
27405 if (!isNil(value)) {
27406 if (!isArray(value)) {
27407 value = [value];
27408 }
27409 each(value, function (val) {
27410 if (!tmpMap[val]) {
27411 rst.push(val);
27412 tmpMap[val] = true;
27413 }
27414 });
27415 }
27416 }
27417 return rst;
27418 };
27419
27420 module.exports = values;
27421
27422 /***/
27423 },
27424 /* 21 */
27425 /***/function (module, exports) {
27426
27427 var toString = {}.toString;
27428
27429 var getType = function getType(value) {
27430 return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
27431 };
27432
27433 module.exports = getType;
27434
27435 /***/
27436 },
27437 /* 22 */
27438 /***/function (module, exports) {
27439
27440 var objectProto = Object.prototype;
27441 var isPrototype = function isPrototype(value) {
27442 var Ctor = value && value.constructor;
27443 var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
27444 return value === proto;
27445 };
27446
27447 module.exports = isPrototype;
27448
27449 /***/
27450 },
27451 /* 23 */
27452 /***/function (module, exports, __webpack_require__) {
27453
27454 var isObjectLike = __webpack_require__(9);
27455 var isType = __webpack_require__(1);
27456
27457 var isPlainObject = function isPlainObject(value) {
27458 /**
27459 * isObjectLike(new Foo) => false
27460 * isObjectLike([1, 2, 3]) => false
27461 * isObjectLike({ x: 0, y: 0 }) => true
27462 * isObjectLike(Object.create(null)) => true
27463 */
27464 if (!isObjectLike(value) || !isType(value, 'Object')) {
27465 return false;
27466 }
27467 if (Object.getPrototypeOf(value) === null) {
27468 return true;
27469 }
27470 var proto = value;
27471 while (Object.getPrototypeOf(proto) !== null) {
27472 proto = Object.getPrototypeOf(proto);
27473 }
27474 return Object.getPrototypeOf(value) === proto;
27475 };
27476
27477 module.exports = isPlainObject;
27478
27479 /***/
27480 },
27481 /* 24 */
27482 /***/function (module, exports) {
27483
27484 module.exports = parseInt;
27485
27486 /***/
27487 },
27488 /* 25 */
27489 /***/function (module, exports, __webpack_require__) {
27490
27491 var isString = __webpack_require__(4);
27492
27493 var lowerCase = function lowerCase(str) {
27494 if (!isString(str)) {
27495 return str;
27496 }
27497 return str.toString().toLowerCase();
27498 };
27499
27500 module.exports = lowerCase;
27501
27502 /***/
27503 },
27504 /* 26 */
27505 /***/function (module, exports, __webpack_require__) {
27506
27507 var isString = __webpack_require__(4);
27508
27509 var upperCase = function upperCase(str) {
27510 if (!isString(str)) {
27511 return str;
27512 }
27513 return str.toString().toUpperCase();
27514 };
27515
27516 module.exports = upperCase;
27517
27518 /***/
27519 },
27520 /* 27 */
27521 /***/function (module, exports, __webpack_require__) {
27522
27523 module.exports = {
27524 arrayUtil: __webpack_require__(28),
27525 stringUtil: __webpack_require__(29),
27526 clone: __webpack_require__(30),
27527 each: __webpack_require__(6),
27528 filter: __webpack_require__(15),
27529 indexOf: __webpack_require__(31),
27530 isEmpty: __webpack_require__(32),
27531 isEqual: __webpack_require__(33),
27532 map: __webpack_require__(34),
27533 toArray: __webpack_require__(10),
27534 uniqueId: __webpack_require__(35),
27535 extend: __webpack_require__(36),
27536 augment: __webpack_require__(37),
27537 deepMix: __webpack_require__(38),
27538 mix: __webpack_require__(12),
27539 clamp: __webpack_require__(39),
27540 fixedBase: __webpack_require__(40),
27541 isDecimal: __webpack_require__(41),
27542 isEven: __webpack_require__(42),
27543 isInteger: __webpack_require__(43),
27544 isNegative: __webpack_require__(44),
27545 isNumberEqual: __webpack_require__(45),
27546 isOdd: __webpack_require__(46),
27547 isPositive: __webpack_require__(47),
27548 mod: __webpack_require__(48),
27549 toDegree: __webpack_require__(49),
27550 toInt: __webpack_require__(24),
27551 toInteger: __webpack_require__(24),
27552 toRadian: __webpack_require__(50),
27553 getType: __webpack_require__(21),
27554 isArray: __webpack_require__(2),
27555 isArrayLike: __webpack_require__(0),
27556 isBoolean: __webpack_require__(51),
27557 isFunction: __webpack_require__(11),
27558 isNil: __webpack_require__(5),
27559 isNull: __webpack_require__(52),
27560 isNumber: __webpack_require__(3),
27561 isObject: __webpack_require__(16),
27562 isObjectLike: __webpack_require__(9),
27563 isPlainObject: __webpack_require__(23),
27564 isPrototype: __webpack_require__(22),
27565 isType: __webpack_require__(1),
27566 isUndefined: __webpack_require__(53),
27567 isString: __webpack_require__(4),
27568 isRegExp: __webpack_require__(54),
27569 lowerCase: __webpack_require__(25),
27570 lowerFirst: __webpack_require__(55),
27571 substitute: __webpack_require__(56),
27572 upperCase: __webpack_require__(26),
27573 upperFirst: __webpack_require__(57),
27574 contains: __webpack_require__(7),
27575 firstValue: __webpack_require__(13),
27576 getRange: __webpack_require__(14),
27577 pull: __webpack_require__(17),
27578 pullAt: __webpack_require__(8),
27579 remove: __webpack_require__(18),
27580 uniq: __webpack_require__(19),
27581 values: __webpack_require__(20)
27582 };
27583
27584 /***/
27585 },
27586 /* 28 */
27587 /***/function (module, exports, __webpack_require__) {
27588
27589 module.exports = {
27590 contains: __webpack_require__(7),
27591 firstValue: __webpack_require__(13),
27592 getRange: __webpack_require__(14),
27593 pull: __webpack_require__(17),
27594 pullAt: __webpack_require__(8),
27595 remove: __webpack_require__(18),
27596 uniq: __webpack_require__(19),
27597 values: __webpack_require__(20)
27598 };
27599
27600 /***/
27601 },
27602 /* 29 */
27603 /***/function (module, exports) {
27604
27605 function toString(value) {
27606 return value.toString();
27607 }
27608
27609 function upperCase(value) {
27610 return toString(value).toUpperCase();
27611 }
27612
27613 function lowerCase(value) {
27614 return toString(value).toLowerCase();
27615 }
27616
27617 var strUtil = {
27618 lc: lowerCase,
27619 lowerCase: lowerCase,
27620 lowerFirst: function lowerFirst(value) {
27621 value = toString(value);
27622 return lowerCase(value.charAt(0)) + value.substring(1);
27623 },
27624
27625 uc: upperCase,
27626 upperCase: upperCase,
27627 upperFirst: function upperFirst(value) {
27628 value = toString(value);
27629 return upperCase(value.charAt(0)) + value.substring(1);
27630 }
27631 };
27632
27633 module.exports = strUtil;
27634
27635 /***/
27636 },
27637 /* 30 */
27638 /***/function (module, exports, __webpack_require__) {
27639
27640 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
27641 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
27642 } : function (obj) {
27643 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
27644 };
27645
27646 var isArray = __webpack_require__(2);
27647
27648 var clone = function clone(obj) {
27649 if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
27650 return obj;
27651 }
27652 var rst = void 0;
27653 if (isArray(obj)) {
27654 rst = [];
27655 for (var i = 0, l = obj.length; i < l; i++) {
27656 if (_typeof(obj[i]) === 'object' && obj[i] != null) {
27657 rst[i] = clone(obj[i]);
27658 } else {
27659 rst[i] = obj[i];
27660 }
27661 }
27662 } else {
27663 rst = {};
27664 for (var k in obj) {
27665 if (_typeof(obj[k]) === 'object' && obj[k] != null) {
27666 rst[k] = clone(obj[k]);
27667 } else {
27668 rst[k] = obj[k];
27669 }
27670 }
27671 }
27672
27673 return rst;
27674 };
27675
27676 module.exports = clone;
27677
27678 /***/
27679 },
27680 /* 31 */
27681 /***/function (module, exports, __webpack_require__) {
27682
27683 var isArrayLike = __webpack_require__(0);
27684
27685 var indexOf = function indexOf(arr, obj) {
27686 if (!isArrayLike(arr)) {
27687 return -1;
27688 }
27689 var m = Array.prototype.indexOf;
27690 if (m) {
27691 return m.call(arr, obj);
27692 }
27693 var index = -1;
27694
27695 for (var i = 0; i < arr.length; i++) {
27696 if (arr[i] === obj) {
27697 index = i;
27698 break;
27699 }
27700 }
27701 return index;
27702 };
27703
27704 module.exports = indexOf;
27705
27706 /***/
27707 },
27708 /* 32 */
27709 /***/function (module, exports, __webpack_require__) {
27710
27711 var isNil = __webpack_require__(5);
27712 var isArrayLike = __webpack_require__(0);
27713 var getType = __webpack_require__(21);
27714 var isPrototype = __webpack_require__(22);
27715 var hasOwnProperty = Object.prototype.hasOwnProperty;
27716
27717 function isEmpty(value) {
27718 /**
27719 * isEmpty(null) => true
27720 * isEmpty() => true
27721 * isEmpty(true) => true
27722 * isEmpty(1) => true
27723 * isEmpty([1, 2, 3]) => false
27724 * isEmpty('abc') => false
27725 * isEmpty({ a: 1 }) => false
27726 */
27727 if (isNil(value)) {
27728 return true;
27729 }
27730 if (isArrayLike(value)) {
27731 return !value.length;
27732 }
27733 var type = getType(value);
27734 if (type === 'Map' || type === 'Set') {
27735 return !value.size;
27736 }
27737 if (isPrototype(value)) {
27738 return !Object.keys(value).length;
27739 }
27740 for (var key in value) {
27741 if (hasOwnProperty.call(value, key)) {
27742 return false;
27743 }
27744 }
27745 return true;
27746 }
27747
27748 module.exports = isEmpty;
27749
27750 /***/
27751 },
27752 /* 33 */
27753 /***/function (module, exports, __webpack_require__) {
27754
27755 var isObjectLike = __webpack_require__(9);
27756 var isArrayLike = __webpack_require__(0);
27757
27758 var isEqual = function isEqual(value, other) {
27759 if (value === other) {
27760 return true;
27761 }
27762 if (!value || !other) {
27763 return false;
27764 }
27765 if (isArrayLike(value) || isArrayLike(other)) {
27766 if (value.length !== other.length) {
27767 return false;
27768 }
27769 var rst = true;
27770 for (var i = 0; i < value.length; i++) {
27771 rst = isEqual(value[i], other[i]);
27772 if (!rst) {
27773 break;
27774 }
27775 }
27776 return rst;
27777 }
27778 if (isObjectLike(value) || isObjectLike(other)) {
27779 var valueKeys = Object.keys(value);
27780 var otherKeys = Object.keys(other);
27781 if (valueKeys.length !== otherKeys.length) {
27782 return false;
27783 }
27784 var _rst = true;
27785 for (var _i = 0; _i < valueKeys.length; _i++) {
27786 _rst = isEqual(value[valueKeys[_i]], other[valueKeys[_i]]);
27787 if (!_rst) {
27788 break;
27789 }
27790 }
27791 return _rst;
27792 }
27793 return false;
27794 };
27795
27796 module.exports = isEqual;
27797
27798 /***/
27799 },
27800 /* 34 */
27801 /***/function (module, exports, __webpack_require__) {
27802
27803 var each = __webpack_require__(6);
27804 var isArrayLike = __webpack_require__(0);
27805
27806 var map = function map(arr, func) {
27807 if (!isArrayLike(arr)) {
27808 return arr;
27809 }
27810 var result = [];
27811 each(arr, function (value, index) {
27812 result.push(func(value, index));
27813 });
27814 return result;
27815 };
27816
27817 module.exports = map;
27818
27819 /***/
27820 },
27821 /* 35 */
27822 /***/function (module, exports) {
27823
27824 var uniqueId = function () {
27825 var map = {};
27826 return function (prefix) {
27827 prefix = prefix || 'g';
27828 if (!map[prefix]) {
27829 map[prefix] = 1;
27830 } else {
27831 map[prefix] += 1;
27832 }
27833 return prefix + map[prefix];
27834 };
27835 }();
27836
27837 module.exports = uniqueId;
27838
27839 /***/
27840 },
27841 /* 36 */
27842 /***/function (module, exports, __webpack_require__) {
27843
27844 var isFunction = __webpack_require__(11);
27845 var mix = __webpack_require__(12);
27846
27847 var extend = function extend(subclass, superclass, overrides, staticOverrides) {
27848 // 如果只提供父类构造函数,则自动生成子类构造函数
27849 if (!isFunction(superclass)) {
27850 overrides = superclass;
27851 superclass = subclass;
27852 subclass = function subclass() {};
27853 }
27854
27855 var create = Object.create ? function (proto, c) {
27856 return Object.create(proto, {
27857 constructor: {
27858 value: c
27859 }
27860 });
27861 } : function (proto, c) {
27862 function Tmp() {}
27863 Tmp.prototype = proto;
27864 var o = new Tmp();
27865 o.constructor = c;
27866 return o;
27867 };
27868
27869 var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
27870 subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
27871 subclass.superclass = create(superclass.prototype, superclass);
27872 mix(superObj, overrides);
27873 mix(subclass, staticOverrides);
27874 return subclass;
27875 };
27876
27877 module.exports = extend;
27878
27879 /***/
27880 },
27881 /* 37 */
27882 /***/function (module, exports, __webpack_require__) {
27883
27884 var isFunction = __webpack_require__(11);
27885 var toArray = __webpack_require__(10);
27886 var mix = __webpack_require__(12);
27887
27888 var augment = function augment(c) {
27889 var args = toArray(arguments);
27890 for (var i = 1; i < args.length; i++) {
27891 var obj = args[i];
27892 if (isFunction(obj)) {
27893 obj = obj.prototype;
27894 }
27895 mix(c.prototype, obj);
27896 }
27897 };
27898
27899 module.exports = augment;
27900
27901 /***/
27902 },
27903 /* 38 */
27904 /***/function (module, exports, __webpack_require__) {
27905
27906 var isPlainObject = __webpack_require__(23);
27907 var isArray = __webpack_require__(2);
27908 var toArray = __webpack_require__(10);
27909
27910 var MAX_MIX_LEVEL = 5;
27911
27912 function _deepMix(dist, src, level, maxLevel) {
27913 level = level || 0;
27914 maxLevel = maxLevel || MAX_MIX_LEVEL;
27915 for (var key in src) {
27916 if (src.hasOwnProperty(key)) {
27917 var value = src[key];
27918 if (value !== null && isPlainObject(value)) {
27919 if (!isPlainObject(dist[key])) {
27920 dist[key] = {};
27921 }
27922 if (level < maxLevel) {
27923 _deepMix(dist[key], value, level + 1, maxLevel);
27924 } else {
27925 dist[key] = src[key];
27926 }
27927 } else if (isArray(value)) {
27928 dist[key] = [];
27929 dist[key] = dist[key].concat(value);
27930 } else if (value !== undefined) {
27931 dist[key] = value;
27932 }
27933 }
27934 }
27935 }
27936
27937 var deepMix = function deepMix() {
27938 var args = toArray(arguments);
27939 var dist = args[0];
27940 for (var i = 1; i < args.length; i++) {
27941 _deepMix(dist, args[i]);
27942 }
27943 return dist;
27944 };
27945
27946 module.exports = deepMix;
27947
27948 /***/
27949 },
27950 /* 39 */
27951 /***/function (module, exports) {
27952
27953 var clamp = function clamp(a, min, max) {
27954 if (a < min) {
27955 return min;
27956 } else if (a > max) {
27957 return max;
27958 }
27959 return a;
27960 };
27961
27962 module.exports = clamp;
27963
27964 /***/
27965 },
27966 /* 40 */
27967 /***/function (module, exports) {
27968
27969 var fixedBase = function fixedBase(v, base) {
27970 var str = base.toString();
27971 var index = str.indexOf('.');
27972 if (index === -1) {
27973 return Math.round(v);
27974 }
27975 var length = str.substr(index + 1).length;
27976 if (length > 20) {
27977 length = 20;
27978 }
27979 return parseFloat(v.toFixed(length));
27980 };
27981
27982 module.exports = fixedBase;
27983
27984 /***/
27985 },
27986 /* 41 */
27987 /***/function (module, exports, __webpack_require__) {
27988
27989 var isNumber = __webpack_require__(3);
27990
27991 var isDecimal = function isDecimal(num) {
27992 return isNumber(num) && num % 1 !== 0;
27993 };
27994
27995 module.exports = isDecimal;
27996
27997 /***/
27998 },
27999 /* 42 */
28000 /***/function (module, exports, __webpack_require__) {
28001
28002 var isNumber = __webpack_require__(3);
28003
28004 var isEven = function isEven(num) {
28005 return isNumber(num) && num % 2 === 0;
28006 };
28007
28008 module.exports = isEven;
28009
28010 /***/
28011 },
28012 /* 43 */
28013 /***/function (module, exports, __webpack_require__) {
28014
28015 var isNumber = __webpack_require__(3);
28016
28017 var isInteger = Number.isInteger ? Number.isInteger : function (num) {
28018 return isNumber(num) && num % 1 === 0;
28019 };
28020
28021 module.exports = isInteger;
28022
28023 /***/
28024 },
28025 /* 44 */
28026 /***/function (module, exports, __webpack_require__) {
28027
28028 var isNumber = __webpack_require__(3);
28029
28030 var isNagative = function isNagative(num) {
28031 return isNumber(num) && num < 0;
28032 };
28033
28034 module.exports = isNagative;
28035
28036 /***/
28037 },
28038 /* 45 */
28039 /***/function (module, exports) {
28040
28041 var PRECISION = 0.00001; // numbers less than this is considered as 0
28042
28043 var isNumberEqual = function isNumberEqual(a, b) {
28044 return Math.abs(a - b) < PRECISION;
28045 };
28046
28047 module.exports = isNumberEqual;
28048
28049 /***/
28050 },
28051 /* 46 */
28052 /***/function (module, exports, __webpack_require__) {
28053
28054 var isNumber = __webpack_require__(3);
28055
28056 var isOdd = function isOdd(num) {
28057 return isNumber(num) && num % 2 !== 0;
28058 };
28059
28060 module.exports = isOdd;
28061
28062 /***/
28063 },
28064 /* 47 */
28065 /***/function (module, exports, __webpack_require__) {
28066
28067 var isNumber = __webpack_require__(3);
28068
28069 var isPositive = function isPositive(num) {
28070 return isNumber(num) && num > 0;
28071 };
28072
28073 module.exports = isPositive;
28074
28075 /***/
28076 },
28077 /* 48 */
28078 /***/function (module, exports) {
28079
28080 var mod = function mod(n, m) {
28081 return (n % m + m) % m;
28082 };
28083
28084 module.exports = mod;
28085
28086 /***/
28087 },
28088 /* 49 */
28089 /***/function (module, exports) {
28090
28091 var DEGREE = 180 / Math.PI;
28092
28093 var toDegree = function toDegree(radian) {
28094 return DEGREE * radian;
28095 };
28096
28097 module.exports = toDegree;
28098
28099 /***/
28100 },
28101 /* 50 */
28102 /***/function (module, exports) {
28103
28104 var RADIAN = Math.PI / 180;
28105
28106 var toRadian = function toRadian(degree) {
28107 return RADIAN * degree;
28108 };
28109
28110 module.exports = toRadian;
28111
28112 /***/
28113 },
28114 /* 51 */
28115 /***/function (module, exports, __webpack_require__) {
28116
28117 /**
28118 * 是否是布尔类型
28119 *
28120 * @param {Object} value 测试的值
28121 * @return {Boolean}
28122 */
28123 var isType = __webpack_require__(1);
28124
28125 var isBoolean = function isBoolean(value) {
28126 return isType(value, 'Boolean');
28127 };
28128
28129 module.exports = isBoolean;
28130
28131 /***/
28132 },
28133 /* 52 */
28134 /***/function (module, exports) {
28135
28136 var isNull = function isNull(value) {
28137 return value === null;
28138 };
28139
28140 module.exports = isNull;
28141
28142 /***/
28143 },
28144 /* 53 */
28145 /***/function (module, exports) {
28146
28147 var isUndefined = function isUndefined(value) {
28148 return value === undefined;
28149 };
28150
28151 module.exports = isUndefined;
28152
28153 /***/
28154 },
28155 /* 54 */
28156 /***/function (module, exports, __webpack_require__) {
28157
28158 var isType = __webpack_require__(1);
28159
28160 var isRegExp = function isRegExp(str) {
28161 return isType(str, 'RegExp');
28162 };
28163
28164 module.exports = isRegExp;
28165
28166 /***/
28167 },
28168 /* 55 */
28169 /***/function (module, exports, __webpack_require__) {
28170
28171 var isString = __webpack_require__(4);
28172 var lowerCase = __webpack_require__(25);
28173
28174 var lowerFirst = function lowerFirst(value) {
28175 if (!isString(value)) {
28176 return value;
28177 }
28178 return lowerCase(value.charAt(0)) + value.substring(1);
28179 };
28180
28181 module.exports = lowerFirst;
28182
28183 /***/
28184 },
28185 /* 56 */
28186 /***/function (module, exports) {
28187
28188 var substitute = function substitute(str, o) {
28189 if (!str || !o) {
28190 return str;
28191 }
28192 return str.replace(/\\?\{([^{}]+)\}/g, function (match, name) {
28193 if (match.charAt(0) === '\\') {
28194 return match.slice(1);
28195 }
28196 return o[name] === undefined ? '' : o[name];
28197 });
28198 };
28199
28200 module.exports = substitute;
28201
28202 /***/
28203 },
28204 /* 57 */
28205 /***/function (module, exports, __webpack_require__) {
28206
28207 var isString = __webpack_require__(4);
28208 var upperCase = __webpack_require__(26);
28209
28210 var upperFirst = function upperFirst(value) {
28211 if (!isString(value)) {
28212 return value;
28213 }
28214 return upperCase(value.charAt(0)) + value.substring(1);
28215 };
28216
28217 module.exports = upperFirst;
28218
28219 /***/
28220 }]
28221 /******/)
28222 );
28223 });
28224 /* WEBPACK VAR INJECTION */
28225 }).call(exports, __webpack_require__(69)(module));
28226
28227 /***/
28228 },
28229 /* 69 */
28230 /***/function (module, exports) {
28231
28232 module.exports = function (module) {
28233 if (!module.webpackPolyfill) {
28234 module.deprecate = function () {};
28235 module.paths = [];
28236 // module.parent = undefined by default
28237 if (!module.children) module.children = [];
28238 Object.defineProperty(module, "loaded", {
28239 enumerable: true,
28240 get: function get() {
28241 return module.l;
28242 }
28243 });
28244 Object.defineProperty(module, "id", {
28245 enumerable: true,
28246 get: function get() {
28247 return module.i;
28248 }
28249 });
28250 module.webpackPolyfill = 1;
28251 }
28252 return module;
28253 };
28254
28255 /***/
28256 },
28257 /* 70 */
28258 /***/function (module, exports, __webpack_require__) {
28259
28260 var Util = __webpack_require__(0);
28261
28262 var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
28263 var CAPITALIZED_ATTRS_MAP = {
28264 r: 'R',
28265 opacity: 'Opacity',
28266 lineWidth: 'LineWidth',
28267 clip: 'Clip',
28268 stroke: 'Stroke',
28269 fill: 'Fill',
28270 strokeOpacity: 'Stroke',
28271 fillOpacity: 'Fill',
28272 x: 'X',
28273 y: 'Y',
28274 rx: 'Rx',
28275 ry: 'Ry',
28276 re: 'Re',
28277 rs: 'Rs',
28278 width: 'Width',
28279 height: 'Height',
28280 img: 'Img',
28281 x1: 'X1',
28282 x2: 'X2',
28283 y1: 'Y1',
28284 y2: 'Y2',
28285 points: 'Points',
28286 p1: 'P1',
28287 p2: 'P2',
28288 p3: 'P3',
28289 p4: 'P4',
28290 text: 'Text',
28291 radius: 'Radius',
28292 textAlign: 'TextAlign',
28293 textBaseline: 'TextBaseline',
28294 font: 'Font',
28295 fontSize: 'FontSize',
28296 fontStyle: 'FontStyle',
28297 fontVariant: 'FontVariant',
28298 fontWeight: 'FontWeight',
28299 fontFamily: 'FontFamily',
28300 clockwise: 'Clockwise',
28301 startAngle: 'StartAngle',
28302 endAngle: 'EndAngle',
28303 path: 'Path',
28304 outline: 'Outline',
28305 html: 'Html'
28306 };
28307 var SVG_ATTR_MAP = {
28308 opacity: 'opacity',
28309 clip: 'clip',
28310 stroke: 'stroke',
28311 fill: 'fill',
28312 strokeOpacity: 'stroke-opacity',
28313 fillOpacity: 'fill-opacity',
28314 strokeStyle: 'stroke',
28315 fillStyle: 'fill',
28316 x: 'x',
28317 y: 'y',
28318 r: 'r',
28319 rx: 'rx',
28320 ry: 'ry',
28321 re: 're',
28322 rs: 'rs',
28323 width: 'width',
28324 height: 'height',
28325 image: 'href',
28326 x1: 'x1',
28327 x2: 'x2',
28328 y1: 'y1',
28329 y2: 'y2',
28330 lineCap: 'stroke-linecap',
28331 lineJoin: 'stroke-linejoin',
28332 lineWidth: 'stroke-width',
28333 lineDash: 'stroke-dasharray',
28334 miterLimit: 'stroke-miterlimit',
28335 font: 'font',
28336 fontSize: 'font-size',
28337 fontStyle: 'font-style',
28338 fontVariant: 'font-variant',
28339 fontWeight: 'font-weight',
28340 fontFamily: 'font-family',
28341 startArrow: 'marker-start',
28342 endArrow: 'marker-end',
28343 preserveAspectRatio: 'preserveAspectRatio'
28344 };
28345 var ALIAS_ATTRS_MAP = {
28346 stroke: 'strokeStyle',
28347 fill: 'fillStyle',
28348 opacity: 'globalAlpha'
28349 };
28350
28351 module.exports = {
28352 canFill: false,
28353 canStroke: false,
28354 initAttrs: function initAttrs(attrs) {
28355 this.__attrs = {
28356 opacity: 1,
28357 fillOpacity: 1,
28358 strokeOpacity: 1
28359 };
28360 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
28361 return this;
28362 },
28363 getDefaultAttrs: function getDefaultAttrs() {
28364 return {};
28365 },
28366
28367 /**
28368 * 设置或者设置属性,有以下 4 种情形:
28369 * - name 不存在, 则返回属性集合
28370 * - name 为字符串,value 为空,获取属性值
28371 * - name 为字符串,value 不为空,设置属性值,返回 this
28372 * - name 为键值对,value 为空,设置属性值
28373 *
28374 * @param {String | Object} name 属性名
28375 * @param {*} value 属性值
28376 * @return {*} 属性值
28377 */
28378 attr: function attr(name, value) {
28379 var self = this;
28380 if (arguments.length === 0) {
28381 return self.__attrs;
28382 }
28383 if (Util.isObject(name)) {
28384 for (var k in name) {
28385 if (ALIAS_ATTRS.indexOf(k) === -1) {
28386 var v = name[k];
28387 self._setAttr(k, v);
28388 }
28389 }
28390 if (self._afterSetAttrAll) {
28391 self._afterSetAttrAll(name);
28392 }
28393 // self.setSilent('box', null);
28394 self.clearBBox();
28395 return self;
28396 }
28397 if (arguments.length === 2) {
28398 self._setAttr(name, value);
28399 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
28400 if (CAPITALIZED_ATTRS_MAP[name] && self[m]) {
28401 self[m](value);
28402 }
28403 self.clearBBox();
28404 return self;
28405 }
28406 return self._getAttr(name);
28407 },
28408 clearBBox: function clearBBox() {
28409 this.setSilent('box', null);
28410 },
28411 _afterSetAttrAll: function _afterSetAttrAll() {},
28412
28413 // 属性获取触发函数
28414 _getAttr: function _getAttr(name) {
28415 return this.__attrs[name];
28416 },
28417
28418 // 属性设置触发函数
28419 _setAttr: function _setAttr(name, value) {
28420 var self = this;
28421 var el = self.get('el');
28422
28423 if (name === 'clip') {
28424 self._setAttrClip(name, value);
28425 return;
28426 }
28427 self.__attrs[name] = value;
28428 if (typeof value === 'number' && isNaN(value)) {
28429 return;
28430 }
28431 if (self.get('destroyed')) {
28432 return;
28433 }
28434 if (name === 'transform' || name === 'rotate') {
28435 self._setAttrTrans(name, value);
28436 } else if (name.startsWith('shadow')) {
28437 self._setAttrShadow(name, value);
28438 } else if (~['stroke', 'strokeStyle', 'fill', 'fillStyle'].indexOf(name) && el) {
28439 if (!value) {
28440 el.setAttribute(SVG_ATTR_MAP[name], 'none');
28441 } else if (/^[r,R,L,l]{1}[\s]*\(/.test(value.trim())) {
28442 self._setAttrGradients(name, value.trim());
28443 } else {
28444 el.setAttribute(SVG_ATTR_MAP[name], value);
28445 }
28446 } else if (~name.toLowerCase().indexOf('arrow')) {
28447 if (!value) {
28448 return self;
28449 }
28450 self._setAttrArrow(name, value);
28451 } else {
28452 // 先存好属性,然后对一些svg和canvas中不同的属性进行特判
28453 if (~['circle', 'ellipse', 'marker'].indexOf(self.type) && ~['x', 'y'].indexOf(name)) {
28454 /**
28455 * 本来考虑想写到对应图形里面的,但是x,y又是svg通用属性,这样会同时存在x,y, cx,cy
28456 * 如果在下面svgAttr设置的时候还是要特判,不如就在这边特殊处理一下吧
28457 */
28458 if (self.type !== 'marker' && typeof value === 'number') {
28459 el.setAttribute('c' + name, value);
28460 }
28461 } else {
28462 var svgAttr = SVG_ATTR_MAP[name];
28463 if (el && svgAttr) {
28464 el.setAttribute(svgAttr, value);
28465 }
28466 var alias = ALIAS_ATTRS_MAP[name];
28467 if (alias) {
28468 svgAttr = SVG_ATTR_MAP[alias];
28469 if (el && svgAttr) {
28470 el.setAttribute(svgAttr, value);
28471 }
28472 self.__attrs[alias] = value;
28473 }
28474 }
28475 }
28476 return self;
28477 },
28478 hasFill: function hasFill() {
28479 return this.canFill && this.__attrs.fillStyle;
28480 },
28481 hasStroke: function hasStroke() {
28482 return this.canStroke && this.__attrs.strokeStyle;
28483 },
28484 _setAttrArrow: function _setAttrArrow(name, value) {
28485 var self = this;
28486 var el = self.get('el');
28487 var defs = self.get('defs');
28488 if (!defs) {
28489 var canvas = self.get('canvas');
28490 if (!canvas) {
28491 this._setAttrDependency(name, value);
28492 return this;
28493 }
28494 defs = canvas.get('defs');
28495 }
28496 name = SVG_ATTR_MAP[name];
28497 if (!name) {
28498 return this;
28499 }
28500 if (!value) {
28501 el.removeAttribute(name);
28502 return this;
28503 }
28504 var id = defs.find(name, { value: value, stroke: self.__attrs.stroke });
28505 if (!id) {
28506 id = defs.addArrow(name, value, self.__attrs.stroke);
28507 }
28508 self.__cfg[name] = id;
28509 self.get('el').setAttribute(name, 'url(#' + id + ')');
28510 },
28511 _setAttrShadow: function _setAttrShadow(name, value) {
28512 var attrs = this.__attrs;
28513 var filter = this.get('filter');
28514 var defs = this.get('defs');
28515 if (!value) {
28516 this.get('el').removeAttribute('filter');
28517 return this;
28518 }
28519 if (filter) {
28520 defs.findById(filter).update(name, value);
28521 return this;
28522 }
28523 if (!defs) {
28524 var canvas = this.get('canvas');
28525 if (!canvas) {
28526 this._setAttrDependency(name, value);
28527 return this;
28528 }
28529 defs = canvas.get('defs');
28530 }
28531 var cfg = {
28532 dx: attrs.shadowOffsetX,
28533 dy: attrs.shadowOffsetY,
28534 blur: attrs.shadowBlur,
28535 color: attrs.shadowColor
28536 };
28537 if (isNaN(Number(cfg.dx)) || isNaN(Number(cfg.dy))) {
28538 return this;
28539 }
28540 var id = defs.find('filter', cfg);
28541 if (!id) {
28542 id = defs.addShadow(cfg, this);
28543 }
28544 this.__cfg.filter = id;
28545 this.get('el').setAttribute('filter', 'url(#' + id + ')');
28546 },
28547 _setAttrGradients: function _setAttrGradients(name, value) {
28548 name = name.replace('Style', '');
28549 var defs = this.get('defs');
28550 if (!value) {
28551 this.get('el').removeAttribute('gradient');
28552 return this;
28553 }
28554 if (!defs) {
28555 var canvas = this.get('canvas');
28556 if (!canvas) {
28557 this._setAttrDependency(name, value);
28558 return this;
28559 }
28560 defs = canvas.get('defs');
28561 }
28562 var id = defs.find('gradient', value);
28563 if (!id) {
28564 id = defs.addGradient(value, this);
28565 }
28566 this.get('el').setAttribute(name, 'url(#' + id + ')');
28567 },
28568 _setAttrDependency: function _setAttrDependency(name, value) {
28569 var dependencies = this.get('dependencies');
28570 if (!dependencies) {
28571 dependencies = {};
28572 }
28573 dependencies[name] = value;
28574 this.__cfg.dependencies = dependencies;
28575 return this;
28576 },
28577 _setAttrClip: function _setAttrClip(name, value) {
28578 var defs = this.get('defs');
28579 var canvas = this.get('canvas');
28580 if (!value) {
28581 this.get('el').removeAttribute('clip-path');
28582 return this;
28583 }
28584 if (!defs) {
28585 var _canvas = this.get('canvas');
28586 if (!_canvas) {
28587 this._setAttrDependency(name, value);
28588 return this;
28589 }
28590 defs = _canvas.get('defs');
28591 }
28592 value.__cfg.canvas = canvas;
28593 var id = defs.addClip(value);
28594 this.get('el').setAttribute('clip-path', 'url(#' + id + ')');
28595 },
28596 _setAttrTrans: function _setAttrTrans(name, value) {
28597 var attrs = this.__attrs;
28598 if (!value) {
28599 this.get('el').removeAttribute('transform');
28600 }
28601 if (!attrs.matrix) {
28602 this.initTransform();
28603 }
28604 if (name === 'transform') {
28605 this.transform(value);
28606 } else {
28607 if (typeof attrs.x === 'undefined' || typeof attrs.y === 'undefined') {
28608 this._setAttrDependency(name, value);
28609 return this;
28610 }
28611 this.rotateAtStart(value);
28612 }
28613 return this;
28614 }
28615 };
28616
28617 /***/
28618 },
28619 /* 71 */
28620 /***/function (module, exports, __webpack_require__) {
28621
28622 var Util = __webpack_require__(0);
28623 var mat3 = __webpack_require__(2).mat3;
28624 var vec3 = __webpack_require__(2).vec3;
28625
28626 // 是否未改变
28627 function isUnchanged(m) {
28628 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
28629 }
28630
28631 // 是否仅仅是scale
28632 function isScale(m) {
28633 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
28634 }
28635
28636 /* function multiple(m1, m2) {
28637 if (!isUnchanged(m2)) {
28638 if (isScale(m2)) {
28639 m1[0] *= m2[0];
28640 m1[4] *= m2[4];
28641 } else {
28642 mat3.multiply(m1, m1, m2);
28643 mat3.multiply(m1, m1, m2);
28644 }
28645 }
28646 }*/
28647
28648 module.exports = {
28649 initTransform: function initTransform() {
28650 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
28651 },
28652 translate: function translate(tx, ty, perform) {
28653 var matrix = this.attr('matrix');
28654 mat3.translate(matrix, matrix, [tx, ty]);
28655 this.attr('matrix', matrix);
28656 if (arguments.length === 2 || perform) {
28657 this._performTransform();
28658 }
28659 return this;
28660 },
28661 rotate: function rotate(radian, perform) {
28662 var matrix = this.attr('matrix');
28663 if (Math.abs(radian) > Math.PI * 2) {
28664 radian = radian / 180 * Math.PI;
28665 }
28666 mat3.rotate(matrix, matrix, radian);
28667 this.attr('matrix', matrix);
28668 if (arguments.length === 1 || perform) {
28669 this._performTransform();
28670 }
28671 return this;
28672 },
28673
28674 /**
28675 * 绕起始点旋转
28676 * @param {Number} rotate 0~360
28677 */
28678 rotateAtStart: function rotateAtStart(rotate) {
28679 var x = this.attr('x');
28680 var y = this.attr('y');
28681 if (Math.abs(rotate) > Math.PI * 2) {
28682 rotate = rotate / 180 * Math.PI;
28683 }
28684 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
28685 },
28686 scale: function scale(s1, s2, perform) {
28687 var matrix = this.attr('matrix');
28688 mat3.scale(matrix, matrix, [s1, s2]);
28689 this.attr('matrix', matrix);
28690 if (arguments.length === 2 || perform) {
28691 this._performTransform();
28692 }
28693 return this;
28694 },
28695
28696 /**
28697 * 移动的到位置
28698 * @param {Number} x 移动到x
28699 * @param {Number} y 移动到y
28700 */
28701 move: function move(x, y) {
28702 var cx = this.get('x') || 0; // 当前的x
28703 var cy = this.get('y') || 0; // 当前的y
28704 this.translate(x - cx, y - cy);
28705 this.set('x', x);
28706 this.set('y', y);
28707 },
28708 _performTransform: function _performTransform() {
28709 var matrix = this.__attrs.matrix;
28710 var transform = [];
28711 for (var i = 0; i < 9; i += 3) {
28712 transform.push(matrix[i] + ',' + matrix[i + 1]);
28713 }
28714 var el = this.get('el');
28715 if (el) {
28716 el.setAttribute('transform', 'matrix(' + transform.join(',') + ')');
28717 }
28718 },
28719 transform: function transform(ts) {
28720 var self = this;
28721 var matrix = self.attr('matrix');
28722 Util.each(ts, function (t) {
28723 switch (t[0]) {
28724 case 't':
28725 self.translate(t[1], t[2], false);
28726 break;
28727 case 's':
28728 self.scale(t[1], t[2], false);
28729 break;
28730 case 'r':
28731 self.rotate(t[1], false);
28732 break;
28733 case 'm':
28734 self.attr('matrix', mat3.multiply([], matrix, t[1]));
28735 break;
28736 default:
28737 break;
28738 }
28739 });
28740 this._performTransform();
28741 return self;
28742 },
28743 setTransform: function setTransform(ts) {
28744 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
28745 return this.transform(ts);
28746 },
28747 getMatrix: function getMatrix() {
28748 return this.attr('matrix');
28749 },
28750 setMatrix: function setMatrix(m) {
28751 this.attr('matrix', m);
28752 this._performTransform();
28753 this.clearTotalMatrix();
28754 return this;
28755 },
28756 apply: function apply(v, root) {
28757 var m = void 0;
28758 if (root) {
28759 m = this._getMatrixByRoot(root);
28760 } else {
28761 m = this.attr('matrix');
28762 }
28763 vec3.transformMat3(v, v, m);
28764 return this;
28765 },
28766 invert: function invert(v) {
28767 var m = this.attr('matrix');
28768 // 单精屏幕下大多数矩阵没变化
28769 if (isScale(m)) {
28770 v[0] /= m[0];
28771 v[1] /= m[4];
28772 } else {
28773 var inm = mat3.invert([], m);
28774 if (inm) {
28775 vec3.transformMat3(v, v, inm);
28776 }
28777 }
28778 return this;
28779 },
28780 resetTransform: function resetTransform(context) {
28781 var mo = this.attr('matrix');
28782 // 不改变时
28783 if (!isUnchanged(mo)) {
28784 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
28785 }
28786 }
28787 };
28788
28789 /***/
28790 },
28791 /* 72 */
28792 /***/function (module, __webpack_exports__, __webpack_require__) {
28793
28794 "use strict";
28795
28796 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
28797 /* harmony export (immutable) */__webpack_exports__["create"] = create;
28798 /* harmony export (immutable) */__webpack_exports__["fromMat4"] = fromMat4;
28799 /* harmony export (immutable) */__webpack_exports__["clone"] = clone;
28800 /* harmony export (immutable) */__webpack_exports__["copy"] = copy;
28801 /* harmony export (immutable) */__webpack_exports__["fromValues"] = fromValues;
28802 /* harmony export (immutable) */__webpack_exports__["set"] = set;
28803 /* harmony export (immutable) */__webpack_exports__["identity"] = identity;
28804 /* harmony export (immutable) */__webpack_exports__["transpose"] = transpose;
28805 /* harmony export (immutable) */__webpack_exports__["invert"] = invert;
28806 /* harmony export (immutable) */__webpack_exports__["adjoint"] = adjoint;
28807 /* harmony export (immutable) */__webpack_exports__["determinant"] = determinant;
28808 /* harmony export (immutable) */__webpack_exports__["multiply"] = multiply;
28809 /* harmony export (immutable) */__webpack_exports__["translate"] = translate;
28810 /* harmony export (immutable) */__webpack_exports__["rotate"] = rotate;
28811 /* harmony export (immutable) */__webpack_exports__["scale"] = scale;
28812 /* harmony export (immutable) */__webpack_exports__["fromTranslation"] = fromTranslation;
28813 /* harmony export (immutable) */__webpack_exports__["fromRotation"] = fromRotation;
28814 /* harmony export (immutable) */__webpack_exports__["fromScaling"] = fromScaling;
28815 /* harmony export (immutable) */__webpack_exports__["fromMat2d"] = fromMat2d;
28816 /* harmony export (immutable) */__webpack_exports__["fromQuat"] = fromQuat;
28817 /* harmony export (immutable) */__webpack_exports__["normalFromMat4"] = normalFromMat4;
28818 /* harmony export (immutable) */__webpack_exports__["projection"] = projection;
28819 /* harmony export (immutable) */__webpack_exports__["str"] = str;
28820 /* harmony export (immutable) */__webpack_exports__["frob"] = frob;
28821 /* harmony export (immutable) */__webpack_exports__["add"] = add;
28822 /* harmony export (immutable) */__webpack_exports__["subtract"] = subtract;
28823 /* harmony export (immutable) */__webpack_exports__["multiplyScalar"] = multiplyScalar;
28824 /* harmony export (immutable) */__webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd;
28825 /* harmony export (immutable) */__webpack_exports__["exactEquals"] = exactEquals;
28826 /* harmony export (immutable) */__webpack_exports__["equals"] = equals;
28827 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "mul", function () {
28828 return mul;
28829 });
28830 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sub", function () {
28831 return sub;
28832 });
28833 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(12);
28834
28835 /**
28836 * 3x3 Matrix
28837 * @module mat3
28838 */
28839
28840 /**
28841 * Creates a new identity mat3
28842 *
28843 * @returns {mat3} a new 3x3 matrix
28844 */
28845 function create() {
28846 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
28847 out[0] = 1;
28848 out[1] = 0;
28849 out[2] = 0;
28850 out[3] = 0;
28851 out[4] = 1;
28852 out[5] = 0;
28853 out[6] = 0;
28854 out[7] = 0;
28855 out[8] = 1;
28856 return out;
28857 }
28858
28859 /**
28860 * Copies the upper-left 3x3 values into the given mat3.
28861 *
28862 * @param {mat3} out the receiving 3x3 matrix
28863 * @param {mat4} a the source 4x4 matrix
28864 * @returns {mat3} out
28865 */
28866 function fromMat4(out, a) {
28867 out[0] = a[0];
28868 out[1] = a[1];
28869 out[2] = a[2];
28870 out[3] = a[4];
28871 out[4] = a[5];
28872 out[5] = a[6];
28873 out[6] = a[8];
28874 out[7] = a[9];
28875 out[8] = a[10];
28876 return out;
28877 }
28878
28879 /**
28880 * Creates a new mat3 initialized with values from an existing matrix
28881 *
28882 * @param {mat3} a matrix to clone
28883 * @returns {mat3} a new 3x3 matrix
28884 */
28885 function clone(a) {
28886 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
28887 out[0] = a[0];
28888 out[1] = a[1];
28889 out[2] = a[2];
28890 out[3] = a[3];
28891 out[4] = a[4];
28892 out[5] = a[5];
28893 out[6] = a[6];
28894 out[7] = a[7];
28895 out[8] = a[8];
28896 return out;
28897 }
28898
28899 /**
28900 * Copy the values from one mat3 to another
28901 *
28902 * @param {mat3} out the receiving matrix
28903 * @param {mat3} a the source matrix
28904 * @returns {mat3} out
28905 */
28906 function copy(out, a) {
28907 out[0] = a[0];
28908 out[1] = a[1];
28909 out[2] = a[2];
28910 out[3] = a[3];
28911 out[4] = a[4];
28912 out[5] = a[5];
28913 out[6] = a[6];
28914 out[7] = a[7];
28915 out[8] = a[8];
28916 return out;
28917 }
28918
28919 /**
28920 * Create a new mat3 with the given values
28921 *
28922 * @param {Number} m00 Component in column 0, row 0 position (index 0)
28923 * @param {Number} m01 Component in column 0, row 1 position (index 1)
28924 * @param {Number} m02 Component in column 0, row 2 position (index 2)
28925 * @param {Number} m10 Component in column 1, row 0 position (index 3)
28926 * @param {Number} m11 Component in column 1, row 1 position (index 4)
28927 * @param {Number} m12 Component in column 1, row 2 position (index 5)
28928 * @param {Number} m20 Component in column 2, row 0 position (index 6)
28929 * @param {Number} m21 Component in column 2, row 1 position (index 7)
28930 * @param {Number} m22 Component in column 2, row 2 position (index 8)
28931 * @returns {mat3} A new mat3
28932 */
28933 function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
28934 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
28935 out[0] = m00;
28936 out[1] = m01;
28937 out[2] = m02;
28938 out[3] = m10;
28939 out[4] = m11;
28940 out[5] = m12;
28941 out[6] = m20;
28942 out[7] = m21;
28943 out[8] = m22;
28944 return out;
28945 }
28946
28947 /**
28948 * Set the components of a mat3 to the given values
28949 *
28950 * @param {mat3} out the receiving matrix
28951 * @param {Number} m00 Component in column 0, row 0 position (index 0)
28952 * @param {Number} m01 Component in column 0, row 1 position (index 1)
28953 * @param {Number} m02 Component in column 0, row 2 position (index 2)
28954 * @param {Number} m10 Component in column 1, row 0 position (index 3)
28955 * @param {Number} m11 Component in column 1, row 1 position (index 4)
28956 * @param {Number} m12 Component in column 1, row 2 position (index 5)
28957 * @param {Number} m20 Component in column 2, row 0 position (index 6)
28958 * @param {Number} m21 Component in column 2, row 1 position (index 7)
28959 * @param {Number} m22 Component in column 2, row 2 position (index 8)
28960 * @returns {mat3} out
28961 */
28962 function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
28963 out[0] = m00;
28964 out[1] = m01;
28965 out[2] = m02;
28966 out[3] = m10;
28967 out[4] = m11;
28968 out[5] = m12;
28969 out[6] = m20;
28970 out[7] = m21;
28971 out[8] = m22;
28972 return out;
28973 }
28974
28975 /**
28976 * Set a mat3 to the identity matrix
28977 *
28978 * @param {mat3} out the receiving matrix
28979 * @returns {mat3} out
28980 */
28981 function identity(out) {
28982 out[0] = 1;
28983 out[1] = 0;
28984 out[2] = 0;
28985 out[3] = 0;
28986 out[4] = 1;
28987 out[5] = 0;
28988 out[6] = 0;
28989 out[7] = 0;
28990 out[8] = 1;
28991 return out;
28992 }
28993
28994 /**
28995 * Transpose the values of a mat3
28996 *
28997 * @param {mat3} out the receiving matrix
28998 * @param {mat3} a the source matrix
28999 * @returns {mat3} out
29000 */
29001 function transpose(out, a) {
29002 // If we are transposing ourselves we can skip a few steps but have to cache some values
29003 if (out === a) {
29004 var a01 = a[1],
29005 a02 = a[2],
29006 a12 = a[5];
29007 out[1] = a[3];
29008 out[2] = a[6];
29009 out[3] = a01;
29010 out[5] = a[7];
29011 out[6] = a02;
29012 out[7] = a12;
29013 } else {
29014 out[0] = a[0];
29015 out[1] = a[3];
29016 out[2] = a[6];
29017 out[3] = a[1];
29018 out[4] = a[4];
29019 out[5] = a[7];
29020 out[6] = a[2];
29021 out[7] = a[5];
29022 out[8] = a[8];
29023 }
29024
29025 return out;
29026 }
29027
29028 /**
29029 * Inverts a mat3
29030 *
29031 * @param {mat3} out the receiving matrix
29032 * @param {mat3} a the source matrix
29033 * @returns {mat3} out
29034 */
29035 function invert(out, a) {
29036 var a00 = a[0],
29037 a01 = a[1],
29038 a02 = a[2];
29039 var a10 = a[3],
29040 a11 = a[4],
29041 a12 = a[5];
29042 var a20 = a[6],
29043 a21 = a[7],
29044 a22 = a[8];
29045
29046 var b01 = a22 * a11 - a12 * a21;
29047 var b11 = -a22 * a10 + a12 * a20;
29048 var b21 = a21 * a10 - a11 * a20;
29049
29050 // Calculate the determinant
29051 var det = a00 * b01 + a01 * b11 + a02 * b21;
29052
29053 if (!det) {
29054 return null;
29055 }
29056 det = 1.0 / det;
29057
29058 out[0] = b01 * det;
29059 out[1] = (-a22 * a01 + a02 * a21) * det;
29060 out[2] = (a12 * a01 - a02 * a11) * det;
29061 out[3] = b11 * det;
29062 out[4] = (a22 * a00 - a02 * a20) * det;
29063 out[5] = (-a12 * a00 + a02 * a10) * det;
29064 out[6] = b21 * det;
29065 out[7] = (-a21 * a00 + a01 * a20) * det;
29066 out[8] = (a11 * a00 - a01 * a10) * det;
29067 return out;
29068 }
29069
29070 /**
29071 * Calculates the adjugate of a mat3
29072 *
29073 * @param {mat3} out the receiving matrix
29074 * @param {mat3} a the source matrix
29075 * @returns {mat3} out
29076 */
29077 function adjoint(out, a) {
29078 var a00 = a[0],
29079 a01 = a[1],
29080 a02 = a[2];
29081 var a10 = a[3],
29082 a11 = a[4],
29083 a12 = a[5];
29084 var a20 = a[6],
29085 a21 = a[7],
29086 a22 = a[8];
29087
29088 out[0] = a11 * a22 - a12 * a21;
29089 out[1] = a02 * a21 - a01 * a22;
29090 out[2] = a01 * a12 - a02 * a11;
29091 out[3] = a12 * a20 - a10 * a22;
29092 out[4] = a00 * a22 - a02 * a20;
29093 out[5] = a02 * a10 - a00 * a12;
29094 out[6] = a10 * a21 - a11 * a20;
29095 out[7] = a01 * a20 - a00 * a21;
29096 out[8] = a00 * a11 - a01 * a10;
29097 return out;
29098 }
29099
29100 /**
29101 * Calculates the determinant of a mat3
29102 *
29103 * @param {mat3} a the source matrix
29104 * @returns {Number} determinant of a
29105 */
29106 function determinant(a) {
29107 var a00 = a[0],
29108 a01 = a[1],
29109 a02 = a[2];
29110 var a10 = a[3],
29111 a11 = a[4],
29112 a12 = a[5];
29113 var a20 = a[6],
29114 a21 = a[7],
29115 a22 = a[8];
29116
29117 return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
29118 }
29119
29120 /**
29121 * Multiplies two mat3's
29122 *
29123 * @param {mat3} out the receiving matrix
29124 * @param {mat3} a the first operand
29125 * @param {mat3} b the second operand
29126 * @returns {mat3} out
29127 */
29128 function multiply(out, a, b) {
29129 var a00 = a[0],
29130 a01 = a[1],
29131 a02 = a[2];
29132 var a10 = a[3],
29133 a11 = a[4],
29134 a12 = a[5];
29135 var a20 = a[6],
29136 a21 = a[7],
29137 a22 = a[8];
29138
29139 var b00 = b[0],
29140 b01 = b[1],
29141 b02 = b[2];
29142 var b10 = b[3],
29143 b11 = b[4],
29144 b12 = b[5];
29145 var b20 = b[6],
29146 b21 = b[7],
29147 b22 = b[8];
29148
29149 out[0] = b00 * a00 + b01 * a10 + b02 * a20;
29150 out[1] = b00 * a01 + b01 * a11 + b02 * a21;
29151 out[2] = b00 * a02 + b01 * a12 + b02 * a22;
29152
29153 out[3] = b10 * a00 + b11 * a10 + b12 * a20;
29154 out[4] = b10 * a01 + b11 * a11 + b12 * a21;
29155 out[5] = b10 * a02 + b11 * a12 + b12 * a22;
29156
29157 out[6] = b20 * a00 + b21 * a10 + b22 * a20;
29158 out[7] = b20 * a01 + b21 * a11 + b22 * a21;
29159 out[8] = b20 * a02 + b21 * a12 + b22 * a22;
29160 return out;
29161 }
29162
29163 /**
29164 * Translate a mat3 by the given vector
29165 *
29166 * @param {mat3} out the receiving matrix
29167 * @param {mat3} a the matrix to translate
29168 * @param {vec2} v vector to translate by
29169 * @returns {mat3} out
29170 */
29171 function translate(out, a, v) {
29172 var a00 = a[0],
29173 a01 = a[1],
29174 a02 = a[2],
29175 a10 = a[3],
29176 a11 = a[4],
29177 a12 = a[5],
29178 a20 = a[6],
29179 a21 = a[7],
29180 a22 = a[8],
29181 x = v[0],
29182 y = v[1];
29183
29184 out[0] = a00;
29185 out[1] = a01;
29186 out[2] = a02;
29187
29188 out[3] = a10;
29189 out[4] = a11;
29190 out[5] = a12;
29191
29192 out[6] = x * a00 + y * a10 + a20;
29193 out[7] = x * a01 + y * a11 + a21;
29194 out[8] = x * a02 + y * a12 + a22;
29195 return out;
29196 }
29197
29198 /**
29199 * Rotates a mat3 by the given angle
29200 *
29201 * @param {mat3} out the receiving matrix
29202 * @param {mat3} a the matrix to rotate
29203 * @param {Number} rad the angle to rotate the matrix by
29204 * @returns {mat3} out
29205 */
29206 function rotate(out, a, rad) {
29207 var a00 = a[0],
29208 a01 = a[1],
29209 a02 = a[2],
29210 a10 = a[3],
29211 a11 = a[4],
29212 a12 = a[5],
29213 a20 = a[6],
29214 a21 = a[7],
29215 a22 = a[8],
29216 s = Math.sin(rad),
29217 c = Math.cos(rad);
29218
29219 out[0] = c * a00 + s * a10;
29220 out[1] = c * a01 + s * a11;
29221 out[2] = c * a02 + s * a12;
29222
29223 out[3] = c * a10 - s * a00;
29224 out[4] = c * a11 - s * a01;
29225 out[5] = c * a12 - s * a02;
29226
29227 out[6] = a20;
29228 out[7] = a21;
29229 out[8] = a22;
29230 return out;
29231 };
29232
29233 /**
29234 * Scales the mat3 by the dimensions in the given vec2
29235 *
29236 * @param {mat3} out the receiving matrix
29237 * @param {mat3} a the matrix to rotate
29238 * @param {vec2} v the vec2 to scale the matrix by
29239 * @returns {mat3} out
29240 **/
29241 function scale(out, a, v) {
29242 var x = v[0],
29243 y = v[1];
29244
29245 out[0] = x * a[0];
29246 out[1] = x * a[1];
29247 out[2] = x * a[2];
29248
29249 out[3] = y * a[3];
29250 out[4] = y * a[4];
29251 out[5] = y * a[5];
29252
29253 out[6] = a[6];
29254 out[7] = a[7];
29255 out[8] = a[8];
29256 return out;
29257 }
29258
29259 /**
29260 * Creates a matrix from a vector translation
29261 * This is equivalent to (but much faster than):
29262 *
29263 * mat3.identity(dest);
29264 * mat3.translate(dest, dest, vec);
29265 *
29266 * @param {mat3} out mat3 receiving operation result
29267 * @param {vec2} v Translation vector
29268 * @returns {mat3} out
29269 */
29270 function fromTranslation(out, v) {
29271 out[0] = 1;
29272 out[1] = 0;
29273 out[2] = 0;
29274 out[3] = 0;
29275 out[4] = 1;
29276 out[5] = 0;
29277 out[6] = v[0];
29278 out[7] = v[1];
29279 out[8] = 1;
29280 return out;
29281 }
29282
29283 /**
29284 * Creates a matrix from a given angle
29285 * This is equivalent to (but much faster than):
29286 *
29287 * mat3.identity(dest);
29288 * mat3.rotate(dest, dest, rad);
29289 *
29290 * @param {mat3} out mat3 receiving operation result
29291 * @param {Number} rad the angle to rotate the matrix by
29292 * @returns {mat3} out
29293 */
29294 function fromRotation(out, rad) {
29295 var s = Math.sin(rad),
29296 c = Math.cos(rad);
29297
29298 out[0] = c;
29299 out[1] = s;
29300 out[2] = 0;
29301
29302 out[3] = -s;
29303 out[4] = c;
29304 out[5] = 0;
29305
29306 out[6] = 0;
29307 out[7] = 0;
29308 out[8] = 1;
29309 return out;
29310 }
29311
29312 /**
29313 * Creates a matrix from a vector scaling
29314 * This is equivalent to (but much faster than):
29315 *
29316 * mat3.identity(dest);
29317 * mat3.scale(dest, dest, vec);
29318 *
29319 * @param {mat3} out mat3 receiving operation result
29320 * @param {vec2} v Scaling vector
29321 * @returns {mat3} out
29322 */
29323 function fromScaling(out, v) {
29324 out[0] = v[0];
29325 out[1] = 0;
29326 out[2] = 0;
29327
29328 out[3] = 0;
29329 out[4] = v[1];
29330 out[5] = 0;
29331
29332 out[6] = 0;
29333 out[7] = 0;
29334 out[8] = 1;
29335 return out;
29336 }
29337
29338 /**
29339 * Copies the values from a mat2d into a mat3
29340 *
29341 * @param {mat3} out the receiving matrix
29342 * @param {mat2d} a the matrix to copy
29343 * @returns {mat3} out
29344 **/
29345 function fromMat2d(out, a) {
29346 out[0] = a[0];
29347 out[1] = a[1];
29348 out[2] = 0;
29349
29350 out[3] = a[2];
29351 out[4] = a[3];
29352 out[5] = 0;
29353
29354 out[6] = a[4];
29355 out[7] = a[5];
29356 out[8] = 1;
29357 return out;
29358 }
29359
29360 /**
29361 * Calculates a 3x3 matrix from the given quaternion
29362 *
29363 * @param {mat3} out mat3 receiving operation result
29364 * @param {quat} q Quaternion to create matrix from
29365 *
29366 * @returns {mat3} out
29367 */
29368 function fromQuat(out, q) {
29369 var x = q[0],
29370 y = q[1],
29371 z = q[2],
29372 w = q[3];
29373 var x2 = x + x;
29374 var y2 = y + y;
29375 var z2 = z + z;
29376
29377 var xx = x * x2;
29378 var yx = y * x2;
29379 var yy = y * y2;
29380 var zx = z * x2;
29381 var zy = z * y2;
29382 var zz = z * z2;
29383 var wx = w * x2;
29384 var wy = w * y2;
29385 var wz = w * z2;
29386
29387 out[0] = 1 - yy - zz;
29388 out[3] = yx - wz;
29389 out[6] = zx + wy;
29390
29391 out[1] = yx + wz;
29392 out[4] = 1 - xx - zz;
29393 out[7] = zy - wx;
29394
29395 out[2] = zx - wy;
29396 out[5] = zy + wx;
29397 out[8] = 1 - xx - yy;
29398
29399 return out;
29400 }
29401
29402 /**
29403 * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
29404 *
29405 * @param {mat3} out mat3 receiving operation result
29406 * @param {mat4} a Mat4 to derive the normal matrix from
29407 *
29408 * @returns {mat3} out
29409 */
29410 function normalFromMat4(out, a) {
29411 var a00 = a[0],
29412 a01 = a[1],
29413 a02 = a[2],
29414 a03 = a[3];
29415 var a10 = a[4],
29416 a11 = a[5],
29417 a12 = a[6],
29418 a13 = a[7];
29419 var a20 = a[8],
29420 a21 = a[9],
29421 a22 = a[10],
29422 a23 = a[11];
29423 var a30 = a[12],
29424 a31 = a[13],
29425 a32 = a[14],
29426 a33 = a[15];
29427
29428 var b00 = a00 * a11 - a01 * a10;
29429 var b01 = a00 * a12 - a02 * a10;
29430 var b02 = a00 * a13 - a03 * a10;
29431 var b03 = a01 * a12 - a02 * a11;
29432 var b04 = a01 * a13 - a03 * a11;
29433 var b05 = a02 * a13 - a03 * a12;
29434 var b06 = a20 * a31 - a21 * a30;
29435 var b07 = a20 * a32 - a22 * a30;
29436 var b08 = a20 * a33 - a23 * a30;
29437 var b09 = a21 * a32 - a22 * a31;
29438 var b10 = a21 * a33 - a23 * a31;
29439 var b11 = a22 * a33 - a23 * a32;
29440
29441 // Calculate the determinant
29442 var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
29443
29444 if (!det) {
29445 return null;
29446 }
29447 det = 1.0 / det;
29448
29449 out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
29450 out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
29451 out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
29452
29453 out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
29454 out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
29455 out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
29456
29457 out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
29458 out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
29459 out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
29460
29461 return out;
29462 }
29463
29464 /**
29465 * Generates a 2D projection matrix with the given bounds
29466 *
29467 * @param {mat3} out mat3 frustum matrix will be written into
29468 * @param {number} width Width of your gl context
29469 * @param {number} height Height of gl context
29470 * @returns {mat3} out
29471 */
29472 function projection(out, width, height) {
29473 out[0] = 2 / width;
29474 out[1] = 0;
29475 out[2] = 0;
29476 out[3] = 0;
29477 out[4] = -2 / height;
29478 out[5] = 0;
29479 out[6] = -1;
29480 out[7] = 1;
29481 out[8] = 1;
29482 return out;
29483 }
29484
29485 /**
29486 * Returns a string representation of a mat3
29487 *
29488 * @param {mat3} a matrix to represent as a string
29489 * @returns {String} string representation of the matrix
29490 */
29491 function str(a) {
29492 return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
29493 }
29494
29495 /**
29496 * Returns Frobenius norm of a mat3
29497 *
29498 * @param {mat3} a the matrix to calculate Frobenius norm of
29499 * @returns {Number} Frobenius norm
29500 */
29501 function frob(a) {
29502 return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2));
29503 }
29504
29505 /**
29506 * Adds two mat3's
29507 *
29508 * @param {mat3} out the receiving matrix
29509 * @param {mat3} a the first operand
29510 * @param {mat3} b the second operand
29511 * @returns {mat3} out
29512 */
29513 function add(out, a, b) {
29514 out[0] = a[0] + b[0];
29515 out[1] = a[1] + b[1];
29516 out[2] = a[2] + b[2];
29517 out[3] = a[3] + b[3];
29518 out[4] = a[4] + b[4];
29519 out[5] = a[5] + b[5];
29520 out[6] = a[6] + b[6];
29521 out[7] = a[7] + b[7];
29522 out[8] = a[8] + b[8];
29523 return out;
29524 }
29525
29526 /**
29527 * Subtracts matrix b from matrix a
29528 *
29529 * @param {mat3} out the receiving matrix
29530 * @param {mat3} a the first operand
29531 * @param {mat3} b the second operand
29532 * @returns {mat3} out
29533 */
29534 function subtract(out, a, b) {
29535 out[0] = a[0] - b[0];
29536 out[1] = a[1] - b[1];
29537 out[2] = a[2] - b[2];
29538 out[3] = a[3] - b[3];
29539 out[4] = a[4] - b[4];
29540 out[5] = a[5] - b[5];
29541 out[6] = a[6] - b[6];
29542 out[7] = a[7] - b[7];
29543 out[8] = a[8] - b[8];
29544 return out;
29545 }
29546
29547 /**
29548 * Multiply each element of the matrix by a scalar.
29549 *
29550 * @param {mat3} out the receiving matrix
29551 * @param {mat3} a the matrix to scale
29552 * @param {Number} b amount to scale the matrix's elements by
29553 * @returns {mat3} out
29554 */
29555 function multiplyScalar(out, a, b) {
29556 out[0] = a[0] * b;
29557 out[1] = a[1] * b;
29558 out[2] = a[2] * b;
29559 out[3] = a[3] * b;
29560 out[4] = a[4] * b;
29561 out[5] = a[5] * b;
29562 out[6] = a[6] * b;
29563 out[7] = a[7] * b;
29564 out[8] = a[8] * b;
29565 return out;
29566 }
29567
29568 /**
29569 * Adds two mat3's after multiplying each element of the second operand by a scalar value.
29570 *
29571 * @param {mat3} out the receiving vector
29572 * @param {mat3} a the first operand
29573 * @param {mat3} b the second operand
29574 * @param {Number} scale the amount to scale b's elements by before adding
29575 * @returns {mat3} out
29576 */
29577 function multiplyScalarAndAdd(out, a, b, scale) {
29578 out[0] = a[0] + b[0] * scale;
29579 out[1] = a[1] + b[1] * scale;
29580 out[2] = a[2] + b[2] * scale;
29581 out[3] = a[3] + b[3] * scale;
29582 out[4] = a[4] + b[4] * scale;
29583 out[5] = a[5] + b[5] * scale;
29584 out[6] = a[6] + b[6] * scale;
29585 out[7] = a[7] + b[7] * scale;
29586 out[8] = a[8] + b[8] * scale;
29587 return out;
29588 }
29589
29590 /**
29591 * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
29592 *
29593 * @param {mat3} a The first matrix.
29594 * @param {mat3} b The second matrix.
29595 * @returns {Boolean} True if the matrices are equal, false otherwise.
29596 */
29597 function exactEquals(a, b) {
29598 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
29599 }
29600
29601 /**
29602 * Returns whether or not the matrices have approximately the same elements in the same position.
29603 *
29604 * @param {mat3} a The first matrix.
29605 * @param {mat3} b The second matrix.
29606 * @returns {Boolean} True if the matrices are equal, false otherwise.
29607 */
29608 function equals(a, b) {
29609 var a0 = a[0],
29610 a1 = a[1],
29611 a2 = a[2],
29612 a3 = a[3],
29613 a4 = a[4],
29614 a5 = a[5],
29615 a6 = a[6],
29616 a7 = a[7],
29617 a8 = a[8];
29618 var b0 = b[0],
29619 b1 = b[1],
29620 b2 = b[2],
29621 b3 = b[3],
29622 b4 = b[4],
29623 b5 = b[5],
29624 b6 = b[6],
29625 b7 = b[7],
29626 b8 = b[8];
29627 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a8), Math.abs(b8));
29628 }
29629
29630 /**
29631 * Alias for {@link mat3.multiply}
29632 * @function
29633 */
29634 var mul = multiply;
29635
29636 /**
29637 * Alias for {@link mat3.subtract}
29638 * @function
29639 */
29640 var sub = subtract;
29641
29642 /***/
29643 },
29644 /* 73 */
29645 /***/function (module, __webpack_exports__, __webpack_require__) {
29646
29647 "use strict";
29648
29649 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
29650 /* harmony export (immutable) */__webpack_exports__["create"] = create;
29651 /* harmony export (immutable) */__webpack_exports__["clone"] = clone;
29652 /* harmony export (immutable) */__webpack_exports__["length"] = length;
29653 /* harmony export (immutable) */__webpack_exports__["fromValues"] = fromValues;
29654 /* harmony export (immutable) */__webpack_exports__["copy"] = copy;
29655 /* harmony export (immutable) */__webpack_exports__["set"] = set;
29656 /* harmony export (immutable) */__webpack_exports__["add"] = add;
29657 /* harmony export (immutable) */__webpack_exports__["subtract"] = subtract;
29658 /* harmony export (immutable) */__webpack_exports__["multiply"] = multiply;
29659 /* harmony export (immutable) */__webpack_exports__["divide"] = divide;
29660 /* harmony export (immutable) */__webpack_exports__["ceil"] = ceil;
29661 /* harmony export (immutable) */__webpack_exports__["floor"] = floor;
29662 /* harmony export (immutable) */__webpack_exports__["min"] = min;
29663 /* harmony export (immutable) */__webpack_exports__["max"] = max;
29664 /* harmony export (immutable) */__webpack_exports__["round"] = round;
29665 /* harmony export (immutable) */__webpack_exports__["scale"] = scale;
29666 /* harmony export (immutable) */__webpack_exports__["scaleAndAdd"] = scaleAndAdd;
29667 /* harmony export (immutable) */__webpack_exports__["distance"] = distance;
29668 /* harmony export (immutable) */__webpack_exports__["squaredDistance"] = squaredDistance;
29669 /* harmony export (immutable) */__webpack_exports__["squaredLength"] = squaredLength;
29670 /* harmony export (immutable) */__webpack_exports__["negate"] = negate;
29671 /* harmony export (immutable) */__webpack_exports__["inverse"] = inverse;
29672 /* harmony export (immutable) */__webpack_exports__["normalize"] = normalize;
29673 /* harmony export (immutable) */__webpack_exports__["dot"] = dot;
29674 /* harmony export (immutable) */__webpack_exports__["cross"] = cross;
29675 /* harmony export (immutable) */__webpack_exports__["lerp"] = lerp;
29676 /* harmony export (immutable) */__webpack_exports__["hermite"] = hermite;
29677 /* harmony export (immutable) */__webpack_exports__["bezier"] = bezier;
29678 /* harmony export (immutable) */__webpack_exports__["random"] = random;
29679 /* harmony export (immutable) */__webpack_exports__["transformMat4"] = transformMat4;
29680 /* harmony export (immutable) */__webpack_exports__["transformMat3"] = transformMat3;
29681 /* harmony export (immutable) */__webpack_exports__["transformQuat"] = transformQuat;
29682 /* harmony export (immutable) */__webpack_exports__["rotateX"] = rotateX;
29683 /* harmony export (immutable) */__webpack_exports__["rotateY"] = rotateY;
29684 /* harmony export (immutable) */__webpack_exports__["rotateZ"] = rotateZ;
29685 /* harmony export (immutable) */__webpack_exports__["angle"] = angle;
29686 /* harmony export (immutable) */__webpack_exports__["str"] = str;
29687 /* harmony export (immutable) */__webpack_exports__["exactEquals"] = exactEquals;
29688 /* harmony export (immutable) */__webpack_exports__["equals"] = equals;
29689 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sub", function () {
29690 return sub;
29691 });
29692 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "mul", function () {
29693 return mul;
29694 });
29695 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "div", function () {
29696 return div;
29697 });
29698 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "dist", function () {
29699 return dist;
29700 });
29701 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrDist", function () {
29702 return sqrDist;
29703 });
29704 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "len", function () {
29705 return len;
29706 });
29707 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrLen", function () {
29708 return sqrLen;
29709 });
29710 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "forEach", function () {
29711 return forEach;
29712 });
29713 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(12);
29714
29715 /**
29716 * 3 Dimensional Vector
29717 * @module vec3
29718 */
29719
29720 /**
29721 * Creates a new, empty vec3
29722 *
29723 * @returns {vec3} a new 3D vector
29724 */
29725 function create() {
29726 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
29727 out[0] = 0;
29728 out[1] = 0;
29729 out[2] = 0;
29730 return out;
29731 }
29732
29733 /**
29734 * Creates a new vec3 initialized with values from an existing vector
29735 *
29736 * @param {vec3} a vector to clone
29737 * @returns {vec3} a new 3D vector
29738 */
29739 function clone(a) {
29740 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
29741 out[0] = a[0];
29742 out[1] = a[1];
29743 out[2] = a[2];
29744 return out;
29745 }
29746
29747 /**
29748 * Calculates the length of a vec3
29749 *
29750 * @param {vec3} a vector to calculate length of
29751 * @returns {Number} length of a
29752 */
29753 function length(a) {
29754 var x = a[0];
29755 var y = a[1];
29756 var z = a[2];
29757 return Math.sqrt(x * x + y * y + z * z);
29758 }
29759
29760 /**
29761 * Creates a new vec3 initialized with the given values
29762 *
29763 * @param {Number} x X component
29764 * @param {Number} y Y component
29765 * @param {Number} z Z component
29766 * @returns {vec3} a new 3D vector
29767 */
29768 function fromValues(x, y, z) {
29769 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
29770 out[0] = x;
29771 out[1] = y;
29772 out[2] = z;
29773 return out;
29774 }
29775
29776 /**
29777 * Copy the values from one vec3 to another
29778 *
29779 * @param {vec3} out the receiving vector
29780 * @param {vec3} a the source vector
29781 * @returns {vec3} out
29782 */
29783 function copy(out, a) {
29784 out[0] = a[0];
29785 out[1] = a[1];
29786 out[2] = a[2];
29787 return out;
29788 }
29789
29790 /**
29791 * Set the components of a vec3 to the given values
29792 *
29793 * @param {vec3} out the receiving vector
29794 * @param {Number} x X component
29795 * @param {Number} y Y component
29796 * @param {Number} z Z component
29797 * @returns {vec3} out
29798 */
29799 function set(out, x, y, z) {
29800 out[0] = x;
29801 out[1] = y;
29802 out[2] = z;
29803 return out;
29804 }
29805
29806 /**
29807 * Adds two vec3's
29808 *
29809 * @param {vec3} out the receiving vector
29810 * @param {vec3} a the first operand
29811 * @param {vec3} b the second operand
29812 * @returns {vec3} out
29813 */
29814 function add(out, a, b) {
29815 out[0] = a[0] + b[0];
29816 out[1] = a[1] + b[1];
29817 out[2] = a[2] + b[2];
29818 return out;
29819 }
29820
29821 /**
29822 * Subtracts vector b from vector a
29823 *
29824 * @param {vec3} out the receiving vector
29825 * @param {vec3} a the first operand
29826 * @param {vec3} b the second operand
29827 * @returns {vec3} out
29828 */
29829 function subtract(out, a, b) {
29830 out[0] = a[0] - b[0];
29831 out[1] = a[1] - b[1];
29832 out[2] = a[2] - b[2];
29833 return out;
29834 }
29835
29836 /**
29837 * Multiplies two vec3's
29838 *
29839 * @param {vec3} out the receiving vector
29840 * @param {vec3} a the first operand
29841 * @param {vec3} b the second operand
29842 * @returns {vec3} out
29843 */
29844 function multiply(out, a, b) {
29845 out[0] = a[0] * b[0];
29846 out[1] = a[1] * b[1];
29847 out[2] = a[2] * b[2];
29848 return out;
29849 }
29850
29851 /**
29852 * Divides two vec3's
29853 *
29854 * @param {vec3} out the receiving vector
29855 * @param {vec3} a the first operand
29856 * @param {vec3} b the second operand
29857 * @returns {vec3} out
29858 */
29859 function divide(out, a, b) {
29860 out[0] = a[0] / b[0];
29861 out[1] = a[1] / b[1];
29862 out[2] = a[2] / b[2];
29863 return out;
29864 }
29865
29866 /**
29867 * Math.ceil the components of a vec3
29868 *
29869 * @param {vec3} out the receiving vector
29870 * @param {vec3} a vector to ceil
29871 * @returns {vec3} out
29872 */
29873 function ceil(out, a) {
29874 out[0] = Math.ceil(a[0]);
29875 out[1] = Math.ceil(a[1]);
29876 out[2] = Math.ceil(a[2]);
29877 return out;
29878 }
29879
29880 /**
29881 * Math.floor the components of a vec3
29882 *
29883 * @param {vec3} out the receiving vector
29884 * @param {vec3} a vector to floor
29885 * @returns {vec3} out
29886 */
29887 function floor(out, a) {
29888 out[0] = Math.floor(a[0]);
29889 out[1] = Math.floor(a[1]);
29890 out[2] = Math.floor(a[2]);
29891 return out;
29892 }
29893
29894 /**
29895 * Returns the minimum of two vec3's
29896 *
29897 * @param {vec3} out the receiving vector
29898 * @param {vec3} a the first operand
29899 * @param {vec3} b the second operand
29900 * @returns {vec3} out
29901 */
29902 function min(out, a, b) {
29903 out[0] = Math.min(a[0], b[0]);
29904 out[1] = Math.min(a[1], b[1]);
29905 out[2] = Math.min(a[2], b[2]);
29906 return out;
29907 }
29908
29909 /**
29910 * Returns the maximum of two vec3's
29911 *
29912 * @param {vec3} out the receiving vector
29913 * @param {vec3} a the first operand
29914 * @param {vec3} b the second operand
29915 * @returns {vec3} out
29916 */
29917 function max(out, a, b) {
29918 out[0] = Math.max(a[0], b[0]);
29919 out[1] = Math.max(a[1], b[1]);
29920 out[2] = Math.max(a[2], b[2]);
29921 return out;
29922 }
29923
29924 /**
29925 * Math.round the components of a vec3
29926 *
29927 * @param {vec3} out the receiving vector
29928 * @param {vec3} a vector to round
29929 * @returns {vec3} out
29930 */
29931 function round(out, a) {
29932 out[0] = Math.round(a[0]);
29933 out[1] = Math.round(a[1]);
29934 out[2] = Math.round(a[2]);
29935 return out;
29936 }
29937
29938 /**
29939 * Scales a vec3 by a scalar number
29940 *
29941 * @param {vec3} out the receiving vector
29942 * @param {vec3} a the vector to scale
29943 * @param {Number} b amount to scale the vector by
29944 * @returns {vec3} out
29945 */
29946 function scale(out, a, b) {
29947 out[0] = a[0] * b;
29948 out[1] = a[1] * b;
29949 out[2] = a[2] * b;
29950 return out;
29951 }
29952
29953 /**
29954 * Adds two vec3's after scaling the second operand by a scalar value
29955 *
29956 * @param {vec3} out the receiving vector
29957 * @param {vec3} a the first operand
29958 * @param {vec3} b the second operand
29959 * @param {Number} scale the amount to scale b by before adding
29960 * @returns {vec3} out
29961 */
29962 function scaleAndAdd(out, a, b, scale) {
29963 out[0] = a[0] + b[0] * scale;
29964 out[1] = a[1] + b[1] * scale;
29965 out[2] = a[2] + b[2] * scale;
29966 return out;
29967 }
29968
29969 /**
29970 * Calculates the euclidian distance between two vec3's
29971 *
29972 * @param {vec3} a the first operand
29973 * @param {vec3} b the second operand
29974 * @returns {Number} distance between a and b
29975 */
29976 function distance(a, b) {
29977 var x = b[0] - a[0];
29978 var y = b[1] - a[1];
29979 var z = b[2] - a[2];
29980 return Math.sqrt(x * x + y * y + z * z);
29981 }
29982
29983 /**
29984 * Calculates the squared euclidian distance between two vec3's
29985 *
29986 * @param {vec3} a the first operand
29987 * @param {vec3} b the second operand
29988 * @returns {Number} squared distance between a and b
29989 */
29990 function squaredDistance(a, b) {
29991 var x = b[0] - a[0];
29992 var y = b[1] - a[1];
29993 var z = b[2] - a[2];
29994 return x * x + y * y + z * z;
29995 }
29996
29997 /**
29998 * Calculates the squared length of a vec3
29999 *
30000 * @param {vec3} a vector to calculate squared length of
30001 * @returns {Number} squared length of a
30002 */
30003 function squaredLength(a) {
30004 var x = a[0];
30005 var y = a[1];
30006 var z = a[2];
30007 return x * x + y * y + z * z;
30008 }
30009
30010 /**
30011 * Negates the components of a vec3
30012 *
30013 * @param {vec3} out the receiving vector
30014 * @param {vec3} a vector to negate
30015 * @returns {vec3} out
30016 */
30017 function negate(out, a) {
30018 out[0] = -a[0];
30019 out[1] = -a[1];
30020 out[2] = -a[2];
30021 return out;
30022 }
30023
30024 /**
30025 * Returns the inverse of the components of a vec3
30026 *
30027 * @param {vec3} out the receiving vector
30028 * @param {vec3} a vector to invert
30029 * @returns {vec3} out
30030 */
30031 function inverse(out, a) {
30032 out[0] = 1.0 / a[0];
30033 out[1] = 1.0 / a[1];
30034 out[2] = 1.0 / a[2];
30035 return out;
30036 }
30037
30038 /**
30039 * Normalize a vec3
30040 *
30041 * @param {vec3} out the receiving vector
30042 * @param {vec3} a vector to normalize
30043 * @returns {vec3} out
30044 */
30045 function normalize(out, a) {
30046 var x = a[0];
30047 var y = a[1];
30048 var z = a[2];
30049 var len = x * x + y * y + z * z;
30050 if (len > 0) {
30051 //TODO: evaluate use of glm_invsqrt here?
30052 len = 1 / Math.sqrt(len);
30053 out[0] = a[0] * len;
30054 out[1] = a[1] * len;
30055 out[2] = a[2] * len;
30056 }
30057 return out;
30058 }
30059
30060 /**
30061 * Calculates the dot product of two vec3's
30062 *
30063 * @param {vec3} a the first operand
30064 * @param {vec3} b the second operand
30065 * @returns {Number} dot product of a and b
30066 */
30067 function dot(a, b) {
30068 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
30069 }
30070
30071 /**
30072 * Computes the cross product of two vec3's
30073 *
30074 * @param {vec3} out the receiving vector
30075 * @param {vec3} a the first operand
30076 * @param {vec3} b the second operand
30077 * @returns {vec3} out
30078 */
30079 function cross(out, a, b) {
30080 var ax = a[0],
30081 ay = a[1],
30082 az = a[2];
30083 var bx = b[0],
30084 by = b[1],
30085 bz = b[2];
30086
30087 out[0] = ay * bz - az * by;
30088 out[1] = az * bx - ax * bz;
30089 out[2] = ax * by - ay * bx;
30090 return out;
30091 }
30092
30093 /**
30094 * Performs a linear interpolation between two vec3's
30095 *
30096 * @param {vec3} out the receiving vector
30097 * @param {vec3} a the first operand
30098 * @param {vec3} b the second operand
30099 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
30100 * @returns {vec3} out
30101 */
30102 function lerp(out, a, b, t) {
30103 var ax = a[0];
30104 var ay = a[1];
30105 var az = a[2];
30106 out[0] = ax + t * (b[0] - ax);
30107 out[1] = ay + t * (b[1] - ay);
30108 out[2] = az + t * (b[2] - az);
30109 return out;
30110 }
30111
30112 /**
30113 * Performs a hermite interpolation with two control points
30114 *
30115 * @param {vec3} out the receiving vector
30116 * @param {vec3} a the first operand
30117 * @param {vec3} b the second operand
30118 * @param {vec3} c the third operand
30119 * @param {vec3} d the fourth operand
30120 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
30121 * @returns {vec3} out
30122 */
30123 function hermite(out, a, b, c, d, t) {
30124 var factorTimes2 = t * t;
30125 var factor1 = factorTimes2 * (2 * t - 3) + 1;
30126 var factor2 = factorTimes2 * (t - 2) + t;
30127 var factor3 = factorTimes2 * (t - 1);
30128 var factor4 = factorTimes2 * (3 - 2 * t);
30129
30130 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
30131 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
30132 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
30133
30134 return out;
30135 }
30136
30137 /**
30138 * Performs a bezier interpolation with two control points
30139 *
30140 * @param {vec3} out the receiving vector
30141 * @param {vec3} a the first operand
30142 * @param {vec3} b the second operand
30143 * @param {vec3} c the third operand
30144 * @param {vec3} d the fourth operand
30145 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
30146 * @returns {vec3} out
30147 */
30148 function bezier(out, a, b, c, d, t) {
30149 var inverseFactor = 1 - t;
30150 var inverseFactorTimesTwo = inverseFactor * inverseFactor;
30151 var factorTimes2 = t * t;
30152 var factor1 = inverseFactorTimesTwo * inverseFactor;
30153 var factor2 = 3 * t * inverseFactorTimesTwo;
30154 var factor3 = 3 * factorTimes2 * inverseFactor;
30155 var factor4 = factorTimes2 * t;
30156
30157 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
30158 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
30159 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
30160
30161 return out;
30162 }
30163
30164 /**
30165 * Generates a random vector with the given scale
30166 *
30167 * @param {vec3} out the receiving vector
30168 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
30169 * @returns {vec3} out
30170 */
30171 function random(out, scale) {
30172 scale = scale || 1.0;
30173
30174 var r = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 * Math.PI;
30175 var z = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 - 1.0;
30176 var zScale = Math.sqrt(1.0 - z * z) * scale;
30177
30178 out[0] = Math.cos(r) * zScale;
30179 out[1] = Math.sin(r) * zScale;
30180 out[2] = z * scale;
30181 return out;
30182 }
30183
30184 /**
30185 * Transforms the vec3 with a mat4.
30186 * 4th vector component is implicitly '1'
30187 *
30188 * @param {vec3} out the receiving vector
30189 * @param {vec3} a the vector to transform
30190 * @param {mat4} m matrix to transform with
30191 * @returns {vec3} out
30192 */
30193 function transformMat4(out, a, m) {
30194 var x = a[0],
30195 y = a[1],
30196 z = a[2];
30197 var w = m[3] * x + m[7] * y + m[11] * z + m[15];
30198 w = w || 1.0;
30199 out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
30200 out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
30201 out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
30202 return out;
30203 }
30204
30205 /**
30206 * Transforms the vec3 with a mat3.
30207 *
30208 * @param {vec3} out the receiving vector
30209 * @param {vec3} a the vector to transform
30210 * @param {mat3} m the 3x3 matrix to transform with
30211 * @returns {vec3} out
30212 */
30213 function transformMat3(out, a, m) {
30214 var x = a[0],
30215 y = a[1],
30216 z = a[2];
30217 out[0] = x * m[0] + y * m[3] + z * m[6];
30218 out[1] = x * m[1] + y * m[4] + z * m[7];
30219 out[2] = x * m[2] + y * m[5] + z * m[8];
30220 return out;
30221 }
30222
30223 /**
30224 * Transforms the vec3 with a quat
30225 * Can also be used for dual quaternions. (Multiply it with the real part)
30226 *
30227 * @param {vec3} out the receiving vector
30228 * @param {vec3} a the vector to transform
30229 * @param {quat} q quaternion to transform with
30230 * @returns {vec3} out
30231 */
30232 function transformQuat(out, a, q) {
30233 // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
30234 var qx = q[0],
30235 qy = q[1],
30236 qz = q[2],
30237 qw = q[3];
30238 var x = a[0],
30239 y = a[1],
30240 z = a[2];
30241 // var qvec = [qx, qy, qz];
30242 // var uv = vec3.cross([], qvec, a);
30243 var uvx = qy * z - qz * y,
30244 uvy = qz * x - qx * z,
30245 uvz = qx * y - qy * x;
30246 // var uuv = vec3.cross([], qvec, uv);
30247 var uuvx = qy * uvz - qz * uvy,
30248 uuvy = qz * uvx - qx * uvz,
30249 uuvz = qx * uvy - qy * uvx;
30250 // vec3.scale(uv, uv, 2 * w);
30251 var w2 = qw * 2;
30252 uvx *= w2;
30253 uvy *= w2;
30254 uvz *= w2;
30255 // vec3.scale(uuv, uuv, 2);
30256 uuvx *= 2;
30257 uuvy *= 2;
30258 uuvz *= 2;
30259 // return vec3.add(out, a, vec3.add(out, uv, uuv));
30260 out[0] = x + uvx + uuvx;
30261 out[1] = y + uvy + uuvy;
30262 out[2] = z + uvz + uuvz;
30263 return out;
30264 }
30265
30266 /**
30267 * Rotate a 3D vector around the x-axis
30268 * @param {vec3} out The receiving vec3
30269 * @param {vec3} a The vec3 point to rotate
30270 * @param {vec3} b The origin of the rotation
30271 * @param {Number} c The angle of rotation
30272 * @returns {vec3} out
30273 */
30274 function rotateX(out, a, b, c) {
30275 var p = [],
30276 r = [];
30277 //Translate point to the origin
30278 p[0] = a[0] - b[0];
30279 p[1] = a[1] - b[1];
30280 p[2] = a[2] - b[2];
30281
30282 //perform rotation
30283 r[0] = p[0];
30284 r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
30285 r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
30286
30287 //translate to correct position
30288 out[0] = r[0] + b[0];
30289 out[1] = r[1] + b[1];
30290 out[2] = r[2] + b[2];
30291
30292 return out;
30293 }
30294
30295 /**
30296 * Rotate a 3D vector around the y-axis
30297 * @param {vec3} out The receiving vec3
30298 * @param {vec3} a The vec3 point to rotate
30299 * @param {vec3} b The origin of the rotation
30300 * @param {Number} c The angle of rotation
30301 * @returns {vec3} out
30302 */
30303 function rotateY(out, a, b, c) {
30304 var p = [],
30305 r = [];
30306 //Translate point to the origin
30307 p[0] = a[0] - b[0];
30308 p[1] = a[1] - b[1];
30309 p[2] = a[2] - b[2];
30310
30311 //perform rotation
30312 r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
30313 r[1] = p[1];
30314 r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
30315
30316 //translate to correct position
30317 out[0] = r[0] + b[0];
30318 out[1] = r[1] + b[1];
30319 out[2] = r[2] + b[2];
30320
30321 return out;
30322 }
30323
30324 /**
30325 * Rotate a 3D vector around the z-axis
30326 * @param {vec3} out The receiving vec3
30327 * @param {vec3} a The vec3 point to rotate
30328 * @param {vec3} b The origin of the rotation
30329 * @param {Number} c The angle of rotation
30330 * @returns {vec3} out
30331 */
30332 function rotateZ(out, a, b, c) {
30333 var p = [],
30334 r = [];
30335 //Translate point to the origin
30336 p[0] = a[0] - b[0];
30337 p[1] = a[1] - b[1];
30338 p[2] = a[2] - b[2];
30339
30340 //perform rotation
30341 r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
30342 r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
30343 r[2] = p[2];
30344
30345 //translate to correct position
30346 out[0] = r[0] + b[0];
30347 out[1] = r[1] + b[1];
30348 out[2] = r[2] + b[2];
30349
30350 return out;
30351 }
30352
30353 /**
30354 * Get the angle between two 3D vectors
30355 * @param {vec3} a The first operand
30356 * @param {vec3} b The second operand
30357 * @returns {Number} The angle in radians
30358 */
30359 function angle(a, b) {
30360 var tempA = fromValues(a[0], a[1], a[2]);
30361 var tempB = fromValues(b[0], b[1], b[2]);
30362
30363 normalize(tempA, tempA);
30364 normalize(tempB, tempB);
30365
30366 var cosine = dot(tempA, tempB);
30367
30368 if (cosine > 1.0) {
30369 return 0;
30370 } else if (cosine < -1.0) {
30371 return Math.PI;
30372 } else {
30373 return Math.acos(cosine);
30374 }
30375 }
30376
30377 /**
30378 * Returns a string representation of a vector
30379 *
30380 * @param {vec3} a vector to represent as a string
30381 * @returns {String} string representation of the vector
30382 */
30383 function str(a) {
30384 return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
30385 }
30386
30387 /**
30388 * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
30389 *
30390 * @param {vec3} a The first vector.
30391 * @param {vec3} b The second vector.
30392 * @returns {Boolean} True if the vectors are equal, false otherwise.
30393 */
30394 function exactEquals(a, b) {
30395 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
30396 }
30397
30398 /**
30399 * Returns whether or not the vectors have approximately the same elements in the same position.
30400 *
30401 * @param {vec3} a The first vector.
30402 * @param {vec3} b The second vector.
30403 * @returns {Boolean} True if the vectors are equal, false otherwise.
30404 */
30405 function equals(a, b) {
30406 var a0 = a[0],
30407 a1 = a[1],
30408 a2 = a[2];
30409 var b0 = b[0],
30410 b1 = b[1],
30411 b2 = b[2];
30412 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2));
30413 }
30414
30415 /**
30416 * Alias for {@link vec3.subtract}
30417 * @function
30418 */
30419 var sub = subtract;
30420
30421 /**
30422 * Alias for {@link vec3.multiply}
30423 * @function
30424 */
30425 var mul = multiply;
30426
30427 /**
30428 * Alias for {@link vec3.divide}
30429 * @function
30430 */
30431 var div = divide;
30432
30433 /**
30434 * Alias for {@link vec3.distance}
30435 * @function
30436 */
30437 var dist = distance;
30438
30439 /**
30440 * Alias for {@link vec3.squaredDistance}
30441 * @function
30442 */
30443 var sqrDist = squaredDistance;
30444
30445 /**
30446 * Alias for {@link vec3.length}
30447 * @function
30448 */
30449 var len = length;
30450
30451 /**
30452 * Alias for {@link vec3.squaredLength}
30453 * @function
30454 */
30455 var sqrLen = squaredLength;
30456
30457 /**
30458 * Perform some operation over an array of vec3s.
30459 *
30460 * @param {Array} a the array of vectors to iterate over
30461 * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
30462 * @param {Number} offset Number of elements to skip at the beginning of the array
30463 * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
30464 * @param {Function} fn Function to call for each vector in the array
30465 * @param {Object} [arg] additional argument to pass to fn
30466 * @returns {Array} a
30467 * @function
30468 */
30469 var forEach = function () {
30470 var vec = create();
30471
30472 return function (a, stride, offset, count, fn, arg) {
30473 var i = void 0,
30474 l = void 0;
30475 if (!stride) {
30476 stride = 3;
30477 }
30478
30479 if (!offset) {
30480 offset = 0;
30481 }
30482
30483 if (count) {
30484 l = Math.min(count * stride + offset, a.length);
30485 } else {
30486 l = a.length;
30487 }
30488
30489 for (i = offset; i < l; i += stride) {
30490 vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
30491 fn(vec, vec, arg);
30492 a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
30493 }
30494
30495 return a;
30496 };
30497 }();
30498
30499 /***/
30500 },
30501 /* 74 */
30502 /***/function (module, __webpack_exports__, __webpack_require__) {
30503
30504 "use strict";
30505
30506 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
30507 /* harmony export (immutable) */__webpack_exports__["create"] = create;
30508 /* harmony export (immutable) */__webpack_exports__["clone"] = clone;
30509 /* harmony export (immutable) */__webpack_exports__["fromValues"] = fromValues;
30510 /* harmony export (immutable) */__webpack_exports__["copy"] = copy;
30511 /* harmony export (immutable) */__webpack_exports__["set"] = set;
30512 /* harmony export (immutable) */__webpack_exports__["add"] = add;
30513 /* harmony export (immutable) */__webpack_exports__["subtract"] = subtract;
30514 /* harmony export (immutable) */__webpack_exports__["multiply"] = multiply;
30515 /* harmony export (immutable) */__webpack_exports__["divide"] = divide;
30516 /* harmony export (immutable) */__webpack_exports__["ceil"] = ceil;
30517 /* harmony export (immutable) */__webpack_exports__["floor"] = floor;
30518 /* harmony export (immutable) */__webpack_exports__["min"] = min;
30519 /* harmony export (immutable) */__webpack_exports__["max"] = max;
30520 /* harmony export (immutable) */__webpack_exports__["round"] = round;
30521 /* harmony export (immutable) */__webpack_exports__["scale"] = scale;
30522 /* harmony export (immutable) */__webpack_exports__["scaleAndAdd"] = scaleAndAdd;
30523 /* harmony export (immutable) */__webpack_exports__["distance"] = distance;
30524 /* harmony export (immutable) */__webpack_exports__["squaredDistance"] = squaredDistance;
30525 /* harmony export (immutable) */__webpack_exports__["length"] = length;
30526 /* harmony export (immutable) */__webpack_exports__["squaredLength"] = squaredLength;
30527 /* harmony export (immutable) */__webpack_exports__["negate"] = negate;
30528 /* harmony export (immutable) */__webpack_exports__["inverse"] = inverse;
30529 /* harmony export (immutable) */__webpack_exports__["normalize"] = normalize;
30530 /* harmony export (immutable) */__webpack_exports__["dot"] = dot;
30531 /* harmony export (immutable) */__webpack_exports__["cross"] = cross;
30532 /* harmony export (immutable) */__webpack_exports__["lerp"] = lerp;
30533 /* harmony export (immutable) */__webpack_exports__["random"] = random;
30534 /* harmony export (immutable) */__webpack_exports__["transformMat2"] = transformMat2;
30535 /* harmony export (immutable) */__webpack_exports__["transformMat2d"] = transformMat2d;
30536 /* harmony export (immutable) */__webpack_exports__["transformMat3"] = transformMat3;
30537 /* harmony export (immutable) */__webpack_exports__["transformMat4"] = transformMat4;
30538 /* harmony export (immutable) */__webpack_exports__["rotate"] = rotate;
30539 /* harmony export (immutable) */__webpack_exports__["angle"] = angle;
30540 /* harmony export (immutable) */__webpack_exports__["str"] = str;
30541 /* harmony export (immutable) */__webpack_exports__["exactEquals"] = exactEquals;
30542 /* harmony export (immutable) */__webpack_exports__["equals"] = equals;
30543 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "len", function () {
30544 return len;
30545 });
30546 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sub", function () {
30547 return sub;
30548 });
30549 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "mul", function () {
30550 return mul;
30551 });
30552 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "div", function () {
30553 return div;
30554 });
30555 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "dist", function () {
30556 return dist;
30557 });
30558 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrDist", function () {
30559 return sqrDist;
30560 });
30561 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "sqrLen", function () {
30562 return sqrLen;
30563 });
30564 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "forEach", function () {
30565 return forEach;
30566 });
30567 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(12);
30568
30569 /**
30570 * 2 Dimensional Vector
30571 * @module vec2
30572 */
30573
30574 /**
30575 * Creates a new, empty vec2
30576 *
30577 * @returns {vec2} a new 2D vector
30578 */
30579 function create() {
30580 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
30581 out[0] = 0;
30582 out[1] = 0;
30583 return out;
30584 }
30585
30586 /**
30587 * Creates a new vec2 initialized with values from an existing vector
30588 *
30589 * @param {vec2} a vector to clone
30590 * @returns {vec2} a new 2D vector
30591 */
30592 function clone(a) {
30593 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
30594 out[0] = a[0];
30595 out[1] = a[1];
30596 return out;
30597 }
30598
30599 /**
30600 * Creates a new vec2 initialized with the given values
30601 *
30602 * @param {Number} x X component
30603 * @param {Number} y Y component
30604 * @returns {vec2} a new 2D vector
30605 */
30606 function fromValues(x, y) {
30607 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
30608 out[0] = x;
30609 out[1] = y;
30610 return out;
30611 }
30612
30613 /**
30614 * Copy the values from one vec2 to another
30615 *
30616 * @param {vec2} out the receiving vector
30617 * @param {vec2} a the source vector
30618 * @returns {vec2} out
30619 */
30620 function copy(out, a) {
30621 out[0] = a[0];
30622 out[1] = a[1];
30623 return out;
30624 }
30625
30626 /**
30627 * Set the components of a vec2 to the given values
30628 *
30629 * @param {vec2} out the receiving vector
30630 * @param {Number} x X component
30631 * @param {Number} y Y component
30632 * @returns {vec2} out
30633 */
30634 function set(out, x, y) {
30635 out[0] = x;
30636 out[1] = y;
30637 return out;
30638 }
30639
30640 /**
30641 * Adds two vec2's
30642 *
30643 * @param {vec2} out the receiving vector
30644 * @param {vec2} a the first operand
30645 * @param {vec2} b the second operand
30646 * @returns {vec2} out
30647 */
30648 function add(out, a, b) {
30649 out[0] = a[0] + b[0];
30650 out[1] = a[1] + b[1];
30651 return out;
30652 }
30653
30654 /**
30655 * Subtracts vector b from vector a
30656 *
30657 * @param {vec2} out the receiving vector
30658 * @param {vec2} a the first operand
30659 * @param {vec2} b the second operand
30660 * @returns {vec2} out
30661 */
30662 function subtract(out, a, b) {
30663 out[0] = a[0] - b[0];
30664 out[1] = a[1] - b[1];
30665 return out;
30666 }
30667
30668 /**
30669 * Multiplies two vec2's
30670 *
30671 * @param {vec2} out the receiving vector
30672 * @param {vec2} a the first operand
30673 * @param {vec2} b the second operand
30674 * @returns {vec2} out
30675 */
30676 function multiply(out, a, b) {
30677 out[0] = a[0] * b[0];
30678 out[1] = a[1] * b[1];
30679 return out;
30680 }
30681
30682 /**
30683 * Divides two vec2's
30684 *
30685 * @param {vec2} out the receiving vector
30686 * @param {vec2} a the first operand
30687 * @param {vec2} b the second operand
30688 * @returns {vec2} out
30689 */
30690 function divide(out, a, b) {
30691 out[0] = a[0] / b[0];
30692 out[1] = a[1] / b[1];
30693 return out;
30694 }
30695
30696 /**
30697 * Math.ceil the components of a vec2
30698 *
30699 * @param {vec2} out the receiving vector
30700 * @param {vec2} a vector to ceil
30701 * @returns {vec2} out
30702 */
30703 function ceil(out, a) {
30704 out[0] = Math.ceil(a[0]);
30705 out[1] = Math.ceil(a[1]);
30706 return out;
30707 }
30708
30709 /**
30710 * Math.floor the components of a vec2
30711 *
30712 * @param {vec2} out the receiving vector
30713 * @param {vec2} a vector to floor
30714 * @returns {vec2} out
30715 */
30716 function floor(out, a) {
30717 out[0] = Math.floor(a[0]);
30718 out[1] = Math.floor(a[1]);
30719 return out;
30720 }
30721
30722 /**
30723 * Returns the minimum of two vec2's
30724 *
30725 * @param {vec2} out the receiving vector
30726 * @param {vec2} a the first operand
30727 * @param {vec2} b the second operand
30728 * @returns {vec2} out
30729 */
30730 function min(out, a, b) {
30731 out[0] = Math.min(a[0], b[0]);
30732 out[1] = Math.min(a[1], b[1]);
30733 return out;
30734 }
30735
30736 /**
30737 * Returns the maximum of two vec2's
30738 *
30739 * @param {vec2} out the receiving vector
30740 * @param {vec2} a the first operand
30741 * @param {vec2} b the second operand
30742 * @returns {vec2} out
30743 */
30744 function max(out, a, b) {
30745 out[0] = Math.max(a[0], b[0]);
30746 out[1] = Math.max(a[1], b[1]);
30747 return out;
30748 }
30749
30750 /**
30751 * Math.round the components of a vec2
30752 *
30753 * @param {vec2} out the receiving vector
30754 * @param {vec2} a vector to round
30755 * @returns {vec2} out
30756 */
30757 function round(out, a) {
30758 out[0] = Math.round(a[0]);
30759 out[1] = Math.round(a[1]);
30760 return out;
30761 }
30762
30763 /**
30764 * Scales a vec2 by a scalar number
30765 *
30766 * @param {vec2} out the receiving vector
30767 * @param {vec2} a the vector to scale
30768 * @param {Number} b amount to scale the vector by
30769 * @returns {vec2} out
30770 */
30771 function scale(out, a, b) {
30772 out[0] = a[0] * b;
30773 out[1] = a[1] * b;
30774 return out;
30775 }
30776
30777 /**
30778 * Adds two vec2's after scaling the second operand by a scalar value
30779 *
30780 * @param {vec2} out the receiving vector
30781 * @param {vec2} a the first operand
30782 * @param {vec2} b the second operand
30783 * @param {Number} scale the amount to scale b by before adding
30784 * @returns {vec2} out
30785 */
30786 function scaleAndAdd(out, a, b, scale) {
30787 out[0] = a[0] + b[0] * scale;
30788 out[1] = a[1] + b[1] * scale;
30789 return out;
30790 }
30791
30792 /**
30793 * Calculates the euclidian distance between two vec2's
30794 *
30795 * @param {vec2} a the first operand
30796 * @param {vec2} b the second operand
30797 * @returns {Number} distance between a and b
30798 */
30799 function distance(a, b) {
30800 var x = b[0] - a[0],
30801 y = b[1] - a[1];
30802 return Math.sqrt(x * x + y * y);
30803 }
30804
30805 /**
30806 * Calculates the squared euclidian distance between two vec2's
30807 *
30808 * @param {vec2} a the first operand
30809 * @param {vec2} b the second operand
30810 * @returns {Number} squared distance between a and b
30811 */
30812 function squaredDistance(a, b) {
30813 var x = b[0] - a[0],
30814 y = b[1] - a[1];
30815 return x * x + y * y;
30816 }
30817
30818 /**
30819 * Calculates the length of a vec2
30820 *
30821 * @param {vec2} a vector to calculate length of
30822 * @returns {Number} length of a
30823 */
30824 function length(a) {
30825 var x = a[0],
30826 y = a[1];
30827 return Math.sqrt(x * x + y * y);
30828 }
30829
30830 /**
30831 * Calculates the squared length of a vec2
30832 *
30833 * @param {vec2} a vector to calculate squared length of
30834 * @returns {Number} squared length of a
30835 */
30836 function squaredLength(a) {
30837 var x = a[0],
30838 y = a[1];
30839 return x * x + y * y;
30840 }
30841
30842 /**
30843 * Negates the components of a vec2
30844 *
30845 * @param {vec2} out the receiving vector
30846 * @param {vec2} a vector to negate
30847 * @returns {vec2} out
30848 */
30849 function negate(out, a) {
30850 out[0] = -a[0];
30851 out[1] = -a[1];
30852 return out;
30853 }
30854
30855 /**
30856 * Returns the inverse of the components of a vec2
30857 *
30858 * @param {vec2} out the receiving vector
30859 * @param {vec2} a vector to invert
30860 * @returns {vec2} out
30861 */
30862 function inverse(out, a) {
30863 out[0] = 1.0 / a[0];
30864 out[1] = 1.0 / a[1];
30865 return out;
30866 }
30867
30868 /**
30869 * Normalize a vec2
30870 *
30871 * @param {vec2} out the receiving vector
30872 * @param {vec2} a vector to normalize
30873 * @returns {vec2} out
30874 */
30875 function normalize(out, a) {
30876 var x = a[0],
30877 y = a[1];
30878 var len = x * x + y * y;
30879 if (len > 0) {
30880 //TODO: evaluate use of glm_invsqrt here?
30881 len = 1 / Math.sqrt(len);
30882 out[0] = a[0] * len;
30883 out[1] = a[1] * len;
30884 }
30885 return out;
30886 }
30887
30888 /**
30889 * Calculates the dot product of two vec2's
30890 *
30891 * @param {vec2} a the first operand
30892 * @param {vec2} b the second operand
30893 * @returns {Number} dot product of a and b
30894 */
30895 function dot(a, b) {
30896 return a[0] * b[0] + a[1] * b[1];
30897 }
30898
30899 /**
30900 * Computes the cross product of two vec2's
30901 * Note that the cross product must by definition produce a 3D vector
30902 *
30903 * @param {vec3} out the receiving vector
30904 * @param {vec2} a the first operand
30905 * @param {vec2} b the second operand
30906 * @returns {vec3} out
30907 */
30908 function cross(out, a, b) {
30909 var z = a[0] * b[1] - a[1] * b[0];
30910 out[0] = out[1] = 0;
30911 out[2] = z;
30912 return out;
30913 }
30914
30915 /**
30916 * Performs a linear interpolation between two vec2's
30917 *
30918 * @param {vec2} out the receiving vector
30919 * @param {vec2} a the first operand
30920 * @param {vec2} b the second operand
30921 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
30922 * @returns {vec2} out
30923 */
30924 function lerp(out, a, b, t) {
30925 var ax = a[0],
30926 ay = a[1];
30927 out[0] = ax + t * (b[0] - ax);
30928 out[1] = ay + t * (b[1] - ay);
30929 return out;
30930 }
30931
30932 /**
30933 * Generates a random vector with the given scale
30934 *
30935 * @param {vec2} out the receiving vector
30936 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
30937 * @returns {vec2} out
30938 */
30939 function random(out, scale) {
30940 scale = scale || 1.0;
30941 var r = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 * Math.PI;
30942 out[0] = Math.cos(r) * scale;
30943 out[1] = Math.sin(r) * scale;
30944 return out;
30945 }
30946
30947 /**
30948 * Transforms the vec2 with a mat2
30949 *
30950 * @param {vec2} out the receiving vector
30951 * @param {vec2} a the vector to transform
30952 * @param {mat2} m matrix to transform with
30953 * @returns {vec2} out
30954 */
30955 function transformMat2(out, a, m) {
30956 var x = a[0],
30957 y = a[1];
30958 out[0] = m[0] * x + m[2] * y;
30959 out[1] = m[1] * x + m[3] * y;
30960 return out;
30961 }
30962
30963 /**
30964 * Transforms the vec2 with a mat2d
30965 *
30966 * @param {vec2} out the receiving vector
30967 * @param {vec2} a the vector to transform
30968 * @param {mat2d} m matrix to transform with
30969 * @returns {vec2} out
30970 */
30971 function transformMat2d(out, a, m) {
30972 var x = a[0],
30973 y = a[1];
30974 out[0] = m[0] * x + m[2] * y + m[4];
30975 out[1] = m[1] * x + m[3] * y + m[5];
30976 return out;
30977 }
30978
30979 /**
30980 * Transforms the vec2 with a mat3
30981 * 3rd vector component is implicitly '1'
30982 *
30983 * @param {vec2} out the receiving vector
30984 * @param {vec2} a the vector to transform
30985 * @param {mat3} m matrix to transform with
30986 * @returns {vec2} out
30987 */
30988 function transformMat3(out, a, m) {
30989 var x = a[0],
30990 y = a[1];
30991 out[0] = m[0] * x + m[3] * y + m[6];
30992 out[1] = m[1] * x + m[4] * y + m[7];
30993 return out;
30994 }
30995
30996 /**
30997 * Transforms the vec2 with a mat4
30998 * 3rd vector component is implicitly '0'
30999 * 4th vector component is implicitly '1'
31000 *
31001 * @param {vec2} out the receiving vector
31002 * @param {vec2} a the vector to transform
31003 * @param {mat4} m matrix to transform with
31004 * @returns {vec2} out
31005 */
31006 function transformMat4(out, a, m) {
31007 var x = a[0];
31008 var y = a[1];
31009 out[0] = m[0] * x + m[4] * y + m[12];
31010 out[1] = m[1] * x + m[5] * y + m[13];
31011 return out;
31012 }
31013
31014 /**
31015 * Rotate a 2D vector
31016 * @param {vec2} out The receiving vec2
31017 * @param {vec2} a The vec2 point to rotate
31018 * @param {vec2} b The origin of the rotation
31019 * @param {Number} c The angle of rotation
31020 * @returns {vec2} out
31021 */
31022 function rotate(out, a, b, c) {
31023 //Translate point to the origin
31024 var p0 = a[0] - b[0],
31025 p1 = a[1] - b[1],
31026 sinC = Math.sin(c),
31027 cosC = Math.cos(c);
31028
31029 //perform rotation and translate to correct position
31030 out[0] = p0 * cosC - p1 * sinC + b[0];
31031 out[1] = p0 * sinC + p1 * cosC + b[1];
31032
31033 return out;
31034 }
31035
31036 /**
31037 * Get the angle between two 2D vectors
31038 * @param {vec2} a The first operand
31039 * @param {vec2} b The second operand
31040 * @returns {Number} The angle in radians
31041 */
31042 function angle(a, b) {
31043 var x1 = a[0],
31044 y1 = a[1],
31045 x2 = b[0],
31046 y2 = b[1];
31047
31048 var len1 = x1 * x1 + y1 * y1;
31049 if (len1 > 0) {
31050 //TODO: evaluate use of glm_invsqrt here?
31051 len1 = 1 / Math.sqrt(len1);
31052 }
31053
31054 var len2 = x2 * x2 + y2 * y2;
31055 if (len2 > 0) {
31056 //TODO: evaluate use of glm_invsqrt here?
31057 len2 = 1 / Math.sqrt(len2);
31058 }
31059
31060 var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
31061
31062 if (cosine > 1.0) {
31063 return 0;
31064 } else if (cosine < -1.0) {
31065 return Math.PI;
31066 } else {
31067 return Math.acos(cosine);
31068 }
31069 }
31070
31071 /**
31072 * Returns a string representation of a vector
31073 *
31074 * @param {vec2} a vector to represent as a string
31075 * @returns {String} string representation of the vector
31076 */
31077 function str(a) {
31078 return 'vec2(' + a[0] + ', ' + a[1] + ')';
31079 }
31080
31081 /**
31082 * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
31083 *
31084 * @param {vec2} a The first vector.
31085 * @param {vec2} b The second vector.
31086 * @returns {Boolean} True if the vectors are equal, false otherwise.
31087 */
31088 function exactEquals(a, b) {
31089 return a[0] === b[0] && a[1] === b[1];
31090 }
31091
31092 /**
31093 * Returns whether or not the vectors have approximately the same elements in the same position.
31094 *
31095 * @param {vec2} a The first vector.
31096 * @param {vec2} b The second vector.
31097 * @returns {Boolean} True if the vectors are equal, false otherwise.
31098 */
31099 function equals(a, b) {
31100 var a0 = a[0],
31101 a1 = a[1];
31102 var b0 = b[0],
31103 b1 = b[1];
31104 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1));
31105 }
31106
31107 /**
31108 * Alias for {@link vec2.length}
31109 * @function
31110 */
31111 var len = length;
31112
31113 /**
31114 * Alias for {@link vec2.subtract}
31115 * @function
31116 */
31117 var sub = subtract;
31118
31119 /**
31120 * Alias for {@link vec2.multiply}
31121 * @function
31122 */
31123 var mul = multiply;
31124
31125 /**
31126 * Alias for {@link vec2.divide}
31127 * @function
31128 */
31129 var div = divide;
31130
31131 /**
31132 * Alias for {@link vec2.distance}
31133 * @function
31134 */
31135 var dist = distance;
31136
31137 /**
31138 * Alias for {@link vec2.squaredDistance}
31139 * @function
31140 */
31141 var sqrDist = squaredDistance;
31142
31143 /**
31144 * Alias for {@link vec2.squaredLength}
31145 * @function
31146 */
31147 var sqrLen = squaredLength;
31148
31149 /**
31150 * Perform some operation over an array of vec2s.
31151 *
31152 * @param {Array} a the array of vectors to iterate over
31153 * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
31154 * @param {Number} offset Number of elements to skip at the beginning of the array
31155 * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
31156 * @param {Function} fn Function to call for each vector in the array
31157 * @param {Object} [arg] additional argument to pass to fn
31158 * @returns {Array} a
31159 * @function
31160 */
31161 var forEach = function () {
31162 var vec = create();
31163
31164 return function (a, stride, offset, count, fn, arg) {
31165 var i = void 0,
31166 l = void 0;
31167 if (!stride) {
31168 stride = 2;
31169 }
31170
31171 if (!offset) {
31172 offset = 0;
31173 }
31174
31175 if (count) {
31176 l = Math.min(count * stride + offset, a.length);
31177 } else {
31178 l = a.length;
31179 }
31180
31181 for (i = offset; i < l; i += stride) {
31182 vec[0] = a[i];vec[1] = a[i + 1];
31183 fn(vec, vec, arg);
31184 a[i] = vec[0];a[i + 1] = vec[1];
31185 }
31186
31187 return a;
31188 };
31189 }();
31190
31191 /***/
31192 },
31193 /* 75 */
31194 /***/function (module, __webpack_exports__, __webpack_require__) {
31195
31196 "use strict";
31197
31198 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
31199 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__src_linear__ = __webpack_require__(76);
31200 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeLinear", function () {
31201 return __WEBPACK_IMPORTED_MODULE_0__src_linear__["a"];
31202 });
31203 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_quad__ = __webpack_require__(77);
31204 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuad", function () {
31205 return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"];
31206 });
31207 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuadIn", function () {
31208 return __WEBPACK_IMPORTED_MODULE_1__src_quad__["a"];
31209 });
31210 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuadOut", function () {
31211 return __WEBPACK_IMPORTED_MODULE_1__src_quad__["c"];
31212 });
31213 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeQuadInOut", function () {
31214 return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"];
31215 });
31216 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_cubic__ = __webpack_require__(78);
31217 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubic", function () {
31218 return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"];
31219 });
31220 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubicIn", function () {
31221 return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["a"];
31222 });
31223 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubicOut", function () {
31224 return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["c"];
31225 });
31226 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCubicInOut", function () {
31227 return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"];
31228 });
31229 /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__src_poly__ = __webpack_require__(79);
31230 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePoly", function () {
31231 return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"];
31232 });
31233 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePolyIn", function () {
31234 return __WEBPACK_IMPORTED_MODULE_3__src_poly__["a"];
31235 });
31236 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePolyOut", function () {
31237 return __WEBPACK_IMPORTED_MODULE_3__src_poly__["c"];
31238 });
31239 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easePolyInOut", function () {
31240 return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"];
31241 });
31242 /* harmony import */var __WEBPACK_IMPORTED_MODULE_4__src_sin__ = __webpack_require__(80);
31243 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSin", function () {
31244 return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"];
31245 });
31246 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSinIn", function () {
31247 return __WEBPACK_IMPORTED_MODULE_4__src_sin__["a"];
31248 });
31249 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSinOut", function () {
31250 return __WEBPACK_IMPORTED_MODULE_4__src_sin__["c"];
31251 });
31252 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeSinInOut", function () {
31253 return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"];
31254 });
31255 /* harmony import */var __WEBPACK_IMPORTED_MODULE_5__src_exp__ = __webpack_require__(81);
31256 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExp", function () {
31257 return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"];
31258 });
31259 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExpIn", function () {
31260 return __WEBPACK_IMPORTED_MODULE_5__src_exp__["a"];
31261 });
31262 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExpOut", function () {
31263 return __WEBPACK_IMPORTED_MODULE_5__src_exp__["c"];
31264 });
31265 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeExpInOut", function () {
31266 return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"];
31267 });
31268 /* harmony import */var __WEBPACK_IMPORTED_MODULE_6__src_circle__ = __webpack_require__(82);
31269 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircle", function () {
31270 return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"];
31271 });
31272 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircleIn", function () {
31273 return __WEBPACK_IMPORTED_MODULE_6__src_circle__["a"];
31274 });
31275 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircleOut", function () {
31276 return __WEBPACK_IMPORTED_MODULE_6__src_circle__["c"];
31277 });
31278 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeCircleInOut", function () {
31279 return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"];
31280 });
31281 /* harmony import */var __WEBPACK_IMPORTED_MODULE_7__src_bounce__ = __webpack_require__(83);
31282 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounce", function () {
31283 return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"];
31284 });
31285 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounceIn", function () {
31286 return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["a"];
31287 });
31288 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounceOut", function () {
31289 return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"];
31290 });
31291 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBounceInOut", function () {
31292 return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["b"];
31293 });
31294 /* harmony import */var __WEBPACK_IMPORTED_MODULE_8__src_back__ = __webpack_require__(84);
31295 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBack", function () {
31296 return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"];
31297 });
31298 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBackIn", function () {
31299 return __WEBPACK_IMPORTED_MODULE_8__src_back__["a"];
31300 });
31301 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBackOut", function () {
31302 return __WEBPACK_IMPORTED_MODULE_8__src_back__["c"];
31303 });
31304 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeBackInOut", function () {
31305 return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"];
31306 });
31307 /* harmony import */var __WEBPACK_IMPORTED_MODULE_9__src_elastic__ = __webpack_require__(85);
31308 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElastic", function () {
31309 return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"];
31310 });
31311 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElasticIn", function () {
31312 return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["a"];
31313 });
31314 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElasticOut", function () {
31315 return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"];
31316 });
31317 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "easeElasticInOut", function () {
31318 return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["b"];
31319 });
31320
31321 /***/
31322 },
31323 /* 76 */
31324 /***/function (module, __webpack_exports__, __webpack_require__) {
31325
31326 "use strict";
31327 /* harmony export (immutable) */
31328 __webpack_exports__["a"] = linear;
31329 function linear(t) {
31330 return +t;
31331 }
31332
31333 /***/
31334 },
31335 /* 77 */
31336 /***/function (module, __webpack_exports__, __webpack_require__) {
31337
31338 "use strict";
31339 /* harmony export (immutable) */
31340 __webpack_exports__["a"] = quadIn;
31341 /* harmony export (immutable) */__webpack_exports__["c"] = quadOut;
31342 /* harmony export (immutable) */__webpack_exports__["b"] = quadInOut;
31343 function quadIn(t) {
31344 return t * t;
31345 }
31346
31347 function quadOut(t) {
31348 return t * (2 - t);
31349 }
31350
31351 function quadInOut(t) {
31352 return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
31353 }
31354
31355 /***/
31356 },
31357 /* 78 */
31358 /***/function (module, __webpack_exports__, __webpack_require__) {
31359
31360 "use strict";
31361 /* harmony export (immutable) */
31362 __webpack_exports__["a"] = cubicIn;
31363 /* harmony export (immutable) */__webpack_exports__["c"] = cubicOut;
31364 /* harmony export (immutable) */__webpack_exports__["b"] = cubicInOut;
31365 function cubicIn(t) {
31366 return t * t * t;
31367 }
31368
31369 function cubicOut(t) {
31370 return --t * t * t + 1;
31371 }
31372
31373 function cubicInOut(t) {
31374 return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
31375 }
31376
31377 /***/
31378 },
31379 /* 79 */
31380 /***/function (module, __webpack_exports__, __webpack_require__) {
31381
31382 "use strict";
31383 /* harmony export (binding) */
31384 __webpack_require__.d(__webpack_exports__, "a", function () {
31385 return polyIn;
31386 });
31387 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
31388 return polyOut;
31389 });
31390 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () {
31391 return polyInOut;
31392 });
31393 var exponent = 3;
31394
31395 var polyIn = function custom(e) {
31396 e = +e;
31397
31398 function polyIn(t) {
31399 return Math.pow(t, e);
31400 }
31401
31402 polyIn.exponent = custom;
31403
31404 return polyIn;
31405 }(exponent);
31406
31407 var polyOut = function custom(e) {
31408 e = +e;
31409
31410 function polyOut(t) {
31411 return 1 - Math.pow(1 - t, e);
31412 }
31413
31414 polyOut.exponent = custom;
31415
31416 return polyOut;
31417 }(exponent);
31418
31419 var polyInOut = function custom(e) {
31420 e = +e;
31421
31422 function polyInOut(t) {
31423 return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
31424 }
31425
31426 polyInOut.exponent = custom;
31427
31428 return polyInOut;
31429 }(exponent);
31430
31431 /***/
31432 },
31433 /* 80 */
31434 /***/function (module, __webpack_exports__, __webpack_require__) {
31435
31436 "use strict";
31437 /* harmony export (immutable) */
31438 __webpack_exports__["a"] = sinIn;
31439 /* harmony export (immutable) */__webpack_exports__["c"] = sinOut;
31440 /* harmony export (immutable) */__webpack_exports__["b"] = sinInOut;
31441 var pi = Math.PI,
31442 halfPi = pi / 2;
31443
31444 function sinIn(t) {
31445 return 1 - Math.cos(t * halfPi);
31446 }
31447
31448 function sinOut(t) {
31449 return Math.sin(t * halfPi);
31450 }
31451
31452 function sinInOut(t) {
31453 return (1 - Math.cos(pi * t)) / 2;
31454 }
31455
31456 /***/
31457 },
31458 /* 81 */
31459 /***/function (module, __webpack_exports__, __webpack_require__) {
31460
31461 "use strict";
31462 /* harmony export (immutable) */
31463 __webpack_exports__["a"] = expIn;
31464 /* harmony export (immutable) */__webpack_exports__["c"] = expOut;
31465 /* harmony export (immutable) */__webpack_exports__["b"] = expInOut;
31466 function expIn(t) {
31467 return Math.pow(2, 10 * t - 10);
31468 }
31469
31470 function expOut(t) {
31471 return 1 - Math.pow(2, -10 * t);
31472 }
31473
31474 function expInOut(t) {
31475 return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
31476 }
31477
31478 /***/
31479 },
31480 /* 82 */
31481 /***/function (module, __webpack_exports__, __webpack_require__) {
31482
31483 "use strict";
31484 /* harmony export (immutable) */
31485 __webpack_exports__["a"] = circleIn;
31486 /* harmony export (immutable) */__webpack_exports__["c"] = circleOut;
31487 /* harmony export (immutable) */__webpack_exports__["b"] = circleInOut;
31488 function circleIn(t) {
31489 return 1 - Math.sqrt(1 - t * t);
31490 }
31491
31492 function circleOut(t) {
31493 return Math.sqrt(1 - --t * t);
31494 }
31495
31496 function circleInOut(t) {
31497 return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
31498 }
31499
31500 /***/
31501 },
31502 /* 83 */
31503 /***/function (module, __webpack_exports__, __webpack_require__) {
31504
31505 "use strict";
31506 /* harmony export (immutable) */
31507 __webpack_exports__["a"] = bounceIn;
31508 /* harmony export (immutable) */__webpack_exports__["c"] = bounceOut;
31509 /* harmony export (immutable) */__webpack_exports__["b"] = bounceInOut;
31510 var b1 = 4 / 11,
31511 b2 = 6 / 11,
31512 b3 = 8 / 11,
31513 b4 = 3 / 4,
31514 b5 = 9 / 11,
31515 b6 = 10 / 11,
31516 b7 = 15 / 16,
31517 b8 = 21 / 22,
31518 b9 = 63 / 64,
31519 b0 = 1 / b1 / b1;
31520
31521 function bounceIn(t) {
31522 return 1 - bounceOut(1 - t);
31523 }
31524
31525 function bounceOut(t) {
31526 return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
31527 }
31528
31529 function bounceInOut(t) {
31530 return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
31531 }
31532
31533 /***/
31534 },
31535 /* 84 */
31536 /***/function (module, __webpack_exports__, __webpack_require__) {
31537
31538 "use strict";
31539 /* harmony export (binding) */
31540 __webpack_require__.d(__webpack_exports__, "a", function () {
31541 return backIn;
31542 });
31543 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
31544 return backOut;
31545 });
31546 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () {
31547 return backInOut;
31548 });
31549 var overshoot = 1.70158;
31550
31551 var backIn = function custom(s) {
31552 s = +s;
31553
31554 function backIn(t) {
31555 return t * t * ((s + 1) * t - s);
31556 }
31557
31558 backIn.overshoot = custom;
31559
31560 return backIn;
31561 }(overshoot);
31562
31563 var backOut = function custom(s) {
31564 s = +s;
31565
31566 function backOut(t) {
31567 return --t * t * ((s + 1) * t + s) + 1;
31568 }
31569
31570 backOut.overshoot = custom;
31571
31572 return backOut;
31573 }(overshoot);
31574
31575 var backInOut = function custom(s) {
31576 s = +s;
31577
31578 function backInOut(t) {
31579 return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
31580 }
31581
31582 backInOut.overshoot = custom;
31583
31584 return backInOut;
31585 }(overshoot);
31586
31587 /***/
31588 },
31589 /* 85 */
31590 /***/function (module, __webpack_exports__, __webpack_require__) {
31591
31592 "use strict";
31593 /* harmony export (binding) */
31594 __webpack_require__.d(__webpack_exports__, "a", function () {
31595 return elasticIn;
31596 });
31597 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "c", function () {
31598 return elasticOut;
31599 });
31600 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () {
31601 return elasticInOut;
31602 });
31603 var tau = 2 * Math.PI,
31604 amplitude = 1,
31605 period = 0.3;
31606
31607 var elasticIn = function custom(a, p) {
31608 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
31609
31610 function elasticIn(t) {
31611 return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
31612 }
31613
31614 elasticIn.amplitude = function (a) {
31615 return custom(a, p * tau);
31616 };
31617 elasticIn.period = function (p) {
31618 return custom(a, p);
31619 };
31620
31621 return elasticIn;
31622 }(amplitude, period);
31623
31624 var elasticOut = function custom(a, p) {
31625 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
31626
31627 function elasticOut(t) {
31628 return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
31629 }
31630
31631 elasticOut.amplitude = function (a) {
31632 return custom(a, p * tau);
31633 };
31634 elasticOut.period = function (p) {
31635 return custom(a, p);
31636 };
31637
31638 return elasticOut;
31639 }(amplitude, period);
31640
31641 var elasticInOut = function custom(a, p) {
31642 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
31643
31644 function elasticInOut(t) {
31645 return ((t = t * 2 - 1) < 0 ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p) : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
31646 }
31647
31648 elasticInOut.amplitude = function (a) {
31649 return custom(a, p * tau);
31650 };
31651 elasticInOut.period = function (p) {
31652 return custom(a, p);
31653 };
31654
31655 return elasticInOut;
31656 }(amplitude, period);
31657
31658 /***/
31659 },
31660 /* 86 */
31661 /***/function (module, __webpack_exports__, __webpack_require__) {
31662
31663 "use strict";
31664
31665 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
31666 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__src_timer__ = __webpack_require__(14);
31667 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "now", function () {
31668 return __WEBPACK_IMPORTED_MODULE_0__src_timer__["b"];
31669 });
31670 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "timer", function () {
31671 return __WEBPACK_IMPORTED_MODULE_0__src_timer__["c"];
31672 });
31673 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "timerFlush", function () {
31674 return __WEBPACK_IMPORTED_MODULE_0__src_timer__["d"];
31675 });
31676 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_timeout__ = __webpack_require__(87);
31677 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "timeout", function () {
31678 return __WEBPACK_IMPORTED_MODULE_1__src_timeout__["a"];
31679 });
31680 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_interval__ = __webpack_require__(88);
31681 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interval", function () {
31682 return __WEBPACK_IMPORTED_MODULE_2__src_interval__["a"];
31683 });
31684
31685 /***/
31686 },
31687 /* 87 */
31688 /***/function (module, __webpack_exports__, __webpack_require__) {
31689
31690 "use strict";
31691 /* harmony import */
31692 var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(14);
31693
31694 /* harmony default export */__webpack_exports__["a"] = function (callback, delay, time) {
31695 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */]();
31696 delay = delay == null ? 0 : +delay;
31697 t.restart(function (elapsed) {
31698 t.stop();
31699 callback(elapsed + delay);
31700 }, delay, time);
31701 return t;
31702 };
31703
31704 /***/
31705 },
31706 /* 88 */
31707 /***/function (module, __webpack_exports__, __webpack_require__) {
31708
31709 "use strict";
31710 /* harmony import */
31711 var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(14);
31712
31713 /* harmony default export */__webpack_exports__["a"] = function (callback, delay, time) {
31714 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */](),
31715 total = delay;
31716 if (delay == null) return t.restart(callback, delay, time), t;
31717 delay = +delay, time = time == null ? Object(__WEBPACK_IMPORTED_MODULE_0__timer__["b" /* now */])() : +time;
31718 t.restart(function tick(elapsed) {
31719 elapsed += total;
31720 t.restart(tick, total += delay, time);
31721 callback(elapsed);
31722 }, delay, time);
31723 return t;
31724 };
31725
31726 /***/
31727 },
31728 /* 89 */
31729 /***/function (module, __webpack_exports__, __webpack_require__) {
31730
31731 "use strict";
31732
31733 Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
31734 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__src_value__ = __webpack_require__(15);
31735 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolate", function () {
31736 return __WEBPACK_IMPORTED_MODULE_0__src_value__["a"];
31737 });
31738 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__src_array__ = __webpack_require__(34);
31739 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateArray", function () {
31740 return __WEBPACK_IMPORTED_MODULE_1__src_array__["a"];
31741 });
31742 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__src_basis__ = __webpack_require__(18);
31743 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateBasis", function () {
31744 return __WEBPACK_IMPORTED_MODULE_2__src_basis__["b"];
31745 });
31746 /* harmony import */var __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__ = __webpack_require__(32);
31747 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateBasisClosed", function () {
31748 return __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__["a"];
31749 });
31750 /* harmony import */var __WEBPACK_IMPORTED_MODULE_4__src_date__ = __webpack_require__(35);
31751 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateDate", function () {
31752 return __WEBPACK_IMPORTED_MODULE_4__src_date__["a"];
31753 });
31754 /* harmony import */var __WEBPACK_IMPORTED_MODULE_5__src_number__ = __webpack_require__(9);
31755 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateNumber", function () {
31756 return __WEBPACK_IMPORTED_MODULE_5__src_number__["a"];
31757 });
31758 /* harmony import */var __WEBPACK_IMPORTED_MODULE_6__src_object__ = __webpack_require__(36);
31759 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateObject", function () {
31760 return __WEBPACK_IMPORTED_MODULE_6__src_object__["a"];
31761 });
31762 /* harmony import */var __WEBPACK_IMPORTED_MODULE_7__src_round__ = __webpack_require__(92);
31763 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRound", function () {
31764 return __WEBPACK_IMPORTED_MODULE_7__src_round__["a"];
31765 });
31766 /* harmony import */var __WEBPACK_IMPORTED_MODULE_8__src_string__ = __webpack_require__(37);
31767 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateString", function () {
31768 return __WEBPACK_IMPORTED_MODULE_8__src_string__["a"];
31769 });
31770 /* harmony import */var __WEBPACK_IMPORTED_MODULE_9__src_transform_index__ = __webpack_require__(93);
31771 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateTransformCss", function () {
31772 return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["a"];
31773 });
31774 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateTransformSvg", function () {
31775 return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["b"];
31776 });
31777 /* harmony import */var __WEBPACK_IMPORTED_MODULE_10__src_zoom__ = __webpack_require__(96);
31778 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateZoom", function () {
31779 return __WEBPACK_IMPORTED_MODULE_10__src_zoom__["a"];
31780 });
31781 /* harmony import */var __WEBPACK_IMPORTED_MODULE_11__src_rgb__ = __webpack_require__(31);
31782 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRgb", function () {
31783 return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["a"];
31784 });
31785 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRgbBasis", function () {
31786 return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["b"];
31787 });
31788 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateRgbBasisClosed", function () {
31789 return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["c"];
31790 });
31791 /* harmony import */var __WEBPACK_IMPORTED_MODULE_12__src_hsl__ = __webpack_require__(97);
31792 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHsl", function () {
31793 return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["a"];
31794 });
31795 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHslLong", function () {
31796 return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["b"];
31797 });
31798 /* harmony import */var __WEBPACK_IMPORTED_MODULE_13__src_lab__ = __webpack_require__(98);
31799 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateLab", function () {
31800 return __WEBPACK_IMPORTED_MODULE_13__src_lab__["a"];
31801 });
31802 /* harmony import */var __WEBPACK_IMPORTED_MODULE_14__src_hcl__ = __webpack_require__(99);
31803 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHcl", function () {
31804 return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["a"];
31805 });
31806 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateHclLong", function () {
31807 return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["b"];
31808 });
31809 /* harmony import */var __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__ = __webpack_require__(100);
31810 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateCubehelix", function () {
31811 return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["b"];
31812 });
31813 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "interpolateCubehelixLong", function () {
31814 return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["a"];
31815 });
31816 /* harmony import */var __WEBPACK_IMPORTED_MODULE_16__src_quantize__ = __webpack_require__(101);
31817 /* harmony reexport (binding) */__webpack_require__.d(__webpack_exports__, "quantize", function () {
31818 return __WEBPACK_IMPORTED_MODULE_16__src_quantize__["a"];
31819 });
31820
31821 /***/
31822 },
31823 /* 90 */
31824 /***/function (module, __webpack_exports__, __webpack_require__) {
31825
31826 "use strict";
31827 /* harmony export (immutable) */
31828 __webpack_exports__["a"] = lab;
31829 /* unused harmony export Lab */
31830 /* harmony export (immutable) */__webpack_exports__["b"] = hcl;
31831 /* unused harmony export Hcl */
31832 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(17);
31833 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(16);
31834 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(30);
31835
31836 var Kn = 18,
31837 Xn = 0.950470,
31838
31839 // D65 standard referent
31840 Yn = 1,
31841 Zn = 1.088830,
31842 t0 = 4 / 29,
31843 t1 = 6 / 29,
31844 t2 = 3 * t1 * t1,
31845 t3 = t1 * t1 * t1;
31846
31847 function labConvert(o) {
31848 if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
31849 if (o instanceof Hcl) {
31850 var h = o.h * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */];
31851 return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
31852 }
31853 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
31854 var b = rgb2xyz(o.r),
31855 a = rgb2xyz(o.g),
31856 l = rgb2xyz(o.b),
31857 x = xyz2lab((0.4124564 * b + 0.3575761 * a + 0.1804375 * l) / Xn),
31858 y = xyz2lab((0.2126729 * b + 0.7151522 * a + 0.0721750 * l) / Yn),
31859 z = xyz2lab((0.0193339 * b + 0.1191920 * a + 0.9503041 * l) / Zn);
31860 return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
31861 }
31862
31863 function lab(l, a, b, opacity) {
31864 return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
31865 }
31866
31867 function Lab(l, a, b, opacity) {
31868 this.l = +l;
31869 this.a = +a;
31870 this.b = +b;
31871 this.opacity = +opacity;
31872 }
31873
31874 Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Lab, lab, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
31875 brighter: function brighter(k) {
31876 return new Lab(this.l + Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
31877 },
31878 darker: function darker(k) {
31879 return new Lab(this.l - Kn * (k == null ? 1 : k), this.a, this.b, this.opacity);
31880 },
31881 rgb: function rgb() {
31882 var y = (this.l + 16) / 116,
31883 x = isNaN(this.a) ? y : y + this.a / 500,
31884 z = isNaN(this.b) ? y : y - this.b / 200;
31885 y = Yn * lab2xyz(y);
31886 x = Xn * lab2xyz(x);
31887 z = Zn * lab2xyz(z);
31888 return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z), // D65 -> sRGB
31889 xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z), xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z), this.opacity);
31890 }
31891 }));
31892
31893 function xyz2lab(t) {
31894 return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
31895 }
31896
31897 function lab2xyz(t) {
31898 return t > t1 ? t * t * t : t2 * (t - t0);
31899 }
31900
31901 function xyz2rgb(x) {
31902 return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
31903 }
31904
31905 function rgb2xyz(x) {
31906 return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
31907 }
31908
31909 function hclConvert(o) {
31910 if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
31911 if (!(o instanceof Lab)) o = labConvert(o);
31912 var h = Math.atan2(o.b, o.a) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */];
31913 return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
31914 }
31915
31916 function hcl(h, c, l, opacity) {
31917 return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
31918 }
31919
31920 function Hcl(h, c, l, opacity) {
31921 this.h = +h;
31922 this.c = +c;
31923 this.l = +l;
31924 this.opacity = +opacity;
31925 }
31926
31927 Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hcl, hcl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
31928 brighter: function brighter(k) {
31929 return new Hcl(this.h, this.c, this.l + Kn * (k == null ? 1 : k), this.opacity);
31930 },
31931 darker: function darker(k) {
31932 return new Hcl(this.h, this.c, this.l - Kn * (k == null ? 1 : k), this.opacity);
31933 },
31934 rgb: function rgb() {
31935 return labConvert(this).rgb();
31936 }
31937 }));
31938
31939 /***/
31940 },
31941 /* 91 */
31942 /***/function (module, __webpack_exports__, __webpack_require__) {
31943
31944 "use strict";
31945 /* harmony export (immutable) */
31946 __webpack_exports__["a"] = cubehelix;
31947 /* unused harmony export Cubehelix */
31948 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(17);
31949 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(16);
31950 /* harmony import */var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(30);
31951
31952 var A = -0.14861,
31953 B = +1.78277,
31954 C = -0.29227,
31955 D = -0.90649,
31956 E = +1.97294,
31957 ED = E * D,
31958 EB = E * B,
31959 BC_DA = B * C - D * A;
31960
31961 function cubehelixConvert(o) {
31962 if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
31963 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
31964 var r = o.r / 255,
31965 g = o.g / 255,
31966 b = o.b / 255,
31967 l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
31968 bl = b - l,
31969 k = (E * (g - l) - C * bl) / D,
31970 s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)),
31971
31972 // NaN if l=0 or l=1
31973 h = s ? Math.atan2(k, bl) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */] - 120 : NaN;
31974 return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
31975 }
31976
31977 function cubehelix(h, s, l, opacity) {
31978 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
31979 }
31980
31981 function Cubehelix(h, s, l, opacity) {
31982 this.h = +h;
31983 this.s = +s;
31984 this.l = +l;
31985 this.opacity = +opacity;
31986 }
31987
31988 Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Cubehelix, cubehelix, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
31989 brighter: function brighter(k) {
31990 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */], k);
31991 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
31992 },
31993 darker: function darker(k) {
31994 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */], k);
31995 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
31996 },
31997 rgb: function rgb() {
31998 var h = isNaN(this.h) ? 0 : (this.h + 120) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */],
31999 l = +this.l,
32000 a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
32001 cosh = Math.cos(h),
32002 sinh = Math.sin(h);
32003 return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity);
32004 }
32005 }));
32006
32007 /***/
32008 },
32009 /* 92 */
32010 /***/function (module, __webpack_exports__, __webpack_require__) {
32011
32012 "use strict";
32013 /* harmony default export */
32014 __webpack_exports__["a"] = function (a, b) {
32015 return a = +a, b -= a, function (t) {
32016 return Math.round(a + b * t);
32017 };
32018 };
32019
32020 /***/
32021 },
32022 /* 93 */
32023 /***/function (module, __webpack_exports__, __webpack_require__) {
32024
32025 "use strict";
32026 /* harmony export (binding) */
32027 __webpack_require__.d(__webpack_exports__, "a", function () {
32028 return interpolateTransformCss;
32029 });
32030 /* harmony export (binding) */__webpack_require__.d(__webpack_exports__, "b", function () {
32031 return interpolateTransformSvg;
32032 });
32033 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(9);
32034 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(94);
32035
32036 function interpolateTransform(parse, pxComma, pxParen, degParen) {
32037
32038 function pop(s) {
32039 return s.length ? s.pop() + " " : "";
32040 }
32041
32042 function translate(xa, ya, xb, yb, s, q) {
32043 if (xa !== xb || ya !== yb) {
32044 var i = s.push("translate(", null, pxComma, null, pxParen);
32045 q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) });
32046 } else if (xb || yb) {
32047 s.push("translate(" + xb + pxComma + yb + pxParen);
32048 }
32049 }
32050
32051 function rotate(a, b, s, q) {
32052 if (a !== b) {
32053 if (a - b > 180) b += 360;else if (b - a > 180) a += 360; // shortest path
32054 q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
32055 } else if (b) {
32056 s.push(pop(s) + "rotate(" + b + degParen);
32057 }
32058 }
32059
32060 function skewX(a, b, s, q) {
32061 if (a !== b) {
32062 q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
32063 } else if (b) {
32064 s.push(pop(s) + "skewX(" + b + degParen);
32065 }
32066 }
32067
32068 function scale(xa, ya, xb, yb, s, q) {
32069 if (xa !== xb || ya !== yb) {
32070 var i = s.push(pop(s) + "scale(", null, ",", null, ")");
32071 q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) });
32072 } else if (xb !== 1 || yb !== 1) {
32073 s.push(pop(s) + "scale(" + xb + "," + yb + ")");
32074 }
32075 }
32076
32077 return function (a, b) {
32078 var s = [],
32079
32080 // string constants and placeholders
32081 q = []; // number interpolators
32082 a = parse(a), b = parse(b);
32083 translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
32084 rotate(a.rotate, b.rotate, s, q);
32085 skewX(a.skewX, b.skewX, s, q);
32086 scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
32087 a = b = null; // gc
32088 return function (t) {
32089 var i = -1,
32090 n = q.length,
32091 o;
32092 while (++i < n) {
32093 s[(o = q[i]).i] = o.x(t);
32094 }return s.join("");
32095 };
32096 };
32097 }
32098
32099 var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)");
32100 var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")");
32101
32102 /***/
32103 },
32104 /* 94 */
32105 /***/function (module, __webpack_exports__, __webpack_require__) {
32106
32107 "use strict";
32108 /* harmony export (immutable) */
32109 __webpack_exports__["a"] = parseCss;
32110 /* harmony export (immutable) */__webpack_exports__["b"] = parseSvg;
32111 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(95);
32112
32113 var cssNode, cssRoot, cssView, svgNode;
32114
32115 function parseCss(value) {
32116 if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
32117 if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
32118 cssNode.style.transform = value;
32119 value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
32120 cssRoot.removeChild(cssNode);
32121 value = value.slice(7, -1).split(",");
32122 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
32123 }
32124
32125 function parseSvg(value) {
32126 if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
32127 if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
32128 svgNode.setAttribute("transform", value);
32129 if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
32130 value = value.matrix;
32131 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f);
32132 }
32133
32134 /***/
32135 },
32136 /* 95 */
32137 /***/function (module, __webpack_exports__, __webpack_require__) {
32138
32139 "use strict";
32140 /* harmony export (binding) */
32141 __webpack_require__.d(__webpack_exports__, "b", function () {
32142 return identity;
32143 });
32144 var degrees = 180 / Math.PI;
32145
32146 var identity = {
32147 translateX: 0,
32148 translateY: 0,
32149 rotate: 0,
32150 skewX: 0,
32151 scaleX: 1,
32152 scaleY: 1
32153 };
32154
32155 /* harmony default export */__webpack_exports__["a"] = function (a, b, c, d, e, f) {
32156 var scaleX, scaleY, skewX;
32157 if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
32158 if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
32159 if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
32160 if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
32161 return {
32162 translateX: e,
32163 translateY: f,
32164 rotate: Math.atan2(b, a) * degrees,
32165 skewX: Math.atan(skewX) * degrees,
32166 scaleX: scaleX,
32167 scaleY: scaleY
32168 };
32169 };
32170
32171 /***/
32172 },
32173 /* 96 */
32174 /***/function (module, __webpack_exports__, __webpack_require__) {
32175
32176 "use strict";
32177
32178 var rho = Math.SQRT2,
32179 rho2 = 2,
32180 rho4 = 4,
32181 epsilon2 = 1e-12;
32182
32183 function cosh(x) {
32184 return ((x = Math.exp(x)) + 1 / x) / 2;
32185 }
32186
32187 function sinh(x) {
32188 return ((x = Math.exp(x)) - 1 / x) / 2;
32189 }
32190
32191 function tanh(x) {
32192 return ((x = Math.exp(2 * x)) - 1) / (x + 1);
32193 }
32194
32195 // p0 = [ux0, uy0, w0]
32196 // p1 = [ux1, uy1, w1]
32197 /* harmony default export */__webpack_exports__["a"] = function (p0, p1) {
32198 var ux0 = p0[0],
32199 uy0 = p0[1],
32200 w0 = p0[2],
32201 ux1 = p1[0],
32202 uy1 = p1[1],
32203 w1 = p1[2],
32204 dx = ux1 - ux0,
32205 dy = uy1 - uy0,
32206 d2 = dx * dx + dy * dy,
32207 i,
32208 S;
32209
32210 // Special case for u0 ≅ u1.
32211 if (d2 < epsilon2) {
32212 S = Math.log(w1 / w0) / rho;
32213 i = function i(t) {
32214 return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
32215 };
32216 }
32217
32218 // General case.
32219 else {
32220 var d1 = Math.sqrt(d2),
32221 b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
32222 b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
32223 r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
32224 r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
32225 S = (r1 - r0) / rho;
32226 i = function i(t) {
32227 var s = t * S,
32228 coshr0 = cosh(r0),
32229 u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
32230 return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)];
32231 };
32232 }
32233
32234 i.duration = S * 1000;
32235
32236 return i;
32237 };
32238
32239 /***/
32240 },
32241 /* 97 */
32242 /***/function (module, __webpack_exports__, __webpack_require__) {
32243
32244 "use strict";
32245 /* harmony export (binding) */
32246 __webpack_require__.d(__webpack_exports__, "b", function () {
32247 return hslLong;
32248 });
32249 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
32250 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
32251
32252 function hsl(hue) {
32253 return function (start, end) {
32254 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(end)).h),
32255 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
32256 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
32257 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
32258 return function (t) {
32259 start.h = h(t);
32260 start.s = s(t);
32261 start.l = l(t);
32262 start.opacity = opacity(t);
32263 return start + "";
32264 };
32265 };
32266 }
32267
32268 /* harmony default export */__webpack_exports__["a"] = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]);
32269 var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
32270
32271 /***/
32272 },
32273 /* 98 */
32274 /***/function (module, __webpack_exports__, __webpack_require__) {
32275
32276 "use strict";
32277 /* harmony export (immutable) */
32278 __webpack_exports__["a"] = lab;
32279 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
32280 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
32281
32282 function lab(start, end) {
32283 var l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(start)).l, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(end)).l),
32284 a = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a),
32285 b = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b),
32286 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
32287 return function (t) {
32288 start.l = l(t);
32289 start.a = a(t);
32290 start.b = b(t);
32291 start.opacity = opacity(t);
32292 return start + "";
32293 };
32294 }
32295
32296 /***/
32297 },
32298 /* 99 */
32299 /***/function (module, __webpack_exports__, __webpack_require__) {
32300
32301 "use strict";
32302 /* harmony export (binding) */
32303 __webpack_require__.d(__webpack_exports__, "b", function () {
32304 return hclLong;
32305 });
32306 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
32307 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
32308
32309 function hcl(hue) {
32310 return function (start, end) {
32311 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(end)).h),
32312 c = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c),
32313 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
32314 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
32315 return function (t) {
32316 start.h = h(t);
32317 start.c = c(t);
32318 start.l = l(t);
32319 start.opacity = opacity(t);
32320 return start + "";
32321 };
32322 };
32323 }
32324
32325 /* harmony default export */__webpack_exports__["a"] = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]);
32326 var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
32327
32328 /***/
32329 },
32330 /* 100 */
32331 /***/function (module, __webpack_exports__, __webpack_require__) {
32332
32333 "use strict";
32334 /* harmony export (binding) */
32335 __webpack_require__.d(__webpack_exports__, "a", function () {
32336 return cubehelixLong;
32337 });
32338 /* harmony import */var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
32339 /* harmony import */var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
32340
32341 function cubehelix(hue) {
32342 return function cubehelixGamma(y) {
32343 y = +y;
32344
32345 function cubehelix(start, end) {
32346 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(end)).h),
32347 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
32348 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
32349 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
32350 return function (t) {
32351 start.h = h(t);
32352 start.s = s(t);
32353 start.l = l(Math.pow(t, y));
32354 start.opacity = opacity(t);
32355 return start + "";
32356 };
32357 }
32358
32359 cubehelix.gamma = cubehelixGamma;
32360
32361 return cubehelix;
32362 }(1);
32363 }
32364
32365 /* harmony default export */__webpack_exports__["b"] = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]);
32366 var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
32367
32368 /***/
32369 },
32370 /* 101 */
32371 /***/function (module, __webpack_exports__, __webpack_require__) {
32372
32373 "use strict";
32374 /* harmony default export */
32375 __webpack_exports__["a"] = function (interpolator, n) {
32376 var samples = new Array(n);
32377 for (var i = 0; i < n; ++i) {
32378 samples[i] = interpolator(i / (n - 1));
32379 }return samples;
32380 };
32381
32382 /***/
32383 },
32384 /* 102 */
32385 /***/function (module, exports, __webpack_require__) {
32386
32387 var Shape = __webpack_require__(4);
32388 Shape.Rect = __webpack_require__(39);
32389 Shape.Circle = __webpack_require__(40);
32390 Shape.Ellipse = __webpack_require__(41);
32391 Shape.Path = __webpack_require__(42);
32392 Shape.Text = __webpack_require__(43);
32393 Shape.Line = __webpack_require__(44);
32394 Shape.Image = __webpack_require__(45);
32395 Shape.Polygon = __webpack_require__(46);
32396 Shape.Marker = __webpack_require__(47);
32397 Shape.Dom = __webpack_require__(48);
32398 Shape.Fa = __webpack_require__(49);
32399
32400 module.exports = Shape;
32401
32402 /***/
32403 },
32404 /* 103 */
32405 /***/function (module, exports, __webpack_require__) {
32406
32407 /**
32408 * Created by Elaine on 2018/5/9.
32409 */
32410 var Util = __webpack_require__(0);
32411 var Element = __webpack_require__(11);
32412 var Gradient = __webpack_require__(104);
32413 var Shadow = __webpack_require__(105);
32414 var Arrow = __webpack_require__(106);
32415 var Clip = __webpack_require__(107);
32416
32417 var Defs = function Defs(cfg) {
32418 Defs.superclass.constructor.call(this, cfg);
32419 this.set('children', []);
32420 };
32421
32422 Util.extend(Defs, Element);
32423
32424 Util.augment(Defs, {
32425 isGroup: false,
32426 canFill: false,
32427 canStroke: false,
32428 capture: false,
32429 visible: false,
32430 init: function init() {
32431 var el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
32432 var id = Util.uniqueId('defs_');
32433 el.setAttribute('id', id);
32434 this.set('el', el);
32435 this.set('children', []);
32436 },
32437 find: function find(type, attr) {
32438 var children = this.get('children');
32439 var result = null;
32440 for (var i = 0; i < children.length; i++) {
32441 if (children[i].match(type, attr)) {
32442 result = children[i].__cfg.id;
32443 break;
32444 }
32445 }
32446 return result;
32447 },
32448 findById: function findById(id) {
32449 var children = this.get('children');
32450 var flag = null;
32451 for (var i = 0; i < children.length; i++) {
32452 if (children[i].__cfg.id === id) {
32453 flag = children[i];
32454 break;
32455 }
32456 }
32457 return flag;
32458 },
32459 add: function add(items) {
32460 var el = this.get('el');
32461 var self = this;
32462 var children = this.get('children');
32463 if (Util.isArray(items)) {
32464 Util.each(items, function (item) {
32465 var parent = item.get('parent');
32466 if (parent) {
32467 parent.removeChild(item, false);
32468 self._setContext(item);
32469 }
32470 el.appendChild(item.get('el'));
32471 });
32472 children.push.apply(children, items);
32473 return self;
32474 }
32475 if (self.findById(items.get('id'))) {
32476 return self;
32477 }
32478 var parent = items.get('parent');
32479 if (parent) {
32480 parent.removeChild(items, false);
32481 }
32482 self._add(items);
32483 el.appendChild(items.get('el'));
32484 return self;
32485 },
32486 _add: function _add(item) {
32487 this.get('el').appendChild(item.__cfg.el);
32488 this.get('children').push(item);
32489 item.__cfg.parent = this;
32490 item.__cfg.defs = this;
32491 item.__cfg.canvas = this.__cfg.canvas;
32492 },
32493 addGradient: function addGradient(cfg) {
32494 var gradient = new Gradient(cfg);
32495 this._add(gradient);
32496 return gradient.__cfg.id;
32497 },
32498 addShadow: function addShadow(cfg) {
32499 var shadow = new Shadow(cfg);
32500 this._add(shadow);
32501 return shadow.__cfg.id;
32502 },
32503 addArrow: function addArrow(name, cfg, stroke) {
32504 var arrow = new Arrow(name, cfg, stroke);
32505 this._add(arrow);
32506 return arrow.__cfg.id;
32507 },
32508 addClip: function addClip(cfg) {
32509 var clip = new Clip(cfg);
32510 this._add(clip);
32511 return clip.__cfg.id;
32512 }
32513 });
32514
32515 module.exports = Defs;
32516
32517 /***/
32518 },
32519 /* 104 */
32520 /***/function (module, exports, __webpack_require__) {
32521
32522 /**
32523 * Created by Elaine on 2018/5/9.
32524 */
32525 var Util = __webpack_require__(0);
32526
32527 var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
32528 var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
32529 var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
32530
32531 function addStop(steps) {
32532 var arr = steps.match(regexColorStop);
32533 if (!arr) {
32534 return '';
32535 }
32536 var stops = '';
32537 arr.sort(function (a, b) {
32538 a = a.split(':');
32539 b = b.split(':');
32540 return Number(a[0]) - Number(b[0]);
32541 });
32542 Util.each(arr, function (item) {
32543 item = item.split(':');
32544 stops += '<stop offset="' + item[0] + '" stop-color="' + item[1] + '"></stop>';
32545 });
32546 return stops;
32547 }
32548
32549 function parseLineGradient(color, el) {
32550 var arr = regexLG.exec(color);
32551 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
32552 var steps = arr[2];
32553 var start = void 0;
32554 var end = void 0;
32555
32556 if (angle >= 0 && angle < 0.5 * Math.PI) {
32557 start = {
32558 x: 0,
32559 y: 0
32560 };
32561 end = {
32562 x: 1,
32563 y: 1
32564 };
32565 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
32566 start = {
32567 x: 1,
32568 y: 0
32569 };
32570 end = {
32571 x: 0,
32572 y: 1
32573 };
32574 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
32575 start = {
32576 x: 1,
32577 y: 1
32578 };
32579 end = {
32580 x: 0,
32581 y: 0
32582 };
32583 } else {
32584 start = {
32585 x: 0,
32586 y: 1
32587 };
32588 end = {
32589 x: 1,
32590 y: 0
32591 };
32592 }
32593
32594 var tanTheta = Math.tan(angle);
32595 var tanTheta2 = tanTheta * tanTheta;
32596
32597 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
32598 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
32599 el.setAttribute('x1', start.x);
32600 el.setAttribute('y1', start.y);
32601 el.setAttribute('x2', x);
32602 el.setAttribute('y2', y);
32603 el.innerHTML = addStop(steps);
32604 }
32605
32606 function parseRadialGradient(color, self) {
32607 var arr = regexRG.exec(color);
32608 var cx = parseFloat(arr[1]);
32609 var cy = parseFloat(arr[2]);
32610 var r = parseFloat(arr[3]);
32611 var steps = arr[4];
32612 self.setAttribute('cx', cx);
32613 self.setAttribute('cy', cy);
32614 self.setAttribute('r', r);
32615 self.innerHTML = addStop(steps);
32616 }
32617
32618 var Gradient = function Gradient(cfg) {
32619 var el = null;
32620 var id = Util.uniqueId('gradient_');
32621 if (cfg.toLowerCase().startsWith('l')) {
32622 el = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');
32623 parseLineGradient(cfg, el);
32624 } else {
32625 el = document.createElementNS('http://www.w3.org/2000/svg', 'radialGradient');
32626 parseRadialGradient(cfg, el);
32627 }
32628 el.setAttribute('id', id);
32629 this.__cfg = { el: el, id: id };
32630 this.__attrs = { config: cfg };
32631 return this;
32632 };
32633
32634 Util.augment(Gradient, {
32635 type: 'gradient',
32636 match: function match(type, attr) {
32637 return this.type === type && this.__attrs.config === attr;
32638 }
32639 });
32640
32641 module.exports = Gradient;
32642
32643 /***/
32644 },
32645 /* 105 */
32646 /***/function (module, exports, __webpack_require__) {
32647
32648 /**
32649 * Created by Elaine on 2018/5/10.
32650 */
32651 var Util = __webpack_require__(0);
32652
32653 var ATTR_MAP = {
32654 shadowColor: 'color',
32655 shadowOpacity: 'opacity',
32656 shadowBlur: 'blur',
32657 shadowOffsetX: 'dx',
32658 shadowOffsetY: 'dy'
32659 };
32660
32661 function parseShadow(config, el) {
32662 var child = '<feDropShadow \n dx="' + config.dx + '" \n dy="' + config.dy + '" \n stdDeviation="' + (config.blur ? config.blur / 10 : 0) + '"\n flood-color="' + (config.color ? config.color : '#000') + '"\n flood-opacity="' + (config.opacity ? config.opacity : 1) + '"\n />';
32663 el.innerHTML = child;
32664 }
32665
32666 var Shadow = function Shadow(cfg) {
32667 var el = document.createElementNS('http://www.w3.org/2000/svg', 'filter');
32668 var id = Util.uniqueId('filter_');
32669 el.setAttribute('id', id);
32670 parseShadow(cfg, el);
32671 this.__cfg = { el: el, id: id };
32672 this.__attrs = { config: cfg };
32673 return this;
32674 };
32675 Util.augment(Shadow, {
32676 type: 'filter',
32677 match: function match(type, cfg) {
32678 if (this.type !== type) {
32679 return false;
32680 }
32681 var flag = false;
32682 var config = this.__attrs.config;
32683 Util.each(Object.keys(config), function (attr) {
32684 if (!flag) {
32685 flag = config[attr] === cfg[attr];
32686 }
32687 });
32688 return flag;
32689 },
32690 update: function update(name, value) {
32691 var config = this.__attrs.config;
32692 config[ATTR_MAP[name]] = value;
32693 parseShadow(config, this.__cfg.el);
32694 return this;
32695 }
32696 });
32697
32698 module.exports = Shadow;
32699
32700 /***/
32701 },
32702 /* 106 */
32703 /***/function (module, exports, __webpack_require__) {
32704
32705 var _typeof = typeof Symbol === "function" && _typeof3(Symbol.iterator) === "symbol" ? function (obj) {
32706 return typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
32707 } : function (obj) {
32708 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof3(obj);
32709 };
32710
32711 /**
32712 * Created by Elaine on 2018/5/11.
32713 */
32714 var Util = __webpack_require__(0);
32715
32716 var DEFAULT_PATH = {
32717 'marker-start': 'M6,0 L0,3 L6,6 L3,3Z',
32718 'marker-end': 'M0,0 L6,3 L0,6 L3,3Z'
32719 };
32720
32721 function setDefaultPath(parent, name, stroke) {
32722 var el = document.createElementNS('http://www.w3.org/2000/svg', 'path');
32723 el.setAttribute('d', DEFAULT_PATH[name]);
32724 el.setAttribute('stroke', 'none');
32725 el.setAttribute('fill', stroke || '#000');
32726 parent.appendChild(el);
32727 parent.setAttribute('refX', 3);
32728 parent.setAttribute('refY', 3);
32729 parent.setAttribute('markerWidth', 16);
32730 parent.setAttribute('markerHeight', 16);
32731 parent.setAttribute('orient', 'auto');
32732 return el;
32733 }
32734
32735 function setMarker(shape, parent, name, stroke) {
32736 if (!shape) {
32737 return setDefaultPath(parent, name);
32738 }
32739 if (shape.type !== 'marker') {
32740 throw new TypeError('the shape of an arrow should be an instance of Marker');
32741 }
32742 shape.attr({ stroke: 'none', fill: stroke });
32743 parent.append(shape.get('el'));
32744 var width = shape.__attrs.x;
32745 var height = shape.__attrs.y;
32746 parent.setAttribute('refX', width);
32747 parent.setAttribute('refY', height);
32748 parent.setAttribute('markerWidth', width * 2);
32749 parent.setAttribute('markerHeight', height * 2);
32750 parent.setAttribute('orient', 'auto');
32751 return shape;
32752 }
32753
32754 var Arrow = function Arrow(name, cfg, stroke) {
32755 var el = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
32756 var id = Util.uniqueId('marker_');
32757 el.setAttribute('id', id);
32758 this.__cfg = { el: el, id: id, stroke: stroke || '#000' };
32759 this.__cfg[name] = true;
32760 var child = null;
32761 if (typeof cfg === 'boolean' && cfg) {
32762 child = setDefaultPath(el, name, stroke);
32763 this._setChild(child, true);
32764 } else if ((typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) === 'object') {
32765 child = setMarker(cfg, el, name, stroke);
32766 this._setChild(child, false);
32767 }
32768 this.__attrs = { config: cfg };
32769 return this;
32770 };
32771
32772 Util.augment(Arrow, {
32773 type: 'arrow',
32774 match: function match(type, attr) {
32775 if (!this.__cfg[type]) {
32776 return false;
32777 }
32778 if (_typeof(attr.value) === 'object') {
32779 return false;
32780 }
32781 if (attr.stroke !== '#000') {
32782 return false;
32783 }
32784 if (typeof attr.value === 'boolean' && !this.__cfg.default) {
32785 return false;
32786 }
32787 return true;
32788 },
32789 _setChild: function _setChild(child, isDefault) {
32790 this.__cfg.child = child;
32791 this.__cfg.default = isDefault;
32792 },
32793 update: function update(fill) {
32794 var child = this.__cfg.child;
32795 this.__cfg.default = false;
32796 if (child.attr) {
32797 child.attr('fill', fill);
32798 } else {
32799 child.setAttribute('fill', fill);
32800 }
32801 }
32802 });
32803
32804 module.exports = Arrow;
32805
32806 /***/
32807 },
32808 /* 107 */
32809 /***/function (module, exports, __webpack_require__) {
32810
32811 /**
32812 * Created by Elaine on 2018/5/14.
32813 */
32814 var Util = __webpack_require__(0);
32815
32816 var Clip = function Clip(cfg) {
32817 var el = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
32818 var id = Util.uniqueId('clip_');
32819 if (cfg.get('el')) {
32820 el.appendChild(cfg.get('el'));
32821 } else if (Util.isString(cfg.nodeName)) {
32822 el.appendChild(cfg);
32823 } else {
32824 throw 'clip element should be a instance of Shape or a SVG node';
32825 }
32826 el.setAttribute('id', id);
32827 this.__cfg = { el: el, id: id };
32828 this.__attrs = { config: cfg };
32829 return this;
32830 };
32831
32832 Util.augment(Clip, {
32833 type: 'clip',
32834 match: function match() {
32835 return false;
32836 }
32837 });
32838
32839 module.exports = Clip;
32840
32841 /***/
32842 },
32843 /* 108 */
32844 /***/function (module, exports, __webpack_require__) {
32845
32846 module.exports = {
32847 Canvas: __webpack_require__(109),
32848 Group: __webpack_require__(51),
32849 Shape: __webpack_require__(1),
32850 Rect: __webpack_require__(23),
32851 Circle: __webpack_require__(53),
32852 Ellipse: __webpack_require__(54),
32853 Path: __webpack_require__(55),
32854 Text: __webpack_require__(56),
32855 Line: __webpack_require__(57),
32856 Image: __webpack_require__(58),
32857 Polygon: __webpack_require__(59),
32858 Polyline: __webpack_require__(60),
32859 Arc: __webpack_require__(61),
32860 Fan: __webpack_require__(62),
32861 Cubic: __webpack_require__(63),
32862 Quadratic: __webpack_require__(64),
32863 Marker: __webpack_require__(25),
32864 PathSegment: __webpack_require__(24),
32865 Event: __webpack_require__(50)
32866 };
32867
32868 /***/
32869 },
32870 /* 109 */
32871 /***/function (module, exports, __webpack_require__) {
32872
32873 var Util = __webpack_require__(0);
32874 var Event = __webpack_require__(50);
32875 var Group = __webpack_require__(51);
32876
32877 var Canvas = function Canvas(cfg) {
32878 Canvas.superclass.constructor.call(this, cfg);
32879 };
32880
32881 Canvas.CFG = {
32882 eventEnable: true,
32883 /**
32884 * 像素宽度
32885 * @type {Number}
32886 */
32887 width: null,
32888 /**
32889 * 像素高度
32890 * @type {Number}
32891 */
32892 height: null,
32893 /**
32894 * 画布宽度
32895 * @type {Number}
32896 */
32897 widthCanvas: null,
32898 /**
32899 * 画布高度
32900 * @type {Number}
32901 */
32902 heightCanvas: null,
32903 /**
32904 * CSS宽
32905 * @type {String}
32906 */
32907 widthStyle: null,
32908 /**
32909 * CSS高
32910 * @type {String}
32911 */
32912 heightStyle: null,
32913 /**
32914 * 容器DOM
32915 * @type {Object}
32916 */
32917 containerDOM: null,
32918 /**
32919 * 当前Canvas的DOM
32920 * @type {Object}
32921 */
32922 canvasDOM: null,
32923 /**
32924 * 屏幕像素比
32925 * @type {Number}
32926 */
32927 pixelRatio: null
32928 };
32929
32930 Util.extend(Canvas, Group);
32931
32932 Util.augment(Canvas, {
32933 init: function init() {
32934 Canvas.superclass.init.call(this);
32935 this._setGlobalParam();
32936 this._setDOM();
32937 this._setInitSize();
32938 this._setCanvas();
32939 this._scale();
32940 if (this.get('eventEnable')) {
32941 this._registEvents();
32942 }
32943 },
32944 getEmitter: function getEmitter(element, event) {
32945 if (element) {
32946 if (Util.isEmpty(element._getEvents())) {
32947 var parent = element.get('parent');
32948 if (parent && !event.propagationStopped) {
32949 return this.getEmitter(parent, event);
32950 }
32951 } else {
32952 return element;
32953 }
32954 }
32955 },
32956 _getEventObj: function _getEventObj(type, e, point, target) {
32957 var event = new Event(type, e, true, true);
32958 event.x = point.x;
32959 event.y = point.y;
32960 event.clientX = e.clientX;
32961 event.clientY = e.clientY;
32962 event.currentTarget = target;
32963 event.target = target;
32964 return event;
32965 },
32966 _triggerEvent: function _triggerEvent(type, e) {
32967 var point = this.getPointByClient(e.clientX, e.clientY);
32968 var shape = this.getShape(point.x, point.y);
32969 var emitObj = void 0;
32970 if (type === 'mousemove') {
32971 var preShape = this.get('preShape');
32972 if (preShape && preShape !== shape) {
32973 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
32974 emitObj = this.getEmitter(preShape, e);
32975 emitObj && emitObj.emit('mouseleave', mouseleave);
32976 }
32977
32978 if (shape) {
32979 var mousemove = this._getEventObj('mousemove', e, point, shape);
32980 emitObj = this.getEmitter(shape, e);
32981 emitObj && emitObj.emit('mousemove', mousemove);
32982
32983 if (preShape !== shape) {
32984 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
32985 emitObj && emitObj.emit('mouseenter', mouseenter, e);
32986 }
32987 } else {
32988 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
32989 this.emit('mousemove', canvasmousemove);
32990 }
32991
32992 this.set('preShape', shape);
32993 } else {
32994 var event = this._getEventObj(type, e, point, shape || this);
32995 emitObj = this.getEmitter(shape, e);
32996 if (emitObj && emitObj !== this) {
32997 emitObj.emit(type, event);
32998 }
32999 this.emit(type, event);
33000 }
33001
33002 var el = this.get('el');
33003 if (shape && !shape.get('destroyed')) {
33004 el.style.cursor = shape.attr('cursor') || 'default';
33005 }
33006 },
33007 _registEvents: function _registEvents() {
33008 var self = this;
33009 var el = self.get('el');
33010 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
33011
33012 Util.each(events, function (event) {
33013 el.addEventListener(event, function (e) {
33014 self._triggerEvent(event, e);
33015 }, false);
33016 });
33017 el.addEventListener('touchstart', function (e) {
33018 if (!Util.isEmpty(e.touches)) {
33019 self._triggerEvent('touchstart', e.touches[0]);
33020 }
33021 }, false);
33022
33023 el.addEventListener('touchmove', function (e) {
33024 if (!Util.isEmpty(e.touches)) {
33025 self._triggerEvent('touchmove', e.touches[0]);
33026 }
33027 }, false);
33028
33029 el.addEventListener('touchend', function (e) {
33030 if (!Util.isEmpty(e.changedTouches)) {
33031 self._triggerEvent('touchend', e.changedTouches[0]);
33032 }
33033 }, false);
33034 },
33035 _scale: function _scale() {
33036 var pixelRatio = this.get('pixelRatio');
33037 this.scale(pixelRatio, pixelRatio);
33038 },
33039 _setCanvas: function _setCanvas() {
33040 var canvasDOM = this.get('canvasDOM');
33041 this.set('el', canvasDOM);
33042 this.set('context', canvasDOM.getContext('2d'));
33043 this.set('canvas', this);
33044 },
33045 _setGlobalParam: function _setGlobalParam() {
33046 var pixelRatio = this.get('pixelRatio');
33047 if (!pixelRatio) {
33048 this.set('pixelRatio', Util.getRatio());
33049 }
33050 return;
33051 },
33052 _setDOM: function _setDOM() {
33053 this._setContainer();
33054 this._setLayer();
33055 },
33056 _setContainer: function _setContainer() {
33057 var containerId = this.get('containerId');
33058 var containerDOM = this.get('containerDOM');
33059 if (!containerDOM) {
33060 containerDOM = document.getElementById(containerId);
33061 this.set('containerDOM', containerDOM);
33062 }
33063 Util.modifyCSS(containerDOM, {
33064 position: 'relative'
33065 });
33066 },
33067 _setLayer: function _setLayer() {
33068 var containerDOM = this.get('containerDOM');
33069 var canvasId = Util.uniqueId('canvas_');
33070 if (containerDOM) {
33071 var canvasDOM = Util.createDom('<canvas id="' + canvasId + '"></canvas>');
33072 containerDOM.appendChild(canvasDOM);
33073 this.set('canvasDOM', canvasDOM);
33074 }
33075 },
33076 _setInitSize: function _setInitSize() {
33077 this.changeSize(this.get('width'), this.get('height'));
33078 },
33079 _resize: function _resize() {
33080 var canvasDOM = this.get('canvasDOM');
33081 var widthCanvas = this.get('widthCanvas');
33082 var heightCanvas = this.get('heightCanvas');
33083 var widthStyle = this.get('widthStyle');
33084 var heightStyle = this.get('heightStyle');
33085
33086 canvasDOM.style.width = widthStyle;
33087 canvasDOM.style.height = heightStyle;
33088 canvasDOM.setAttribute('width', widthCanvas);
33089 canvasDOM.setAttribute('height', heightCanvas);
33090 },
33091 getWidth: function getWidth() {
33092 var pixelRatio = this.get('pixelRatio');
33093 var width = this.get('width');
33094 return width * pixelRatio;
33095 },
33096 getHeight: function getHeight() {
33097 var pixelRatio = this.get('pixelRatio');
33098 var height = this.get('height');
33099 return height * pixelRatio;
33100 },
33101 changeSize: function changeSize(width, height) {
33102 var pixelRatio = this.get('pixelRatio');
33103 var widthCanvas = width * pixelRatio;
33104 var heightCanvas = height * pixelRatio;
33105
33106 this.set('widthCanvas', widthCanvas);
33107 this.set('heightCanvas', heightCanvas);
33108 this.set('widthStyle', width + 'px');
33109 this.set('heightStyle', height + 'px');
33110 this.set('width', width);
33111 this.set('height', height);
33112 this._resize();
33113 },
33114
33115 /**
33116 * 将窗口坐标转变成 canvas 坐标
33117 * @param {Number} clientX 窗口x坐标
33118 * @param {Number} clientY 窗口y坐标
33119 * @return {Object} canvas坐标
33120 */
33121 getPointByClient: function getPointByClient(clientX, clientY) {
33122 var el = this.get('el');
33123 var bbox = el.getBoundingClientRect();
33124 var width = bbox.right - bbox.left;
33125 var height = bbox.bottom - bbox.top;
33126 return {
33127 x: (clientX - bbox.left) * (el.width / width),
33128 y: (clientY - bbox.top) * (el.height / height)
33129 };
33130 },
33131 getClientByPoint: function getClientByPoint(x, y) {
33132 var el = this.get('el');
33133 var bbox = el.getBoundingClientRect();
33134 var width = bbox.right - bbox.left;
33135 var height = bbox.bottom - bbox.top;
33136 return {
33137 clientX: x / (el.width / width) + bbox.left,
33138 clientY: y / (el.height / height) + bbox.top
33139 };
33140 },
33141 beforeDraw: function beforeDraw() {
33142 var context = this.get('context');
33143 var el = this.get('el');
33144 context && context.clearRect(0, 0, el.width, el.height);
33145 },
33146 _beginDraw: function _beginDraw() {
33147 this.setSilent('toDraw', true);
33148 },
33149 _endDraw: function _endDraw() {
33150 this.setSilent('toDraw', false);
33151 },
33152 draw: function draw() {
33153 var self = this;
33154 function drawInner() {
33155 self.setSilent('animateHandler', Util.requestAnimationFrame(function () {
33156 self.setSilent('animateHandler', undefined);
33157 if (self.get('toDraw')) {
33158 drawInner();
33159 }
33160 }));
33161 self.beforeDraw();
33162 try {
33163 var context = self.get('context');
33164 Canvas.superclass.draw.call(self, context);
33165 // self._drawCanvas();
33166 } catch (ev) {
33167 // 绘制时异常,中断重绘
33168 console.warn('error in draw canvas, detail as:');
33169 console.warn(ev);
33170 self._endDraw();
33171 }
33172 self._endDraw();
33173 }
33174
33175 if (self.get('destroyed')) {
33176 return;
33177 }
33178 if (self.get('animateHandler')) {
33179 this._beginDraw();
33180 } else {
33181 drawInner();
33182 }
33183 },
33184 destroy: function destroy() {
33185 var containerDOM = this.get('containerDOM');
33186 var canvasDOM = this.get('canvasDOM');
33187 if (canvasDOM && containerDOM) {
33188 containerDOM.removeChild(canvasDOM);
33189 }
33190 Canvas.superclass.destroy.call(this);
33191 }
33192 });
33193
33194 module.exports = Canvas;
33195
33196 /***/
33197 },
33198 /* 110 */
33199 /***/function (module, exports, __webpack_require__) {
33200
33201 var Util = __webpack_require__(0);
33202
33203 var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
33204 var CLIP_SHAPES = ['circle', 'ellipse', 'fan', 'polygon', 'rect', 'path'];
33205 var CAPITALIZED_ATTRS_MAP = {
33206 r: 'R',
33207 opacity: 'Opacity',
33208 lineWidth: 'LineWidth',
33209 clip: 'Clip',
33210 stroke: 'Stroke',
33211 fill: 'Fill',
33212 strokeOpacity: 'Stroke',
33213 fillOpacity: 'Fill',
33214 x: 'X',
33215 y: 'Y',
33216 rx: 'Rx',
33217 ry: 'Ry',
33218 re: 'Re',
33219 rs: 'Rs',
33220 width: 'Width',
33221 height: 'Height',
33222 img: 'Img',
33223 x1: 'X1',
33224 x2: 'X2',
33225 y1: 'Y1',
33226 y2: 'Y2',
33227 points: 'Points',
33228 p1: 'P1',
33229 p2: 'P2',
33230 p3: 'P3',
33231 p4: 'P4',
33232 text: 'Text',
33233 radius: 'Radius',
33234 textAlign: 'TextAlign',
33235 textBaseline: 'TextBaseline',
33236 font: 'Font',
33237 fontSize: 'FontSize',
33238 fontStyle: 'FontStyle',
33239 fontVariant: 'FontVariant',
33240 fontWeight: 'FontWeight',
33241 fontFamily: 'FontFamily',
33242 clockwise: 'Clockwise',
33243 startAngle: 'StartAngle',
33244 endAngle: 'EndAngle',
33245 path: 'Path'
33246 };
33247 var ALIAS_ATTRS_MAP = {
33248 stroke: 'strokeStyle',
33249 fill: 'fillStyle',
33250 opacity: 'globalAlpha'
33251 };
33252
33253 module.exports = {
33254 canFill: false,
33255 canStroke: false,
33256 initAttrs: function initAttrs(attrs) {
33257 this.__attrs = {
33258 opacity: 1,
33259 fillOpacity: 1,
33260 strokeOpacity: 1
33261 };
33262 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
33263 return this;
33264 },
33265 getDefaultAttrs: function getDefaultAttrs() {
33266 return {};
33267 },
33268
33269 /**
33270 * 设置或者设置属性,有以下 4 种情形:
33271 * - name 不存在, 则返回属性集合
33272 * - name 为字符串,value 为空,获取属性值
33273 * - name 为字符串,value 不为空,设置属性值,返回 this
33274 * - name 为键值对,value 为空,设置属性值
33275 *
33276 * @param {String | Object} name 属性名
33277 * @param {*} value 属性值
33278 * @return {*} 属性值
33279 */
33280 attr: function attr(name, value) {
33281 var self = this;
33282 if (arguments.length === 0) {
33283 return self.__attrs;
33284 }
33285
33286 if (Util.isObject(name)) {
33287 for (var k in name) {
33288 if (ALIAS_ATTRS.indexOf(k) === -1) {
33289 var v = name[k];
33290 self._setAttr(k, v);
33291 }
33292 }
33293 if (self._afterSetAttrAll) {
33294 self._afterSetAttrAll(name);
33295 }
33296 // self.setSilent('box', null);
33297 self.clearBBox();
33298 return self;
33299 }
33300 if (arguments.length === 2) {
33301 if (self._setAttr(name, value) !== false) {
33302 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
33303 if (self[m]) {
33304 self[m](value);
33305 }
33306 }
33307 // self.setSilent('box', null);
33308 self.clearBBox();
33309 return self;
33310 }
33311 return self._getAttr(name);
33312 },
33313 clearBBox: function clearBBox() {
33314 this.setSilent('box', null);
33315 },
33316 _afterSetAttrAll: function _afterSetAttrAll() {},
33317
33318 // 属性获取触发函数
33319 _getAttr: function _getAttr(name) {
33320 return this.__attrs[name];
33321 },
33322
33323 // 属性设置触发函数
33324 _setAttr: function _setAttr(name, value) {
33325 var self = this;
33326 if (name === 'clip') {
33327 self._setAttrClip(value);
33328 self.__attrs.clip = value;
33329 } else if (name === 'transform') {
33330 self._setAttrTrans(value);
33331 } else {
33332 self.__attrs[name] = value;
33333 var alias = ALIAS_ATTRS_MAP[name];
33334 if (alias) {
33335 self.__attrs[alias] = value;
33336 }
33337 }
33338 return self;
33339 },
33340 hasFill: function hasFill() {
33341 return this.canFill && this.__attrs.fillStyle;
33342 },
33343 hasStroke: function hasStroke() {
33344 return this.canStroke && this.__attrs.strokeStyle;
33345 },
33346
33347 // 设置透明度
33348 _setAttrOpacity: function _setAttrOpacity(v) {
33349 this.__attrs.globalAlpha = v;
33350 return v;
33351 },
33352 _setAttrClip: function _setAttrClip(clip) {
33353 var self = this;
33354 if (clip && CLIP_SHAPES.indexOf(clip.type) > -1) {
33355 if (clip.get('canvas') === null) {
33356 clip = Util.clone(clip);
33357 }
33358 clip.set('parent', self.get('parent'));
33359 clip.set('canvas', self.get('canvas'));
33360 clip.set('context', self.get('context'));
33361 clip.inside = function (x, y) {
33362 var v = [x, y, 1];
33363 clip.invert(v, self.get('canvas')); // 已经在外面转换
33364 return clip._isPointInFill(v[0], v[1]);
33365 };
33366 return clip;
33367 }
33368 return null;
33369 },
33370 _setAttrTrans: function _setAttrTrans(value) {
33371 return this.transform(value);
33372 }
33373 };
33374
33375 /***/
33376 },
33377 /* 111 */
33378 /***/function (module, exports, __webpack_require__) {
33379
33380 var Util = __webpack_require__(0);
33381 var mat3 = __webpack_require__(2).mat3;
33382 var vec3 = __webpack_require__(2).vec3;
33383
33384 // 是否未改变
33385 function isUnchanged(m) {
33386 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
33387 }
33388
33389 // 是否仅仅是scale
33390 function isScale(m) {
33391 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
33392 }
33393
33394 function multiple(m1, m2) {
33395 if (!isUnchanged(m2)) {
33396 if (isScale(m2)) {
33397 m1[0] *= m2[0];
33398 m1[4] *= m2[4];
33399 } else {
33400 mat3.multiply(m1, m1, m2);
33401 }
33402 }
33403 }
33404
33405 module.exports = {
33406 initTransform: function initTransform() {
33407 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
33408 },
33409 translate: function translate(tx, ty) {
33410 var matrix = this.attr('matrix');
33411 mat3.translate(matrix, matrix, [tx, ty]);
33412 this.clearTotalMatrix();
33413 this.attr('matrix', matrix);
33414 return this;
33415 },
33416 rotate: function rotate(radian) {
33417 var matrix = this.attr('matrix');
33418 mat3.rotate(matrix, matrix, radian);
33419 this.clearTotalMatrix();
33420 this.attr('matrix', matrix);
33421 return this;
33422 },
33423 scale: function scale(s1, s2) {
33424 var matrix = this.attr('matrix');
33425 mat3.scale(matrix, matrix, [s1, s2]);
33426 this.clearTotalMatrix();
33427 this.attr('matrix', matrix);
33428 return this;
33429 },
33430
33431 /**
33432 * 绕起始点旋转
33433 * @param {Number} rotate 0~360
33434 */
33435 rotateAtStart: function rotateAtStart(rotate) {
33436 var x = this.attr('x');
33437 var y = this.attr('y');
33438 if (Math.abs(rotate) > Math.PI * 2) {
33439 rotate = rotate / 180 * Math.PI;
33440 }
33441 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
33442 },
33443
33444 /**
33445 * 移动的到位置
33446 * @param {Number} x 移动到x
33447 * @param {Number} y 移动到y
33448 */
33449 move: function move(x, y) {
33450 var cx = this.get('x') || 0; // 当前的x
33451 var cy = this.get('y') || 0; // 当前的y
33452 this.translate(x - cx, y - cy);
33453 this.set('x', x);
33454 this.set('y', y);
33455 },
33456 transform: function transform(ts) {
33457 var self = this;
33458 var matrix = self.attr('matrix');
33459
33460 Util.each(ts, function (t) {
33461 switch (t[0]) {
33462 case 't':
33463 self.translate(t[1], t[2]);
33464 break;
33465 case 's':
33466 self.scale(t[1], t[2]);
33467 break;
33468 case 'r':
33469 self.rotate(t[1]);
33470 break;
33471 case 'm':
33472 self.attr('matrix', mat3.multiply([], matrix, t[1]));
33473 self.clearTotalMatrix();
33474 break;
33475 default:
33476 break;
33477 }
33478 });
33479 return self;
33480 },
33481 setTransform: function setTransform(ts) {
33482 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
33483 return this.transform(ts);
33484 },
33485 getMatrix: function getMatrix() {
33486 return this.attr('matrix');
33487 },
33488 setMatrix: function setMatrix(m) {
33489 this.attr('matrix', m);
33490 this.clearTotalMatrix();
33491 return this;
33492 },
33493 apply: function apply(v, root) {
33494 var m = void 0;
33495 if (root) {
33496 m = this._getMatrixByRoot(root);
33497 } else {
33498 m = this.attr('matrix');
33499 }
33500 vec3.transformMat3(v, v, m);
33501 return this;
33502 },
33503
33504 // 获取到达指定根节点的矩阵
33505 _getMatrixByRoot: function _getMatrixByRoot(root) {
33506 var self = this;
33507 root = root || self;
33508 var parent = self;
33509 var parents = [];
33510
33511 while (parent !== root) {
33512 parents.unshift(parent);
33513 parent = parent.get('parent');
33514 }
33515 parents.unshift(parent);
33516
33517 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
33518 Util.each(parents, function (child) {
33519 mat3.multiply(m, child.attr('matrix'), m);
33520 });
33521 return m;
33522 },
33523
33524 /**
33525 * 应用到当前元素上的总的矩阵
33526 * @return {Matrix} 矩阵
33527 */
33528 getTotalMatrix: function getTotalMatrix() {
33529 var m = this.__cfg.totalMatrix;
33530 if (!m) {
33531 m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
33532 var parent = this.__cfg.parent;
33533 if (parent) {
33534 var pm = parent.getTotalMatrix();
33535 multiple(m, pm);
33536 }
33537
33538 multiple(m, this.attr('matrix'));
33539 this.__cfg.totalMatrix = m;
33540 }
33541 return m;
33542 },
33543
33544 // 清除当前的矩阵
33545 clearTotalMatrix: function clearTotalMatrix() {
33546 // this.__cfg.totalMatrix = null;
33547 },
33548 invert: function invert(v) {
33549 var m = this.getTotalMatrix();
33550 // 单精屏幕下大多数矩阵没变化
33551 if (isScale(m)) {
33552 v[0] /= m[0];
33553 v[1] /= m[4];
33554 } else {
33555 var inm = mat3.invert([], m);
33556 if (inm) {
33557 vec3.transformMat3(v, v, inm);
33558 }
33559 }
33560 return this;
33561 },
33562 resetTransform: function resetTransform(context) {
33563 var mo = this.attr('matrix');
33564 // 不改变时
33565 if (!isUnchanged(mo)) {
33566 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
33567 }
33568 }
33569 };
33570
33571 /***/
33572 },
33573 /* 112 */
33574 /***/function (module, exports, __webpack_require__) {
33575
33576 var Shape = __webpack_require__(1);
33577 Shape.Rect = __webpack_require__(23);
33578 Shape.Rect = __webpack_require__(23);
33579 Shape.Circle = __webpack_require__(53);
33580 Shape.Ellipse = __webpack_require__(54);
33581 Shape.Path = __webpack_require__(55);
33582 Shape.Text = __webpack_require__(56);
33583 Shape.Line = __webpack_require__(57);
33584 Shape.Image = __webpack_require__(58);
33585 Shape.Polygon = __webpack_require__(59);
33586 Shape.Polyline = __webpack_require__(60);
33587 Shape.Arc = __webpack_require__(61);
33588 Shape.Fan = __webpack_require__(62);
33589 Shape.Cubic = __webpack_require__(63);
33590 Shape.Quadratic = __webpack_require__(64);
33591 Shape.Marker = __webpack_require__(25);
33592
33593 module.exports = Shape;
33594
33595 /***/
33596 },
33597 /* 113 */
33598 /***/function (module, exports) {
33599
33600 module.exports = {
33601 xAt: function xAt(psi, rx, ry, cx, t) {
33602 return rx * Math.cos(psi) * Math.cos(t) - ry * Math.sin(psi) * Math.sin(t) + cx;
33603 },
33604 yAt: function yAt(psi, rx, ry, cy, t) {
33605 return rx * Math.sin(psi) * Math.cos(t) + ry * Math.cos(psi) * Math.sin(t) + cy;
33606 },
33607 xExtrema: function xExtrema(psi, rx, ry) {
33608 return Math.atan(-ry / rx * Math.tan(psi));
33609 },
33610 yExtrema: function yExtrema(psi, rx, ry) {
33611 return Math.atan(ry / (rx * Math.tan(psi)));
33612 }
33613 };
33614
33615 /***/
33616 }]
33617 /******/)
33618 );
33619});
33620/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(28)(module)))
33621
33622/***/ })
33623/******/ ]);
33624});
33625//# sourceMappingURL=interaction.js.map
\No newline at end of file