UNPKG

470 kBJavaScriptView 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 = 83);
74/******/ })
75/************************************************************************/
76/******/ ([
77/* 0 */
78/***/ (function(module, exports, __webpack_require__) {
79
80var CommonUtil = __webpack_require__(9);
81var DomUtil = __webpack_require__(41);
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__(68);
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__(9);
253var mat3 = __webpack_require__(113);
254var vec3 = __webpack_require__(114);
255var vec2 = __webpack_require__(115);
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__(28);
349var Quadratic = __webpack_require__(29);
350var Cubic = __webpack_require__(16);
351var Arc = __webpack_require__(30);
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__(19);
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, exports) {
512
513var isArrayLike = function isArrayLike(value) {
514 /**
515 * isArrayLike([1, 2, 3]) => true
516 * isArrayLike(document.body.children) => true
517 * isArrayLike('abc') => true
518 * isArrayLike(Function) => false
519 */
520 return value !== null && typeof value !== 'function' && isFinite(value.length);
521};
522
523module.exports = isArrayLike;
524
525/***/ }),
526/* 6 */
527/***/ (function(module, __webpack_exports__, __webpack_require__) {
528
529"use strict";
530/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_color__ = __webpack_require__(24);
531/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["e"]; });
532/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["g"]; });
533/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["f"]; });
534/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_lab__ = __webpack_require__(137);
535/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["a"]; });
536/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["b"]; });
537/* unused harmony reexport lch */
538/* unused harmony reexport gray */
539/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__ = __webpack_require__(138);
540/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__["a"]; });
541
542
543
544
545/***/ }),
546/* 7 */
547/***/ (function(module, exports) {
548
549var _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; };
550
551var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
552 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
553} : function (obj) {
554 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
555};
556
557var PI = Math.PI;
558var sin = Math.sin;
559var cos = Math.cos;
560var atan2 = Math.atan2;
561var DEFAULT_LENGTH = 10;
562var DEFAULT_ANGLE = PI / 3;
563
564function _addArrow(ctx, attrs, x1, y1, x2, y2) {
565 var leftX = void 0;
566 var leftY = void 0;
567 var rightX = void 0;
568 var rightY = void 0;
569 var offsetX = void 0;
570 var offsetY = void 0;
571 var angle = void 0;
572
573 if (!attrs.fill) {
574 // 闭合的不绘制箭头
575 var arrowLength = attrs.arrowLength || DEFAULT_LENGTH;
576 var arrowAngle = attrs.arrowAngle ? attrs.arrowAngle * PI / 180 : DEFAULT_ANGLE; // 转换为弧
577 // Calculate angle
578 angle = atan2(y2 - y1, x2 - x1);
579 // Adjust angle correctly
580 angle -= PI;
581 // Calculate offset to place arrow at edge of path
582 offsetX = attrs.lineWidth * cos(angle);
583 offsetY = attrs.lineWidth * sin(angle);
584
585 // Calculate coordinates for left half of arrow
586 leftX = x2 + arrowLength * cos(angle + arrowAngle / 2);
587 leftY = y2 + arrowLength * sin(angle + arrowAngle / 2);
588 // Calculate coordinates for right half of arrow
589 rightX = x2 + arrowLength * cos(angle - arrowAngle / 2);
590 rightY = y2 + arrowLength * sin(angle - arrowAngle / 2);
591 ctx.beginPath();
592 // Draw left half of arrow
593 ctx.moveTo(leftX - offsetX, leftY - offsetY);
594 ctx.lineTo(x2 - offsetX, y2 - offsetY);
595 // Draw right half of arrow
596 ctx.lineTo(rightX - offsetX, rightY - offsetY);
597
598 // Visually connect arrow to path
599 ctx.moveTo(x2 - offsetX, y2 - offsetY);
600 ctx.lineTo(x2 + offsetX, y2 + offsetY);
601 // Move back to end of path
602 ctx.moveTo(x2, y2);
603 ctx.stroke();
604 }
605}
606
607function _addMarker(ctx, attrs, x1, y1, x2, y2, shape) {
608 var marker = shape.__attrs;
609 if (!marker.x) {
610 marker.x = x2;
611 }
612 if (!marker.y) {
613 marker.y = y2;
614 }
615 if (!marker.r) {
616 marker.r = attrs.lineWidth;
617 }
618
619 var deg = 0;
620 var x = x2 - x1;
621 var y = y2 - y1;
622 var tan = Math.atan(x / y);
623 if (y === 0 && x < 0) {
624 deg = Math.PI;
625 } else if (x > 0 && y > 0) {
626 deg = Math.PI / 2 - tan;
627 } else if (x < 0 && y < 0) {
628 deg = -Math.PI / 2 - tan;
629 } else if (x >= 0 && y < 0) {
630 deg = -tan - Math.PI / 2;
631 } else if (x <= 0 && y > 0) {
632 deg = Math.PI / 2 - tan;
633 }
634 ctx.save();
635 ctx.beginPath();
636 ctx.translate(marker.x, marker.y);
637 ctx.rotate(deg);
638 ctx.translate(-marker.x, -marker.y);
639 shape.createPath(ctx);
640 ctx.setTransform(1, 0, 0, 1, 0, 0);
641 ctx.fillStyle = shape.attr('fill') || ctx.strokeStyle;
642 ctx.fill();
643 ctx.restore();
644}
645
646module.exports = {
647 addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) {
648 if (_typeof(attrs.startArrow) === 'object') {
649 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.startArrow);
650 } else if (attrs.startArrow) {
651 _addArrow(ctx, attrs, x1, y1, x2, y2);
652 }
653 },
654 addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) {
655 if (_typeof(attrs.endArrow) === 'object') {
656 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.endArrow);
657 } else if (attrs.endArrow) {
658 _addArrow(ctx, attrs, x1, y1, x2, y2);
659 }
660 }
661};
662
663/***/ }),
664/* 8 */
665/***/ (function(module, exports, __webpack_require__) {
666
667function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
668
669var G = __webpack_require__(32);
670var EventUtil = __webpack_require__(34);
671var DomUtil = G.DomUtil;
672var CommonUtil = G.CommonUtil;
673
674var assign = CommonUtil.assign;
675
676var EVENT_TYPES = ['start', 'process', 'end', 'reset'];
677
678var Interaction = function () {
679 Interaction.prototype.getDefaultCfg = function getDefaultCfg() {
680 return {
681 startEvent: 'mousedown',
682 processEvent: 'mousemove',
683 endEvent: 'mouseup',
684 resetEvent: 'dblclick'
685 };
686 };
687
688 Interaction.prototype._start = function _start(ev) {
689 var me = this;
690 me.preStart && me.preStart(ev);
691 me.start(ev);
692 me.onStart && me.onStart(ev);
693 };
694
695 Interaction.prototype._process = function _process(ev) {
696 var me = this;
697 me.preProcess && me.preProcess(ev);
698 me.process(ev);
699 me.onProcess && me.onProcess(ev);
700 };
701
702 Interaction.prototype._end = function _end(ev) {
703 var me = this;
704 me.preEnd && me.preEnd(ev);
705 me.end(ev);
706 me.onEnd && me.onEnd(ev);
707 };
708
709 Interaction.prototype._reset = function _reset(ev) {
710 var me = this;
711 me.preReset && me.preReset(ev);
712 me.reset(ev);
713 me.onReset && me.onReset(ev);
714 };
715
716 Interaction.prototype.start = function start() {
717 // TODO override
718 };
719
720 Interaction.prototype.process = function process() {
721 // TODO override
722 };
723
724 Interaction.prototype.end = function end() {
725 // TODO override
726 };
727
728 Interaction.prototype.reset = function reset() {
729 // TODO override
730 };
731
732 function Interaction(cfg, view) {
733 _classCallCheck(this, Interaction);
734
735 var me = this;
736 var defaultCfg = me.getDefaultCfg();
737 assign(me, defaultCfg, cfg);
738 me.view = me.chart = view;
739 me.canvas = view.get('canvas');
740 me._bindEvents();
741 }
742
743 Interaction.prototype._bindEvents = function _bindEvents() {
744 var me = this;
745 var canvas = me.canvas;
746 var canvasDOM = canvas.get('canvasDOM');
747 me._clearEvents();
748 CommonUtil.each(EVENT_TYPES, function (type) {
749 var ucType = CommonUtil.upperFirst(type);
750 me['_on' + ucType + 'Listener'] = DomUtil.addEventListener(canvasDOM, me[type + 'Event'], EventUtil.wrapBehavior(me, '_' + type));
751 });
752 };
753
754 Interaction.prototype._clearEvents = function _clearEvents() {
755 var me = this;
756 CommonUtil.each(EVENT_TYPES, function (type) {
757 var listenerName = '_on' + CommonUtil.upperFirst(type) + 'Listener';
758 me[listenerName] && me[listenerName].remove();
759 });
760 };
761
762 Interaction.prototype.destroy = function destroy() {
763 this._clearEvents();
764 };
765
766 return Interaction;
767}();
768
769module.exports = Interaction;
770
771/***/ }),
772/* 9 */
773/***/ (function(module, exports, __webpack_require__) {
774
775var Util = __webpack_require__(33);
776
777module.exports = {
778 isFunction: Util.isFunction,
779 isObject: Util.isObject,
780 isBoolean: Util.isBoolean,
781 isNil: Util.isNil,
782 isString: Util.isString,
783 isArray: Util.isArray,
784 isNumber: Util.isNumber,
785 isEmpty: Util.isEmpty, // isBlank
786 uniqueId: Util.uniqueId,
787 clone: Util.clone,
788 assign: Util.mix, // simpleMix
789 merge: Util.deepMix, // mix
790 upperFirst: Util.upperFirst, // ucfirst
791 each: Util.each,
792 isEqual: Util.isEqual,
793 toArray: Util.toArray,
794 extend: Util.extend,
795 augment: Util.augment,
796 remove: Util.arrayUtil.pull,
797 isNumberEqual: Util.isNumberEqual,
798 toRadian: Util.toRadian,
799 toDegree: Util.toDegree,
800 mod: Util.mod,
801 clamp: Util.clamp
802};
803
804/***/ }),
805/* 10 */
806/***/ (function(module, exports) {
807
808var toString = {}.toString;
809var isType = function isType(value, type) {
810 return toString.call(value) === '[object ' + type + ']';
811};
812
813module.exports = isType;
814
815/***/ }),
816/* 11 */
817/***/ (function(module, exports, __webpack_require__) {
818
819var isObject = __webpack_require__(93);
820var isArray = __webpack_require__(12);
821
822var each = function each(elements, func) {
823 if (!elements) {
824 return;
825 }
826 var rst = void 0;
827 if (isArray(elements)) {
828 for (var i = 0, len = elements.length; i < len; i++) {
829 rst = func(elements[i], i);
830 if (rst === false) {
831 break;
832 }
833 }
834 } else if (isObject(elements)) {
835 for (var k in elements) {
836 if (elements.hasOwnProperty(k)) {
837 rst = func(elements[k], k);
838 if (rst === false) {
839 break;
840 }
841 }
842 }
843 }
844};
845
846module.exports = each;
847
848/***/ }),
849/* 12 */
850/***/ (function(module, exports, __webpack_require__) {
851
852var isType = __webpack_require__(10);
853
854var isArray = Array.isArray ? Array.isArray : function (value) {
855 return isType(value, 'Array');
856};
857
858module.exports = isArray;
859
860/***/ }),
861/* 13 */
862/***/ (function(module, __webpack_exports__, __webpack_require__) {
863
864"use strict";
865/* harmony export (immutable) */ __webpack_exports__["c"] = hue;
866/* harmony export (immutable) */ __webpack_exports__["b"] = gamma;
867/* harmony export (immutable) */ __webpack_exports__["a"] = nogamma;
868/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(61);
869
870
871function linear(a, d) {
872 return function (t) {
873 return a + t * d;
874 };
875}
876
877function exponential(a, b, y) {
878 return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function (t) {
879 return Math.pow(a + t * b, y);
880 };
881}
882
883function hue(a, b) {
884 var d = b - a;
885 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);
886}
887
888function gamma(y) {
889 return (y = +y) === 1 ? nogamma : function (a, b) {
890 return b - a ? exponential(a, b, y) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
891 };
892}
893
894function nogamma(a, b) {
895 var d = b - a;
896 return d ? linear(a, d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
897}
898
899/***/ }),
900/* 14 */
901/***/ (function(module, exports, __webpack_require__) {
902
903/**
904 * 是否为函数
905 * @param {*} fn 对象
906 * @return {Boolean} 是否函数
907 */
908var isType = __webpack_require__(10);
909
910var isFunction = function isFunction(value) {
911 return isType(value, 'Function');
912};
913
914module.exports = isFunction;
915
916/***/ }),
917/* 15 */
918/***/ (function(module, __webpack_exports__, __webpack_require__) {
919
920"use strict";
921/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
922 return a = +a, b -= a, function (t) {
923 return a + b * t;
924 };
925});
926
927/***/ }),
928/* 16 */
929/***/ (function(module, exports, __webpack_require__) {
930
931var Util = __webpack_require__(0);
932var vec2 = __webpack_require__(2).vec2;
933
934function cubicAt(p0, p1, p2, p3, t) {
935 var onet = 1 - t;
936 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
937}
938
939function cubicDerivativeAt(p0, p1, p2, p3, t) {
940 var onet = 1 - t;
941 return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
942}
943
944function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) {
945 var t = void 0;
946 var interval = 0.005;
947 var d = Infinity;
948 var _t = void 0;
949 var v1 = void 0;
950 var d1 = void 0;
951 var d2 = void 0;
952 var v2 = void 0;
953 var prev = void 0;
954 var next = void 0;
955 var EPSILON = 0.0001;
956 var v0 = [x, y];
957
958 for (_t = 0; _t < 1; _t += 0.05) {
959 v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)];
960
961 d1 = vec2.squaredDistance(v0, v1);
962 if (d1 < d) {
963 t = _t;
964 d = d1;
965 }
966 }
967 d = Infinity;
968
969 for (var i = 0; i < 32; i++) {
970 if (interval < EPSILON) {
971 break;
972 }
973
974 prev = t - interval;
975 next = t + interval;
976
977 v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)];
978
979 d1 = vec2.squaredDistance(v0, v1);
980
981 if (prev >= 0 && d1 < d) {
982 t = prev;
983 d = d1;
984 } else {
985 v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)];
986
987 d2 = vec2.squaredDistance(v0, v2);
988
989 if (next <= 1 && d2 < d) {
990 t = next;
991 d = d2;
992 } else {
993 interval *= 0.5;
994 }
995 }
996 }
997
998 if (out) {
999 out.x = cubicAt(x1, x2, x3, x4, t);
1000 out.y = cubicAt(y1, y2, y3, y4, t);
1001 }
1002
1003 return Math.sqrt(d);
1004}
1005
1006function cubicExtrema(p0, p1, p2, p3) {
1007 var a = 3 * p0 - 9 * p1 + 9 * p2 - 3 * p3;
1008 var b = 6 * p1 - 12 * p2 + 6 * p3;
1009 var c = 3 * p2 - 3 * p3;
1010 var extrema = [];
1011 var t1 = void 0;
1012 var t2 = void 0;
1013 var discSqrt = void 0;
1014
1015 if (Util.isNumberEqual(a, 0)) {
1016 if (!Util.isNumberEqual(b, 0)) {
1017 t1 = -c / b;
1018 if (t1 >= 0 && t1 <= 1) {
1019 extrema.push(t1);
1020 }
1021 }
1022 } else {
1023 var disc = b * b - 4 * a * c;
1024 if (Util.isNumberEqual(disc, 0)) {
1025 extrema.push(-b / (2 * a));
1026 } else if (disc > 0) {
1027 discSqrt = Math.sqrt(disc);
1028 t1 = (-b + discSqrt) / (2 * a);
1029 t2 = (-b - discSqrt) / (2 * a);
1030 if (t1 >= 0 && t1 <= 1) {
1031 extrema.push(t1);
1032 }
1033 if (t2 >= 0 && t2 <= 1) {
1034 extrema.push(t2);
1035 }
1036 }
1037 }
1038 return extrema;
1039}
1040
1041function base3(t, p1, p2, p3, p4) {
1042 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
1043 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
1044 return t * t2 - 3 * p1 + 3 * p2;
1045}
1046
1047function cubiclLen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
1048 if (Util.isNil(z)) {
1049 z = 1;
1050 }
1051 z = z > 1 ? 1 : z < 0 ? 0 : z;
1052 var z2 = z / 2;
1053 var n = 12;
1054 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];
1055 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];
1056 var sum = 0;
1057 for (var i = 0; i < n; i++) {
1058 var ct = z2 * Tvalues[i] + z2;
1059 var xbase = base3(ct, x1, x2, x3, x4);
1060 var ybase = base3(ct, y1, y2, y3, y4);
1061 var comb = xbase * xbase + ybase * ybase;
1062 sum += Cvalues[i] * Math.sqrt(comb);
1063 }
1064 return z2 * sum;
1065}
1066
1067module.exports = {
1068 at: cubicAt,
1069 derivativeAt: cubicDerivativeAt,
1070 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y) {
1071 var rst = {};
1072 cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, rst);
1073 return rst;
1074 },
1075
1076 pointDistance: cubicProjectPoint,
1077 extrema: cubicExtrema,
1078 len: cubiclLen
1079};
1080
1081/***/ }),
1082/* 17 */
1083/***/ (function(module, exports, __webpack_require__) {
1084
1085var CommonUtil = __webpack_require__(33);
1086
1087var Util = {};
1088
1089CommonUtil.mix(Util, CommonUtil);
1090
1091module.exports = Util;
1092
1093/***/ }),
1094/* 18 */
1095/***/ (function(module, exports) {
1096
1097function _mix(dist, obj) {
1098 for (var key in obj) {
1099 if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
1100 dist[key] = obj[key];
1101 }
1102 }
1103}
1104
1105var mix = function mix(dist, src1, src2, src3) {
1106 if (src1) _mix(dist, src1);
1107 if (src2) _mix(dist, src2);
1108 if (src3) _mix(dist, src3);
1109 return dist;
1110};
1111
1112module.exports = mix;
1113
1114/***/ }),
1115/* 19 */
1116/***/ (function(module, exports, __webpack_require__) {
1117
1118var Util = __webpack_require__(0);
1119var Attribute = __webpack_require__(111);
1120var Transform = __webpack_require__(112);
1121var Animate = __webpack_require__(44);
1122var EventEmitter = __webpack_require__(45);
1123
1124var Element = function Element(cfg) {
1125 this.__cfg = {
1126 zIndex: 0,
1127 capture: true,
1128 visible: true,
1129 destroyed: false
1130 }; // 配置存放地
1131
1132 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
1133 // 在子元素的init中创建新svg元素,然后设置属性和变换。在这边设置id而不是attr里,是考虑id一旦设置后应不能修改
1134 this.init(cfg ? cfg.id : null); // 类型初始化
1135 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
1136 this.initTransform(); // 初始化变换
1137};
1138
1139Element.CFG = {
1140 /**
1141 * 唯一标示
1142 * @type {Number}
1143 */
1144 id: null,
1145 /**
1146 * Z轴的层叠关系,Z值越大离用户越近
1147 * @type {Number}
1148 */
1149 zIndex: 0,
1150 /**
1151 * Canvas对象
1152 * @type: {Object}
1153 */
1154 canvas: null,
1155 /**
1156 * 父元素指针
1157 * @type {Object}
1158 */
1159 parent: null,
1160 /**
1161 * 用来设置当前对象是否能被捕捉
1162 * true 能
1163 * false 不能
1164 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
1165 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
1166 * @type {Boolean}
1167 **/
1168 capture: true,
1169 /**
1170 * 画布的上下文
1171 * @type {Object}
1172 */
1173 context: null,
1174 /**
1175 * 是否显示
1176 * @type {Boolean}
1177 */
1178 visible: true,
1179 /**
1180 * 是否被销毁
1181 * @type: {Boolean}
1182 */
1183 destroyed: false
1184};
1185
1186Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
1187 init: function init() {
1188 this.setSilent('animable', true);
1189 this.setSilent('animating', false); // 初始时不处于动画状态
1190 },
1191 getParent: function getParent() {
1192 return this.get('parent');
1193 },
1194
1195 /**
1196 * 获取默认的配置信息
1197 * @protected
1198 * @return {Object} 默认的属性
1199 */
1200 getDefaultCfg: function getDefaultCfg() {
1201 return {};
1202 },
1203 set: function set(name, value) {
1204 if (name === 'zIndex') {
1205 this._beforeSetZIndex(value);
1206 }
1207 this.__cfg[name] = value;
1208 return this;
1209 },
1210 setSilent: function setSilent(name, value) {
1211 this.__cfg[name] = value;
1212 },
1213 get: function get(name) {
1214 return this.__cfg[name];
1215 },
1216 draw: function draw() {},
1217 drawInner: function drawInner() {},
1218 show: function show() {
1219 this.set('visible', true);
1220 var el = this.get('el');
1221 if (el) {
1222 el.setAttribute('visibility', 'visible');
1223 }
1224 return this;
1225 },
1226 hide: function hide() {
1227 this.set('visible', false);
1228 var el = this.get('el');
1229 if (el) {
1230 el.setAttribute('visibility', 'hidden');
1231 }
1232 return this;
1233 },
1234 remove: function remove(destroy) {
1235 var el = this.get('el');
1236 if (destroy === undefined) {
1237 destroy = true;
1238 }
1239
1240 if (this.get('parent')) {
1241 var parent = this.get('parent');
1242 var children = parent.get('children');
1243 Util.remove(children, this);
1244 el.parentNode.removeChild(el);
1245 }
1246
1247 if (destroy) {
1248 this.destroy();
1249 }
1250
1251 return this;
1252 },
1253 destroy: function destroy() {
1254 var destroyed = this.get('destroyed');
1255 if (destroyed) {
1256 return;
1257 }
1258 this.__cfg = {};
1259 this.__attrs = null;
1260 this.removeEvent(); // 移除所有的事件
1261 this.set('destroyed', true);
1262 },
1263 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
1264 this.__cfg.zIndex = zIndex;
1265
1266 if (!Util.isNil(this.get('parent'))) {
1267 this.get('parent').sort();
1268 }
1269 return zIndex;
1270 },
1271 _setAttrs: function _setAttrs(attrs) {
1272 this.attr(attrs);
1273 return attrs;
1274 },
1275 setZIndex: function setZIndex(zIndex) {
1276 this.__cfg.zIndex = zIndex;
1277 return zIndex;
1278 },
1279 clone: function clone() {
1280 return Util.clone(this);
1281 },
1282 getBBox: function getBBox() {
1283 var el = this.get('el');
1284 if (!el) {
1285 return {
1286 minX: 0,
1287 minY: 0,
1288 maxX: 0,
1289 maxY: 0,
1290 width: 0,
1291 height: 0,
1292 x: 0,
1293 y: 0
1294 };
1295 }
1296 var bbox = el.getBBox();
1297 if (!el.parentNode || bbox.width === 0 && bbox.height === 0) {
1298 var node = el.cloneNode();
1299 node.innerHTML = el.innerHTML;
1300 node.setAttribute('visible', 'hidden');
1301 var svg = document.getElementsByTagName('svg')[0];
1302 svg.appendChild(node);
1303 bbox = node.getBBox();
1304 svg.removeChild(node);
1305 }
1306 bbox.minX = bbox.x;
1307 bbox.minY = bbox.y;
1308 bbox.maxX = bbox.x + bbox.width;
1309 bbox.maxY = bbox.y + bbox.height;
1310 return {
1311 minX: bbox.x,
1312 minY: bbox.y,
1313 maxX: bbox.x + bbox.width,
1314 maxY: bbox.y + bbox.height,
1315 width: bbox.width,
1316 height: bbox.height,
1317 x: bbox.x,
1318 y: bbox.y
1319 };
1320 }
1321});
1322
1323module.exports = Element;
1324
1325/***/ }),
1326/* 20 */
1327/***/ (function(module, exports) {
1328
1329
1330
1331Object.defineProperty(exports, "__esModule", {
1332 value: true
1333});
1334exports.setMatrixArrayType = setMatrixArrayType;
1335exports.toRadian = toRadian;
1336exports.equals = equals;
1337/**
1338 * Common utilities
1339 * @module glMatrix
1340 */
1341
1342// Configuration Constants
1343var EPSILON = exports.EPSILON = 0.000001;
1344var ARRAY_TYPE = exports.ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
1345var RANDOM = exports.RANDOM = Math.random;
1346
1347/**
1348 * Sets the type of array used when creating new vectors and matrices
1349 *
1350 * @param {Type} type Array type, such as Float32Array or Array
1351 */
1352function setMatrixArrayType(type) {
1353 exports.ARRAY_TYPE = ARRAY_TYPE = type;
1354}
1355
1356var degree = Math.PI / 180;
1357
1358/**
1359 * Convert Degree To Radian
1360 *
1361 * @param {Number} a Angle in Degrees
1362 */
1363function toRadian(a) {
1364 return a * degree;
1365}
1366
1367/**
1368 * Tests whether or not the arguments have approximately the same value, within an absolute
1369 * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
1370 * than or equal to 1.0, and a relative tolerance is used for larger values)
1371 *
1372 * @param {Number} a The first number to test.
1373 * @param {Number} b The second number to test.
1374 * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
1375 */
1376function equals(a, b) {
1377 return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
1378}
1379
1380/***/ }),
1381/* 21 */
1382/***/ (function(module, exports, __webpack_require__) {
1383
1384var _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; };
1385
1386var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
1387 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
1388} : function (obj) {
1389 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
1390};
1391
1392var Util = __webpack_require__(9);
1393var 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";
1394var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
1395var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
1396
1397// Parses given path string into an array of arrays of path segments
1398var parsePathString = function parsePathString(pathString) {
1399 if (!pathString) {
1400 return null;
1401 }
1402
1403 if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
1404 return pathString;
1405 }
1406 var paramCounts = {
1407 a: 7,
1408 c: 6,
1409 o: 2,
1410 h: 1,
1411 l: 2,
1412 m: 2,
1413 r: 4,
1414 q: 4,
1415 s: 4,
1416 t: 2,
1417 v: 1,
1418 u: 3,
1419 z: 0
1420 };
1421 var data = [];
1422
1423 String(pathString).replace(PATH_COMMAND, function (a, b, c) {
1424 var params = [];
1425 var name = b.toLowerCase();
1426 c.replace(PATH_VALUES, function (a, b) {
1427 b && params.push(+b);
1428 });
1429 if (name === 'm' && params.length > 2) {
1430 data.push([b].concat(params.splice(0, 2)));
1431 name = 'l';
1432 b = b === 'm' ? 'l' : 'L';
1433 }
1434 if (name === 'o' && params.length === 1) {
1435 data.push([b, params[0]]);
1436 }
1437 if (name === 'r') {
1438 data.push([b].concat(params));
1439 } else {
1440 while (params.length >= paramCounts[name]) {
1441 data.push([b].concat(params.splice(0, paramCounts[name])));
1442 if (!paramCounts[name]) {
1443 break;
1444 }
1445 }
1446 }
1447 });
1448
1449 return data;
1450};
1451
1452// http://schepers.cc/getting-to-the-point
1453var catmullRom2bezier = function catmullRom2bezier(crp, z) {
1454 var d = [];
1455 for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
1456 var p = [{
1457 x: +crp[i - 2],
1458 y: +crp[i - 1]
1459 }, {
1460 x: +crp[i],
1461 y: +crp[i + 1]
1462 }, {
1463 x: +crp[i + 2],
1464 y: +crp[i + 3]
1465 }, {
1466 x: +crp[i + 4],
1467 y: +crp[i + 5]
1468 }];
1469 if (z) {
1470 if (!i) {
1471 p[0] = {
1472 x: +crp[iLen - 2],
1473 y: +crp[iLen - 1]
1474 };
1475 } else if (iLen - 4 === i) {
1476 p[3] = {
1477 x: +crp[0],
1478 y: +crp[1]
1479 };
1480 } else if (iLen - 2 === i) {
1481 p[2] = {
1482 x: +crp[0],
1483 y: +crp[1]
1484 };
1485 p[3] = {
1486 x: +crp[2],
1487 y: +crp[3]
1488 };
1489 }
1490 } else {
1491 if (iLen - 4 === i) {
1492 p[3] = p[2];
1493 } else if (!i) {
1494 p[0] = {
1495 x: +crp[i],
1496 y: +crp[i + 1]
1497 };
1498 }
1499 }
1500 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]);
1501 }
1502
1503 return d;
1504};
1505
1506var ellipsePath = function ellipsePath(x, y, rx, ry, a) {
1507 var res = [];
1508 if (a === null && ry === null) {
1509 ry = rx;
1510 }
1511 x = +x;
1512 y = +y;
1513 rx = +rx;
1514 ry = +ry;
1515 if (a !== null) {
1516 var rad = Math.PI / 180;
1517 var x1 = x + rx * Math.cos(-ry * rad);
1518 var x2 = x + rx * Math.cos(-a * rad);
1519 var y1 = y + rx * Math.sin(-ry * rad);
1520 var y2 = y + rx * Math.sin(-a * rad);
1521 res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
1522 } else {
1523 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']];
1524 }
1525 return res;
1526};
1527
1528var pathToAbsolute = function pathToAbsolute(pathArray) {
1529 pathArray = parsePathString(pathArray);
1530
1531 if (!pathArray || !pathArray.length) {
1532 return [['M', 0, 0]];
1533 }
1534 var res = [];
1535 var x = 0;
1536 var y = 0;
1537 var mx = 0;
1538 var my = 0;
1539 var start = 0;
1540 var pa0 = void 0;
1541 var dots = void 0;
1542 if (pathArray[0][0] === 'M') {
1543 x = +pathArray[0][1];
1544 y = +pathArray[0][2];
1545 mx = x;
1546 my = y;
1547 start++;
1548 res[0] = ['M', x, y];
1549 }
1550 var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
1551 for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
1552 res.push(r = []);
1553 pa = pathArray[i];
1554 pa0 = pa[0];
1555 if (pa0 !== pa0.toUpperCase()) {
1556 r[0] = pa0.toUpperCase();
1557 switch (r[0]) {
1558 case 'A':
1559 r[1] = pa[1];
1560 r[2] = pa[2];
1561 r[3] = pa[3];
1562 r[4] = pa[4];
1563 r[5] = pa[5];
1564 r[6] = +pa[6] + x;
1565 r[7] = +pa[7] + y;
1566 break;
1567 case 'V':
1568 r[1] = +pa[1] + y;
1569 break;
1570 case 'H':
1571 r[1] = +pa[1] + x;
1572 break;
1573 case 'R':
1574 dots = [x, y].concat(pa.slice(1));
1575 for (var j = 2, jj = dots.length; j < jj; j++) {
1576 dots[j] = +dots[j] + x;
1577 dots[++j] = +dots[j] + y;
1578 }
1579 res.pop();
1580 res = res.concat(catmullRom2bezier(dots, crz));
1581 break;
1582 case 'O':
1583 res.pop();
1584 dots = ellipsePath(x, y, pa[1], pa[2]);
1585 dots.push(dots[0]);
1586 res = res.concat(dots);
1587 break;
1588 case 'U':
1589 res.pop();
1590 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
1591 r = ['U'].concat(res[res.length - 1].slice(-2));
1592 break;
1593 case 'M':
1594 mx = +pa[1] + x;
1595 my = +pa[2] + y;
1596 break; // for lint
1597 default:
1598 for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
1599 r[_j] = +pa[_j] + (_j % 2 ? x : y);
1600 }
1601 }
1602 } else if (pa0 === 'R') {
1603 dots = [x, y].concat(pa.slice(1));
1604 res.pop();
1605 res = res.concat(catmullRom2bezier(dots, crz));
1606 r = ['R'].concat(pa.slice(-2));
1607 } else if (pa0 === 'O') {
1608 res.pop();
1609 dots = ellipsePath(x, y, pa[1], pa[2]);
1610 dots.push(dots[0]);
1611 res = res.concat(dots);
1612 } else if (pa0 === 'U') {
1613 res.pop();
1614 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
1615 r = ['U'].concat(res[res.length - 1].slice(-2));
1616 } else {
1617 for (var k = 0, kk = pa.length; k < kk; k++) {
1618 r[k] = pa[k];
1619 }
1620 }
1621 pa0 = pa0.toUpperCase();
1622 if (pa0 !== 'O') {
1623 switch (r[0]) {
1624 case 'Z':
1625 x = +mx;
1626 y = +my;
1627 break;
1628 case 'H':
1629 x = r[1];
1630 break;
1631 case 'V':
1632 y = r[1];
1633 break;
1634 case 'M':
1635 mx = r[r.length - 2];
1636 my = r[r.length - 1];
1637 break; // for lint
1638 default:
1639 x = r[r.length - 2];
1640 y = r[r.length - 1];
1641 }
1642 }
1643 }
1644
1645 return res;
1646};
1647
1648var l2c = function l2c(x1, y1, x2, y2) {
1649 return [x1, y1, x2, y2, x2, y2];
1650};
1651
1652var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
1653 var _13 = 1 / 3;
1654 var _23 = 2 / 3;
1655 return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
1656};
1657
1658var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
1659 // for more information of where this math came from visit:
1660 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
1661 if (rx === ry) {
1662 rx += 1;
1663 }
1664
1665 var _120 = Math.PI * 120 / 180;
1666 var rad = Math.PI / 180 * (+angle || 0);
1667 var res = [];
1668 var xy = void 0;
1669 var f1 = void 0;
1670 var f2 = void 0;
1671 var cx = void 0;
1672 var cy = void 0;
1673 var rotate = function rotate(x, y, rad) {
1674 var X = x * Math.cos(rad) - y * Math.sin(rad);
1675 var Y = x * Math.sin(rad) + y * Math.cos(rad);
1676 return {
1677 x: X,
1678 y: Y
1679 };
1680 };
1681 if (!recursive) {
1682 xy = rotate(x1, y1, -rad);
1683 x1 = xy.x;
1684 y1 = xy.y;
1685 xy = rotate(x2, y2, -rad);
1686 x2 = xy.x;
1687 y2 = xy.y;
1688 if (x1 === x2 && y1 === y2) {
1689 // 若弧的起始点和终点重叠则错开一点
1690 x2 += 1;
1691 y2 += 1;
1692 }
1693 // const cos = Math.cos(Math.PI / 180 * angle);
1694 // const sin = Math.sin(Math.PI / 180 * angle);
1695 var x = (x1 - x2) / 2;
1696 var y = (y1 - y2) / 2;
1697 var h = x * x / (rx * rx) + y * y / (ry * ry);
1698 if (h > 1) {
1699 h = Math.sqrt(h);
1700 rx = h * rx;
1701 ry = h * ry;
1702 }
1703 var rx2 = rx * rx;
1704 var ry2 = ry * ry;
1705 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)));
1706 cx = k * rx * y / ry + (x1 + x2) / 2;
1707 cy = k * -ry * x / rx + (y1 + y2) / 2;
1708 f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
1709 f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
1710
1711 f1 = x1 < cx ? Math.PI - f1 : f1;
1712 f2 = x2 < cx ? Math.PI - f2 : f2;
1713 f1 < 0 && (f1 = Math.PI * 2 + f1);
1714 f2 < 0 && (f2 = Math.PI * 2 + f2);
1715 if (sweep_flag && f1 > f2) {
1716 f1 = f1 - Math.PI * 2;
1717 }
1718 if (!sweep_flag && f2 > f1) {
1719 f2 = f2 - Math.PI * 2;
1720 }
1721 } else {
1722 f1 = recursive[0];
1723 f2 = recursive[1];
1724 cx = recursive[2];
1725 cy = recursive[3];
1726 }
1727 var df = f2 - f1;
1728 if (Math.abs(df) > _120) {
1729 var f2old = f2;
1730 var x2old = x2;
1731 var y2old = y2;
1732 f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
1733 x2 = cx + rx * Math.cos(f2);
1734 y2 = cy + ry * Math.sin(f2);
1735 res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
1736 }
1737 df = f2 - f1;
1738 var c1 = Math.cos(f1);
1739 var s1 = Math.sin(f1);
1740 var c2 = Math.cos(f2);
1741 var s2 = Math.sin(f2);
1742 var t = Math.tan(df / 4);
1743 var hx = 4 / 3 * rx * t;
1744 var hy = 4 / 3 * ry * t;
1745 var m1 = [x1, y1];
1746 var m2 = [x1 + hx * s1, y1 - hy * c1];
1747 var m3 = [x2 + hx * s2, y2 - hy * c2];
1748 var m4 = [x2, y2];
1749 m2[0] = 2 * m1[0] - m2[0];
1750 m2[1] = 2 * m1[1] - m2[1];
1751 if (recursive) {
1752 return [m2, m3, m4].concat(res);
1753 }
1754 res = [m2, m3, m4].concat(res).join().split(',');
1755 var newres = [];
1756 for (var i = 0, ii = res.length; i < ii; i++) {
1757 newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
1758 }
1759 return newres;
1760};
1761
1762var pathTocurve = function pathTocurve(path, path2) {
1763 var p = pathToAbsolute(path);
1764 var p2 = path2 && pathToAbsolute(path2);
1765 var attrs = {
1766 x: 0,
1767 y: 0,
1768 bx: 0,
1769 by: 0,
1770 X: 0,
1771 Y: 0,
1772 qx: null,
1773 qy: null
1774 };
1775 var attrs2 = {
1776 x: 0,
1777 y: 0,
1778 bx: 0,
1779 by: 0,
1780 X: 0,
1781 Y: 0,
1782 qx: null,
1783 qy: null
1784 };
1785 var pcoms1 = []; // path commands of original path p
1786 var pcoms2 = []; // path commands of original path p2
1787 var pfirst = ''; // temporary holder for original path command
1788 var pcom = ''; // holder for previous path command of original path
1789 var ii = void 0;
1790 var processPath = function processPath(path, d, pcom) {
1791 var nx = void 0,
1792 ny = void 0;
1793 if (!path) {
1794 return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
1795 }!(path[0] in {
1796 T: 1,
1797 Q: 1
1798 }) && (d.qx = d.qy = null);
1799 switch (path[0]) {
1800 case 'M':
1801 d.X = path[1];
1802 d.Y = path[2];
1803 break;
1804 case 'A':
1805 path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
1806 break;
1807 case 'S':
1808 if (pcom === 'C' || pcom === 'S') {
1809 // In "S" case we have to take into account, if the previous command is C/S.
1810 nx = d.x * 2 - d.bx; // And reflect the previous
1811 ny = d.y * 2 - d.by; // command's control point relative to the current point.
1812 } else {
1813 // or some else or nothing
1814 nx = d.x;
1815 ny = d.y;
1816 }
1817 path = ['C', nx, ny].concat(path.slice(1));
1818 break;
1819 case 'T':
1820 if (pcom === 'Q' || pcom === 'T') {
1821 // In "T" case we have to take into account, if the previous command is Q/T.
1822 d.qx = d.x * 2 - d.qx; // And make a reflection similar
1823 d.qy = d.y * 2 - d.qy; // to case "S".
1824 } else {
1825 // or something else or nothing
1826 d.qx = d.x;
1827 d.qy = d.y;
1828 }
1829 path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
1830 break;
1831 case 'Q':
1832 d.qx = path[1];
1833 d.qy = path[2];
1834 path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
1835 break;
1836 case 'L':
1837 path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
1838 break;
1839 case 'H':
1840 path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
1841 break;
1842 case 'V':
1843 path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
1844 break;
1845 case 'Z':
1846 path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
1847 break;
1848 default:
1849 break;
1850 }
1851 return path;
1852 };
1853 var fixArc = function fixArc(pp, i) {
1854 if (pp[i].length > 7) {
1855 pp[i].shift();
1856 var pi = pp[i];
1857 while (pi.length) {
1858 pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
1859 p2 && (pcoms2[i] = 'A'); // the same as above
1860 pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
1861 }
1862 pp.splice(i, 1);
1863 ii = Math.max(p.length, p2 && p2.length || 0);
1864 }
1865 };
1866 var fixM = function fixM(path1, path2, a1, a2, i) {
1867 if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
1868 path2.splice(i, 0, ['M', a2.x, a2.y]);
1869 a1.bx = 0;
1870 a1.by = 0;
1871 a1.x = path1[i][1];
1872 a1.y = path1[i][2];
1873 ii = Math.max(p.length, p2 && p2.length || 0);
1874 }
1875 };
1876 ii = Math.max(p.length, p2 && p2.length || 0);
1877 for (var i = 0; i < ii; i++) {
1878
1879 p[i] && (pfirst = p[i][0]); // save current path command
1880
1881 if (pfirst !== 'C') {
1882 // C is not saved yet, because it may be result of conversion
1883 pcoms1[i] = pfirst; // Save current path command
1884 i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
1885 }
1886 p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
1887
1888 if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
1889 // which may produce multiple C:s
1890 // so we have to make sure that C is also C in original path
1891
1892 fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
1893
1894 if (p2) {
1895 // the same procedures is done to p2
1896 p2[i] && (pfirst = p2[i][0]);
1897 if (pfirst !== 'C') {
1898 pcoms2[i] = pfirst;
1899 i && (pcom = pcoms2[i - 1]);
1900 }
1901 p2[i] = processPath(p2[i], attrs2, pcom);
1902
1903 if (pcoms2[i] !== 'A' && pfirst === 'C') {
1904 pcoms2[i] = 'C';
1905 }
1906
1907 fixArc(p2, i);
1908 }
1909 fixM(p, p2, attrs, attrs2, i);
1910 fixM(p2, p, attrs2, attrs, i);
1911 var seg = p[i];
1912 var seg2 = p2 && p2[i];
1913 var seglen = seg.length;
1914 var seg2len = p2 && seg2.length;
1915 attrs.x = seg[seglen - 2];
1916 attrs.y = seg[seglen - 1];
1917 attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
1918 attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
1919 attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
1920 attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
1921 attrs2.x = p2 && seg2[seg2len - 2];
1922 attrs2.y = p2 && seg2[seg2len - 1];
1923 }
1924
1925 return p2 ? [p, p2] : p;
1926};
1927
1928var p2s = /,?([a-z]),?/gi;
1929var parsePathArray = function parsePathArray(path) {
1930 return path.join(',').replace(p2s, '$1');
1931};
1932
1933var base3 = function base3(t, p1, p2, p3, p4) {
1934 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
1935 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
1936 return t * t2 - 3 * p1 + 3 * p2;
1937};
1938
1939var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
1940 if (z === null) {
1941 z = 1;
1942 }
1943 z = z > 1 ? 1 : z < 0 ? 0 : z;
1944 var z2 = z / 2;
1945 var n = 12;
1946 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];
1947 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];
1948 var sum = 0;
1949 for (var i = 0; i < n; i++) {
1950 var ct = z2 * Tvalues[i] + z2;
1951 var xbase = base3(ct, x1, x2, x3, x4);
1952 var ybase = base3(ct, y1, y2, y3, y4);
1953 var comb = xbase * xbase + ybase * ybase;
1954 sum += Cvalues[i] * Math.sqrt(comb);
1955 }
1956 return z2 * sum;
1957};
1958
1959var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
1960 var tvalues = [];
1961 var bounds = [[], []];
1962 var a = void 0;
1963 var b = void 0;
1964 var c = void 0;
1965 var t = void 0;
1966
1967 for (var i = 0; i < 2; ++i) {
1968 if (i === 0) {
1969 b = 6 * x0 - 12 * x1 + 6 * x2;
1970 a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
1971 c = 3 * x1 - 3 * x0;
1972 } else {
1973 b = 6 * y0 - 12 * y1 + 6 * y2;
1974 a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
1975 c = 3 * y1 - 3 * y0;
1976 }
1977 if (Math.abs(a) < 1e-12) {
1978 if (Math.abs(b) < 1e-12) {
1979 continue;
1980 }
1981 t = -c / b;
1982 if (t > 0 && t < 1) {
1983 tvalues.push(t);
1984 }
1985 continue;
1986 }
1987 var b2ac = b * b - 4 * c * a;
1988 var sqrtb2ac = Math.sqrt(b2ac);
1989 if (b2ac < 0) {
1990 continue;
1991 }
1992 var t1 = (-b + sqrtb2ac) / (2 * a);
1993 if (t1 > 0 && t1 < 1) {
1994 tvalues.push(t1);
1995 }
1996 var t2 = (-b - sqrtb2ac) / (2 * a);
1997 if (t2 > 0 && t2 < 1) {
1998 tvalues.push(t2);
1999 }
2000 }
2001
2002 var j = tvalues.length;
2003 var jlen = j;
2004 var mt = void 0;
2005 while (j--) {
2006 t = tvalues[j];
2007 mt = 1 - t;
2008 bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
2009 bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
2010 }
2011
2012 bounds[0][jlen] = x0;
2013 bounds[1][jlen] = y0;
2014 bounds[0][jlen + 1] = x3;
2015 bounds[1][jlen + 1] = y3;
2016 bounds[0].length = bounds[1].length = jlen + 2;
2017
2018 return {
2019 min: {
2020 x: Math.min.apply(0, bounds[0]),
2021 y: Math.min.apply(0, bounds[1])
2022 },
2023 max: {
2024 x: Math.max.apply(0, bounds[0]),
2025 y: Math.max.apply(0, bounds[1])
2026 }
2027 };
2028};
2029
2030var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
2031 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)) {
2032 return;
2033 }
2034 var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
2035 var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
2036 var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
2037
2038 if (!denominator) {
2039 return;
2040 }
2041 var px = nx / denominator;
2042 var py = ny / denominator;
2043 var px2 = +px.toFixed(2);
2044 var py2 = +py.toFixed(2);
2045 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)) {
2046 return;
2047 }
2048 return {
2049 x: px,
2050 y: py
2051 };
2052};
2053
2054var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
2055 return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
2056};
2057
2058var rectPath = function rectPath(x, y, w, h, r) {
2059 if (r) {
2060 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']];
2061 }
2062 var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
2063 res.parsePathArray = parsePathArray;
2064 return res;
2065};
2066
2067var box = function box(x, y, width, height) {
2068 if (x === null) {
2069 x = y = width = height = 0;
2070 }
2071 if (y === null) {
2072 y = x.y;
2073 width = x.width;
2074 height = x.height;
2075 x = x.x;
2076 }
2077 return {
2078 x: x,
2079 y: y,
2080 width: width,
2081 w: width,
2082 height: height,
2083 h: height,
2084 x2: x + width,
2085 y2: y + height,
2086 cx: x + width / 2,
2087 cy: y + height / 2,
2088 r1: Math.min(width, height) / 2,
2089 r2: Math.max(width, height) / 2,
2090 r0: Math.sqrt(width * width + height * height) / 2,
2091 path: rectPath(x, y, width, height),
2092 vb: [x, y, width, height].join(' ')
2093 };
2094};
2095
2096var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
2097 bbox1 = box(bbox1);
2098 bbox2 = box(bbox2);
2099 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);
2100};
2101
2102var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
2103 if (!Util.isArray(p1x)) {
2104 p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
2105 }
2106 var bbox = curveDim.apply(null, p1x);
2107 return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
2108};
2109
2110var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
2111 var t1 = 1 - t;
2112 var t13 = Math.pow(t1, 3);
2113 var t12 = Math.pow(t1, 2);
2114 var t2 = t * t;
2115 var t3 = t2 * t;
2116 var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
2117 var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
2118 var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
2119 var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
2120 var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
2121 var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
2122 var ax = t1 * p1x + t * c1x;
2123 var ay = t1 * p1y + t * c1y;
2124 var cx = t1 * c2x + t * p2x;
2125 var cy = t1 * c2y + t * p2y;
2126 var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
2127 // (mx > nx || my < ny) && (alpha += 180);
2128 return {
2129 x: x,
2130 y: y,
2131 m: {
2132 x: mx,
2133 y: my
2134 },
2135 n: {
2136 x: nx,
2137 y: ny
2138 },
2139 start: {
2140 x: ax,
2141 y: ay
2142 },
2143 end: {
2144 x: cx,
2145 y: cy
2146 },
2147 alpha: alpha
2148 };
2149};
2150
2151var interHelper = function interHelper(bez1, bez2, justCount) {
2152 var bbox1 = bezierBBox(bez1);
2153 var bbox2 = bezierBBox(bez2);
2154 if (!isBBoxIntersect(bbox1, bbox2)) {
2155 return justCount ? 0 : [];
2156 }
2157 var l1 = bezlen.apply(0, bez1);
2158 var l2 = bezlen.apply(0, bez2);
2159 var n1 = ~~(l1 / 8);
2160 var n2 = ~~(l2 / 8);
2161 var dots1 = [];
2162 var dots2 = [];
2163 var xy = {};
2164 var res = justCount ? 0 : [];
2165 for (var i = 0; i < n1 + 1; i++) {
2166 var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
2167 dots1.push({
2168 x: d.x,
2169 y: d.y,
2170 t: i / n1
2171 });
2172 }
2173 for (var _i = 0; _i < n2 + 1; _i++) {
2174 var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
2175 dots2.push({
2176 x: _d.x,
2177 y: _d.y,
2178 t: _i / n2
2179 });
2180 }
2181 for (var _i2 = 0; _i2 < n1; _i2++) {
2182 for (var j = 0; j < n2; j++) {
2183 var di = dots1[_i2];
2184 var di1 = dots1[_i2 + 1];
2185 var dj = dots2[j];
2186 var dj1 = dots2[j + 1];
2187 var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
2188 var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
2189 var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
2190 if (is) {
2191 if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
2192 continue;
2193 }
2194 xy[is.x.toFixed(4)] = is.y.toFixed(4);
2195 var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
2196 var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
2197 if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
2198 if (justCount) {
2199 res++;
2200 } else {
2201 res.push({
2202 x: is.x,
2203 y: is.y,
2204 t1: t1,
2205 t2: t2
2206 });
2207 }
2208 }
2209 }
2210 }
2211 }
2212 return res;
2213};
2214
2215var interPathHelper = function interPathHelper(path1, path2, justCount) {
2216 path1 = pathTocurve(path1);
2217 path2 = pathTocurve(path2);
2218 var x1 = void 0;
2219 var y1 = void 0;
2220 var x2 = void 0;
2221 var y2 = void 0;
2222 var x1m = void 0;
2223 var y1m = void 0;
2224 var x2m = void 0;
2225 var y2m = void 0;
2226 var bez1 = void 0;
2227 var bez2 = void 0;
2228 var res = justCount ? 0 : [];
2229 for (var i = 0, ii = path1.length; i < ii; i++) {
2230 var pi = path1[i];
2231 if (pi[0] === 'M') {
2232 x1 = x1m = pi[1];
2233 y1 = y1m = pi[2];
2234 } else {
2235 if (pi[0] === 'C') {
2236 bez1 = [x1, y1].concat(pi.slice(1));
2237 x1 = bez1[6];
2238 y1 = bez1[7];
2239 } else {
2240 bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
2241 x1 = x1m;
2242 y1 = y1m;
2243 }
2244 for (var j = 0, jj = path2.length; j < jj; j++) {
2245 var pj = path2[j];
2246 if (pj[0] === 'M') {
2247 x2 = x2m = pj[1];
2248 y2 = y2m = pj[2];
2249 } else {
2250 if (pj[0] === 'C') {
2251 bez2 = [x2, y2].concat(pj.slice(1));
2252 x2 = bez2[6];
2253 y2 = bez2[7];
2254 } else {
2255 bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
2256 x2 = x2m;
2257 y2 = y2m;
2258 }
2259 var intr = interHelper(bez1, bez2, justCount);
2260 if (justCount) {
2261 res += intr;
2262 } else {
2263 for (var k = 0, kk = intr.length; k < kk; k++) {
2264 intr[k].segment1 = i;
2265 intr[k].segment2 = j;
2266 intr[k].bez1 = bez1;
2267 intr[k].bez2 = bez2;
2268 }
2269 res = res.concat(intr);
2270 }
2271 }
2272 }
2273 }
2274 }
2275 return res;
2276};
2277
2278var pathIntersection = function pathIntersection(path1, path2) {
2279 return interPathHelper(path1, path2);
2280};
2281
2282module.exports = {
2283 parsePathString: parsePathString,
2284 parsePathArray: parsePathArray,
2285 pathTocurve: pathTocurve,
2286 pathToAbsolute: pathToAbsolute,
2287 catmullRomToBezier: catmullRom2bezier,
2288 rectPath: rectPath,
2289 intersection: pathIntersection
2290};
2291
2292/***/ }),
2293/* 22 */
2294/***/ (function(module, __webpack_exports__, __webpack_require__) {
2295
2296"use strict";
2297/* harmony export (immutable) */ __webpack_exports__["b"] = now;
2298/* harmony export (immutable) */ __webpack_exports__["a"] = Timer;
2299/* harmony export (immutable) */ __webpack_exports__["c"] = timer;
2300/* harmony export (immutable) */ __webpack_exports__["d"] = timerFlush;
2301var _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; };
2302
2303var frame = 0,
2304 // is an animation frame pending?
2305timeout = 0,
2306 // is a timeout pending?
2307interval = 0,
2308 // are any timers active?
2309pokeDelay = 1000,
2310 // how frequently we check for clock skew
2311taskHead,
2312 taskTail,
2313 clockLast = 0,
2314 clockNow = 0,
2315 clockSkew = 0,
2316 clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === "object" && performance.now ? performance : Date,
2317 setFrame = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function (f) {
2318 setTimeout(f, 17);
2319};
2320
2321function now() {
2322 return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
2323}
2324
2325function clearNow() {
2326 clockNow = 0;
2327}
2328
2329function Timer() {
2330 this._call = this._time = this._next = null;
2331}
2332
2333Timer.prototype = timer.prototype = {
2334 constructor: Timer,
2335 restart: function restart(callback, delay, time) {
2336 if (typeof callback !== "function") throw new TypeError("callback is not a function");
2337 time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
2338 if (!this._next && taskTail !== this) {
2339 if (taskTail) taskTail._next = this;else taskHead = this;
2340 taskTail = this;
2341 }
2342 this._call = callback;
2343 this._time = time;
2344 sleep();
2345 },
2346 stop: function stop() {
2347 if (this._call) {
2348 this._call = null;
2349 this._time = Infinity;
2350 sleep();
2351 }
2352 }
2353};
2354
2355function timer(callback, delay, time) {
2356 var t = new Timer();
2357 t.restart(callback, delay, time);
2358 return t;
2359}
2360
2361function timerFlush() {
2362 now(); // Get the current time, if not already set.
2363 ++frame; // Pretend we’ve set an alarm, if we haven’t already.
2364 var t = taskHead,
2365 e;
2366 while (t) {
2367 if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
2368 t = t._next;
2369 }
2370 --frame;
2371}
2372
2373function wake() {
2374 clockNow = (clockLast = clock.now()) + clockSkew;
2375 frame = timeout = 0;
2376 try {
2377 timerFlush();
2378 } finally {
2379 frame = 0;
2380 nap();
2381 clockNow = 0;
2382 }
2383}
2384
2385function poke() {
2386 var now = clock.now(),
2387 delay = now - clockLast;
2388 if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
2389}
2390
2391function nap() {
2392 var t0,
2393 t1 = taskHead,
2394 t2,
2395 time = Infinity;
2396 while (t1) {
2397 if (t1._call) {
2398 if (time > t1._time) time = t1._time;
2399 t0 = t1, t1 = t1._next;
2400 } else {
2401 t2 = t1._next, t1._next = null;
2402 t1 = t0 ? t0._next = t2 : taskHead = t2;
2403 }
2404 }
2405 taskTail = t0;
2406 sleep(time);
2407}
2408
2409function sleep(time) {
2410 if (frame) return; // Soonest alarm already set, or will be.
2411 if (timeout) timeout = clearTimeout(timeout);
2412 var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
2413 if (delay > 24) {
2414 if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
2415 if (interval) interval = clearInterval(interval);
2416 } else {
2417 if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
2418 frame = 1, setFrame(wake);
2419 }
2420}
2421
2422/***/ }),
2423/* 23 */
2424/***/ (function(module, __webpack_exports__, __webpack_require__) {
2425
2426"use strict";
2427/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(6);
2428/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(59);
2429/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(62);
2430/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(63);
2431/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(15);
2432/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(64);
2433/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(65);
2434/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(61);
2435var _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; };
2436
2437
2438
2439
2440
2441
2442
2443
2444
2445
2446/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
2447 var t = typeof b === "undefined" ? "undefined" : _typeof(b),
2448 c;
2449 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);
2450});
2451
2452/***/ }),
2453/* 24 */
2454/***/ (function(module, __webpack_exports__, __webpack_require__) {
2455
2456"use strict";
2457/* harmony export (immutable) */ __webpack_exports__["a"] = Color;
2458/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return _darker; });
2459/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _brighter; });
2460/* harmony export (immutable) */ __webpack_exports__["e"] = color;
2461/* harmony export (immutable) */ __webpack_exports__["h"] = rgbConvert;
2462/* harmony export (immutable) */ __webpack_exports__["g"] = rgb;
2463/* harmony export (immutable) */ __webpack_exports__["b"] = Rgb;
2464/* unused harmony export hslConvert */
2465/* harmony export (immutable) */ __webpack_exports__["f"] = hsl;
2466/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(25);
2467
2468
2469function Color() {}
2470
2471var _darker = 0.7;
2472
2473var _brighter = 1 / _darker;
2474
2475
2476var reI = "\\s*([+-]?\\d+)\\s*",
2477 reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
2478 reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
2479 reHex3 = /^#([0-9a-f]{3})$/,
2480 reHex6 = /^#([0-9a-f]{6})$/,
2481 reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
2482 reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
2483 reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
2484 reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
2485 reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
2486 reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
2487
2488var named = {
2489 aliceblue: 0xf0f8ff,
2490 antiquewhite: 0xfaebd7,
2491 aqua: 0x00ffff,
2492 aquamarine: 0x7fffd4,
2493 azure: 0xf0ffff,
2494 beige: 0xf5f5dc,
2495 bisque: 0xffe4c4,
2496 black: 0x000000,
2497 blanchedalmond: 0xffebcd,
2498 blue: 0x0000ff,
2499 blueviolet: 0x8a2be2,
2500 brown: 0xa52a2a,
2501 burlywood: 0xdeb887,
2502 cadetblue: 0x5f9ea0,
2503 chartreuse: 0x7fff00,
2504 chocolate: 0xd2691e,
2505 coral: 0xff7f50,
2506 cornflowerblue: 0x6495ed,
2507 cornsilk: 0xfff8dc,
2508 crimson: 0xdc143c,
2509 cyan: 0x00ffff,
2510 darkblue: 0x00008b,
2511 darkcyan: 0x008b8b,
2512 darkgoldenrod: 0xb8860b,
2513 darkgray: 0xa9a9a9,
2514 darkgreen: 0x006400,
2515 darkgrey: 0xa9a9a9,
2516 darkkhaki: 0xbdb76b,
2517 darkmagenta: 0x8b008b,
2518 darkolivegreen: 0x556b2f,
2519 darkorange: 0xff8c00,
2520 darkorchid: 0x9932cc,
2521 darkred: 0x8b0000,
2522 darksalmon: 0xe9967a,
2523 darkseagreen: 0x8fbc8f,
2524 darkslateblue: 0x483d8b,
2525 darkslategray: 0x2f4f4f,
2526 darkslategrey: 0x2f4f4f,
2527 darkturquoise: 0x00ced1,
2528 darkviolet: 0x9400d3,
2529 deeppink: 0xff1493,
2530 deepskyblue: 0x00bfff,
2531 dimgray: 0x696969,
2532 dimgrey: 0x696969,
2533 dodgerblue: 0x1e90ff,
2534 firebrick: 0xb22222,
2535 floralwhite: 0xfffaf0,
2536 forestgreen: 0x228b22,
2537 fuchsia: 0xff00ff,
2538 gainsboro: 0xdcdcdc,
2539 ghostwhite: 0xf8f8ff,
2540 gold: 0xffd700,
2541 goldenrod: 0xdaa520,
2542 gray: 0x808080,
2543 green: 0x008000,
2544 greenyellow: 0xadff2f,
2545 grey: 0x808080,
2546 honeydew: 0xf0fff0,
2547 hotpink: 0xff69b4,
2548 indianred: 0xcd5c5c,
2549 indigo: 0x4b0082,
2550 ivory: 0xfffff0,
2551 khaki: 0xf0e68c,
2552 lavender: 0xe6e6fa,
2553 lavenderblush: 0xfff0f5,
2554 lawngreen: 0x7cfc00,
2555 lemonchiffon: 0xfffacd,
2556 lightblue: 0xadd8e6,
2557 lightcoral: 0xf08080,
2558 lightcyan: 0xe0ffff,
2559 lightgoldenrodyellow: 0xfafad2,
2560 lightgray: 0xd3d3d3,
2561 lightgreen: 0x90ee90,
2562 lightgrey: 0xd3d3d3,
2563 lightpink: 0xffb6c1,
2564 lightsalmon: 0xffa07a,
2565 lightseagreen: 0x20b2aa,
2566 lightskyblue: 0x87cefa,
2567 lightslategray: 0x778899,
2568 lightslategrey: 0x778899,
2569 lightsteelblue: 0xb0c4de,
2570 lightyellow: 0xffffe0,
2571 lime: 0x00ff00,
2572 limegreen: 0x32cd32,
2573 linen: 0xfaf0e6,
2574 magenta: 0xff00ff,
2575 maroon: 0x800000,
2576 mediumaquamarine: 0x66cdaa,
2577 mediumblue: 0x0000cd,
2578 mediumorchid: 0xba55d3,
2579 mediumpurple: 0x9370db,
2580 mediumseagreen: 0x3cb371,
2581 mediumslateblue: 0x7b68ee,
2582 mediumspringgreen: 0x00fa9a,
2583 mediumturquoise: 0x48d1cc,
2584 mediumvioletred: 0xc71585,
2585 midnightblue: 0x191970,
2586 mintcream: 0xf5fffa,
2587 mistyrose: 0xffe4e1,
2588 moccasin: 0xffe4b5,
2589 navajowhite: 0xffdead,
2590 navy: 0x000080,
2591 oldlace: 0xfdf5e6,
2592 olive: 0x808000,
2593 olivedrab: 0x6b8e23,
2594 orange: 0xffa500,
2595 orangered: 0xff4500,
2596 orchid: 0xda70d6,
2597 palegoldenrod: 0xeee8aa,
2598 palegreen: 0x98fb98,
2599 paleturquoise: 0xafeeee,
2600 palevioletred: 0xdb7093,
2601 papayawhip: 0xffefd5,
2602 peachpuff: 0xffdab9,
2603 peru: 0xcd853f,
2604 pink: 0xffc0cb,
2605 plum: 0xdda0dd,
2606 powderblue: 0xb0e0e6,
2607 purple: 0x800080,
2608 rebeccapurple: 0x663399,
2609 red: 0xff0000,
2610 rosybrown: 0xbc8f8f,
2611 royalblue: 0x4169e1,
2612 saddlebrown: 0x8b4513,
2613 salmon: 0xfa8072,
2614 sandybrown: 0xf4a460,
2615 seagreen: 0x2e8b57,
2616 seashell: 0xfff5ee,
2617 sienna: 0xa0522d,
2618 silver: 0xc0c0c0,
2619 skyblue: 0x87ceeb,
2620 slateblue: 0x6a5acd,
2621 slategray: 0x708090,
2622 slategrey: 0x708090,
2623 snow: 0xfffafa,
2624 springgreen: 0x00ff7f,
2625 steelblue: 0x4682b4,
2626 tan: 0xd2b48c,
2627 teal: 0x008080,
2628 thistle: 0xd8bfd8,
2629 tomato: 0xff6347,
2630 turquoise: 0x40e0d0,
2631 violet: 0xee82ee,
2632 wheat: 0xf5deb3,
2633 white: 0xffffff,
2634 whitesmoke: 0xf5f5f5,
2635 yellow: 0xffff00,
2636 yellowgreen: 0x9acd32
2637};
2638
2639Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Color, color, {
2640 displayable: function displayable() {
2641 return this.rgb().displayable();
2642 },
2643 hex: function hex() {
2644 return this.rgb().hex();
2645 },
2646 toString: function toString() {
2647 return this.rgb() + "";
2648 }
2649});
2650
2651function color(format) {
2652 var m;
2653 format = (format + "").trim().toLowerCase();
2654 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
2655 ) : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
2656 : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
2657 : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
2658 : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
2659 : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
2660 : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
2661 : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
2662 : named.hasOwnProperty(format) ? rgbn(named[format]) : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
2663}
2664
2665function rgbn(n) {
2666 return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
2667}
2668
2669function rgba(r, g, b, a) {
2670 if (a <= 0) r = g = b = NaN;
2671 return new Rgb(r, g, b, a);
2672}
2673
2674function rgbConvert(o) {
2675 if (!(o instanceof Color)) o = color(o);
2676 if (!o) return new Rgb();
2677 o = o.rgb();
2678 return new Rgb(o.r, o.g, o.b, o.opacity);
2679}
2680
2681function rgb(r, g, b, opacity) {
2682 return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
2683}
2684
2685function Rgb(r, g, b, opacity) {
2686 this.r = +r;
2687 this.g = +g;
2688 this.b = +b;
2689 this.opacity = +opacity;
2690}
2691
2692Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Rgb, rgb, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
2693 brighter: function brighter(k) {
2694 k = k == null ? _brighter : Math.pow(_brighter, k);
2695 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2696 },
2697 darker: function darker(k) {
2698 k = k == null ? _darker : Math.pow(_darker, k);
2699 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
2700 },
2701 rgb: function rgb() {
2702 return this;
2703 },
2704 displayable: function displayable() {
2705 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;
2706 },
2707 hex: function hex() {
2708 return "#" + _hex(this.r) + _hex(this.g) + _hex(this.b);
2709 },
2710 toString: function toString() {
2711 var a = this.opacity;a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
2712 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 + ")");
2713 }
2714}));
2715
2716function _hex(value) {
2717 value = Math.max(0, Math.min(255, Math.round(value) || 0));
2718 return (value < 16 ? "0" : "") + value.toString(16);
2719}
2720
2721function hsla(h, s, l, a) {
2722 if (a <= 0) h = s = l = NaN;else if (l <= 0 || l >= 1) h = s = NaN;else if (s <= 0) h = NaN;
2723 return new Hsl(h, s, l, a);
2724}
2725
2726function hslConvert(o) {
2727 if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
2728 if (!(o instanceof Color)) o = color(o);
2729 if (!o) return new Hsl();
2730 if (o instanceof Hsl) return o;
2731 o = o.rgb();
2732 var r = o.r / 255,
2733 g = o.g / 255,
2734 b = o.b / 255,
2735 min = Math.min(r, g, b),
2736 max = Math.max(r, g, b),
2737 h = NaN,
2738 s = max - min,
2739 l = (max + min) / 2;
2740 if (s) {
2741 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;
2742 s /= l < 0.5 ? max + min : 2 - max - min;
2743 h *= 60;
2744 } else {
2745 s = l > 0 && l < 1 ? 0 : h;
2746 }
2747 return new Hsl(h, s, l, o.opacity);
2748}
2749
2750function hsl(h, s, l, opacity) {
2751 return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
2752}
2753
2754function Hsl(h, s, l, opacity) {
2755 this.h = +h;
2756 this.s = +s;
2757 this.l = +l;
2758 this.opacity = +opacity;
2759}
2760
2761Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hsl, hsl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
2762 brighter: function brighter(k) {
2763 k = k == null ? _brighter : Math.pow(_brighter, k);
2764 return new Hsl(this.h, this.s, this.l * k, this.opacity);
2765 },
2766 darker: function darker(k) {
2767 k = k == null ? _darker : Math.pow(_darker, k);
2768 return new Hsl(this.h, this.s, this.l * k, this.opacity);
2769 },
2770 rgb: function rgb() {
2771 var h = this.h % 360 + (this.h < 0) * 360,
2772 s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
2773 l = this.l,
2774 m2 = l + (l < 0.5 ? l : 1 - l) * s,
2775 m1 = 2 * l - m2;
2776 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);
2777 },
2778 displayable: function displayable() {
2779 return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
2780 }
2781}));
2782
2783/* From FvD 13.37, CSS Color Module Level 3 */
2784function hsl2rgb(h, m1, m2) {
2785 return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
2786}
2787
2788/***/ }),
2789/* 25 */
2790/***/ (function(module, __webpack_exports__, __webpack_require__) {
2791
2792"use strict";
2793/* harmony export (immutable) */ __webpack_exports__["b"] = extend;
2794/* harmony default export */ __webpack_exports__["a"] = (function (constructor, factory, prototype) {
2795 constructor.prototype = factory.prototype = prototype;
2796 prototype.constructor = constructor;
2797});
2798
2799function extend(parent, definition) {
2800 var prototype = Object.create(parent.prototype);
2801 for (var key in definition) {
2802 prototype[key] = definition[key];
2803 }return prototype;
2804}
2805
2806/***/ }),
2807/* 26 */
2808/***/ (function(module, __webpack_exports__, __webpack_require__) {
2809
2810"use strict";
2811/* harmony export (immutable) */ __webpack_exports__["a"] = basis;
2812function basis(t1, v0, v1, v2, v3) {
2813 var t2 = t1 * t1,
2814 t3 = t2 * t1;
2815 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;
2816}
2817
2818/* harmony default export */ __webpack_exports__["b"] = (function (values) {
2819 var n = values.length - 1;
2820 return function (t) {
2821 var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
2822 v1 = values[i],
2823 v2 = values[i + 1],
2824 v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
2825 v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
2826 return basis((t - i / n) * n, v0, v1, v2, v3);
2827 };
2828});
2829
2830/***/ }),
2831/* 27 */
2832/***/ (function(module, exports, __webpack_require__) {
2833
2834var Util = __webpack_require__(0);
2835
2836var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
2837var regexDot = /[^\s\,]+/ig;
2838var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
2839var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
2840var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
2841var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
2842var numColorCache = {};
2843
2844function addStop(steps, gradient) {
2845 var arr = steps.match(regexColorStop);
2846 Util.each(arr, function (item) {
2847 item = item.split(':');
2848 gradient.addColorStop(item[0], item[1]);
2849 });
2850}
2851
2852function parseLineGradient(color, self) {
2853 var arr = regexLG.exec(color);
2854 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
2855 var steps = arr[2];
2856 var box = self.getBBox();
2857 var start = void 0;
2858 var end = void 0;
2859
2860 if (angle >= 0 && angle < 0.5 * Math.PI) {
2861 start = {
2862 x: box.minX,
2863 y: box.minY
2864 };
2865 end = {
2866 x: box.maxX,
2867 y: box.maxY
2868 };
2869 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
2870 start = {
2871 x: box.maxX,
2872 y: box.minY
2873 };
2874 end = {
2875 x: box.minX,
2876 y: box.maxY
2877 };
2878 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
2879 start = {
2880 x: box.maxX,
2881 y: box.maxY
2882 };
2883 end = {
2884 x: box.minX,
2885 y: box.minY
2886 };
2887 } else {
2888 start = {
2889 x: box.minX,
2890 y: box.maxY
2891 };
2892 end = {
2893 x: box.maxX,
2894 y: box.minY
2895 };
2896 }
2897
2898 var tanTheta = Math.tan(angle);
2899 var tanTheta2 = tanTheta * tanTheta;
2900
2901 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
2902 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
2903 var context = self.get('context');
2904 var gradient = context.createLinearGradient(start.x, start.y, x, y);
2905 addStop(steps, gradient);
2906 return gradient;
2907}
2908
2909function parseRadialGradient(color, self) {
2910 var arr = regexRG.exec(color);
2911 var fx = parseFloat(arr[1]);
2912 var fy = parseFloat(arr[2]);
2913 var fr = parseFloat(arr[3]);
2914 var steps = arr[4];
2915 // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
2916 if (fr === 0) {
2917 var colors = steps.match(regexColorStop);
2918 return colors[colors.length - 1].split(':')[1];
2919 }
2920 var box = self.getBBox();
2921 var context = self.get('context');
2922 var width = box.maxX - box.minX;
2923 var height = box.maxY - box.minY;
2924 var r = Math.sqrt(width * width + height * height) / 2;
2925 var gradient = context.createRadialGradient(box.minX + width * fx, box.minY + height * fy, fr * r, box.minX + width / 2, box.minY + height / 2, r);
2926 addStop(steps, gradient);
2927 return gradient;
2928}
2929
2930function parsePattern(color, self) {
2931 if (self.get('patternSource') && self.get('patternSource') === color) {
2932 return self.get('pattern');
2933 }
2934 var pattern = void 0;
2935 var img = void 0;
2936 var arr = regexPR.exec(color);
2937 var repeat = arr[1];
2938 var source = arr[2];
2939
2940 // Function to be called when pattern loads
2941 function onload() {
2942 // Create pattern
2943 var context = self.get('context');
2944 pattern = context.createPattern(img, repeat);
2945 self.setSilent('pattern', pattern); // be a cache
2946 self.setSilent('patternSource', color);
2947 }
2948
2949 switch (repeat) {
2950 case 'a':
2951 repeat = 'repeat';
2952 break;
2953 case 'x':
2954 repeat = 'repeat-x';
2955 break;
2956 case 'y':
2957 repeat = 'repeat-y';
2958 break;
2959 case 'n':
2960 repeat = 'no-repeat';
2961 break;
2962 default:
2963 repeat = 'no-repeat';
2964 }
2965
2966 img = new Image();
2967 // If source URL is not a data URL
2968 if (!source.match(/^data:/i)) {
2969 // Set crossOrigin for this image
2970 img.crossOrigin = 'Anonymous';
2971 }
2972 img.src = source;
2973
2974 if (img.complete) {
2975 onload();
2976 } else {
2977 img.onload = onload;
2978 // Fix onload() bug in IE9
2979 img.src = img.src;
2980 }
2981
2982 return pattern;
2983}
2984
2985module.exports = {
2986 parsePath: function parsePath(path) {
2987 path = path || [];
2988 if (Util.isArray(path)) {
2989 return path;
2990 }
2991
2992 if (Util.isString(path)) {
2993 path = path.match(regexTags);
2994 Util.each(path, function (item, index) {
2995 item = item.match(regexDot);
2996 if (item[0].length > 1) {
2997 var tag = item[0].charAt(0);
2998 item.splice(1, 0, item[0].substr(1));
2999 item[0] = tag;
3000 }
3001 Util.each(item, function (sub, i) {
3002 if (!isNaN(sub)) {
3003 item[i] = +sub;
3004 }
3005 });
3006 path[index] = item;
3007 });
3008 return path;
3009 }
3010 },
3011 parseStyle: function parseStyle(color, self) {
3012 if (Util.isString(color)) {
3013 if (color[1] === '(' || color[2] === '(') {
3014 if (color[0] === 'l') {
3015 // regexLG.test(color)
3016 return parseLineGradient(color, self);
3017 } else if (color[0] === 'r') {
3018 // regexRG.test(color)
3019 return parseRadialGradient(color, self);
3020 } else if (color[0] === 'p') {
3021 // regexPR.test(color)
3022 return parsePattern(color, self);
3023 }
3024 }
3025 return color;
3026 }
3027 },
3028 numberToColor: function numberToColor(num) {
3029 // 增加缓存
3030 var color = numColorCache[num];
3031 if (!color) {
3032 var str = num.toString(16);
3033 for (var i = str.length; i < 6; i++) {
3034 str = '0' + str;
3035 }
3036 color = '#' + str;
3037 numColorCache[num] = color;
3038 }
3039 return color;
3040 }
3041};
3042
3043/***/ }),
3044/* 28 */
3045/***/ (function(module, exports, __webpack_require__) {
3046
3047var vec2 = __webpack_require__(2).vec2;
3048
3049module.exports = {
3050 at: function at(p1, p2, t) {
3051 return (p2 - p1) * t + p1;
3052 },
3053 pointDistance: function pointDistance(x1, y1, x2, y2, x, y) {
3054 var d = [x2 - x1, y2 - y1];
3055 if (vec2.exactEquals(d, [0, 0])) {
3056 return NaN;
3057 }
3058
3059 var u = [-d[1], d[0]];
3060 vec2.normalize(u, u);
3061 var a = [x - x1, y - y1];
3062 return Math.abs(vec2.dot(a, u));
3063 },
3064 box: function box(x1, y1, x2, y2, lineWidth) {
3065 var halfWidth = lineWidth / 2;
3066 var minX = Math.min(x1, x2);
3067 var maxX = Math.max(x1, x2);
3068 var minY = Math.min(y1, y2);
3069 var maxY = Math.max(y1, y2);
3070
3071 return {
3072 minX: minX - halfWidth,
3073 minY: minY - halfWidth,
3074 maxX: maxX + halfWidth,
3075 maxY: maxY + halfWidth
3076 };
3077 },
3078 len: function len(x1, y1, x2, y2) {
3079 return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
3080 }
3081};
3082
3083/***/ }),
3084/* 29 */
3085/***/ (function(module, exports, __webpack_require__) {
3086
3087var Util = __webpack_require__(0);
3088var vec2 = __webpack_require__(2).vec2;
3089
3090function quadraticAt(p0, p1, p2, t) {
3091 var onet = 1 - t;
3092 return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
3093}
3094
3095function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) {
3096 var t = void 0;
3097 var interval = 0.005;
3098 var d = Infinity;
3099 var d1 = void 0;
3100 var v1 = void 0;
3101 var v2 = void 0;
3102 var _t = void 0;
3103 var d2 = void 0;
3104 var i = void 0;
3105 var EPSILON = 0.0001;
3106 var v0 = [x, y];
3107
3108 for (_t = 0; _t < 1; _t += 0.05) {
3109 v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)];
3110
3111 d1 = vec2.squaredDistance(v0, v1);
3112 if (d1 < d) {
3113 t = _t;
3114 d = d1;
3115 }
3116 }
3117 d = Infinity;
3118
3119 for (i = 0; i < 32; i++) {
3120 if (interval < EPSILON) {
3121 break;
3122 }
3123
3124 var prev = t - interval;
3125 var next = t + interval;
3126
3127 v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)];
3128
3129 d1 = vec2.squaredDistance(v0, v1);
3130
3131 if (prev >= 0 && d1 < d) {
3132 t = prev;
3133 d = d1;
3134 } else {
3135 v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)];
3136
3137 d2 = vec2.squaredDistance(v0, v2);
3138
3139 if (next <= 1 && d2 < d) {
3140 t = next;
3141 d = d2;
3142 } else {
3143 interval *= 0.5;
3144 }
3145 }
3146 }
3147
3148 if (out) {
3149 out.x = quadraticAt(x1, x2, x3, t);
3150 out.y = quadraticAt(y1, y2, y3, t);
3151 }
3152
3153 return Math.sqrt(d);
3154}
3155
3156function quadraticExtrema(p0, p1, p2) {
3157 var a = p0 + p2 - 2 * p1;
3158 if (Util.isNumberEqual(a, 0)) {
3159 return [0.5];
3160 }
3161 var rst = (p0 - p1) / a;
3162 if (rst <= 1 && rst >= 0) {
3163 return [rst];
3164 }
3165 return [];
3166}
3167
3168module.exports = {
3169 at: quadraticAt,
3170 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x, y) {
3171 var rst = {};
3172 quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, rst);
3173 return rst;
3174 },
3175
3176 pointDistance: quadraticProjectPoint,
3177 extrema: quadraticExtrema
3178};
3179
3180/***/ }),
3181/* 30 */
3182/***/ (function(module, exports, __webpack_require__) {
3183
3184var Util = __webpack_require__(0);
3185var vec2 = __webpack_require__(2).vec2;
3186
3187function circlePoint(cx, cy, r, angle) {
3188 return {
3189 x: Math.cos(angle) * r + cx,
3190 y: Math.sin(angle) * r + cy
3191 };
3192}
3193
3194function angleNearTo(angle, min, max, out) {
3195 var v1 = void 0;
3196 var v2 = void 0;
3197 if (out) {
3198 if (angle < min) {
3199 v1 = min - angle;
3200 v2 = Math.PI * 2 - max + angle;
3201 } else if (angle > max) {
3202 v1 = Math.PI * 2 - angle + min;
3203 v2 = angle - max;
3204 }
3205 } else {
3206 v1 = angle - min;
3207 v2 = max - angle;
3208 }
3209
3210 return v1 > v2 ? max : min;
3211}
3212
3213function nearAngle(angle, startAngle, endAngle, clockwise) {
3214 var plus = 0;
3215 if (endAngle - startAngle >= Math.PI * 2) {
3216 plus = Math.PI * 2;
3217 }
3218 startAngle = Util.mod(startAngle, Math.PI * 2);
3219 endAngle = Util.mod(endAngle, Math.PI * 2) + plus;
3220 angle = Util.mod(angle, Math.PI * 2);
3221 if (clockwise) {
3222 if (startAngle >= endAngle) {
3223 if (angle > endAngle && angle < startAngle) {
3224 return angle;
3225 }
3226 return angleNearTo(angle, endAngle, startAngle, true);
3227 }
3228 if (angle < startAngle || angle > endAngle) {
3229 return angle;
3230 }
3231 return angleNearTo(angle, startAngle, endAngle);
3232 }
3233 if (startAngle <= endAngle) {
3234 if (startAngle < angle && angle < endAngle) {
3235 return angle;
3236 }
3237 return angleNearTo(angle, startAngle, endAngle, true);
3238 }
3239 if (angle > startAngle || angle < endAngle) {
3240 return angle;
3241 }
3242 return angleNearTo(angle, endAngle, startAngle);
3243}
3244
3245function arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, out) {
3246 var v = [x, y];
3247 var v0 = [cx, cy];
3248 var v1 = [1, 0];
3249 var subv = vec2.subtract([], v, v0);
3250 var angle = vec2.angleTo(v1, subv);
3251
3252 angle = nearAngle(angle, startAngle, endAngle, clockwise);
3253 var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy];
3254 if (out) {
3255 out.x = vpoint[0];
3256 out.y = vpoint[1];
3257 }
3258 var d = vec2.distance(vpoint, v);
3259 return d;
3260}
3261
3262function arcBox(cx, cy, r, startAngle, endAngle, clockwise) {
3263 var angleRight = 0;
3264 var angleBottom = Math.PI / 2;
3265 var angleLeft = Math.PI;
3266 var angleTop = Math.PI * 3 / 2;
3267 var points = [];
3268 var angle = nearAngle(angleRight, startAngle, endAngle, clockwise);
3269 if (angle === angleRight) {
3270 points.push(circlePoint(cx, cy, r, angleRight));
3271 }
3272
3273 angle = nearAngle(angleBottom, startAngle, endAngle, clockwise);
3274 if (angle === angleBottom) {
3275 points.push(circlePoint(cx, cy, r, angleBottom));
3276 }
3277
3278 angle = nearAngle(angleLeft, startAngle, endAngle, clockwise);
3279 if (angle === angleLeft) {
3280 points.push(circlePoint(cx, cy, r, angleLeft));
3281 }
3282
3283 angle = nearAngle(angleTop, startAngle, endAngle, clockwise);
3284 if (angle === angleTop) {
3285 points.push(circlePoint(cx, cy, r, angleTop));
3286 }
3287
3288 points.push(circlePoint(cx, cy, r, startAngle));
3289 points.push(circlePoint(cx, cy, r, endAngle));
3290 var minX = Infinity;
3291 var maxX = -Infinity;
3292 var minY = Infinity;
3293 var maxY = -Infinity;
3294 Util.each(points, function (point) {
3295 if (minX > point.x) {
3296 minX = point.x;
3297 }
3298 if (maxX < point.x) {
3299 maxX = point.x;
3300 }
3301 if (minY > point.y) {
3302 minY = point.y;
3303 }
3304 if (maxY < point.y) {
3305 maxY = point.y;
3306 }
3307 });
3308
3309 return {
3310 minX: minX,
3311 minY: minY,
3312 maxX: maxX,
3313 maxY: maxY
3314 };
3315}
3316
3317module.exports = {
3318 nearAngle: nearAngle,
3319 projectPoint: function projectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y) {
3320 var rst = {};
3321 arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, rst);
3322 return rst;
3323 },
3324
3325 pointDistance: arcProjectPoint,
3326 box: arcBox
3327};
3328
3329/***/ }),
3330/* 31 */
3331/***/ (function(module, exports, __webpack_require__) {
3332
3333var Util = __webpack_require__(0);
3334var Inside = __webpack_require__(3);
3335var Cubic = __webpack_require__(16);
3336var Quadratic = __webpack_require__(29);
3337var Ellipse = __webpack_require__(154);
3338var vec3 = __webpack_require__(2).vec3;
3339var mat3 = __webpack_require__(2).mat3;
3340
3341var ARR_CMD = ['m', 'l', 'c', 'a', 'q', 'h', 'v', 't', 's', 'z'];
3342
3343function toAbsolute(x, y, curPoint) {
3344 // 获取绝对坐标
3345 return {
3346 x: curPoint.x + x,
3347 y: curPoint.y + y
3348 };
3349}
3350
3351function toSymmetry(point, center) {
3352 // 点对称
3353 return {
3354 x: center.x + (center.x - point.x),
3355 y: center.y + (center.y - point.y)
3356 };
3357}
3358
3359function vMag(v) {
3360 return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
3361}
3362
3363function vRatio(u, v) {
3364 return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
3365}
3366
3367function vAngle(u, v) {
3368 return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
3369}
3370
3371function getArcParams(point1, point2, fa, fs, rx, ry, psiDeg) {
3372 var psi = Util.mod(Util.toRadian(psiDeg), Math.PI * 2);
3373 var x1 = point1.x;
3374 var y1 = point1.y;
3375 var x2 = point2.x;
3376 var y2 = point2.y;
3377 var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
3378 var yp = -1 * Math.sin(psi) * (x1 - x2) / 2.0 + Math.cos(psi) * (y1 - y2) / 2.0;
3379 var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
3380 if (lambda > 1) {
3381 rx *= Math.sqrt(lambda);
3382 ry *= Math.sqrt(lambda);
3383 }
3384 var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);
3385 var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff);
3386
3387 if (fa === fs) {
3388 f *= -1;
3389 }
3390 if (isNaN(f)) {
3391 f = 0;
3392 }
3393
3394 var cxp = f * rx * yp / ry;
3395 var cyp = f * -ry * xp / rx;
3396
3397 var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
3398 var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
3399
3400 var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
3401 var u = [(xp - cxp) / rx, (yp - cyp) / ry];
3402 var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
3403 var dTheta = vAngle(u, v);
3404 if (fs === 0 && dTheta > 0) {
3405 dTheta = dTheta - 2 * Math.PI;
3406 }
3407 if (fs === 1 && dTheta < 0) {
3408 dTheta = dTheta + 2 * Math.PI;
3409 }
3410 return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs];
3411}
3412
3413var PathSegment = function PathSegment(item, preSegment, isLast) {
3414 this.preSegment = preSegment;
3415 this.isLast = isLast;
3416 this.init(item, preSegment);
3417};
3418
3419Util.augment(PathSegment, {
3420 init: function init(item, preSegment) {
3421 var command = item[0];
3422 preSegment = preSegment || {
3423 endPoint: {
3424 x: 0,
3425 y: 0
3426 }
3427 };
3428 var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command);
3429 var cmd = relative ? command.toUpperCase() : command;
3430 var p = item;
3431 var point1 = void 0;
3432 var point2 = void 0;
3433 var point3 = void 0;
3434 var point = void 0;
3435 var preEndPoint = preSegment.endPoint;
3436
3437 var p1 = p[1];
3438 var p2 = p[2];
3439 switch (cmd) {
3440 default:
3441 break;
3442 case 'M':
3443 if (relative) {
3444 point = toAbsolute(p1, p2, preEndPoint);
3445 } else {
3446 point = {
3447 x: p1,
3448 y: p2
3449 };
3450 }
3451 this.command = 'M';
3452 this.params = [preEndPoint, point];
3453 this.subStart = point;
3454 this.endPoint = point;
3455 break;
3456 case 'L':
3457 if (relative) {
3458 point = toAbsolute(p1, p2, preEndPoint);
3459 } else {
3460 point = {
3461 x: p1,
3462 y: p2
3463 };
3464 }
3465 this.command = 'L';
3466 this.params = [preEndPoint, point];
3467 this.subStart = preSegment.subStart;
3468 this.endPoint = point;
3469 this.endTangent = function () {
3470 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
3471 };
3472 this.startTangent = function () {
3473 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
3474 };
3475 break;
3476 case 'H':
3477 if (relative) {
3478 point = toAbsolute(p1, 0, preEndPoint);
3479 } else {
3480 point = {
3481 x: p1,
3482 y: preEndPoint.y
3483 };
3484 }
3485 this.command = 'L';
3486 this.params = [preEndPoint, point];
3487 this.subStart = preSegment.subStart;
3488 this.endPoint = point;
3489 this.endTangent = function () {
3490 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
3491 };
3492 this.startTangent = function () {
3493 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
3494 };
3495 break;
3496 case 'V':
3497 if (relative) {
3498 point = toAbsolute(0, p1, preEndPoint);
3499 } else {
3500 point = {
3501 x: preEndPoint.x,
3502 y: p1
3503 };
3504 }
3505 this.command = 'L';
3506 this.params = [preEndPoint, point];
3507 this.subStart = preSegment.subStart;
3508 this.endPoint = point;
3509 this.endTangent = function () {
3510 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
3511 };
3512 this.startTangent = function () {
3513 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
3514 };
3515 break;
3516 case 'Q':
3517 if (relative) {
3518 point1 = toAbsolute(p1, p2, preEndPoint);
3519 point2 = toAbsolute(p[3], p[4], preEndPoint);
3520 } else {
3521 point1 = {
3522 x: p1,
3523 y: p2
3524 };
3525 point2 = {
3526 x: p[3],
3527 y: p[4]
3528 };
3529 }
3530 this.command = 'Q';
3531 this.params = [preEndPoint, point1, point2];
3532 this.subStart = preSegment.subStart;
3533 this.endPoint = point2;
3534 this.endTangent = function () {
3535 return [point2.x - point1.x, point2.y - point1.y];
3536 };
3537 this.startTangent = function () {
3538 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
3539 };
3540 break;
3541 case 'T':
3542 if (relative) {
3543 point2 = toAbsolute(p1, p2, preEndPoint);
3544 } else {
3545 point2 = {
3546 x: p1,
3547 y: p2
3548 };
3549 }
3550 if (preSegment.command === 'Q') {
3551 point1 = toSymmetry(preSegment.params[1], preEndPoint);
3552 this.command = 'Q';
3553 this.params = [preEndPoint, point1, point2];
3554 this.subStart = preSegment.subStart;
3555 this.endPoint = point2;
3556 this.endTangent = function () {
3557 return [point2.x - point1.x, point2.y - point1.y];
3558 };
3559 this.startTangent = function () {
3560 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
3561 };
3562 } else {
3563 this.command = 'TL';
3564 this.params = [preEndPoint, point2];
3565 this.subStart = preSegment.subStart;
3566 this.endPoint = point2;
3567 this.endTangent = function () {
3568 return [point2.x - preEndPoint.x, point2.y - preEndPoint.y];
3569 };
3570 this.startTangent = function () {
3571 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
3572 };
3573 }
3574
3575 break;
3576 case 'C':
3577 if (relative) {
3578 point1 = toAbsolute(p1, p2, preEndPoint);
3579 point2 = toAbsolute(p[3], p[4], preEndPoint);
3580 point3 = toAbsolute(p[5], p[6], preEndPoint);
3581 } else {
3582 point1 = {
3583 x: p1,
3584 y: p2
3585 };
3586 point2 = {
3587 x: p[3],
3588 y: p[4]
3589 };
3590 point3 = {
3591 x: p[5],
3592 y: p[6]
3593 };
3594 }
3595 this.command = 'C';
3596 this.params = [preEndPoint, point1, point2, point3];
3597 this.subStart = preSegment.subStart;
3598 this.endPoint = point3;
3599 this.endTangent = function () {
3600 return [point3.x - point2.x, point3.y - point2.y];
3601 };
3602 this.startTangent = function () {
3603 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
3604 };
3605 break;
3606 case 'S':
3607 if (relative) {
3608 point2 = toAbsolute(p1, p2, preEndPoint);
3609 point3 = toAbsolute(p[3], p[4], preEndPoint);
3610 } else {
3611 point2 = {
3612 x: p1,
3613 y: p2
3614 };
3615 point3 = {
3616 x: p[3],
3617 y: p[4]
3618 };
3619 }
3620 if (preSegment.command === 'C') {
3621 point1 = toSymmetry(preSegment.params[2], preEndPoint);
3622 this.command = 'C';
3623 this.params = [preEndPoint, point1, point2, point3];
3624 this.subStart = preSegment.subStart;
3625 this.endPoint = point3;
3626 this.endTangent = function () {
3627 return [point3.x - point2.x, point3.y - point2.y];
3628 };
3629 this.startTangent = function () {
3630 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
3631 };
3632 } else {
3633 this.command = 'SQ';
3634 this.params = [preEndPoint, point2, point3];
3635 this.subStart = preSegment.subStart;
3636 this.endPoint = point3;
3637 this.endTangent = function () {
3638 return [point3.x - point2.x, point3.y - point2.y];
3639 };
3640 this.startTangent = function () {
3641 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
3642 };
3643 }
3644 break;
3645 case 'A':
3646 {
3647 var rx = p1;
3648 var ry = p2;
3649 var psi = p[3];
3650 var fa = p[4];
3651 var fs = p[5];
3652 if (relative) {
3653 point = toAbsolute(p[6], p[7], preEndPoint);
3654 } else {
3655 point = {
3656 x: p[6],
3657 y: p[7]
3658 };
3659 }
3660
3661 this.command = 'A';
3662 var params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi);
3663 this.params = params;
3664 var start = preSegment.subStart;
3665 this.subStart = start;
3666 this.endPoint = point;
3667 var startAngle = params[5] % (Math.PI * 2);
3668 if (Util.isNumberEqual(startAngle, Math.PI * 2)) {
3669 startAngle = 0;
3670 }
3671 var endAngle = params[6] % (Math.PI * 2);
3672 if (Util.isNumberEqual(endAngle, Math.PI * 2)) {
3673 endAngle = 0;
3674 }
3675 var d = 0.001;
3676 this.startTangent = function () {
3677 if (fs === 0) {
3678 d *= -1;
3679 }
3680 var dx = params[3] * Math.cos(startAngle - d) + params[1];
3681 var dy = params[4] * Math.sin(startAngle - d) + params[2];
3682 return [dx - start.x, dy - start.y];
3683 };
3684 this.endTangent = function () {
3685 var endAngle = params[6];
3686 if (endAngle - Math.PI * 2 < 0.0001) {
3687 endAngle = 0;
3688 }
3689 var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1];
3690 var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2];
3691 return [preEndPoint.x - dx, preEndPoint.y - dy];
3692 };
3693 break;
3694 }
3695 case 'Z':
3696 {
3697 this.command = 'Z';
3698 this.params = [preEndPoint, preSegment.subStart];
3699 this.subStart = preSegment.subStart;
3700 this.endPoint = preSegment.subStart;
3701 }
3702 }
3703 },
3704 isInside: function isInside(x, y, lineWidth) {
3705 var self = this;
3706 var command = self.command;
3707 var params = self.params;
3708 var box = self.box;
3709 if (box) {
3710 if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
3711 return false;
3712 }
3713 }
3714 switch (command) {
3715 default:
3716 break;
3717 case 'M':
3718 return false;
3719 case 'TL':
3720 case 'L':
3721 case 'Z':
3722 return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y);
3723 case 'SQ':
3724 case 'Q':
3725 return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y);
3726 case 'C':
3727 {
3728 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);
3729 }
3730 case 'A':
3731 {
3732 var p = params;
3733 var cx = p[1];
3734 var cy = p[2];
3735 var rx = p[3];
3736 var ry = p[4];
3737 var theta = p[5];
3738 var dTheta = p[6];
3739 var psi = p[7];
3740 var fs = p[8];
3741
3742 var r = rx > ry ? rx : ry;
3743 var scaleX = rx > ry ? 1 : rx / ry;
3744 var scaleY = rx > ry ? ry / rx : 1;
3745
3746 p = [x, y, 1];
3747 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
3748 mat3.translate(m, m, [-cx, -cy]);
3749 mat3.rotate(m, m, -psi);
3750 mat3.scale(m, m, [1 / scaleX, 1 / scaleY]);
3751 vec3.transformMat3(p, p, m);
3752 return Inside.arcline(0, 0, r, theta, theta + dTheta, 1 - fs, lineWidth, p[0], p[1]);
3753 }
3754 }
3755 return false;
3756 },
3757 draw: function draw(context) {
3758 var command = this.command;
3759 var params = this.params;
3760 var point1 = void 0;
3761 var point2 = void 0;
3762 var point3 = void 0;
3763
3764 switch (command) {
3765 default:
3766 break;
3767 case 'M':
3768 context.moveTo(params[1].x, params[1].y);
3769 break;
3770 case 'TL':
3771 case 'L':
3772 context.lineTo(params[1].x, params[1].y);
3773 break;
3774 case 'SQ':
3775 case 'Q':
3776 point1 = params[1];
3777 point2 = params[2];
3778 context.quadraticCurveTo(point1.x, point1.y, point2.x, point2.y);
3779 break;
3780 case 'C':
3781 point1 = params[1];
3782 point2 = params[2];
3783 point3 = params[3];
3784 context.bezierCurveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
3785 break;
3786 case 'A':
3787 {
3788 var p = params;
3789 var p1 = p[1];
3790 var p2 = p[2];
3791 var cx = p1;
3792 var cy = p2;
3793 var rx = p[3];
3794 var ry = p[4];
3795 var theta = p[5];
3796 var dTheta = p[6];
3797 var psi = p[7];
3798 var fs = p[8];
3799
3800 var r = rx > ry ? rx : ry;
3801 var scaleX = rx > ry ? 1 : rx / ry;
3802 var scaleY = rx > ry ? ry / rx : 1;
3803
3804 context.translate(cx, cy);
3805 context.rotate(psi);
3806 context.scale(scaleX, scaleY);
3807 context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);
3808 context.scale(1 / scaleX, 1 / scaleY);
3809 context.rotate(-psi);
3810 context.translate(-cx, -cy);
3811 break;
3812 }
3813 case 'Z':
3814 context.closePath();
3815 break;
3816 }
3817 },
3818 getBBox: function getBBox(lineWidth) {
3819 var halfWidth = lineWidth / 2;
3820 var params = this.params;
3821 var yDims = void 0;
3822 var xDims = void 0;
3823 var i = void 0;
3824 var l = void 0;
3825
3826 switch (this.command) {
3827 default:
3828 case 'M':
3829 case 'Z':
3830 break;
3831 case 'TL':
3832 case 'L':
3833 this.box = {
3834 minX: Math.min(params[0].x, params[1].x) - halfWidth,
3835 maxX: Math.max(params[0].x, params[1].x) + halfWidth,
3836 minY: Math.min(params[0].y, params[1].y) - halfWidth,
3837 maxY: Math.max(params[0].y, params[1].y) + halfWidth
3838 };
3839 break;
3840 case 'SQ':
3841 case 'Q':
3842 xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x);
3843 for (i = 0, l = xDims.length; i < l; i++) {
3844 xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]);
3845 }
3846 xDims.push(params[0].x, params[2].x);
3847 yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y);
3848 for (i = 0, l = yDims.length; i < l; i++) {
3849 yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims);
3850 }
3851 yDims.push(params[0].y, params[2].y);
3852 this.box = {
3853 minX: Math.min.apply(Math, xDims) - halfWidth,
3854 maxX: Math.max.apply(Math, xDims) + halfWidth,
3855 minY: Math.min.apply(Math, yDims) - halfWidth,
3856 maxY: Math.max.apply(Math, yDims) + halfWidth
3857 };
3858 break;
3859 case 'C':
3860 xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x);
3861 for (i = 0, l = xDims.length; i < l; i++) {
3862 xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]);
3863 }
3864 yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y);
3865 for (i = 0, l = yDims.length; i < l; i++) {
3866 yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]);
3867 }
3868 xDims.push(params[0].x, params[3].x);
3869 yDims.push(params[0].y, params[3].y);
3870 this.box = {
3871 minX: Math.min.apply(Math, xDims) - halfWidth,
3872 maxX: Math.max.apply(Math, xDims) + halfWidth,
3873 minY: Math.min.apply(Math, yDims) - halfWidth,
3874 maxY: Math.max.apply(Math, yDims) + halfWidth
3875 };
3876 break;
3877 case 'A':
3878 {
3879 // todo 待优化
3880 var p = params;
3881 var cx = p[1];
3882 var cy = p[2];
3883 var rx = p[3];
3884 var ry = p[4];
3885 var theta = p[5];
3886 var dTheta = p[6];
3887 var psi = p[7];
3888 var fs = p[8];
3889 var start = theta;
3890 var end = theta + dTheta;
3891
3892 var xDim = Ellipse.xExtrema(psi, rx, ry);
3893 var minX = Infinity;
3894 var maxX = -Infinity;
3895 var xs = [start, end];
3896 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
3897 var xAngle = xDim + i;
3898 if (fs === 1) {
3899 if (start < xAngle && xAngle < end) {
3900 xs.push(xAngle);
3901 }
3902 } else {
3903 if (end < xAngle && xAngle < start) {
3904 xs.push(xAngle);
3905 }
3906 }
3907 }
3908
3909 for (i = 0, l = xs.length; i < l; i++) {
3910 var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]);
3911 if (x < minX) {
3912 minX = x;
3913 }
3914 if (x > maxX) {
3915 maxX = x;
3916 }
3917 }
3918
3919 var yDim = Ellipse.yExtrema(psi, rx, ry);
3920 var minY = Infinity;
3921 var maxY = -Infinity;
3922 var ys = [start, end];
3923 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
3924 var yAngle = yDim + i;
3925 if (fs === 1) {
3926 if (start < yAngle && yAngle < end) {
3927 ys.push(yAngle);
3928 }
3929 } else {
3930 if (end < yAngle && yAngle < start) {
3931 ys.push(yAngle);
3932 }
3933 }
3934 }
3935
3936 for (i = 0, l = ys.length; i < l; i++) {
3937 var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]);
3938 if (y < minY) {
3939 minY = y;
3940 }
3941 if (y > maxY) {
3942 maxY = y;
3943 }
3944 }
3945 this.box = {
3946 minX: minX - halfWidth,
3947 maxX: maxX + halfWidth,
3948 minY: minY - halfWidth,
3949 maxY: maxY + halfWidth
3950 };
3951 break;
3952 }
3953 }
3954 }
3955});
3956
3957module.exports = PathSegment;
3958
3959/***/ }),
3960/* 32 */
3961/***/ (function(module, exports, __webpack_require__) {
3962
3963module.exports = {
3964 // renderers
3965 svg: __webpack_require__(84),
3966 canvas: __webpack_require__(149),
3967 // utils
3968 CommonUtil: __webpack_require__(9),
3969 DomUtil: __webpack_require__(41),
3970 MatrixUtil: __webpack_require__(2),
3971 PathUtil: __webpack_require__(21),
3972 // version, etc.
3973 version: '3.0.0-beta.9'
3974};
3975
3976/***/ }),
3977/* 33 */
3978/***/ (function(module, exports, __webpack_require__) {
3979
3980
3981var arrayUtil = __webpack_require__(86);
3982var eventUtil = __webpack_require__(34);
3983var mathUtil = __webpack_require__(89);
3984var stringUtil = __webpack_require__(91);
3985var typeUtil = __webpack_require__(92);
3986var each = __webpack_require__(11);
3987var mix = __webpack_require__(18);
3988
3989var util = {
3990 // collections
3991 arrayUtil: arrayUtil,
3992 eventUtil: eventUtil,
3993 mathUtil: mathUtil,
3994 stringUtil: stringUtil,
3995 typeUtil: typeUtil,
3996 // others
3997 augment: __webpack_require__(94),
3998 clone: __webpack_require__(95),
3999 deepMix: __webpack_require__(96),
4000 each: each,
4001 extend: __webpack_require__(97),
4002 filter: __webpack_require__(98),
4003 group: __webpack_require__(99),
4004 groupBy: __webpack_require__(39),
4005 groupToMap: __webpack_require__(38),
4006 indexOf: __webpack_require__(100),
4007 isEmpty: __webpack_require__(101),
4008 isEqual: __webpack_require__(40),
4009 isEqualWith: __webpack_require__(106),
4010 map: __webpack_require__(107),
4011 mix: mix,
4012 pick: __webpack_require__(108),
4013 toArray: __webpack_require__(35),
4014 toString: __webpack_require__(109),
4015 uniqueId: __webpack_require__(110)
4016};
4017
4018each([arrayUtil, eventUtil, mathUtil, stringUtil, typeUtil], function (collection) {
4019 mix(util, collection);
4020});
4021
4022module.exports = util;
4023
4024/***/ }),
4025/* 34 */
4026/***/ (function(module, exports, __webpack_require__) {
4027
4028
4029module.exports = {
4030 getWrapBehavior: __webpack_require__(87),
4031 wrapBehavior: __webpack_require__(88)
4032};
4033
4034/***/ }),
4035/* 35 */
4036/***/ (function(module, exports, __webpack_require__) {
4037
4038var isArrayLike = __webpack_require__(5);
4039
4040function toArray(value) {
4041 return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
4042}
4043
4044module.exports = toArray;
4045
4046/***/ }),
4047/* 36 */
4048/***/ (function(module, exports, __webpack_require__) {
4049
4050var isObjectLike = __webpack_require__(37);
4051var isType = __webpack_require__(10);
4052
4053var isPlainObject = function isPlainObject(value) {
4054 /**
4055 * isObjectLike(new Foo) => false
4056 * isObjectLike([1, 2, 3]) => false
4057 * isObjectLike({ x: 0, y: 0 }) => true
4058 * isObjectLike(Object.create(null)) => true
4059 */
4060 if (!isObjectLike(value) || !isType(value, 'Object')) {
4061 return false;
4062 }
4063 if (Object.getPrototypeOf(value) === null) {
4064 return true;
4065 }
4066 var proto = value;
4067 while (Object.getPrototypeOf(proto) !== null) {
4068 proto = Object.getPrototypeOf(proto);
4069 }
4070 return Object.getPrototypeOf(value) === proto;
4071};
4072
4073module.exports = isPlainObject;
4074
4075/***/ }),
4076/* 37 */
4077/***/ (function(module, exports) {
4078
4079var _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; };
4080
4081var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
4082 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
4083} : function (obj) {
4084 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
4085};
4086
4087var isObjectLike = function isObjectLike(value) {
4088 /**
4089 * isObjectLike({}) => true
4090 * isObjectLike([1, 2, 3]) => true
4091 * isObjectLike(Function) => false
4092 * isObjectLike(null) => false
4093 */
4094 return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
4095};
4096
4097module.exports = isObjectLike;
4098
4099/***/ }),
4100/* 38 */
4101/***/ (function(module, exports, __webpack_require__) {
4102
4103var isFunction = __webpack_require__(14);
4104var isArray = __webpack_require__(12);
4105var groupBy = __webpack_require__(39);
4106
4107var groupToMap = function groupToMap(data, condition) {
4108 if (!condition) {
4109 return {
4110 0: data
4111 };
4112 }
4113 if (!isFunction(condition)) {
4114 var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
4115 condition = function condition(row) {
4116 var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
4117 for (var i = 0, l = paramsCondition.length; i < l; i++) {
4118 unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();
4119 }
4120 return unique;
4121 };
4122 }
4123 var groups = groupBy(data, condition);
4124 return groups;
4125};
4126
4127module.exports = groupToMap;
4128
4129/***/ }),
4130/* 39 */
4131/***/ (function(module, exports, __webpack_require__) {
4132
4133var each = __webpack_require__(11);
4134var isArray = __webpack_require__(12);
4135var hasOwnProperty = Object.prototype.hasOwnProperty;
4136var groupBy = function groupBy(data, condition) {
4137 if (!condition || !isArray(data)) {
4138 return data;
4139 }
4140 var result = {};
4141 var key = null;
4142 each(data, function (item) {
4143 key = condition(item);
4144 if (hasOwnProperty.call(result, key)) {
4145 result[key].push(item);
4146 } else {
4147 result[key] = [item];
4148 }
4149 });
4150 return result;
4151};
4152
4153module.exports = groupBy;
4154
4155/***/ }),
4156/* 40 */
4157/***/ (function(module, exports, __webpack_require__) {
4158
4159var isObjectLike = __webpack_require__(37);
4160var isArrayLike = __webpack_require__(5);
4161var isString = __webpack_require__(105);
4162
4163var isEqual = function isEqual(value, other) {
4164 if (value === other) {
4165 return true;
4166 }
4167 if (!value || !other) {
4168 return false;
4169 }
4170 if (isString(value) || isString(other)) {
4171 return false;
4172 }
4173 if (isArrayLike(value) || isArrayLike(other)) {
4174 if (value.length !== other.length) {
4175 return false;
4176 }
4177 var rst = true;
4178 for (var i = 0; i < value.length; i++) {
4179 rst = isEqual(value[i], other[i]);
4180 if (!rst) {
4181 break;
4182 }
4183 }
4184 return rst;
4185 }
4186 if (isObjectLike(value) || isObjectLike(other)) {
4187 var valueKeys = Object.keys(value);
4188 var otherKeys = Object.keys(other);
4189 if (valueKeys.length !== otherKeys.length) {
4190 return false;
4191 }
4192 var _rst = true;
4193 for (var _i = 0; _i < valueKeys.length; _i++) {
4194 _rst = isEqual(value[valueKeys[_i]], other[valueKeys[_i]]);
4195 if (!_rst) {
4196 break;
4197 }
4198 }
4199 return _rst;
4200 }
4201 return false;
4202};
4203
4204module.exports = isEqual;
4205
4206/***/ }),
4207/* 41 */
4208/***/ (function(module, exports, __webpack_require__) {
4209
4210var Util = __webpack_require__(9);
4211
4212var TABLE = document.createElement('table');
4213var TABLE_TR = document.createElement('tr');
4214var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
4215var CONTAINERS = {
4216 tr: document.createElement('tbody'),
4217 tbody: TABLE,
4218 thead: TABLE,
4219 tfoot: TABLE,
4220 td: TABLE_TR,
4221 th: TABLE_TR,
4222 '*': document.createElement('div')
4223};
4224
4225module.exports = {
4226 getBoundingClientRect: function getBoundingClientRect(node, defaultValue) {
4227 if (node && node.getBoundingClientRect) {
4228 var rect = node.getBoundingClientRect();
4229 var top = document.documentElement.clientTop;
4230 var left = document.documentElement.clientLeft;
4231 return {
4232 top: rect.top - top,
4233 bottom: rect.bottom - top,
4234 left: rect.left - left,
4235 right: rect.right - left
4236 };
4237 }
4238 return defaultValue || null;
4239 },
4240
4241 /**
4242 * 获取样式
4243 * @param {Object} dom DOM节点
4244 * @param {String} name 样式名
4245 * @param {Any} defaultValue 默认值
4246 * @return {String} 属性值
4247 */
4248 getStyle: function getStyle(dom, name, defaultValue) {
4249 try {
4250 if (window.getComputedStyle) {
4251 return window.getComputedStyle(dom, null)[name];
4252 }
4253 return dom.currentStyle[name];
4254 } catch (e) {
4255 if (!Util.isNil(defaultValue)) {
4256 return defaultValue;
4257 }
4258 return null;
4259 }
4260 },
4261 modifyCSS: function modifyCSS(dom, css) {
4262 if (dom) {
4263 for (var key in css) {
4264 if (css.hasOwnProperty(key)) {
4265 dom.style[key] = css[key];
4266 }
4267 }
4268 }
4269 return dom;
4270 },
4271
4272 /**
4273 * 创建DOM 节点
4274 * @param {String} str Dom 字符串
4275 * @return {HTMLElement} DOM 节点
4276 */
4277 createDom: function createDom(str) {
4278 var name = FRAGMENT_REG.test(str) && RegExp.$1;
4279 if (!(name in CONTAINERS)) {
4280 name = '*';
4281 }
4282 var container = CONTAINERS[name];
4283 str = str.replace(/(^\s*)|(\s*$)/g, '');
4284 container.innerHTML = '' + str;
4285 var dom = container.childNodes[0];
4286 container.removeChild(dom);
4287 return dom;
4288 },
4289 getRatio: function getRatio() {
4290 return window.devicePixelRatio ? window.devicePixelRatio : 2;
4291 },
4292
4293 /**
4294 * 获取宽度
4295 * @param {HTMLElement} el dom节点
4296 * @param {Number} defaultValue 默认值
4297 * @return {Number} 宽度
4298 */
4299 getWidth: function getWidth(el, defaultValue) {
4300 var width = this.getStyle(el, 'width', defaultValue);
4301 if (width === 'auto') {
4302 width = el.offsetWidth;
4303 }
4304 return parseFloat(width);
4305 },
4306
4307 /**
4308 * 获取高度
4309 * @param {HTMLElement} el dom节点
4310 * @param {Number} defaultValue 默认值
4311 * @return {Number} 高度
4312 */
4313 getHeight: function getHeight(el, defaultValue) {
4314 var height = this.getStyle(el, 'height', defaultValue);
4315 if (height === 'auto') {
4316 height = el.offsetHeight;
4317 }
4318 return parseFloat(height);
4319 },
4320
4321 /**
4322 * 获取外层高度
4323 * @param {HTMLElement} el dom节点
4324 * @param {Number} defaultValue 默认值
4325 * @return {Number} 高度
4326 */
4327 getOuterHeight: function getOuterHeight(el, defaultValue) {
4328 var height = this.getHeight(el, defaultValue);
4329 var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
4330 var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
4331 var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
4332 var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
4333 return height + bTop + bBottom + pTop + pBottom;
4334 },
4335
4336 /**
4337 * 获取外层宽度
4338 * @param {HTMLElement} el dom节点
4339 * @param {Number} defaultValue 默认值
4340 * @return {Number} 宽度
4341 */
4342 getOuterWidth: function getOuterWidth(el, defaultValue) {
4343 var width = this.getWidth(el, defaultValue);
4344 var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
4345 var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
4346 var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
4347 var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
4348 return width + bLeft + bRight + pLeft + pRight;
4349 },
4350
4351 /**
4352 * 添加事件监听器
4353 * @param {Object} target DOM对象
4354 * @param {String} eventType 事件名
4355 * @param {Funtion} callback 回调函数
4356 * @return {Object} 返回对象
4357 */
4358 addEventListener: function addEventListener(target, eventType, callback) {
4359 if (target) {
4360 if (target.addEventListener) {
4361 target.addEventListener(eventType, callback, false);
4362 return {
4363 remove: function remove() {
4364 target.removeEventListener(eventType, callback, false);
4365 }
4366 };
4367 } else if (target.attachEvent) {
4368 target.attachEvent('on' + eventType, callback);
4369 return {
4370 remove: function remove() {
4371 target.detachEvent('on' + eventType, callback);
4372 }
4373 };
4374 }
4375 }
4376 },
4377 requestAnimationFrame: function requestAnimationFrame(fn) {
4378 var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
4379 return setTimeout(fn, 16);
4380 };
4381
4382 return method(fn);
4383 }
4384};
4385
4386/***/ }),
4387/* 42 */
4388/***/ (function(module, exports, __webpack_require__) {
4389
4390var Util = __webpack_require__(0);
4391
4392var Event = function Event(type, event, bubbles, cancelable) {
4393 this.type = type; // 事件类型
4394 this.target = null; // 目标
4395 this.currentTarget = null; // 当前目标
4396 this.bubbles = bubbles; // 冒泡
4397 this.cancelable = cancelable; // 是否能够阻止
4398 this.timeStamp = new Date().getTime(); // 时间戳
4399 this.defaultPrevented = false; // 阻止默认
4400 this.propagationStopped = false; // 阻止冒泡
4401 this.removed = false; // 是否被移除
4402 this.event = event; // 触发的原生事件
4403};
4404
4405Util.augment(Event, {
4406 preventDefault: function preventDefault() {
4407 this.defaultPrevented = this.cancelable && true;
4408 },
4409 stopPropagation: function stopPropagation() {
4410 this.propagationStopped = true;
4411 },
4412 remove: function remove() {
4413 this.remove = true;
4414 },
4415 clone: function clone() {
4416 return Util.clone(this);
4417 },
4418 toString: function toString() {
4419 return '[Event (type=' + this.type + ')]';
4420 }
4421});
4422
4423module.exports = Event;
4424
4425/***/ }),
4426/* 43 */
4427/***/ (function(module, exports, __webpack_require__) {
4428
4429var Util = __webpack_require__(0);
4430var Element = __webpack_require__(19);
4431var Shape = __webpack_require__(116);
4432
4433var SHAPE_MAP = {}; // 缓存图形类型
4434var INDEX = '_INDEX';
4435
4436function getComparer(compare) {
4437 return function (left, right) {
4438 var result = compare(left, right);
4439 return result === 0 ? left[INDEX] - right[INDEX] : result;
4440 };
4441}
4442
4443var Group = function Group(cfg) {
4444 Group.superclass.constructor.call(this, cfg);
4445 this.set('children', []);
4446
4447 this._beforeRenderUI();
4448 this._renderUI();
4449 this._bindUI();
4450};
4451
4452function initClassCfgs(c) {
4453 if (c.__cfg || c === Group) {
4454 return;
4455 }
4456 var superCon = c.superclass.constructor;
4457 if (superCon && !superCon.__cfg) {
4458 initClassCfgs(superCon);
4459 }
4460 c.__cfg = {};
4461
4462 Util.merge(c.__cfg, superCon.__cfg);
4463 Util.merge(c.__cfg, c.CFG);
4464}
4465
4466Util.extend(Group, Element);
4467
4468Util.augment(Group, {
4469 isGroup: true,
4470 canFill: true,
4471 canStroke: true,
4472 init: function init(id) {
4473 Group.superclass.init.call(this);
4474 var shape = document.createElementNS('http://www.w3.org/2000/svg', 'g');
4475 id = id || Util.uniqueId('g_');
4476 shape.setAttribute('id', id);
4477 this.setSilent('el', shape);
4478 this.setSilent('id', id);
4479 },
4480 getDefaultCfg: function getDefaultCfg() {
4481 initClassCfgs(this.constructor);
4482 return Util.merge({}, this.constructor.__cfg);
4483 },
4484 _beforeRenderUI: function _beforeRenderUI() {},
4485 _renderUI: function _renderUI() {},
4486 _bindUI: function _bindUI() {},
4487 addShape: function addShape(type, cfg) {
4488 var canvas = this.get('canvas');
4489 cfg = cfg || {};
4490 var shapeType = SHAPE_MAP[type];
4491 if (!shapeType) {
4492 shapeType = Util.upperFirst(type);
4493 SHAPE_MAP[type] = shapeType;
4494 }
4495 if (cfg.attrs) {
4496 var attrs = cfg.attrs;
4497 if (type === 'text') {
4498 // 临时解决
4499 var topFontFamily = canvas.get('fontFamily');
4500 if (topFontFamily) {
4501 attrs.fontFamily = attrs.fontFamily || topFontFamily;
4502 }
4503 }
4504 }
4505 cfg.canvas = canvas;
4506 cfg.defs = this.get('defs');
4507 cfg.type = type;
4508 var shape = Shape[shapeType];
4509 if (!shape) {
4510 throw new TypeError('the shape ' + shapeType + ' is not supported by svg version, use canvas instead');
4511 }
4512 var rst = new shape(cfg);
4513 this.add(rst);
4514 return rst;
4515 },
4516
4517 /** 添加图组
4518 * @param {Function|Object|undefined} param 图组类
4519 * @param {Object} cfg 配置项
4520 * @return {Object} rst 图组
4521 */
4522 addGroup: function addGroup(param, cfg) {
4523 var canvas = this.get('canvas');
4524 var rst = void 0;
4525 cfg = Util.merge({}, cfg);
4526 if (Util.isFunction(param)) {
4527 if (cfg) {
4528 cfg.canvas = canvas;
4529 cfg.parent = this;
4530 rst = new param(cfg);
4531 } else {
4532 rst = new param({
4533 canvas: canvas,
4534 parent: this
4535 });
4536 }
4537 this.add(rst);
4538 } else if (Util.isObject(param)) {
4539 param.canvas = canvas;
4540 rst = new Group(param);
4541 this.add(rst);
4542 } else if (param === undefined) {
4543 rst = new Group();
4544 this.add(rst);
4545 } else {
4546 return false;
4547 }
4548 return rst;
4549 },
4550
4551 /** 绘制背景
4552 * @param {Array} padding 内边距
4553 * @param {Attrs} attrs 图形属性
4554 * @param {Shape} backShape 背景图形
4555 * @return {Object} 背景层对象
4556 */
4557 renderBack: function renderBack(padding, attrs) {
4558 var backShape = this.get('backShape');
4559 var innerBox = this.getBBox();
4560 // const parent = this.get('parent'); // getParent
4561 Util.merge(attrs, {
4562 x: innerBox.minX - padding[3],
4563 y: innerBox.minY - padding[0],
4564 width: innerBox.width + padding[1] + padding[3],
4565 height: innerBox.height + padding[0] + padding[2]
4566 });
4567 if (backShape) {
4568 backShape.attr(attrs);
4569 } else {
4570 backShape = this.addShape('rect', {
4571 zIndex: -1,
4572 attrs: attrs
4573 });
4574 }
4575 this.set('backShape', backShape);
4576 this.sort();
4577 return backShape;
4578 },
4579 removeChild: function removeChild(item, destroy) {
4580 if (arguments.length >= 2) {
4581 if (this.contain(item)) {
4582 item.remove(destroy);
4583 }
4584 } else {
4585 if (arguments.length === 1) {
4586 if (Util.isBoolean(item)) {
4587 destroy = item;
4588 } else {
4589 if (this.contain(item)) {
4590 item.remove(true);
4591 }
4592 return this;
4593 }
4594 }
4595 if (arguments.length === 0) {
4596 destroy = true;
4597 }
4598
4599 Group.superclass.remove.call(this, destroy);
4600 }
4601 return this;
4602 },
4603
4604 /**
4605 * 向组中添加shape或者group
4606 * @param {Object} items 图形或者分组
4607 * @return {Object} group 本尊
4608 */
4609 add: function add(items) {
4610 var self = this;
4611 var children = self.get('children');
4612 var el = self.get('el');
4613 if (Util.isArray(items)) {
4614 Util.each(items, function (item) {
4615 var parent = item.get('parent');
4616 if (parent) {
4617 parent.removeChild(item, false);
4618 }
4619 if (item.get('dependencies')) {
4620 self._addDependency(item);
4621 }
4622 self._setEvn(item);
4623 el.appendChild(item.get('el'));
4624 });
4625 children.push.apply(children, items);
4626 } else {
4627 var item = items;
4628 var parent = item.get('parent');
4629 if (parent) {
4630 parent.removeChild(item, false);
4631 }
4632 self._setEvn(item);
4633 if (item.get('dependencies')) {
4634 self._addDependency(item);
4635 }
4636 el.appendChild(item.get('el'));
4637 children.push(item);
4638 }
4639 return self;
4640 },
4641 contain: function contain(item) {
4642 var children = this.get('children');
4643 return children.indexOf(item) > -1;
4644 },
4645 getChildByIndex: function getChildByIndex(index) {
4646 var children = this.get('children');
4647 return children[index];
4648 },
4649 getFirst: function getFirst() {
4650 return this.getChildByIndex(0);
4651 },
4652 getLast: function getLast() {
4653 var lastIndex = this.get('children').length - 1;
4654 return this.getChildByIndex(lastIndex);
4655 },
4656 _addDependency: function _addDependency(item) {
4657 var dependencies = item.get('dependencies');
4658 item.attr(dependencies);
4659 item.__cfg.dependencies = {};
4660 },
4661 _setEvn: function _setEvn(item) {
4662 var self = this;
4663 var cfg = self.__cfg;
4664 item.__cfg.parent = self;
4665 item.__cfg.timeline = cfg.timeline;
4666 item.__cfg.canvas = cfg.canvas;
4667 item.__cfg.defs = cfg.defs;
4668 var clip = item.__attrs.clip;
4669 if (clip) {
4670 clip.setSilent('parent', self);
4671 clip.setSilent('timeline', cfg.timeline);
4672 clip.setSilent('canvas', cfg.canvas);
4673 }
4674 var children = item.__cfg.children;
4675 if (children) {
4676 Util.each(children, function (child) {
4677 item._setEvn(child);
4678 });
4679 }
4680 },
4681 getCount: function getCount() {
4682 return this.get('children').length;
4683 },
4684 sort: function sort() {
4685 var children = this.get('children');
4686 // 稳定排序
4687 Util.each(children, function (child, index) {
4688 child[INDEX] = index;
4689 return child;
4690 });
4691
4692 children.sort(getComparer(function (obj1, obj2) {
4693 return obj1.get('zIndex') - obj2.get('zIndex');
4694 }));
4695
4696 return this;
4697 },
4698 findById: function findById(id) {
4699 return this.find(function (item) {
4700 return item.get('id') === id;
4701 });
4702 },
4703
4704 /**
4705 * 根据查找函数查找分组或者图形
4706 * @param {Function} fn 匹配函数
4707 * @return {Canvas.Base} 分组或者图形
4708 */
4709 find: function find(fn) {
4710 if (Util.isString(fn)) {
4711 return this.findById(fn);
4712 }
4713 var children = this.get('children');
4714 var rst = null;
4715
4716 Util.each(children, function (item) {
4717 if (fn(item)) {
4718 rst = item;
4719 } else if (item.find) {
4720 rst = item.find(fn);
4721 }
4722 if (rst) {
4723 return false;
4724 }
4725 });
4726 return rst;
4727 },
4728
4729 /**
4730 * @param {Function} fn filter mathod
4731 * @return {Array} all the matching shapes and groups
4732 */
4733 findAll: function findAll(fn) {
4734 var children = this.get('children');
4735 var rst = [];
4736 var childRst = [];
4737 Util.each(children, function (item) {
4738 if (fn(item)) {
4739 rst.push(item);
4740 }
4741 if (item.findAllBy) {
4742 childRst = item.findAllBy(fn);
4743 rst = rst.concat(childRst);
4744 }
4745 });
4746 return rst;
4747 },
4748
4749 /**
4750 * @Deprecated
4751 * @param {Function} fn filter method
4752 * @return {Object} found shape or group
4753 */
4754 findBy: function findBy(fn) {
4755 var children = this.get('children');
4756 var rst = null;
4757
4758 Util.each(children, function (item) {
4759 if (fn(item)) {
4760 rst = item;
4761 } else if (item.findBy) {
4762 rst = item.findBy(fn);
4763 }
4764 if (rst) {
4765 return false;
4766 }
4767 });
4768 return rst;
4769 },
4770
4771 /**
4772 * @Deprecated
4773 * @param {Function} fn filter mathod
4774 * @return {Array} all the matching shapes and groups
4775 */
4776 findAllBy: function findAllBy(fn) {
4777 var children = this.get('children');
4778 var rst = [];
4779 var childRst = [];
4780 Util.each(children, function (item) {
4781 if (fn(item)) {
4782 rst.push(item);
4783 }
4784 if (item.findAllBy) {
4785 childRst = item.findAllBy(fn);
4786 rst = rst.concat(childRst);
4787 }
4788 });
4789 return rst;
4790 },
4791
4792 // svg不进行拾取,仅保留接口
4793 getShape: function getShape() {
4794 return null;
4795 },
4796
4797 /**
4798 * 根据点击事件的element获取对应的图形对象
4799 * @param {Object} el 点击的dom元素
4800 * @return {Object} 对应图形对象
4801 */
4802 findShape: function findShape(el) {
4803 if (this.__cfg.visible && this.__cfg.capture && this.get('el') === el) {
4804 return this;
4805 }
4806 var children = this.__cfg.children;
4807 var shape = null;
4808 for (var i = children.length - 1; i >= 0; i--) {
4809 var child = children[i];
4810 if (child.isGroup) {
4811 shape = child.findShape(el);
4812 shape = child.findShape(el);
4813 } else if (child.get('visible') && child.get('el') === el) {
4814 shape = child;
4815 }
4816 if (shape) {
4817 break;
4818 }
4819 }
4820 return shape;
4821 },
4822 clearTotalMatrix: function clearTotalMatrix() {
4823 var m = this.get('totalMatrix');
4824 if (m) {
4825 this.setSilent('totalMatrix', null);
4826 var children = this.__cfg.children;
4827 for (var i = 0; i < children.length; i++) {
4828 var child = children[i];
4829 child.clearTotalMatrix();
4830 }
4831 }
4832 },
4833 clear: function clear() {
4834 var children = this.get('children');
4835
4836 while (children.length !== 0) {
4837 children[children.length - 1].remove();
4838 }
4839 return this;
4840 },
4841 destroy: function destroy() {
4842 if (this.get('destroyed')) {
4843 return;
4844 }
4845 this.clear();
4846 Group.superclass.destroy.call(this);
4847 }
4848});
4849
4850module.exports = Group;
4851
4852/***/ }),
4853/* 44 */
4854/***/ (function(module, exports, __webpack_require__) {
4855
4856var Util = __webpack_require__(0);
4857var MatrixUtil = __webpack_require__(2);
4858
4859var ReservedProps = { delay: 'delay' };
4860
4861function getFromAttrs(toAttrs, shape) {
4862 var rst = {};
4863 for (var k in toAttrs) {
4864 rst[k] = shape.attr(k);
4865 }
4866 return rst;
4867}
4868
4869function getFormatProps(props, shape) {
4870 var rst = {
4871 matrix: null,
4872 attrs: {}
4873 };
4874 for (var k in props) {
4875 if (k === 'transform') {
4876 rst.matrix = MatrixUtil.transform(shape.getMatrix(), props[k]);
4877 } else if (k === 'matrix') {
4878 rst.matrix = props[k];
4879 } else if (!ReservedProps[k]) {
4880 rst.attrs[k] = props[k];
4881 }
4882 }
4883 return rst;
4884}
4885
4886function checkExistedAttrs(animators, animator) {
4887 var hasOwnProperty = Object.prototype.hasOwnProperty;
4888 Util.each(animator.toAttrs, function (v, k) {
4889 Util.each(animators, function (animator) {
4890 if (hasOwnProperty.call(animator.toAttrs, k)) {
4891 delete animator.toAttrs[k];
4892 delete animator.fromAttrs[k];
4893 }
4894 });
4895 });
4896 return animators;
4897}
4898
4899module.exports = {
4900 /**
4901 * 执行动画
4902 * @param {Object} toProps 动画最终状态
4903 * @param {Number} duration 动画执行时间
4904 * @param {String} easing 动画缓动效果
4905 * @param {Function} callback 动画执行后的回调
4906 * @param {Number} delay 动画延迟时间
4907 */
4908 animate: function animate(toProps, duration, easing, callback) {
4909 var delay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
4910
4911 var self = this;
4912 self.set('animating', true);
4913 var timeline = self.get('timeline');
4914 if (!timeline) {
4915 timeline = self.get('canvas').get('timeline');
4916 self.setSilent('timeline', timeline);
4917 }
4918 var animators = self.get('animators') || [];
4919 // 初始化tick
4920 if (!timeline._timer) {
4921 timeline.initTimer();
4922 }
4923 if (Util.isNumber(callback)) {
4924 delay = callback;
4925 callback = null;
4926 }
4927 if (Util.isFunction(easing)) {
4928 callback = easing;
4929 easing = 'easeLinear';
4930 } else {
4931 easing = easing ? easing : 'easeLinear';
4932 }
4933 var formatProps = getFormatProps(toProps, self);
4934 // 记录动画属性
4935 var animator = {
4936 fromAttrs: getFromAttrs(toProps, self),
4937 toAttrs: formatProps.attrs,
4938 fromMatrix: Util.clone(self.getMatrix()),
4939 toMatrix: formatProps.matrix,
4940 duration: duration,
4941 easing: easing,
4942 callback: callback,
4943 delay: delay,
4944 startTime: timeline.getTime(),
4945 id: Util.uniqueId()
4946 };
4947 // 如果动画队列中已经有这个图形了
4948 if (animators.length > 0) {
4949 // 先检查是否需要合并属性。若有相同的动画,将该属性从前一个动画中删除,直接用后一个动画中
4950 animators = checkExistedAttrs(animators, animator);
4951 } else {
4952 // 否则将图形添加到队列
4953 timeline.addAnimator(self);
4954 }
4955 animators.push(animator);
4956 self.setSilent('animators', animators);
4957 self.setSilent('pause', { isPaused: false });
4958 },
4959 stopAnimate: function stopAnimate() {
4960 var _this = this;
4961
4962 var animators = this.get('animators');
4963 // 将动画执行到最后一帧,执行回调
4964 Util.each(animators, function (animator) {
4965 _this.attr(animator.toAttrs);
4966 if (animator.toMatrix) {
4967 _this.attr('matrix', animator.toMatrix);
4968 }
4969 if (animator.callback) {
4970 animator.callback();
4971 }
4972 });
4973 this.setSilent('animating', false);
4974 this.setSilent('animators', []);
4975 },
4976 pauseAnimate: function pauseAnimate() {
4977 var self = this;
4978 var timeline = self.get('timeline');
4979 // 记录下是在什么时候暂停的
4980 self.setSilent('pause', {
4981 isPaused: true,
4982 pauseTime: timeline.getTime()
4983 });
4984 return self;
4985 },
4986 resumeAnimate: function resumeAnimate() {
4987 var self = this;
4988 var timeline = self.get('timeline');
4989 var current = timeline.getTime();
4990 var animators = self.get('animators');
4991 var pauseTime = self.get('pause').pauseTime;
4992 // 之后更新属性需要计算动画已经执行的时长,如果暂停了,就把初始时间调后
4993 Util.each(animators, function (animator) {
4994 animator.startTime = animator.startTime + (current - pauseTime);
4995 animator._paused = false;
4996 animator._pauseTime = null;
4997 });
4998 self.setSilent('pause', {
4999 isPaused: false
5000 });
5001 self.setSilent('animators', animators);
5002 return self;
5003 }
5004};
5005
5006/***/ }),
5007/* 45 */
5008/***/ (function(module, exports, __webpack_require__) {
5009
5010var __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; };
5011
5012/*!
5013 * EventEmitter v5.1.0 - git.io/ee
5014 * Unlicense - http://unlicense.org/
5015 * Oliver Caldwell - http://oli.me.uk/
5016 * @preserve
5017 */
5018
5019;(function (exports) {
5020 'use strict';
5021
5022 /**
5023 * Class for managing events.
5024 * Can be extended to provide event functionality in other classes.
5025 *
5026 * @class EventEmitter Manages event registering and emitting.
5027 */
5028
5029 function EventEmitter() {}
5030
5031 // Shortcuts to improve speed and size
5032 var proto = EventEmitter.prototype;
5033 var originalGlobalValue = exports.EventEmitter;
5034
5035 /**
5036 * Finds the index of the listener for the event in its storage array.
5037 *
5038 * @param {Function[]} listeners Array of listeners to search through.
5039 * @param {Function} listener Method to look for.
5040 * @return {Number} Index of the specified listener, -1 if not found
5041 * @api private
5042 */
5043 function indexOfListener(listeners, listener) {
5044 var i = listeners.length;
5045 while (i--) {
5046 if (listeners[i].listener === listener) {
5047 return i;
5048 }
5049 }
5050
5051 return -1;
5052 }
5053
5054 /**
5055 * Alias a method while keeping the context correct, to allow for overwriting of target method.
5056 *
5057 * @param {String} name The name of the target method.
5058 * @return {Function} The aliased method
5059 * @api private
5060 */
5061 function alias(name) {
5062 return function aliasClosure() {
5063 return this[name].apply(this, arguments);
5064 };
5065 }
5066
5067 /**
5068 * Returns the listener array for the specified event.
5069 * Will initialise the event object and listener arrays if required.
5070 * 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.
5071 * Each property in the object response is an array of listener functions.
5072 *
5073 * @param {String|RegExp} evt Name of the event to return the listeners from.
5074 * @return {Function[]|Object} All listener functions for the event.
5075 */
5076 proto.getListeners = function getListeners(evt) {
5077 var events = this._getEvents();
5078 var response;
5079 var key;
5080
5081 // Return a concatenated array of all matching events if
5082 // the selector is a regular expression.
5083 if (evt instanceof RegExp) {
5084 response = {};
5085 for (key in events) {
5086 if (events.hasOwnProperty(key) && evt.test(key)) {
5087 response[key] = events[key];
5088 }
5089 }
5090 } else {
5091 response = events[evt] || (events[evt] = []);
5092 }
5093
5094 return response;
5095 };
5096
5097 /**
5098 * Takes a list of listener objects and flattens it into a list of listener functions.
5099 *
5100 * @param {Object[]} listeners Raw listener objects.
5101 * @return {Function[]} Just the listener functions.
5102 */
5103 proto.flattenListeners = function flattenListeners(listeners) {
5104 var flatListeners = [];
5105 var i;
5106
5107 for (i = 0; i < listeners.length; i += 1) {
5108 flatListeners.push(listeners[i].listener);
5109 }
5110
5111 return flatListeners;
5112 };
5113
5114 /**
5115 * 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.
5116 *
5117 * @param {String|RegExp} evt Name of the event to return the listeners from.
5118 * @return {Object} All listener functions for an event in an object.
5119 */
5120 proto.getListenersAsObject = function getListenersAsObject(evt) {
5121 var listeners = this.getListeners(evt);
5122 var response;
5123
5124 if (listeners instanceof Array) {
5125 response = {};
5126 response[evt] = listeners;
5127 }
5128
5129 return response || listeners;
5130 };
5131
5132 function isValidListener(listener) {
5133 if (typeof listener === 'function' || listener instanceof RegExp) {
5134 return true;
5135 } else if (listener && (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object') {
5136 return isValidListener(listener.listener);
5137 } else {
5138 return false;
5139 }
5140 }
5141
5142 /**
5143 * Adds a listener function to the specified event.
5144 * The listener will not be added if it is a duplicate.
5145 * If the listener returns true then it will be removed after it is called.
5146 * If you pass a regular expression as the event name then the listener will be added to all events that match it.
5147 *
5148 * @param {String|RegExp} evt Name of the event to attach the listener to.
5149 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
5150 * @return {Object} Current instance of EventEmitter for chaining.
5151 */
5152 proto.addListener = function addListener(evt, listener) {
5153 if (!isValidListener(listener)) {
5154 throw new TypeError('listener must be a function');
5155 }
5156
5157 var listeners = this.getListenersAsObject(evt);
5158 var listenerIsWrapped = (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object';
5159 var key;
5160
5161 for (key in listeners) {
5162 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
5163 listeners[key].push(listenerIsWrapped ? listener : {
5164 listener: listener,
5165 once: false
5166 });
5167 }
5168 }
5169
5170 return this;
5171 };
5172
5173 /**
5174 * Alias of addListener
5175 */
5176 proto.on = alias('addListener');
5177
5178 /**
5179 * Semi-alias of addListener. It will add a listener that will be
5180 * automatically removed after its first execution.
5181 *
5182 * @param {String|RegExp} evt Name of the event to attach the listener to.
5183 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
5184 * @return {Object} Current instance of EventEmitter for chaining.
5185 */
5186 proto.addOnceListener = function addOnceListener(evt, listener) {
5187 return this.addListener(evt, {
5188 listener: listener,
5189 once: true
5190 });
5191 };
5192
5193 /**
5194 * Alias of addOnceListener.
5195 */
5196 proto.once = alias('addOnceListener');
5197
5198 /**
5199 * 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.
5200 * You need to tell it what event names should be matched by a regex.
5201 *
5202 * @param {String} evt Name of the event to create.
5203 * @return {Object} Current instance of EventEmitter for chaining.
5204 */
5205 proto.defineEvent = function defineEvent(evt) {
5206 this.getListeners(evt);
5207 return this;
5208 };
5209
5210 /**
5211 * Uses defineEvent to define multiple events.
5212 *
5213 * @param {String[]} evts An array of event names to define.
5214 * @return {Object} Current instance of EventEmitter for chaining.
5215 */
5216 proto.defineEvents = function defineEvents(evts) {
5217 for (var i = 0; i < evts.length; i += 1) {
5218 this.defineEvent(evts[i]);
5219 }
5220 return this;
5221 };
5222
5223 /**
5224 * Removes a listener function from the specified event.
5225 * When passed a regular expression as the event name, it will remove the listener from all events that match it.
5226 *
5227 * @param {String|RegExp} evt Name of the event to remove the listener from.
5228 * @param {Function} listener Method to remove from the event.
5229 * @return {Object} Current instance of EventEmitter for chaining.
5230 */
5231 proto.removeListener = function removeListener(evt, listener) {
5232 var listeners = this.getListenersAsObject(evt);
5233 var index;
5234 var key;
5235
5236 for (key in listeners) {
5237 if (listeners.hasOwnProperty(key)) {
5238 index = indexOfListener(listeners[key], listener);
5239
5240 if (index !== -1) {
5241 listeners[key].splice(index, 1);
5242 }
5243 }
5244 }
5245
5246 return this;
5247 };
5248
5249 /**
5250 * Alias of removeListener
5251 */
5252 proto.off = alias('removeListener');
5253
5254 /**
5255 * Adds listeners in bulk using the manipulateListeners method.
5256 * 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.
5257 * You can also pass it a regular expression to add the array of listeners to all events that match it.
5258 * Yeah, this function does quite a bit. That's probably a bad thing.
5259 *
5260 * @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.
5261 * @param {Function[]} [listeners] An optional array of listener functions to add.
5262 * @return {Object} Current instance of EventEmitter for chaining.
5263 */
5264 proto.addListeners = function addListeners(evt, listeners) {
5265 // Pass through to manipulateListeners
5266 return this.manipulateListeners(false, evt, listeners);
5267 };
5268
5269 /**
5270 * Removes listeners in bulk using the manipulateListeners method.
5271 * 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.
5272 * You can also pass it an event name and an array of listeners to be removed.
5273 * You can also pass it a regular expression to remove the listeners from all events that match it.
5274 *
5275 * @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.
5276 * @param {Function[]} [listeners] An optional array of listener functions to remove.
5277 * @return {Object} Current instance of EventEmitter for chaining.
5278 */
5279 proto.removeListeners = function removeListeners(evt, listeners) {
5280 // Pass through to manipulateListeners
5281 return this.manipulateListeners(true, evt, listeners);
5282 };
5283
5284 /**
5285 * 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.
5286 * The first argument will determine if the listeners are removed (true) or added (false).
5287 * 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.
5288 * You can also pass it an event name and an array of listeners to be added/removed.
5289 * You can also pass it a regular expression to manipulate the listeners of all events that match it.
5290 *
5291 * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
5292 * @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.
5293 * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
5294 * @return {Object} Current instance of EventEmitter for chaining.
5295 */
5296 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
5297 var i;
5298 var value;
5299 var single = remove ? this.removeListener : this.addListener;
5300 var multiple = remove ? this.removeListeners : this.addListeners;
5301
5302 // If evt is an object then pass each of its properties to this method
5303 if ((typeof evt === 'undefined' ? 'undefined' : _typeof(evt)) === 'object' && !(evt instanceof RegExp)) {
5304 for (i in evt) {
5305 if (evt.hasOwnProperty(i) && (value = evt[i])) {
5306 // Pass the single listener straight through to the singular method
5307 if (typeof value === 'function') {
5308 single.call(this, i, value);
5309 } else {
5310 // Otherwise pass back to the multiple function
5311 multiple.call(this, i, value);
5312 }
5313 }
5314 }
5315 } else {
5316 // So evt must be a string
5317 // And listeners must be an array of listeners
5318 // Loop over it and pass each one to the multiple method
5319 i = listeners.length;
5320 while (i--) {
5321 single.call(this, evt, listeners[i]);
5322 }
5323 }
5324
5325 return this;
5326 };
5327
5328 /**
5329 * Removes all listeners from a specified event.
5330 * If you do not specify an event then all listeners will be removed.
5331 * That means every event will be emptied.
5332 * You can also pass a regex to remove all events that match it.
5333 *
5334 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
5335 * @return {Object} Current instance of EventEmitter for chaining.
5336 */
5337 proto.removeEvent = function removeEvent(evt) {
5338 var type = typeof evt === 'undefined' ? 'undefined' : _typeof(evt);
5339 var events = this._getEvents();
5340 var key;
5341
5342 // Remove different things depending on the state of evt
5343 if (type === 'string') {
5344 // Remove all listeners for the specified event
5345 delete events[evt];
5346 } else if (evt instanceof RegExp) {
5347 // Remove all events matching the regex.
5348 for (key in events) {
5349 if (events.hasOwnProperty(key) && evt.test(key)) {
5350 delete events[key];
5351 }
5352 }
5353 } else {
5354 // Remove all listeners in all events
5355 delete this._events;
5356 }
5357
5358 return this;
5359 };
5360
5361 /**
5362 * Alias of removeEvent.
5363 *
5364 * Added to mirror the node API.
5365 */
5366 proto.removeAllListeners = alias('removeEvent');
5367
5368 /**
5369 * Emits an event of your choice.
5370 * When emitted, every listener attached to that event will be executed.
5371 * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
5372 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
5373 * So they will not arrive within the array on the other side, they will be separate.
5374 * You can also pass a regular expression to emit to all events that match it.
5375 *
5376 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
5377 * @param {Array} [args] Optional array of arguments to be passed to each listener.
5378 * @return {Object} Current instance of EventEmitter for chaining.
5379 */
5380 proto.emitEvent = function emitEvent(evt, args) {
5381 var listenersMap = this.getListenersAsObject(evt);
5382 var listeners;
5383 var listener;
5384 var i;
5385 var key;
5386 var response;
5387
5388 for (key in listenersMap) {
5389 if (listenersMap.hasOwnProperty(key)) {
5390 listeners = listenersMap[key].slice(0);
5391
5392 for (i = 0; i < listeners.length; i++) {
5393 // If the listener returns true then it shall be removed from the event
5394 // The function is executed either with a basic call or an apply if there is an args array
5395 listener = listeners[i];
5396
5397 if (listener.once === true) {
5398 this.removeListener(evt, listener.listener);
5399 }
5400
5401 response = listener.listener.apply(this, args || []);
5402
5403 if (response === this._getOnceReturnValue()) {
5404 this.removeListener(evt, listener.listener);
5405 }
5406 }
5407 }
5408 }
5409
5410 return this;
5411 };
5412
5413 /**
5414 * Alias of emitEvent
5415 */
5416 proto.trigger = alias('emitEvent');
5417
5418 /**
5419 * 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.
5420 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
5421 *
5422 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
5423 * @param {...*} Optional additional arguments to be passed to each listener.
5424 * @return {Object} Current instance of EventEmitter for chaining.
5425 */
5426 proto.emit = function emit(evt) {
5427 var args = Array.prototype.slice.call(arguments, 1);
5428 return this.emitEvent(evt, args);
5429 };
5430
5431 /**
5432 * Sets the current value to check against when executing listeners. If a
5433 * listeners return value matches the one set here then it will be removed
5434 * after execution. This value defaults to true.
5435 *
5436 * @param {*} value The new value to check for when executing listeners.
5437 * @return {Object} Current instance of EventEmitter for chaining.
5438 */
5439 proto.setOnceReturnValue = function setOnceReturnValue(value) {
5440 this._onceReturnValue = value;
5441 return this;
5442 };
5443
5444 /**
5445 * Fetches the current value to check against when executing listeners. If
5446 * the listeners return value matches this one then it should be removed
5447 * automatically. It will return true by default.
5448 *
5449 * @return {*|Boolean} The current value to check for or the default, true.
5450 * @api private
5451 */
5452 proto._getOnceReturnValue = function _getOnceReturnValue() {
5453 if (this.hasOwnProperty('_onceReturnValue')) {
5454 return this._onceReturnValue;
5455 } else {
5456 return true;
5457 }
5458 };
5459
5460 /**
5461 * Fetches the events object and creates one if required.
5462 *
5463 * @return {Object} The events storage object.
5464 * @api private
5465 */
5466 proto._getEvents = function _getEvents() {
5467 return this._events || (this._events = {});
5468 };
5469
5470 /**
5471 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
5472 *
5473 * @return {Function} Non conflicting EventEmitter class.
5474 */
5475 EventEmitter.noConflict = function noConflict() {
5476 exports.EventEmitter = originalGlobalValue;
5477 return EventEmitter;
5478 };
5479
5480 // Expose the class either via AMD, CommonJS or the global object
5481 if (true) {
5482 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
5483 return EventEmitter;
5484 }).call(exports, __webpack_require__, exports, module),
5485 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
5486 } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports) {
5487 module.exports = EventEmitter;
5488 } else {
5489 exports.EventEmitter = EventEmitter;
5490 }
5491})(this || {});
5492
5493/***/ }),
5494/* 46 */
5495/***/ (function(module, exports, __webpack_require__) {
5496
5497var Util = __webpack_require__(0);
5498var Shape = __webpack_require__(4);
5499
5500var Rect = function Rect(cfg) {
5501 Rect.superclass.constructor.call(this, cfg);
5502};
5503
5504Rect.ATTRS = {
5505 x: 0,
5506 y: 0,
5507 width: 0,
5508 height: 0,
5509 radius: 0,
5510 lineWidth: 1,
5511 fill: 'none'
5512};
5513
5514Util.extend(Rect, Shape);
5515
5516Util.augment(Rect, {
5517 canFill: true,
5518 canStroke: true,
5519 type: 'rect',
5520 getDefaultAttrs: function getDefaultAttrs() {
5521 return {
5522 lineWidth: 1,
5523 fill: 'none'
5524 };
5525 },
5526 _afterSetRadius: function _afterSetRadius() {
5527 var el = this.get('el');
5528 el.setAttribute('rx', this.__attrs.radius);
5529 el.setAttribute('ry', this.__attrs.radius);
5530 },
5531 _afterSetAttrAll: function _afterSetAttrAll(objs) {
5532 if ('radius' in objs) {
5533 this._afterSetRadius();
5534 }
5535 }
5536});
5537
5538module.exports = Rect;
5539
5540/***/ }),
5541/* 47 */
5542/***/ (function(module, exports, __webpack_require__) {
5543
5544var Util = __webpack_require__(0);
5545var Shape = __webpack_require__(4);
5546
5547var Circle = function Circle(cfg) {
5548 Circle.superclass.constructor.call(this, cfg);
5549};
5550
5551Circle.ATTRS = {
5552 x: 0,
5553 y: 0,
5554 r: 0,
5555 lineWidth: 1
5556};
5557
5558Util.extend(Circle, Shape);
5559
5560Util.augment(Circle, {
5561 canFill: true,
5562 canStroke: true,
5563 type: 'circle',
5564 getDefaultAttrs: function getDefaultAttrs() {
5565 return {
5566 lineWidth: 1,
5567 fill: 'none'
5568 };
5569 }
5570});
5571
5572module.exports = Circle;
5573
5574/***/ }),
5575/* 48 */
5576/***/ (function(module, exports, __webpack_require__) {
5577
5578var Util = __webpack_require__(0);
5579var Shape = __webpack_require__(4);
5580
5581var Ellipse = function Ellipse(cfg) {
5582 Ellipse.superclass.constructor.call(this, cfg);
5583};
5584
5585Ellipse.ATTRS = {
5586 x: 0,
5587 y: 0,
5588 rx: 1,
5589 ry: 1,
5590 lineWidth: 1
5591};
5592
5593Util.extend(Ellipse, Shape);
5594
5595Util.augment(Ellipse, {
5596 canFill: true,
5597 canStroke: true,
5598 type: 'ellipse',
5599 getDefaultAttrs: function getDefaultAttrs() {
5600 return {
5601 lineWidth: 1
5602 };
5603 }
5604});
5605
5606module.exports = Ellipse;
5607
5608/***/ }),
5609/* 49 */
5610/***/ (function(module, exports, __webpack_require__) {
5611
5612var Util = __webpack_require__(0);
5613var Shape = __webpack_require__(4);
5614
5615var Path = function Path(cfg) {
5616 Path.superclass.constructor.call(this, cfg);
5617};
5618
5619function at(p0, p1, p2, p3, t) {
5620 var onet = 1 - t;
5621 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
5622}
5623
5624Path.ATTRS = {
5625 path: null,
5626 lineWidth: 1,
5627 curve: null, // 曲线path
5628 tCache: null,
5629 startArrow: false,
5630 endArrow: false
5631};
5632
5633Util.extend(Path, Shape);
5634
5635Util.augment(Path, {
5636 canFill: true,
5637 canStroke: true,
5638 type: 'path',
5639 getDefaultAttrs: function getDefaultAttrs() {
5640 return {
5641 lineWidth: 1,
5642 fill: 'none',
5643 startArrow: false,
5644 endArrow: false
5645 };
5646 },
5647 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
5648 var start = this.get('marker-start');
5649 var end = this.get('marker-end');
5650 if (start) {
5651 this.get('defs').findById(start).update(null, value);
5652 }
5653 if (end) {
5654 this.get('defs').findById(end).update(null, value);
5655 }
5656 },
5657 _afterSetAttrPath: function _afterSetAttrPath(value) {
5658 var el = this.get('el');
5659 var d = value;
5660 if (Util.isArray(d)) {
5661 d = d.map(function (path) {
5662 return path.join(' ');
5663 }).join('');
5664 }
5665 if (~d.indexOf('NaN')) {
5666 el.setAttribute('d', '');
5667 } else {
5668 el.setAttribute('d', d);
5669 }
5670 },
5671 _afterSetAttrAll: function _afterSetAttrAll(objs) {
5672 if (objs.path) {
5673 this._afterSetAttrPath(objs.path);
5674 }
5675 if (objs.stroke) {
5676 this._afterSetAttrStroke(objs.stroke);
5677 }
5678 },
5679 getPoint: function getPoint(t) {
5680 var tCache = this.tCache;
5681 var subt = void 0;
5682 var index = void 0;
5683
5684 if (!tCache) {
5685 this._calculateCurve();
5686 this._setTcache();
5687 tCache = this.tCache;
5688 }
5689
5690 var curve = this.curve;
5691
5692 if (!tCache) {
5693 if (curve) {
5694 return {
5695 x: curve[0][1],
5696 y: curve[0][2]
5697 };
5698 }
5699 return null;
5700 }
5701 Util.each(tCache, function (v, i) {
5702 if (t >= v[0] && t <= v[1]) {
5703 subt = (t - v[0]) / (v[1] - v[0]);
5704 index = i;
5705 }
5706 });
5707 var seg = curve[index];
5708 if (Util.isNil(seg) || Util.isNil(index)) {
5709 return null;
5710 }
5711 var l = seg.length;
5712 var nextSeg = curve[index + 1];
5713
5714 return {
5715 x: at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
5716 y: at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
5717 };
5718 },
5719 createPath: function createPath() {}
5720});
5721
5722module.exports = Path;
5723
5724/***/ }),
5725/* 50 */
5726/***/ (function(module, exports, __webpack_require__) {
5727
5728var Util = __webpack_require__(0);
5729var Shape = __webpack_require__(4);
5730
5731var CText = function CText(cfg) {
5732 CText.superclass.constructor.call(this, cfg);
5733};
5734
5735var BASELINE_MAP = {
5736 top: 'before-edge',
5737 middle: 'central',
5738 bottom: 'after-edge',
5739 alphabetic: 'baseline',
5740 hanging: 'hanging'
5741};
5742
5743var ANCHOR_MAP = {
5744 left: 'left',
5745 start: 'left',
5746 center: 'middle',
5747 right: 'end',
5748 end: 'end'
5749};
5750
5751CText.ATTRS = {
5752 x: 0,
5753 y: 0,
5754 text: null,
5755 fontSize: 12,
5756 fontFamily: 'sans-serif',
5757 fontStyle: 'normal',
5758 fontWeight: 'normal',
5759 fontVariant: 'normal',
5760 textAlign: 'start',
5761 textBaseline: 'bottom',
5762 lineHeight: null,
5763 textArr: null
5764};
5765
5766Util.extend(CText, Shape);
5767
5768Util.augment(CText, {
5769 canFill: true,
5770 canStroke: true,
5771 type: 'text',
5772 getDefaultAttrs: function getDefaultAttrs() {
5773 return {
5774 lineWidth: 1,
5775 lineCount: 1,
5776 fontSize: 12,
5777 fill: '#000',
5778 fontFamily: 'sans-serif',
5779 fontStyle: 'normal',
5780 fontWeight: 'normal',
5781 fontVariant: 'normal',
5782 textAlign: 'start',
5783 textBaseline: 'bottom'
5784 };
5785 },
5786 initTransform: function initTransform() {
5787 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
5788 var fontSize = this.__attrs.fontSize;
5789 if (fontSize && +fontSize < 12) {
5790 // 小于 12 像素的文本进行 scale 处理
5791 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
5792 }
5793 },
5794 _assembleFont: function _assembleFont() {
5795 var el = this.get('el');
5796 var attrs = this.__attrs;
5797 var fontSize = attrs.fontSize;
5798 var fontFamily = attrs.fontFamily;
5799 var fontWeight = attrs.fontWeight;
5800 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
5801 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
5802 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
5803 var font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
5804 attrs.font = font;
5805 el.setAttribute('font', attrs.font);
5806 },
5807 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
5808 /* this.attr({
5809 height: this._getTextHeight()
5810 }); */
5811 this._assembleFont();
5812 },
5813 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
5814 this._assembleFont();
5815 },
5816 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
5817 this._assembleFont();
5818 },
5819 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
5820 this._assembleFont();
5821 },
5822 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
5823 this._assembleFont();
5824 },
5825 _afterSetAttrTextAlign: function _afterSetAttrTextAlign() {
5826 // 由于本身不支持设置direction,所以left = start, right = end。之后看是否需要根据direction判断
5827 var attr = this.__attrs.textAlign;
5828 var el = this.get('el');
5829 el.setAttribute('text-anchor', ANCHOR_MAP[attr]);
5830 },
5831 _afterSetAttrTextBaseLine: function _afterSetAttrTextBaseLine() {
5832 var attr = this.__attrs.textBaseline;
5833 this.get('el').setAttribute('alignment-baseline', BASELINE_MAP[attr] || 'baseline');
5834 },
5835 _afterSetAttrText: function _afterSetAttrText(text) {
5836 var attrs = this.__attrs;
5837 var textArr = void 0;
5838 if (Util.isString(text) && text.indexOf('\n') !== -1) {
5839 textArr = text.split('\n');
5840 var lineCount = textArr.length;
5841 attrs.lineCount = lineCount;
5842 attrs.textArr = textArr;
5843 }
5844 var el = this.get('el');
5845 if (~['undefined', 'null', 'NaN'].indexOf(String(text)) && el) {
5846 el.innerHTML = '';
5847 } else if (~text.indexOf('\n')) {
5848 textArr = text.split('\n');
5849 attrs.lineCount = textArr.length;
5850 attrs.textArr = textArr;
5851 var arr = '';
5852 Util.each(textArr, function (segment, i) {
5853 arr += '<tspan x="0" y="' + (i + 1) + 'em">' + segment + '</tspan>';
5854 });
5855 el.innerHTML = arr;
5856 } else {
5857 el.innerHTML = text;
5858 }
5859 },
5860 _afterSetAttrOutline: function _afterSetAttrOutline(val) {
5861 var el = this.get('el');
5862 if (!val) {
5863 el.setAttribute('paint-order', 'normal');
5864 }
5865 var stroke = val.stroke || '#000';
5866 var fill = val.fill || this.__attrs.stroke;
5867 var lineWidth = val.lineWidth || this.__attrs.lineWidth * 2;
5868 el.setAttribute('paint-order', 'stroke');
5869 el.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');
5870 el.setAttribute('stroke', stroke);
5871 el.setAttribute('fill', fill);
5872 el.setAttribute('stroke-width', lineWidth);
5873 },
5874
5875 // 计算浪费,效率低,待优化
5876 _afterSetAttrAll: function _afterSetAttrAll(objs) {
5877 var self = this;
5878 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
5879 self._assembleFont();
5880 }
5881 if ('textAlign' in objs) {
5882 this._afterSetAttrTextAlign();
5883 }
5884 if ('textBaseline' in objs) {
5885 this._afterSetAttrTextBaseLine();
5886 }
5887 if ('text' in objs) {
5888 self._afterSetAttrText(objs.text);
5889 }
5890 if ('outline' in objs) {
5891 self._afterSetAttrOutline(objs.outline);
5892 }
5893 }
5894});
5895
5896module.exports = CText;
5897
5898/***/ }),
5899/* 51 */
5900/***/ (function(module, exports, __webpack_require__) {
5901
5902var Util = __webpack_require__(0);
5903var Shape = __webpack_require__(4);
5904
5905var Line = function Line(cfg) {
5906 Line.superclass.constructor.call(this, cfg);
5907};
5908
5909Line.ATTRS = {
5910 x1: 0,
5911 y1: 0,
5912 x2: 0,
5913 y2: 0,
5914 lineWidth: 1,
5915 startArrow: false,
5916 endArrow: false
5917};
5918
5919Util.extend(Line, Shape);
5920
5921Util.augment(Line, {
5922 canStroke: true,
5923 type: 'line',
5924 getDefaultAttrs: function getDefaultAttrs() {
5925 return {
5926 lineWidth: 1,
5927 stroke: '#000',
5928 startArrow: false,
5929 endArrow: false
5930 };
5931 },
5932 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
5933 var start = this.get('marker-start');
5934 var end = this.get('marker-end');
5935 if (start) {
5936 this.get('defs').findById(start).update(value);
5937 }
5938 if (end) {
5939 this.get('defs').findById(end).update(value);
5940 }
5941 },
5942 _afterSetAttrAll: function _afterSetAttrAll(objs) {
5943 if (objs.stroke) {
5944 this._afterSetAttrStroke(objs.stroke);
5945 }
5946 },
5947 createPath: function createPath() {},
5948 getPoint: function getPoint(t) {
5949 var attrs = this.__attrs;
5950 return {
5951 x: (attrs.x2 - attrs.x1) * t + attrs.x1,
5952 y: (attrs.y2 - attrs.y1) * t + attrs.y1
5953 };
5954 }
5955});
5956
5957module.exports = Line;
5958
5959/***/ }),
5960/* 52 */
5961/***/ (function(module, exports, __webpack_require__) {
5962
5963var Util = __webpack_require__(0);
5964var Shape = __webpack_require__(4);
5965
5966var CImage = function CImage(cfg) {
5967 CImage.superclass.constructor.call(this, cfg);
5968};
5969
5970CImage.ATTRS = {
5971 x: 0,
5972 y: 0,
5973 img: undefined,
5974 width: 0,
5975 height: 0,
5976 sx: null,
5977 sy: null,
5978 swidth: null,
5979 sheight: null
5980};
5981
5982Util.extend(CImage, Shape);
5983
5984Util.augment(CImage, {
5985 type: 'image',
5986 _afterSetAttrImg: function _afterSetAttrImg(img) {
5987 this._setAttrImg(img);
5988 },
5989 _afterSetAttrAll: function _afterSetAttrAll(params) {
5990 if (params.img) {
5991 this._setAttrImg(params.img);
5992 }
5993 },
5994 _setAttrImg: function _setAttrImg(image) {
5995 var self = this;
5996 var el = this.get('el');
5997 var attrs = self.__attrs;
5998 var img = image;
5999
6000 if (Util.isString(img)) {
6001 // 如果传入的
6002 el.setAttribute('href', img);
6003 } else if (img instanceof Image) {
6004 if (!attrs.width) {
6005 self.attr('width', img.width);
6006 }
6007 if (!attrs.height) {
6008 self.attr('height', img.height);
6009 }
6010 el.setAttribute('href', img.src);
6011 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
6012 el.setAttribute('href', img.toDataURL());
6013 } else if (img instanceof ImageData) {
6014 var canvas = document.createElement('canvas');
6015 canvas.setAttribute('width', img.width);
6016 canvas.setAttribute('height', img.height);
6017 canvas.getContext('2d').putImageData(img, 0, 0);
6018 if (!attrs.width) {
6019 self.attr('width', img.width);
6020 }
6021
6022 if (!attrs.height) {
6023 self.attr('height', img.height);
6024 }
6025 el.setAttribute('href', canvas.toDataURL());
6026 }
6027 },
6028 drawInner: function drawInner() {}
6029});
6030
6031module.exports = CImage;
6032
6033/***/ }),
6034/* 53 */
6035/***/ (function(module, exports, __webpack_require__) {
6036
6037var Util = __webpack_require__(0);
6038var Shape = __webpack_require__(4);
6039
6040var Polygon = function Polygon(cfg) {
6041 Polygon.superclass.constructor.call(this, cfg);
6042};
6043
6044Polygon.ATTRS = {
6045 points: null,
6046 lineWidth: 1
6047};
6048
6049Util.extend(Polygon, Shape);
6050
6051Util.augment(Polygon, {
6052 canFill: true,
6053 canStroke: true,
6054 type: 'polygon',
6055 getDefaultAttrs: function getDefaultAttrs() {
6056 return {
6057 lineWidth: 1,
6058 fill: 'none'
6059 };
6060 },
6061 _afterSetAttrPoints: function _afterSetAttrPoints() {
6062 var value = this.__attrs.points;
6063 var el = this.get('el');
6064 var points = value;
6065 if (!value || value.length === 0) {
6066 points = '';
6067 } else if (Util.isArray(value)) {
6068 points = points.map(function (point) {
6069 return point[0] + ',' + point[1];
6070 });
6071 points = points.join(' ');
6072 }
6073 el.setAttribute('points', points);
6074 },
6075 _afterSetAttrAll: function _afterSetAttrAll(obj) {
6076 if ('points' in obj) {
6077 this._afterSetAttrPoints();
6078 }
6079 },
6080 createPath: function createPath() {}
6081});
6082
6083module.exports = Polygon;
6084
6085/***/ }),
6086/* 54 */
6087/***/ (function(module, exports, __webpack_require__) {
6088
6089var Util = __webpack_require__(0);
6090var Shape = __webpack_require__(4);
6091
6092var Marker = function Marker(cfg) {
6093 Marker.superclass.constructor.call(this, cfg);
6094};
6095
6096Marker.Symbols = {
6097 // 圆
6098 circle: function circle(x, y, r) {
6099 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';
6100 },
6101
6102 // 正方形
6103 square: function square(x, y, r) {
6104 return 'M' + (x - r) + ',' + (y - r) + '\n H' + (x + r) + 'V' + (y + r) + '\n H' + (x - r) + 'Z';
6105 },
6106
6107 // 菱形
6108 diamond: function diamond(x, y, r) {
6109 return 'M' + (x - r) + ',' + y + '\n L' + x + ',' + (y - r) + '\n L' + (x + r) + ',' + y + ',\n L' + x + ',' + (y + r) + 'Z';
6110 },
6111
6112 // 三角形
6113 triangle: function triangle(x, y, r) {
6114 var diff = r * Math.sin(1 / 3 * Math.PI);
6115 return 'M' + (x - r) + ',' + (y + diff) + '\n L' + x + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y + diff) + 'Z';
6116 },
6117
6118 // 倒三角形
6119 'triangle-down': function triangleDown(x, y, r) {
6120 var diff = r * Math.sin(1 / 3 * Math.PI);
6121 return 'M' + (x - r) + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y - diff) + '\n L' + x + ',' + (y + diff) + 'Z';
6122 }
6123};
6124
6125Marker.ATTRS = {
6126 path: null,
6127 lineWidth: 1
6128};
6129
6130Util.extend(Marker, Shape);
6131
6132Util.augment(Marker, {
6133 type: 'marker',
6134 canFill: true,
6135 canStroke: true,
6136 init: function init(id) {
6137 Marker.superclass.init.call(this);
6138 var marker = document.createElementNS('http://www.w3.org/2000/svg', 'path');
6139 id = id || Util.uniqueId(this.type + '_');
6140 marker.setAttribute('id', id);
6141 this.setSilent('el', marker);
6142 },
6143 getDefaultAttrs: function getDefaultAttrs() {
6144 return {
6145 x: 0,
6146 y: 0,
6147 lineWidth: 1,
6148 fill: 'none'
6149 };
6150 },
6151 _afterSetX: function _afterSetX() {
6152 this._assembleShape();
6153 },
6154 _afterSetY: function _afterSetY() {
6155 this._assembleShape();
6156 },
6157 _afterSetRadius: function _afterSetRadius() {
6158 this._assembleShape();
6159 },
6160 _afterSetR: function _afterSetR() {
6161 this._assembleShape();
6162 },
6163 _afterSetAttrAll: function _afterSetAttrAll(objs) {
6164 if ('x' in objs || 'y' in objs || 'radius' in objs) {
6165 this._assembleShape();
6166 }
6167 },
6168 _assembleShape: function _assembleShape() {
6169 var attrs = this.__attrs;
6170 var r = attrs.r;
6171 if (typeof attrs.r === 'undefined') {
6172 r = attrs.radius;
6173 }
6174 if (isNaN(Number(attrs.x)) || isNaN(Number(attrs.y)) || isNaN(Number(r))) {
6175 return;
6176 }
6177 var d = '';
6178 if (typeof attrs.symbol === 'function') {
6179 d = attrs.symbol(attrs.x, attrs.y, r);
6180 } else {
6181 d = Marker.Symbols[attrs.symbol || 'circle'](attrs.x, attrs.y, r);
6182 }
6183 if (Util.isArray(d)) {
6184 d = d.map(function (path) {
6185 return path.join(' ');
6186 }).join('');
6187 }
6188 this.get('el').setAttribute('d', d);
6189 }
6190});
6191
6192module.exports = Marker;
6193
6194/***/ }),
6195/* 55 */
6196/***/ (function(module, exports, __webpack_require__) {
6197
6198var Util = __webpack_require__(0);
6199var Shape = __webpack_require__(4);
6200
6201var Dom = function Dom(cfg) {
6202 Dom.superclass.constructor.call(this, cfg);
6203};
6204
6205Util.extend(Dom, Shape);
6206
6207Util.augment(Dom, {
6208 canFill: true,
6209 canStroke: true,
6210 type: 'dom',
6211 _afterSetAttrHtml: function _afterSetAttrHtml() {
6212 var html = this.__attrs.html;
6213 var el = this.get('el');
6214 if (typeof html === 'string') {
6215 el.innerHTML = html;
6216 } else {
6217 el.innerHTML = '';
6218 el.appendChild(html);
6219 }
6220 },
6221 _afterSetAttrAll: function _afterSetAttrAll(objs) {
6222 if ('html' in objs) {
6223 this._afterSetAttrHtml();
6224 }
6225 }
6226});
6227
6228module.exports = Dom;
6229
6230/***/ }),
6231/* 56 */
6232/***/ (function(module, exports, __webpack_require__) {
6233
6234var Util = __webpack_require__(0);
6235var Shape = __webpack_require__(4);
6236
6237var Fan = function Fan(cfg) {
6238 Fan.superclass.constructor.call(this, cfg);
6239};
6240
6241function getPoint(angle, radius, center) {
6242 return {
6243 x: radius * Math.cos(angle) + center.x,
6244 y: radius * Math.sin(angle) + center.y
6245 };
6246}
6247
6248Fan.ATTRS = {
6249 x: 0,
6250 y: 0,
6251 rs: 0,
6252 re: 0,
6253 startAngle: 0,
6254 endAngle: 0,
6255 clockwise: false,
6256 lineWidth: 1
6257};
6258
6259Util.extend(Fan, Shape);
6260
6261Util.augment(Fan, {
6262 canFill: true,
6263 canStroke: true,
6264 type: 'fan',
6265 getDefaultAttrs: function getDefaultAttrs() {
6266 return {
6267 clockwise: false,
6268 lineWidth: 1,
6269 rs: 0,
6270 re: 0,
6271 fill: 'none'
6272 };
6273 },
6274 _afterSetAttrX: function _afterSetAttrX() {
6275 this._calculatePath();
6276 },
6277 _afterSetAttrY: function _afterSetAttrY() {
6278 this._calculatePath();
6279 },
6280 _afterSetAttrRs: function _afterSetAttrRs() {
6281 this._calculatePath();
6282 },
6283 _afterSetAttrRe: function _afterSetAttrRe() {
6284 this._calculatePath();
6285 },
6286 _afterSetAttrStartAngle: function _afterSetAttrStartAngle() {
6287 this._calculatePath();
6288 },
6289 _afterSetAttrEndAngle: function _afterSetAttrEndAngle() {
6290 this._calculatePath();
6291 },
6292 _afterSetAttrClockwise: function _afterSetAttrClockwise() {
6293 this._calculatePath();
6294 },
6295 _afterSetAttrAll: function _afterSetAttrAll(obj) {
6296 if ('x' in obj || 'y' in obj || 'rs' in obj || 're' in obj || 'startAngle' in obj || 'endAngle' in obj || 'clockwise' in obj) {
6297 this._calculatePath();
6298 }
6299 },
6300 _calculatePath: function _calculatePath() {
6301 var self = this;
6302 var attrs = self.__attrs;
6303 var center = {
6304 x: attrs.x,
6305 y: attrs.y
6306 };
6307 var d = [];
6308 var startAngle = attrs.startAngle;
6309 var endAngle = attrs.endAngle;
6310 if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
6311 endAngle -= 0.00001;
6312 }
6313 var outerStart = getPoint(startAngle, attrs.re, center);
6314 var outerEnd = getPoint(endAngle, attrs.re, center);
6315 var fa = endAngle > startAngle ? 1 : 0;
6316 var fs = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
6317 var rs = attrs.rs;
6318 var re = attrs.re;
6319 var innerStart = getPoint(startAngle, attrs.rs, center);
6320 var innerEnd = getPoint(endAngle, attrs.rs, center);
6321 if (attrs.rs > 0) {
6322 d.push('M ' + outerEnd.x + ',' + outerEnd.y);
6323 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
6324 /* if (endAngle - startAngle >= Math.PI) {
6325 const endPoint = getSymmetricalPoint(innerStart, center);
6326 d.push(`A ${rs},${rs},0,0,${fa},${endPoint.x},${endPoint.y}`);
6327 d.push(`M ${endPoint.x},${endPoint.y}`);
6328 }*/
6329 d.push('A ' + rs + ',' + rs + ',0,' + fs + ',' + (fa === 1 ? 0 : 1) + ',' + innerStart.x + ',' + innerStart.y);
6330 d.push('L ' + outerStart.x + ' ' + outerStart.y);
6331 } else {
6332 d.push('M ' + center.x + ',' + center.y);
6333 d.push('L ' + outerStart.x + ',' + outerStart.y);
6334 }
6335 /* if (endAngle - startAngle >= Math.PI) {
6336 const endPoint = getSymmetricalPoint(outerStart, center);
6337 d.push(`A ${re},${re},0,0,${fa},${endPoint.x},${endPoint.y}`);
6338 }*/
6339 d.push('A ' + re + ',' + re + ',0,' + fs + ',' + fa + ',' + outerEnd.x + ',' + outerEnd.y);
6340 if (attrs.rs > 0) {
6341 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
6342 } else {
6343 d.push('Z');
6344 }
6345 self.get('el').setAttribute('d', d.join(' '));
6346 }
6347});
6348
6349module.exports = Fan;
6350
6351/***/ }),
6352/* 57 */
6353/***/ (function(module, exports, __webpack_require__) {
6354
6355var Util = __webpack_require__(0);
6356var PathUtil = __webpack_require__(21);
6357var d3Timer = __webpack_require__(122);
6358var d3Ease = __webpack_require__(125);
6359
6360var _require = __webpack_require__(136),
6361 interpolate = _require.interpolate,
6362 interpolateArray = _require.interpolateArray; // 目前整体动画只需要数值和数组的差值计算
6363
6364var Timeline = function Timeline() {
6365 // 待执行动画的队列
6366 this._animators = [];
6367 // 当前时间
6368 this._current = 0;
6369 // 计时器实例
6370 this._timer = null;
6371};
6372
6373function _update(self, animator, ratio) {
6374 var cProps = {}; // 此刻属性
6375 var toAttrs = animator.toAttrs;
6376 var fromAttrs = animator.fromAttrs;
6377 var toMatrix = animator.toMatrix;
6378 if (self.get('destroyed')) {
6379 return;
6380 }
6381 var interf = void 0; // 差值函数
6382 for (var k in toAttrs) {
6383 if (!Util.isEqual(fromAttrs[k], toAttrs[k])) {
6384 if (k === 'path') {
6385 var toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态
6386 var fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态
6387 cProps[k] = [];
6388 for (var i = 0; i < toPath.length; i++) {
6389 var toPathPoint = toPath[i];
6390 var fromPathPoint = fromPath[i];
6391 var cPathPoint = [];
6392 for (var j = 0; j < toPathPoint.length; j++) {
6393 if (Util.isNumber(toPathPoint[j]) && fromPathPoint) {
6394 interf = interpolate(fromPathPoint[j], toPathPoint[j]);
6395 cPathPoint.push(interf(ratio));
6396 } else {
6397 cPathPoint.push(toPathPoint[j]);
6398 }
6399 }
6400 cProps[k].push(cPathPoint);
6401 }
6402 } else {
6403 interf = interpolate(fromAttrs[k], toAttrs[k]);
6404 cProps[k] = interf(ratio);
6405 }
6406 }
6407 }
6408 if (toMatrix) {
6409 var mf = interpolateArray(animator.fromMatrix, toMatrix);
6410 var cM = mf(ratio);
6411 self.setMatrix(cM);
6412 }
6413 self.attr(cProps);
6414}
6415
6416function update(shape, animator, elapsed) {
6417 var startTime = animator.startTime;
6418 // 如果还没有开始执行或暂停,先不更新
6419 if (elapsed < startTime + animator.delay || animator.isPaused) {
6420 return false;
6421 }
6422 var ratio = void 0;
6423 var isFinished = false;
6424 var duration = animator.duration;
6425 var easing = animator.easing;
6426 // 已执行时间
6427 elapsed = elapsed - startTime - animator.delay;
6428 if (animator.toAttrs.repeat) {
6429 ratio = elapsed % duration / duration;
6430 ratio = d3Ease[easing](ratio);
6431 } else {
6432 ratio = elapsed / duration;
6433 if (ratio < 1) {
6434 ratio = d3Ease[easing](ratio);
6435 } else {
6436 ratio = 1;
6437 if (animator.callback) {
6438 animator.callback();
6439 }
6440 isFinished = true;
6441 }
6442 }
6443 _update(shape, animator, ratio);
6444 return isFinished;
6445}
6446
6447Util.augment(Timeline, {
6448 initTimer: function initTimer() {
6449 var _this = this;
6450
6451 var self = this;
6452 var isFinished = false;
6453 var shape = void 0,
6454 animators = void 0,
6455 animator = void 0,
6456 canvas = void 0;
6457 self._timer = d3Timer.timer(function (elapsed) {
6458 self._current = elapsed;
6459 if (_this._animators.length > 0) {
6460 for (var i = _this._animators.length - 1; i >= 0; i--) {
6461 shape = _this._animators[i];
6462 if (shape.get('destroyed')) {
6463 // 如果已经被销毁,直接移出队列
6464 self.removeAnimator(i);
6465 continue;
6466 }
6467 if (!canvas) {
6468 canvas = shape.get('canvas');
6469 }
6470 if (!shape.get('pause').isPaused) {
6471 animators = shape.get('animators');
6472 for (var j = animators.length - 1; j >= 0; j--) {
6473 animator = animators[j];
6474 isFinished = update(shape, animator, elapsed);
6475 if (isFinished) {
6476 animators.splice(j, 1);
6477 isFinished = false;
6478 }
6479 }
6480 }
6481 if (animators.length === 0) {
6482 self.removeAnimator(i);
6483 }
6484 }
6485 if (canvas) {
6486 canvas.draw();
6487 }
6488 }
6489 });
6490 },
6491 addAnimator: function addAnimator(shape) {
6492 this._animators.push(shape);
6493 },
6494 removeAnimator: function removeAnimator(index) {
6495 this._animators.splice(index, 1);
6496 },
6497 clear: function clear() {
6498 this._animators = [];
6499 },
6500 isAnimating: function isAnimating() {
6501 return !!this._animators.length;
6502 },
6503 getTime: function getTime() {
6504 return this._current;
6505 }
6506});
6507
6508module.exports = Timeline;
6509
6510/***/ }),
6511/* 58 */
6512/***/ (function(module, __webpack_exports__, __webpack_require__) {
6513
6514"use strict";
6515/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return deg2rad; });
6516/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rad2deg; });
6517var deg2rad = Math.PI / 180;
6518var rad2deg = 180 / Math.PI;
6519
6520/***/ }),
6521/* 59 */
6522/***/ (function(module, __webpack_exports__, __webpack_require__) {
6523
6524"use strict";
6525/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rgbBasis; });
6526/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return rgbBasisClosed; });
6527/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(6);
6528/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(26);
6529/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(60);
6530/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(13);
6531
6532
6533
6534
6535
6536/* harmony default export */ __webpack_exports__["a"] = ((function rgbGamma(y) {
6537 var color = Object(__WEBPACK_IMPORTED_MODULE_3__color__["b" /* gamma */])(y);
6538
6539 function rgb(start, end) {
6540 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),
6541 g = color(start.g, end.g),
6542 b = color(start.b, end.b),
6543 opacity = Object(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity);
6544 return function (t) {
6545 start.r = r(t);
6546 start.g = g(t);
6547 start.b = b(t);
6548 start.opacity = opacity(t);
6549 return start + "";
6550 };
6551 }
6552
6553 rgb.gamma = rgbGamma;
6554
6555 return rgb;
6556})(1));
6557
6558function rgbSpline(spline) {
6559 return function (colors) {
6560 var n = colors.length,
6561 r = new Array(n),
6562 g = new Array(n),
6563 b = new Array(n),
6564 i,
6565 color;
6566 for (i = 0; i < n; ++i) {
6567 color = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(colors[i]);
6568 r[i] = color.r || 0;
6569 g[i] = color.g || 0;
6570 b[i] = color.b || 0;
6571 }
6572 r = spline(r);
6573 g = spline(g);
6574 b = spline(b);
6575 color.opacity = 1;
6576 return function (t) {
6577 color.r = r(t);
6578 color.g = g(t);
6579 color.b = b(t);
6580 return color + "";
6581 };
6582 };
6583}
6584
6585var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["b" /* default */]);
6586var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]);
6587
6588/***/ }),
6589/* 60 */
6590/***/ (function(module, __webpack_exports__, __webpack_require__) {
6591
6592"use strict";
6593/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(26);
6594
6595
6596/* harmony default export */ __webpack_exports__["a"] = (function (values) {
6597 var n = values.length;
6598 return function (t) {
6599 var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
6600 v0 = values[(i + n - 1) % n],
6601 v1 = values[i % n],
6602 v2 = values[(i + 1) % n],
6603 v3 = values[(i + 2) % n];
6604 return Object(__WEBPACK_IMPORTED_MODULE_0__basis__["a" /* basis */])((t - i / n) * n, v0, v1, v2, v3);
6605 };
6606});
6607
6608/***/ }),
6609/* 61 */
6610/***/ (function(module, __webpack_exports__, __webpack_require__) {
6611
6612"use strict";
6613/* harmony default export */ __webpack_exports__["a"] = (function (x) {
6614 return function () {
6615 return x;
6616 };
6617});
6618
6619/***/ }),
6620/* 62 */
6621/***/ (function(module, __webpack_exports__, __webpack_require__) {
6622
6623"use strict";
6624/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(23);
6625
6626
6627/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6628 var nb = b ? b.length : 0,
6629 na = a ? Math.min(nb, a.length) : 0,
6630 x = new Array(na),
6631 c = new Array(nb),
6632 i;
6633
6634 for (i = 0; i < na; ++i) {
6635 x[i] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[i], b[i]);
6636 }for (; i < nb; ++i) {
6637 c[i] = b[i];
6638 }return function (t) {
6639 for (i = 0; i < na; ++i) {
6640 c[i] = x[i](t);
6641 }return c;
6642 };
6643});
6644
6645/***/ }),
6646/* 63 */
6647/***/ (function(module, __webpack_exports__, __webpack_require__) {
6648
6649"use strict";
6650/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6651 var d = new Date();
6652 return a = +a, b -= a, function (t) {
6653 return d.setTime(a + b * t), d;
6654 };
6655});
6656
6657/***/ }),
6658/* 64 */
6659/***/ (function(module, __webpack_exports__, __webpack_require__) {
6660
6661"use strict";
6662/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(23);
6663var _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; };
6664
6665
6666
6667/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6668 var i = {},
6669 c = {},
6670 k;
6671
6672 if (a === null || (typeof a === "undefined" ? "undefined" : _typeof(a)) !== "object") a = {};
6673 if (b === null || (typeof b === "undefined" ? "undefined" : _typeof(b)) !== "object") b = {};
6674
6675 for (k in b) {
6676 if (k in a) {
6677 i[k] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]);
6678 } else {
6679 c[k] = b[k];
6680 }
6681 }
6682
6683 return function (t) {
6684 for (k in i) {
6685 c[k] = i[k](t);
6686 }return c;
6687 };
6688});
6689
6690/***/ }),
6691/* 65 */
6692/***/ (function(module, __webpack_exports__, __webpack_require__) {
6693
6694"use strict";
6695/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(15);
6696
6697
6698var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
6699 reB = new RegExp(reA.source, "g");
6700
6701function zero(b) {
6702 return function () {
6703 return b;
6704 };
6705}
6706
6707function one(b) {
6708 return function (t) {
6709 return b(t) + "";
6710 };
6711}
6712
6713/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6714 var bi = reA.lastIndex = reB.lastIndex = 0,
6715 // scan index for next number in b
6716 am,
6717 // current match in a
6718 bm,
6719 // current match in b
6720 bs,
6721 // string preceding current number in b, if any
6722 i = -1,
6723 // index in s
6724 s = [],
6725 // string constants and placeholders
6726 q = []; // number interpolators
6727
6728 // Coerce inputs to strings.
6729 a = a + "", b = b + "";
6730
6731 // Interpolate pairs of numbers in a & b.
6732 while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
6733 if ((bs = bm.index) > bi) {
6734 // a string precedes the next number in b
6735 bs = b.slice(bi, bs);
6736 if (s[i]) s[i] += bs; // coalesce with previous string
6737 else s[++i] = bs;
6738 }
6739 if ((am = am[0]) === (bm = bm[0])) {
6740 // numbers in a & b match
6741 if (s[i]) s[i] += bm; // coalesce with previous string
6742 else s[++i] = bm;
6743 } else {
6744 // interpolate non-matching numbers
6745 s[++i] = null;
6746 q.push({ i: i, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm) });
6747 }
6748 bi = reB.lastIndex;
6749 }
6750
6751 // Add remains of b.
6752 if (bi < b.length) {
6753 bs = b.slice(bi);
6754 if (s[i]) s[i] += bs; // coalesce with previous string
6755 else s[++i] = bs;
6756 }
6757
6758 // Special optimization for only a single match.
6759 // Otherwise, interpolate each of the numbers and rejoin the string.
6760 return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) {
6761 for (var i = 0, o; i < b; ++i) {
6762 s[(o = q[i]).i] = o.x(t);
6763 }return s.join("");
6764 });
6765});
6766
6767/***/ }),
6768/* 66 */
6769/***/ (function(module, exports, __webpack_require__) {
6770
6771var Util = __webpack_require__(0);
6772
6773var Event = function Event(type, event, bubbles, cancelable) {
6774 this.type = type; // 事件类型
6775 this.target = null; // 目标
6776 this.currentTarget = null; // 当前目标
6777 this.bubbles = bubbles; // 冒泡
6778 this.cancelable = cancelable; // 是否能够阻止
6779 this.timeStamp = new Date().getTime(); // 时间戳
6780 this.defaultPrevented = false; // 阻止默认
6781 this.propagationStopped = false; // 阻止冒泡
6782 this.removed = false; // 是否被移除
6783 this.event = event; // 触发的原生事件
6784};
6785
6786Util.augment(Event, {
6787 preventDefault: function preventDefault() {
6788 this.defaultPrevented = this.cancelable && true;
6789 },
6790 stopPropagation: function stopPropagation() {
6791 this.propagationStopped = true;
6792 },
6793 remove: function remove() {
6794 this.remove = true;
6795 },
6796 clone: function clone() {
6797 return Util.clone(this);
6798 },
6799 toString: function toString() {
6800 return '[Event (type=' + this.type + ')]';
6801 }
6802});
6803
6804module.exports = Event;
6805
6806/***/ }),
6807/* 67 */
6808/***/ (function(module, exports, __webpack_require__) {
6809
6810var Util = __webpack_require__(0);
6811var Element = __webpack_require__(68);
6812var Shape = __webpack_require__(153);
6813var SHAPE_MAP = {}; // 缓存图形类型
6814var INDEX = '_INDEX';
6815
6816function find(children, x, y) {
6817 var rst = void 0;
6818 for (var i = children.length - 1; i >= 0; i--) {
6819 var child = children[i];
6820 if (child.__cfg.visible && child.__cfg.capture) {
6821 if (child.isGroup) {
6822 rst = child.getShape(x, y);
6823 } else if (child.isHit(x, y)) {
6824 rst = child;
6825 }
6826 }
6827 if (rst) {
6828 break;
6829 }
6830 }
6831 return rst;
6832}
6833
6834function getComparer(compare) {
6835 return function (left, right) {
6836 var result = compare(left, right);
6837 return result === 0 ? left[INDEX] - right[INDEX] : result;
6838 };
6839}
6840
6841var Group = function Group(cfg) {
6842 Group.superclass.constructor.call(this, cfg);
6843 this.set('children', []);
6844
6845 this._beforeRenderUI();
6846 this._renderUI();
6847 this._bindUI();
6848};
6849
6850function initClassCfgs(c) {
6851 if (c.__cfg || c === Group) {
6852 return;
6853 }
6854 var superCon = c.superclass.constructor;
6855 if (superCon && !superCon.__cfg) {
6856 initClassCfgs(superCon);
6857 }
6858 c.__cfg = {};
6859
6860 Util.merge(c.__cfg, superCon.__cfg);
6861 Util.merge(c.__cfg, c.CFG);
6862}
6863
6864Util.extend(Group, Element);
6865
6866Util.augment(Group, {
6867 isGroup: true,
6868 canFill: true,
6869 canStroke: true,
6870 getDefaultCfg: function getDefaultCfg() {
6871 initClassCfgs(this.constructor);
6872 return Util.merge({}, this.constructor.__cfg);
6873 },
6874 _beforeRenderUI: function _beforeRenderUI() {},
6875 _renderUI: function _renderUI() {},
6876 _bindUI: function _bindUI() {},
6877 addShape: function addShape(type, cfg) {
6878 var canvas = this.get('canvas');
6879 cfg = cfg || {};
6880 var shapeType = SHAPE_MAP[type];
6881 if (!shapeType) {
6882 shapeType = Util.upperFirst(type);
6883 SHAPE_MAP[type] = shapeType;
6884 }
6885 if (cfg.attrs) {
6886 var attrs = cfg.attrs;
6887 if (type === 'text') {
6888 // 临时解决
6889 var topFontFamily = canvas.get('fontFamily');
6890 if (topFontFamily) {
6891 attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily;
6892 }
6893 }
6894 }
6895 cfg.canvas = canvas;
6896 cfg.type = type;
6897 var rst = new Shape[shapeType](cfg);
6898 this.add(rst);
6899 return rst;
6900 },
6901
6902 /** 添加图组
6903 * @param {Function|Object|undefined} param 图组类
6904 * @param {Object} cfg 配置项
6905 * @return {Object} rst 图组
6906 */
6907 addGroup: function addGroup(param, cfg) {
6908 var canvas = this.get('canvas');
6909 var rst = void 0;
6910 cfg = Util.merge({}, cfg);
6911 if (Util.isFunction(param)) {
6912 if (cfg) {
6913 cfg.canvas = canvas;
6914 cfg.parent = this;
6915 rst = new param(cfg);
6916 } else {
6917 rst = new param({
6918 canvas: canvas,
6919 parent: this
6920 });
6921 }
6922 this.add(rst);
6923 } else if (Util.isObject(param)) {
6924 param.canvas = canvas;
6925 rst = new Group(param);
6926 this.add(rst);
6927 } else if (param === undefined) {
6928 rst = new Group();
6929 this.add(rst);
6930 } else {
6931 return false;
6932 }
6933 return rst;
6934 },
6935
6936 /** 绘制背景
6937 * @param {Array} padding 内边距
6938 * @param {Attrs} attrs 图形属性
6939 * @param {Shape} backShape 背景图形
6940 * @return {Object} 背景层对象
6941 */
6942 renderBack: function renderBack(padding, attrs) {
6943 var backShape = this.get('backShape');
6944 var innerBox = this.getBBox();
6945 // const parent = this.get('parent'); // getParent
6946 Util.merge(attrs, {
6947 x: innerBox.minX - padding[3],
6948 y: innerBox.minY - padding[0],
6949 width: innerBox.width + padding[1] + padding[3],
6950 height: innerBox.height + padding[0] + padding[2]
6951 });
6952 if (backShape) {
6953 backShape.attr(attrs);
6954 } else {
6955 backShape = this.addShape('rect', {
6956 zIndex: -1,
6957 attrs: attrs
6958 });
6959 }
6960 this.set('backShape', backShape);
6961 this.sort();
6962 return backShape;
6963 },
6964 removeChild: function removeChild(item, destroy) {
6965 if (arguments.length >= 2) {
6966 if (this.contain(item)) {
6967 item.remove(destroy);
6968 }
6969 } else {
6970 if (arguments.length === 1) {
6971 if (Util.isBoolean(item)) {
6972 destroy = item;
6973 } else {
6974 if (this.contain(item)) {
6975 item.remove(true);
6976 }
6977 return this;
6978 }
6979 }
6980 if (arguments.length === 0) {
6981 destroy = true;
6982 }
6983
6984 Group.superclass.remove.call(this, destroy);
6985 }
6986 return this;
6987 },
6988
6989 /**
6990 * 向组中添加shape或者group
6991 * @param {Object} items 图形或者分组
6992 * @return {Object} group 本尊
6993 */
6994 add: function add(items) {
6995 var self = this;
6996 var children = self.get('children');
6997 if (Util.isArray(items)) {
6998 Util.each(items, function (item) {
6999 var parent = item.get('parent');
7000 if (parent) {
7001 parent.removeChild(item, false);
7002 }
7003 self._setCfgProperty(item);
7004 });
7005 children.push.apply(children, items);
7006 } else {
7007 var item = items;
7008 var parent = item.get('parent');
7009 if (parent) {
7010 parent.removeChild(item, false);
7011 }
7012 self._setCfgProperty(item);
7013 children.push(item);
7014 }
7015 return self;
7016 },
7017 contain: function contain(item) {
7018 var children = this.get('children');
7019 return children.indexOf(item) > -1;
7020 },
7021 getChildByIndex: function getChildByIndex(index) {
7022 var children = this.get('children');
7023 return children[index];
7024 },
7025 getFirst: function getFirst() {
7026 return this.getChildByIndex(0);
7027 },
7028 getLast: function getLast() {
7029 var lastIndex = this.get('children').length - 1;
7030 return this.getChildByIndex(lastIndex);
7031 },
7032 _setCfgProperty: function _setCfgProperty(item) {
7033 var self = this;
7034 var cfg = self.__cfg;
7035 item.__cfg.parent = self;
7036 item.__cfg.context = cfg.context;
7037 item.__cfg.canvas = cfg.canvas;
7038 var clip = item.__attrs.clip;
7039 if (clip) {
7040 clip.setSilent('parent', self);
7041 clip.setSilent('canvas', cfg.canvas);
7042 clip.setSilent('timeline', cfg.timeline);
7043 clip.setSilent('context', self.get('context'));
7044 }
7045 var children = item.__cfg.children;
7046 if (children) {
7047 Util.each(children, function (child) {
7048 item._setCfgProperty(child);
7049 });
7050 }
7051 },
7052 getBBox: function getBBox() {
7053 var self = this;
7054 var minX = Infinity;
7055 var maxX = -Infinity;
7056 var minY = Infinity;
7057 var maxY = -Infinity;
7058 var children = self.get('children');
7059 if (children.length > 0) {
7060 Util.each(children, function (child) {
7061 if (child.get('visible')) {
7062 var _box = child.getBBox();
7063 if (!_box) {
7064 return true;
7065 }
7066
7067 var leftTop = [_box.minX, _box.minY, 1];
7068 var leftBottom = [_box.minX, _box.maxY, 1];
7069 var rightTop = [_box.maxX, _box.minY, 1];
7070 var rightBottom = [_box.maxX, _box.maxY, 1];
7071
7072 child.apply(leftTop);
7073 child.apply(leftBottom);
7074 child.apply(rightTop);
7075 child.apply(rightBottom);
7076
7077 var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
7078 var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
7079 var boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
7080 var boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
7081
7082 if (boxMinX < minX) {
7083 minX = boxMinX;
7084 }
7085
7086 if (boxMaxX > maxX) {
7087 maxX = boxMaxX;
7088 }
7089
7090 if (boxMinY < minY) {
7091 minY = boxMinY;
7092 }
7093
7094 if (boxMaxY > maxY) {
7095 maxY = boxMaxY;
7096 }
7097 }
7098 });
7099 } else {
7100 minX = 0;
7101 maxX = 0;
7102 minY = 0;
7103 maxY = 0;
7104 }
7105
7106 var box = {
7107 minX: minX,
7108 minY: minY,
7109 maxX: maxX,
7110 maxY: maxY
7111 };
7112 box.x = box.minX;
7113 box.y = box.minY;
7114 box.width = box.maxX - box.minX;
7115 box.height = box.maxY - box.minY;
7116 return box;
7117 },
7118 drawInner: function drawInner(context) {
7119 var children = this.get('children');
7120 for (var i = 0; i < children.length; i++) {
7121 var child = children[i];
7122 child.draw(context);
7123 }
7124 return this;
7125 },
7126 getCount: function getCount() {
7127 return this.get('children').length;
7128 },
7129 sort: function sort() {
7130 var children = this.get('children');
7131 // 稳定排序
7132 Util.each(children, function (child, index) {
7133 child[INDEX] = index;
7134 return child;
7135 });
7136
7137 children.sort(getComparer(function (obj1, obj2) {
7138 return obj1.get('zIndex') - obj2.get('zIndex');
7139 }));
7140
7141 return this;
7142 },
7143 findById: function findById(id) {
7144 return this.find(function (item) {
7145 return item.get('id') === id;
7146 });
7147 },
7148
7149 /**
7150 * 根据查找函数查找分组或者图形
7151 * @param {Function} fn 匹配函数
7152 * @return {Canvas.Base} 分组或者图形
7153 */
7154 find: function find(fn) {
7155 if (Util.isString(fn)) {
7156 return this.findById(fn);
7157 }
7158 var children = this.get('children');
7159 var rst = null;
7160
7161 Util.each(children, function (item) {
7162 if (fn(item)) {
7163 rst = item;
7164 } else if (item.find) {
7165 rst = item.find(fn);
7166 }
7167 if (rst) {
7168 return false;
7169 }
7170 });
7171 return rst;
7172 },
7173
7174 /**
7175 * @param {Function} fn filter mathod
7176 * @return {Array} all the matching shapes and groups
7177 */
7178 findAll: function findAll(fn) {
7179 var children = this.get('children');
7180 var rst = [];
7181 var childRst = [];
7182 Util.each(children, function (item) {
7183 if (fn(item)) {
7184 rst.push(item);
7185 }
7186 if (item.findAllBy) {
7187 childRst = item.findAllBy(fn);
7188 rst = rst.concat(childRst);
7189 }
7190 });
7191 return rst;
7192 },
7193
7194 /**
7195 * @Deprecated
7196 * @param {Function} fn filter method
7197 * @return {Object} found shape or group
7198 */
7199 findBy: function findBy(fn) {
7200 var children = this.get('children');
7201 var rst = null;
7202
7203 Util.each(children, function (item) {
7204 if (fn(item)) {
7205 rst = item;
7206 } else if (item.findBy) {
7207 rst = item.findBy(fn);
7208 }
7209 if (rst) {
7210 return false;
7211 }
7212 });
7213 return rst;
7214 },
7215
7216 /**
7217 * @Deprecated
7218 * @param {Function} fn filter mathod
7219 * @return {Array} all the matching shapes and groups
7220 */
7221 findAllBy: function findAllBy(fn) {
7222 var children = this.get('children');
7223 var rst = [];
7224 var childRst = [];
7225 Util.each(children, function (item) {
7226 if (fn(item)) {
7227 rst.push(item);
7228 }
7229 if (item.findAllBy) {
7230 childRst = item.findAllBy(fn);
7231 rst = rst.concat(childRst);
7232 }
7233 });
7234 return rst;
7235 },
7236
7237 /**
7238 * 根据x,y轴坐标获取对应的图形
7239 * @param {Number} x x坐标
7240 * @param {Number} y y坐标
7241 * @return {Object} 最上面的图形
7242 */
7243 getShape: function getShape(x, y) {
7244 var self = this;
7245 var clip = self.__attrs.clip;
7246 var children = self.__cfg.children;
7247 var rst = void 0;
7248 if (clip) {
7249 if (clip.inside(x, y)) {
7250 rst = find(children, x, y);
7251 }
7252 } else {
7253 rst = find(children, x, y);
7254 }
7255 return rst;
7256 },
7257 clearTotalMatrix: function clearTotalMatrix() {
7258 var m = this.get('totalMatrix');
7259 if (m) {
7260 this.setSilent('totalMatrix', null);
7261 var children = this.__cfg.children;
7262 for (var i = 0; i < children.length; i++) {
7263 var child = children[i];
7264 child.clearTotalMatrix();
7265 }
7266 }
7267 },
7268 clear: function clear() {
7269 var children = this.get('children');
7270
7271 while (children.length !== 0) {
7272 children[children.length - 1].remove();
7273 }
7274 return this;
7275 },
7276 destroy: function destroy() {
7277 if (this.get('destroyed')) {
7278 return;
7279 }
7280 this.clear();
7281 Group.superclass.destroy.call(this);
7282 }
7283});
7284
7285module.exports = Group;
7286
7287/***/ }),
7288/* 68 */
7289/***/ (function(module, exports, __webpack_require__) {
7290
7291var Util = __webpack_require__(0);
7292var Attribute = __webpack_require__(151);
7293var Transform = __webpack_require__(152);
7294var Animate = __webpack_require__(44);
7295var Format = __webpack_require__(27);
7296var EventEmitter = __webpack_require__(45);
7297
7298var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'lineDashOffset'];
7299
7300var Element = function Element(cfg) {
7301 this.__cfg = {
7302 zIndex: 0,
7303 capture: true,
7304 visible: true,
7305 destroyed: false
7306 }; // 配置存放地
7307
7308 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
7309 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
7310 this.initTransform(); // 初始化变换
7311 this.init(); // 类型初始化
7312};
7313
7314Element.CFG = {
7315 /**
7316 * 唯一标示
7317 * @type {Number}
7318 */
7319 id: null,
7320 /**
7321 * Z轴的层叠关系,Z值越大离用户越近
7322 * @type {Number}
7323 */
7324 zIndex: 0,
7325 /**
7326 * Canvas对象
7327 * @type: {Object}
7328 */
7329 canvas: null,
7330 /**
7331 * 父元素指针
7332 * @type {Object}
7333 */
7334 parent: null,
7335 /**
7336 * 用来设置当前对象是否能被捕捉
7337 * true 能
7338 * false 不能
7339 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
7340 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
7341 * @type {Boolean}
7342 **/
7343 capture: true,
7344 /**
7345 * 画布的上下文
7346 * @type {Object}
7347 */
7348 context: null,
7349 /**
7350 * 是否显示
7351 * @type {Boolean}
7352 */
7353 visible: true,
7354 /**
7355 * 是否被销毁
7356 * @type: {Boolean}
7357 */
7358 destroyed: false
7359};
7360
7361Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
7362 init: function init() {
7363 this.setSilent('animable', true);
7364 this.setSilent('animating', false); // 初始时不处于动画状态
7365 var attrs = this.__attrs;
7366 if (attrs && attrs.rotate) {
7367 this.rotateAtStart(attrs.rotate);
7368 }
7369 },
7370 getParent: function getParent() {
7371 return this.get('parent');
7372 },
7373
7374 /**
7375 * 获取默认的配置信息
7376 * @protected
7377 * @return {Object} 默认的属性
7378 */
7379 getDefaultCfg: function getDefaultCfg() {
7380 return {};
7381 },
7382 set: function set(name, value) {
7383 if (name === 'zIndex' && this._beforeSetZIndex) {
7384 this._beforeSetZIndex(value);
7385 }
7386 if (name === 'loading' && this._beforeSetLoading) {
7387 this._beforeSetLoading(value);
7388 }
7389 this.__cfg[name] = value;
7390 return this;
7391 },
7392 setSilent: function setSilent(name, value) {
7393 this.__cfg[name] = value;
7394 },
7395 get: function get(name) {
7396 return this.__cfg[name];
7397 },
7398 draw: function draw(context) {
7399 if (this.get('destroyed')) {
7400 return;
7401 }
7402 if (this.get('visible')) {
7403 this.setContext(context);
7404 this.drawInner(context);
7405 this.restoreContext(context);
7406 }
7407 },
7408 setContext: function setContext(context) {
7409 var clip = this.__attrs.clip;
7410 context.save();
7411 if (clip) {
7412 // context.save();
7413 clip.resetTransform(context);
7414 clip.createPath(context);
7415 context.clip();
7416 // context.restore();
7417 }
7418 this.resetContext(context);
7419 this.resetTransform(context);
7420 },
7421 restoreContext: function restoreContext(context) {
7422 context.restore();
7423 },
7424 resetContext: function resetContext(context) {
7425 var elAttrs = this.__attrs;
7426 // var canvas = this.get('canvas');
7427 if (!this.isGroup) {
7428 // canvas.registShape(this); // 快速拾取方案暂时不执行
7429 for (var k in elAttrs) {
7430 if (SHAPE_ATTRS.indexOf(k) > -1) {
7431 // 非canvas属性不附加
7432 var v = elAttrs[k];
7433 if (k === 'fillStyle') {
7434 v = Format.parseStyle(v, this);
7435 }
7436 if (k === 'strokeStyle') {
7437 v = Format.parseStyle(v, this);
7438 }
7439 if (k === 'lineDash' && context.setLineDash) {
7440 if (Util.isArray(v)) {
7441 context.setLineDash(v);
7442 } else if (Util.isString(v)) {
7443 context.setLineDash(v.split(' '));
7444 }
7445 } else {
7446 context[k] = v;
7447 }
7448 }
7449 }
7450 }
7451 },
7452 drawInner: function drawInner() /* context */{},
7453 show: function show() {
7454 this.set('visible', true);
7455 return this;
7456 },
7457 hide: function hide() {
7458 this.set('visible', false);
7459 return this;
7460 },
7461 remove: function remove(destroy) {
7462 if (destroy === undefined) {
7463 destroy = true;
7464 }
7465
7466 if (this.get('parent')) {
7467 var parent = this.get('parent');
7468 var children = parent.get('children');
7469 Util.remove(children, this);
7470 }
7471
7472 if (destroy) {
7473 this.destroy();
7474 }
7475
7476 return this;
7477 },
7478 destroy: function destroy() {
7479 var destroyed = this.get('destroyed');
7480 if (destroyed) {
7481 return;
7482 }
7483 // 如果正在执行动画,清理动画
7484 if (this.get('animating')) {
7485 var timer = this.get('animateTimer');
7486 timer && timer.stop();
7487 }
7488 this.__cfg = {};
7489 this.__attrs = null;
7490 this.removeEvent(); // 移除所有的事件
7491 this.set('destroyed', true);
7492 },
7493 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
7494 this.__cfg.zIndex = zIndex;
7495
7496 if (!Util.isNil(this.get('parent'))) {
7497 this.get('parent').sort();
7498 }
7499 return zIndex;
7500 },
7501 _setAttrs: function _setAttrs(attrs) {
7502 this.attr(attrs);
7503 return attrs;
7504 },
7505 setZIndex: function setZIndex(zIndex) {
7506 this.__cfg.zIndex = zIndex;
7507 return zIndex;
7508 },
7509 clone: function clone() {
7510 return Util.clone(this);
7511 },
7512 getBBox: function getBBox() {
7513 return {
7514 minX: 0,
7515 maxX: 0,
7516 minY: 0,
7517 maxY: 0
7518 };
7519 }
7520});
7521
7522module.exports = Element;
7523
7524/***/ }),
7525/* 69 */
7526/***/ (function(module, exports, __webpack_require__) {
7527
7528var Util = __webpack_require__(0);
7529var Shape = __webpack_require__(1);
7530var Inside = __webpack_require__(3);
7531
7532var Rect = function Rect(cfg) {
7533 Rect.superclass.constructor.call(this, cfg);
7534};
7535
7536Rect.ATTRS = {
7537 x: 0,
7538 y: 0,
7539 width: 0,
7540 height: 0,
7541 radius: 0,
7542 lineWidth: 1
7543};
7544
7545Util.extend(Rect, Shape);
7546
7547Util.augment(Rect, {
7548 canFill: true,
7549 canStroke: true,
7550 type: 'rect',
7551 getDefaultAttrs: function getDefaultAttrs() {
7552 return {
7553 lineWidth: 1,
7554 radius: 0
7555 };
7556 },
7557 calculateBox: function calculateBox() {
7558 var self = this;
7559 var attrs = self.__attrs;
7560 var x = attrs.x;
7561 var y = attrs.y;
7562 var width = attrs.width;
7563 var height = attrs.height;
7564 var lineWidth = this.getHitLineWidth();
7565
7566 var halfWidth = lineWidth / 2;
7567 return {
7568 minX: x - halfWidth,
7569 minY: y - halfWidth,
7570 maxX: x + width + halfWidth,
7571 maxY: y + height + halfWidth
7572 };
7573 },
7574 isPointInPath: function isPointInPath(x, y) {
7575 var self = this;
7576 var fill = self.hasFill();
7577 var stroke = self.hasStroke();
7578
7579 if (fill && stroke) {
7580 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
7581 }
7582
7583 if (fill) {
7584 return self._isPointInFill(x, y);
7585 }
7586
7587 if (stroke) {
7588 return self._isPointInStroke(x, y);
7589 }
7590
7591 return false;
7592 },
7593 _isPointInFill: function _isPointInFill(x, y) {
7594 var context = this.get('context');
7595
7596 if (!context) return false;
7597 this.createPath();
7598 return context.isPointInPath(x, y);
7599 },
7600 _isPointInStroke: function _isPointInStroke(x, y) {
7601 var self = this;
7602 var attrs = self.__attrs;
7603 var rx = attrs.x;
7604 var ry = attrs.y;
7605 var width = attrs.width;
7606 var height = attrs.height;
7607 var radius = attrs.radius;
7608 var lineWidth = this.getHitLineWidth();
7609
7610 if (radius === 0) {
7611 var halfWidth = lineWidth / 2;
7612 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);
7613 }
7614
7615 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);
7616 },
7617 createPath: function createPath(context) {
7618 var self = this;
7619 var attrs = self.__attrs;
7620 var x = attrs.x;
7621 var y = attrs.y;
7622 var width = attrs.width;
7623 var height = attrs.height;
7624 var radius = attrs.radius;
7625 context = context || self.get('context');
7626
7627 context.beginPath();
7628 if (radius === 0) {
7629 // 改成原生的rect方法
7630 context.rect(x, y, width, height);
7631 } else {
7632 context.moveTo(x + radius, y);
7633 context.lineTo(x + width - radius, y);
7634 context.arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0, false);
7635 context.lineTo(x + width, y + height - radius);
7636 context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2, false);
7637 context.lineTo(x + radius, y + height);
7638 context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI, false);
7639 context.lineTo(x, y + radius);
7640 context.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2, false);
7641 context.closePath();
7642 }
7643 }
7644});
7645
7646module.exports = Rect;
7647
7648/***/ }),
7649/* 70 */
7650/***/ (function(module, exports, __webpack_require__) {
7651
7652var Util = __webpack_require__(0);
7653var Shape = __webpack_require__(1);
7654var Inside = __webpack_require__(3);
7655
7656var Circle = function Circle(cfg) {
7657 Circle.superclass.constructor.call(this, cfg);
7658};
7659
7660Circle.ATTRS = {
7661 x: 0,
7662 y: 0,
7663 r: 0,
7664 lineWidth: 1
7665};
7666
7667Util.extend(Circle, Shape);
7668
7669Util.augment(Circle, {
7670 canFill: true,
7671 canStroke: true,
7672 type: 'circle',
7673 getDefaultAttrs: function getDefaultAttrs() {
7674 return {
7675 lineWidth: 1
7676 };
7677 },
7678 calculateBox: function calculateBox() {
7679 var attrs = this.__attrs;
7680 var cx = attrs.x;
7681 var cy = attrs.y;
7682 var r = attrs.r;
7683 var lineWidth = this.getHitLineWidth();
7684 var halfWidth = lineWidth / 2 + r;
7685 return {
7686 minX: cx - halfWidth,
7687 minY: cy - halfWidth,
7688 maxX: cx + halfWidth,
7689 maxY: cy + halfWidth
7690 };
7691 },
7692 isPointInPath: function isPointInPath(x, y) {
7693 var fill = this.hasFill();
7694 var stroke = this.hasStroke();
7695 if (fill && stroke) {
7696 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
7697 }
7698
7699 if (fill) {
7700 return this._isPointInFill(x, y);
7701 }
7702
7703 if (stroke) {
7704 return this._isPointInStroke(x, y);
7705 }
7706
7707 return false;
7708 },
7709 _isPointInFill: function _isPointInFill(x, y) {
7710 var attrs = this.__attrs;
7711 var cx = attrs.x;
7712 var cy = attrs.y;
7713 var r = attrs.r;
7714
7715 return Inside.circle(cx, cy, r, x, y);
7716 },
7717 _isPointInStroke: function _isPointInStroke(x, y) {
7718 var attrs = this.__attrs;
7719 var cx = attrs.x;
7720 var cy = attrs.y;
7721 var r = attrs.r;
7722 var lineWidth = this.getHitLineWidth();
7723
7724 return Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y);
7725 },
7726 createPath: function createPath(context) {
7727 var attrs = this.__attrs;
7728 var cx = attrs.x;
7729 var cy = attrs.y;
7730 var r = attrs.r;
7731 context = context || self.get('context');
7732
7733 context.beginPath();
7734 context.arc(cx, cy, r, 0, Math.PI * 2, false);
7735 context.closePath();
7736 }
7737});
7738
7739module.exports = Circle;
7740
7741/***/ }),
7742/* 71 */
7743/***/ (function(module, exports, __webpack_require__) {
7744
7745var Util = __webpack_require__(0);
7746var Shape = __webpack_require__(1);
7747var Inside = __webpack_require__(3);
7748var mat3 = __webpack_require__(2).mat3;
7749var vec3 = __webpack_require__(2).vec3;
7750
7751var Ellipse = function Ellipse(cfg) {
7752 Ellipse.superclass.constructor.call(this, cfg);
7753};
7754
7755Ellipse.ATTRS = {
7756 x: 0,
7757 y: 0,
7758 rx: 1,
7759 ry: 1,
7760 lineWidth: 1
7761};
7762
7763Util.extend(Ellipse, Shape);
7764
7765Util.augment(Ellipse, {
7766 canFill: true,
7767 canStroke: true,
7768 type: 'ellipse',
7769 getDefaultAttrs: function getDefaultAttrs() {
7770 return {
7771 lineWidth: 1
7772 };
7773 },
7774 calculateBox: function calculateBox() {
7775 var attrs = this.__attrs;
7776 var cx = attrs.x;
7777 var cy = attrs.y;
7778 var rx = attrs.rx;
7779 var ry = attrs.ry;
7780 var lineWidth = this.getHitLineWidth();
7781 var halfXWidth = rx + lineWidth / 2;
7782 var halfYWidth = ry + lineWidth / 2;
7783
7784 return {
7785 minX: cx - halfXWidth,
7786 minY: cy - halfYWidth,
7787 maxX: cx + halfXWidth,
7788 maxY: cy + halfYWidth
7789 };
7790 },
7791 isPointInPath: function isPointInPath(x, y) {
7792 var fill = this.hasFill();
7793 var stroke = this.hasStroke();
7794
7795 if (fill && stroke) {
7796 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
7797 }
7798
7799 if (fill) {
7800 return this._isPointInFill(x, y);
7801 }
7802
7803 if (stroke) {
7804 return this._isPointInStroke(x, y);
7805 }
7806
7807 return false;
7808 },
7809 _isPointInFill: function _isPointInFill(x, y) {
7810 var attrs = this.__attrs;
7811 var cx = attrs.x;
7812 var cy = attrs.y;
7813 var rx = attrs.rx;
7814 var ry = attrs.ry;
7815
7816 var r = rx > ry ? rx : ry;
7817 var scaleX = rx > ry ? 1 : rx / ry;
7818 var scaleY = rx > ry ? ry / rx : 1;
7819
7820 var p = [x, y, 1];
7821 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
7822 mat3.scale(m, m, [scaleX, scaleY]);
7823 mat3.translate(m, m, [cx, cy]);
7824 var inm = mat3.invert([], m);
7825 vec3.transformMat3(p, p, inm);
7826
7827 return Inside.circle(0, 0, r, p[0], p[1]);
7828 },
7829 _isPointInStroke: function _isPointInStroke(x, y) {
7830 var attrs = this.__attrs;
7831 var cx = attrs.x;
7832 var cy = attrs.y;
7833 var rx = attrs.rx;
7834 var ry = attrs.ry;
7835 var lineWidth = this.getHitLineWidth();
7836
7837 var r = rx > ry ? rx : ry;
7838 var scaleX = rx > ry ? 1 : rx / ry;
7839 var scaleY = rx > ry ? ry / rx : 1;
7840 var p = [x, y, 1];
7841 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
7842 mat3.scale(m, m, [scaleX, scaleY]);
7843 mat3.translate(m, m, [cx, cy]);
7844 var inm = mat3.invert([], m);
7845 vec3.transformMat3(p, p, inm);
7846
7847 return Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]);
7848 },
7849 createPath: function createPath(context) {
7850 var attrs = this.__attrs;
7851 var cx = attrs.x;
7852 var cy = attrs.y;
7853 var rx = attrs.rx;
7854 var ry = attrs.ry;
7855
7856 context = context || self.get('context');
7857 var r = rx > ry ? rx : ry;
7858 var scaleX = rx > ry ? 1 : rx / ry;
7859 var scaleY = rx > ry ? ry / rx : 1;
7860
7861 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
7862 mat3.scale(m, m, [scaleX, scaleY]);
7863 mat3.translate(m, m, [cx, cy]);
7864 context.beginPath();
7865 context.save();
7866 context.transform(m[0], m[1], m[3], m[4], m[6], m[7]);
7867 context.arc(0, 0, r, 0, Math.PI * 2);
7868 context.restore();
7869 context.closePath();
7870 }
7871});
7872
7873module.exports = Ellipse;
7874
7875/***/ }),
7876/* 72 */
7877/***/ (function(module, exports, __webpack_require__) {
7878
7879var Util = __webpack_require__(0);
7880var Shape = __webpack_require__(1);
7881var PathSegment = __webpack_require__(31);
7882var Format = __webpack_require__(27);
7883var Arrow = __webpack_require__(7);
7884var PathUtil = __webpack_require__(21);
7885var CubicMath = __webpack_require__(16);
7886
7887var Path = function Path(cfg) {
7888 Path.superclass.constructor.call(this, cfg);
7889};
7890
7891Path.ATTRS = {
7892 path: null,
7893 lineWidth: 1,
7894 curve: null, // 曲线path
7895 tCache: null,
7896 startArrow: false,
7897 endArrow: false
7898};
7899
7900Util.extend(Path, Shape);
7901
7902Util.augment(Path, {
7903 canFill: true,
7904 canStroke: true,
7905 type: 'path',
7906 getDefaultAttrs: function getDefaultAttrs() {
7907 return {
7908 lineWidth: 1,
7909 startArrow: false,
7910 endArrow: false
7911 };
7912 },
7913 _afterSetAttrPath: function _afterSetAttrPath(path) {
7914 var self = this;
7915 if (Util.isNil(path)) {
7916 self.setSilent('segments', null);
7917 self.setSilent('box', undefined);
7918 return;
7919 }
7920 var pathArray = Format.parsePath(path);
7921 var preSegment = void 0;
7922 var segments = [];
7923
7924 if (!Util.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {
7925 return;
7926 }
7927 var count = pathArray.length;
7928 for (var i = 0; i < pathArray.length; i++) {
7929 var item = pathArray[i];
7930 preSegment = new PathSegment(item, preSegment, i === count - 1);
7931 segments.push(preSegment);
7932 }
7933 self.setSilent('segments', segments);
7934 self.set('tCache', null);
7935 this.setSilent('box', null);
7936 },
7937 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7938 if (objs.path) {
7939 this._afterSetAttrPath(objs.path);
7940 }
7941 },
7942 calculateBox: function calculateBox() {
7943 var self = this;
7944 var segments = self.get('segments');
7945
7946 if (!segments) {
7947 return null;
7948 }
7949 var lineWidth = this.getHitLineWidth();
7950 var minX = Infinity;
7951 var maxX = -Infinity;
7952 var minY = Infinity;
7953 var maxY = -Infinity;
7954 Util.each(segments, function (segment) {
7955 segment.getBBox(lineWidth);
7956 var box = segment.box;
7957 if (box) {
7958 if (box.minX < minX) {
7959 minX = box.minX;
7960 }
7961
7962 if (box.maxX > maxX) {
7963 maxX = box.maxX;
7964 }
7965
7966 if (box.minY < minY) {
7967 minY = box.minY;
7968 }
7969
7970 if (box.maxY > maxY) {
7971 maxY = box.maxY;
7972 }
7973 }
7974 });
7975 return {
7976 minX: minX,
7977 minY: minY,
7978 maxX: maxX,
7979 maxY: maxY
7980 };
7981 },
7982 isPointInPath: function isPointInPath(x, y) {
7983 var self = this;
7984 var fill = self.hasFill();
7985 var stroke = self.hasStroke();
7986
7987 if (fill && stroke) {
7988 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
7989 }
7990
7991 if (fill) {
7992 return self._isPointInFill(x, y);
7993 }
7994
7995 if (stroke) {
7996 return self._isPointInStroke(x, y);
7997 }
7998
7999 return false;
8000 },
8001 _isPointInFill: function _isPointInFill(x, y) {
8002 var self = this;
8003 var context = self.get('context');
8004 if (!context) return undefined;
8005 self.createPath();
8006 return context.isPointInPath(x, y);
8007 },
8008 _isPointInStroke: function _isPointInStroke(x, y) {
8009 var self = this;
8010 var segments = self.get('segments');
8011 if (!Util.isEmpty(segments)) {
8012 var lineWidth = self.getHitLineWidth();
8013 for (var i = 0, l = segments.length; i < l; i++) {
8014 if (segments[i].isInside(x, y, lineWidth)) {
8015 return true;
8016 }
8017 }
8018 }
8019
8020 return false;
8021 },
8022 _setTcache: function _setTcache() {
8023 var totalLength = 0;
8024 var tempLength = 0;
8025 var tCache = [];
8026 var segmentT = void 0;
8027 var segmentL = void 0;
8028 var segmentN = void 0;
8029 var l = void 0;
8030 var curve = this.curve;
8031
8032 if (!curve) {
8033 return;
8034 }
8035
8036 Util.each(curve, function (segment, i) {
8037 segmentN = curve[i + 1];
8038 l = segment.length;
8039 if (segmentN) {
8040 totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
8041 }
8042 });
8043
8044 Util.each(curve, function (segment, i) {
8045 segmentN = curve[i + 1];
8046 l = segment.length;
8047 if (segmentN) {
8048 segmentT = [];
8049 segmentT[0] = tempLength / totalLength;
8050 segmentL = CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
8051 tempLength += segmentL;
8052 segmentT[1] = tempLength / totalLength;
8053 tCache.push(segmentT);
8054 }
8055 });
8056
8057 this.tCache = tCache;
8058 },
8059 _calculateCurve: function _calculateCurve() {
8060 var self = this;
8061 var attrs = self.__attrs;
8062 var path = attrs.path;
8063 this.curve = PathUtil.pathTocurve(path);
8064 },
8065 getStartTangent: function getStartTangent() {
8066 var segments = this.get('segments');
8067 var startPoint = void 0,
8068 endPoint = void 0,
8069 tangent = void 0,
8070 result = void 0;
8071 if (segments.length > 1) {
8072 startPoint = segments[0].endPoint;
8073 endPoint = segments[1].endPoint;
8074 tangent = segments[1].startTangent;
8075 result = [];
8076 if (Util.isFunction(tangent)) {
8077 var v = tangent();
8078 result.push([startPoint.x - v[0], startPoint.y - v[1]]);
8079 result.push([startPoint.x, startPoint.y]);
8080 } else {
8081 result.push([endPoint.x, endPoint.y]);
8082 result.push([startPoint.x, startPoint.y]);
8083 }
8084 }
8085 return result;
8086 },
8087 getEndTangent: function getEndTangent() {
8088 var segments = this.get('segments');
8089 var segmentsLen = segments.length;
8090 var startPoint = void 0,
8091 endPoint = void 0,
8092 tangent = void 0,
8093 result = void 0;
8094 if (segmentsLen > 1) {
8095 startPoint = segments[segmentsLen - 2].endPoint;
8096 endPoint = segments[segmentsLen - 1].endPoint;
8097 tangent = segments[segmentsLen - 1].endTangent;
8098 result = [];
8099 if (Util.isFunction(tangent)) {
8100 var v = tangent();
8101 result.push([endPoint.x - v[0], endPoint.y - v[1]]);
8102 result.push([endPoint.x, endPoint.y]);
8103 } else {
8104 result.push([startPoint.x, startPoint.y]);
8105 result.push([endPoint.x, endPoint.y]);
8106 }
8107 }
8108 return result;
8109 },
8110 getPoint: function getPoint(t) {
8111 var tCache = this.tCache;
8112 var subt = void 0;
8113 var index = void 0;
8114
8115 if (!tCache) {
8116 this._calculateCurve();
8117 this._setTcache();
8118 tCache = this.tCache;
8119 }
8120
8121 var curve = this.curve;
8122
8123 if (!tCache) {
8124 if (curve) {
8125 return {
8126 x: curve[0][1],
8127 y: curve[0][2]
8128 };
8129 }
8130 return null;
8131 }
8132 Util.each(tCache, function (v, i) {
8133 if (t >= v[0] && t <= v[1]) {
8134 subt = (t - v[0]) / (v[1] - v[0]);
8135 index = i;
8136 }
8137 });
8138 var seg = curve[index];
8139 if (Util.isNil(seg) || Util.isNil(index)) {
8140 return null;
8141 }
8142 var l = seg.length;
8143 var nextSeg = curve[index + 1];
8144 return {
8145 x: CubicMath.at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
8146 y: CubicMath.at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
8147 };
8148 },
8149 createPath: function createPath(context) {
8150 var self = this;
8151 var segments = self.get('segments');
8152 if (!Util.isArray(segments)) return;
8153
8154 context = context || self.get('context');
8155
8156 context.beginPath();
8157 var segmentsLen = segments.length;
8158
8159 for (var i = 0; i < segmentsLen; i++) {
8160 segments[i].draw(context);
8161 }
8162 },
8163 afterPath: function afterPath(context) {
8164 var self = this;
8165 var attrs = self.__attrs;
8166 var segments = self.get('segments');
8167 var path = attrs.path;
8168 context = context || self.get('context');
8169 if (!Util.isArray(segments)) return;
8170 if (!attrs.startArrow && !attrs.endArrow) {
8171 return;
8172 }
8173 if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) {
8174 // 闭合路径不绘制箭头
8175 return;
8176 }
8177 var startPoints = self.getStartTangent();
8178 Arrow.addStartArrow(context, attrs, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]);
8179
8180 var endPoints = self.getEndTangent();
8181 Arrow.addEndArrow(context, attrs, endPoints[0][0], endPoints[0][1], endPoints[1][0], endPoints[1][1]);
8182 }
8183});
8184
8185module.exports = Path;
8186
8187/***/ }),
8188/* 73 */
8189/***/ (function(module, exports, __webpack_require__) {
8190
8191var Util = __webpack_require__(0);
8192var Shape = __webpack_require__(1);
8193var Inside = __webpack_require__(3);
8194
8195var CText = function CText(cfg) {
8196 CText.superclass.constructor.call(this, cfg);
8197};
8198
8199CText.ATTRS = {
8200 x: 0,
8201 y: 0,
8202 text: null,
8203 fontSize: 12,
8204 fontFamily: 'sans-serif',
8205 fontStyle: 'normal',
8206 fontWeight: 'normal',
8207 fontVariant: 'normal',
8208 textAlign: 'start',
8209 textBaseline: 'bottom',
8210 lineHeight: null,
8211 textArr: null
8212};
8213
8214Util.extend(CText, Shape);
8215
8216Util.augment(CText, {
8217 canFill: true,
8218 canStroke: true,
8219 type: 'text',
8220 getDefaultAttrs: function getDefaultAttrs() {
8221 return {
8222 lineWidth: 1,
8223 lineCount: 1,
8224 fontSize: 12,
8225 fontFamily: 'sans-serif',
8226 fontStyle: 'normal',
8227 fontWeight: 'normal',
8228 fontVariant: 'normal',
8229 textAlign: 'start',
8230 textBaseline: 'bottom'
8231 };
8232 },
8233 initTransform: function initTransform() {
8234 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
8235 var fontSize = this.__attrs.fontSize;
8236 if (fontSize && +fontSize < 12) {
8237 // 小于 12 像素的文本进行 scale 处理
8238 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
8239 }
8240 },
8241 _assembleFont: function _assembleFont() {
8242 // var self = this;
8243 var attrs = this.__attrs;
8244 var fontSize = attrs.fontSize;
8245 var fontFamily = attrs.fontFamily;
8246 var fontWeight = attrs.fontWeight;
8247 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
8248 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
8249 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
8250 attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
8251 },
8252 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
8253 /* this.attr({
8254 height: this.__getTextHeight()
8255 }); */
8256 this._assembleFont();
8257 },
8258 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
8259 this._assembleFont();
8260 },
8261 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
8262 this._assembleFont();
8263 },
8264 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
8265 this._assembleFont();
8266 },
8267 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
8268 this._assembleFont();
8269 },
8270 _afterSetAttrFont: function _afterSetAttrFont() {
8271 // this.attr('width', this.measureText());
8272 },
8273 _afterSetAttrText: function _afterSetAttrText() {
8274 var attrs = this.__attrs;
8275 var text = attrs.text;
8276 var textArr = void 0;
8277 if (Util.isString(text) && text.indexOf('\n') !== -1) {
8278 textArr = text.split('\n');
8279 var lineCount = textArr.length;
8280 attrs.lineCount = lineCount;
8281 attrs.textArr = textArr;
8282 }
8283 // attrs.height = this.__getTextHeight();
8284 // attrs.width = this.measureText();
8285 },
8286 _getTextHeight: function _getTextHeight() {
8287 var attrs = this.__attrs;
8288 var lineCount = attrs.lineCount;
8289 var fontSize = attrs.fontSize * 1;
8290 if (lineCount > 1) {
8291 var spaceingY = this._getSpaceingY();
8292 return fontSize * lineCount + spaceingY * (lineCount - 1);
8293 }
8294 return fontSize;
8295 },
8296
8297 // 计算浪费,效率低,待优化
8298 _afterSetAttrAll: function _afterSetAttrAll(objs) {
8299 var self = this;
8300 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
8301 self._assembleFont();
8302 }
8303
8304 if ('text' in objs) {
8305 self._afterSetAttrText(objs.text);
8306 }
8307 },
8308 isHitBox: function isHitBox() {
8309 return false;
8310 },
8311 calculateBox: function calculateBox() {
8312 var self = this;
8313 var attrs = self.__attrs;
8314 var x = attrs.x;
8315 var y = attrs.y;
8316 var width = self.measureText(); // attrs.width
8317 if (!width) {
8318 // 如果width不存在,四点共其实点
8319 return {
8320 minX: x,
8321 minY: y,
8322 maxX: x,
8323 maxY: y
8324 };
8325 }
8326 var height = self._getTextHeight(); // attrs.height
8327 var textAlign = attrs.textAlign;
8328 var textBaseline = attrs.textBaseline;
8329 var lineWidth = self.getHitLineWidth();
8330 var point = {
8331 x: x,
8332 y: y - height
8333 };
8334
8335 if (textAlign) {
8336 if (textAlign === 'end' || textAlign === 'right') {
8337 point.x -= width;
8338 } else if (textAlign === 'center') {
8339 point.x -= width / 2;
8340 }
8341 }
8342
8343 if (textBaseline) {
8344 if (textBaseline === 'top') {
8345 point.y += height;
8346 } else if (textBaseline === 'middle') {
8347 point.y += height / 2;
8348 }
8349 }
8350
8351 this.set('startPoint', point);
8352 var halfWidth = lineWidth / 2;
8353 return {
8354 minX: point.x - halfWidth,
8355 minY: point.y - halfWidth,
8356 maxX: point.x + width + halfWidth,
8357 maxY: point.y + height + halfWidth
8358 };
8359 },
8360 _getSpaceingY: function _getSpaceingY() {
8361 var attrs = this.__attrs;
8362 var lineHeight = attrs.lineHeight;
8363 var fontSize = attrs.fontSize * 1;
8364 return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
8365 },
8366 isPointInPath: function isPointInPath(x, y) {
8367 var self = this;
8368 var box = self.getBBox();
8369 if (self.hasFill() || self.hasStroke()) {
8370 return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y);
8371 }
8372 },
8373 drawInner: function drawInner(context) {
8374 var self = this;
8375 var attrs = self.__attrs;
8376 var text = attrs.text;
8377 if (!text) {
8378 return;
8379 }
8380 var textArr = attrs.textArr;
8381 var x = attrs.x;
8382 var y = attrs.y;
8383
8384 context.beginPath();
8385 if (self.hasStroke()) {
8386 var strokeOpacity = attrs.strokeOpacity;
8387 if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
8388 context.globalAlpha = strokeOpacity;
8389 }
8390 if (textArr) {
8391 self._drawTextArr(context, false);
8392 } else {
8393 context.strokeText(text, x, y);
8394 }
8395 context.globalAlpha = 1;
8396 }
8397 if (self.hasFill()) {
8398 var fillOpacity = attrs.fillOpacity;
8399 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
8400 context.globalAlpha = fillOpacity;
8401 }
8402 if (textArr) {
8403 self._drawTextArr(context, true);
8404 } else {
8405 context.fillText(text, x, y);
8406 }
8407 }
8408 },
8409 _drawTextArr: function _drawTextArr(context, fill) {
8410 var textArr = this.__attrs.textArr;
8411 var textBaseline = this.__attrs.textBaseline;
8412 var fontSize = this.__attrs.fontSize * 1;
8413 var spaceingY = this._getSpaceingY();
8414 var x = this.__attrs.x;
8415 var y = this.__attrs.y;
8416 var box = this.getBBox();
8417 var height = box.maxY - box.minY;
8418 var subY = void 0;
8419
8420 Util.each(textArr, function (subText, index) {
8421 subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;
8422 if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;
8423 if (textBaseline === 'top') subY += height - fontSize;
8424 if (fill) {
8425 context.fillText(subText, x, subY);
8426 } else {
8427 context.strokeText(subText, x, subY);
8428 }
8429 });
8430 },
8431 measureText: function measureText() {
8432 var self = this;
8433 var attrs = self.__attrs;
8434 var text = attrs.text;
8435 var font = attrs.font;
8436 var textArr = attrs.textArr;
8437 var measureWidth = void 0;
8438 var width = 0;
8439
8440 if (Util.isNil(text)) return undefined;
8441 var context = document.createElement('canvas').getContext('2d');
8442 context.save();
8443 context.font = font;
8444 if (textArr) {
8445 Util.each(textArr, function (subText) {
8446 measureWidth = context.measureText(subText).width;
8447 if (width < measureWidth) {
8448 width = measureWidth;
8449 }
8450 context.restore();
8451 });
8452 } else {
8453 width = context.measureText(text).width;
8454 context.restore();
8455 }
8456 return width;
8457 }
8458});
8459
8460module.exports = CText;
8461
8462/***/ }),
8463/* 74 */
8464/***/ (function(module, exports, __webpack_require__) {
8465
8466var Util = __webpack_require__(0);
8467var Shape = __webpack_require__(1);
8468var Inside = __webpack_require__(3);
8469var Arrow = __webpack_require__(7);
8470var LineMath = __webpack_require__(28);
8471
8472var Line = function Line(cfg) {
8473 Line.superclass.constructor.call(this, cfg);
8474};
8475
8476Line.ATTRS = {
8477 x1: 0,
8478 y1: 0,
8479 x2: 0,
8480 y2: 0,
8481 lineWidth: 1,
8482 startArrow: false,
8483 endArrow: false
8484};
8485
8486Util.extend(Line, Shape);
8487
8488Util.augment(Line, {
8489 canStroke: true,
8490 type: 'line',
8491 getDefaultAttrs: function getDefaultAttrs() {
8492 return {
8493 lineWidth: 1,
8494 startArrow: false,
8495 endArrow: false
8496 };
8497 },
8498 calculateBox: function calculateBox() {
8499 var attrs = this.__attrs;
8500 var x1 = attrs.x1,
8501 y1 = attrs.y1,
8502 x2 = attrs.x2,
8503 y2 = attrs.y2;
8504
8505 var lineWidth = this.getHitLineWidth();
8506 return LineMath.box(x1, y1, x2, y2, lineWidth);
8507 },
8508 isPointInPath: function isPointInPath(x, y) {
8509 var attrs = this.__attrs;
8510 var x1 = attrs.x1,
8511 y1 = attrs.y1,
8512 x2 = attrs.x2,
8513 y2 = attrs.y2;
8514
8515 var lineWidth = this.getHitLineWidth();
8516
8517 if (this.hasStroke()) {
8518 return Inside.line(x1, y1, x2, y2, lineWidth, x, y);
8519 }
8520
8521 return false;
8522 },
8523 createPath: function createPath(context) {
8524 var attrs = this.__attrs;
8525 var x1 = attrs.x1,
8526 y1 = attrs.y1,
8527 x2 = attrs.x2,
8528 y2 = attrs.y2;
8529
8530 context = context || self.get('context');
8531 context.beginPath();
8532 context.moveTo(x1, y1);
8533 context.lineTo(x2, y2);
8534 },
8535 afterPath: function afterPath(context) {
8536 var attrs = this.__attrs;
8537 var x1 = attrs.x1,
8538 y1 = attrs.y1,
8539 x2 = attrs.x2,
8540 y2 = attrs.y2;
8541
8542 context = context || this.get('context');
8543 if (attrs.startArrow) {
8544 Arrow.addStartArrow(context, attrs, x2, y2, x1, y1);
8545 }
8546 if (attrs.endArrow) {
8547 Arrow.addEndArrow(context, attrs, x1, y1, x2, y2);
8548 }
8549 },
8550 getPoint: function getPoint(t) {
8551 var attrs = this.__attrs;
8552 return {
8553 x: LineMath.at(attrs.x1, attrs.x2, t),
8554 y: LineMath.at(attrs.y1, attrs.y2, t)
8555 };
8556 }
8557});
8558
8559module.exports = Line;
8560
8561/***/ }),
8562/* 75 */
8563/***/ (function(module, exports, __webpack_require__) {
8564
8565var Util = __webpack_require__(0);
8566var Shape = __webpack_require__(1);
8567var Inside = __webpack_require__(3);
8568
8569var CImage = function CImage(cfg) {
8570 CImage.superclass.constructor.call(this, cfg);
8571};
8572
8573CImage.ATTRS = {
8574 x: 0,
8575 y: 0,
8576 img: undefined,
8577 width: 0,
8578 height: 0,
8579 sx: null,
8580 sy: null,
8581 swidth: null,
8582 sheight: null
8583};
8584
8585Util.extend(CImage, Shape);
8586
8587Util.augment(CImage, {
8588 type: 'image',
8589 _afterSetAttrImg: function _afterSetAttrImg(img) {
8590 this._setAttrImg(img);
8591 },
8592 _afterSetAttrAll: function _afterSetAttrAll(params) {
8593 if (params.img) {
8594 this._setAttrImg(params.img);
8595 }
8596 },
8597 isHitBox: function isHitBox() {
8598 return false;
8599 },
8600 calculateBox: function calculateBox() {
8601 var attrs = this.__attrs;
8602 var x = attrs.x;
8603 var y = attrs.y;
8604 var width = attrs.width;
8605 var height = attrs.height;
8606
8607 return {
8608 minX: x,
8609 minY: y,
8610 maxX: x + width,
8611 maxY: y + height
8612 };
8613 },
8614 isPointInPath: function isPointInPath(x, y) {
8615 var attrs = this.__attrs;
8616 if (this.get('toDraw') || !attrs.img) {
8617 return false;
8618 }
8619 var rx = attrs.x;
8620 var ry = attrs.y;
8621 var width = attrs.width;
8622 var height = attrs.height;
8623 return Inside.rect(rx, ry, width, height, x, y);
8624 },
8625 _beforeSetLoading: function _beforeSetLoading(loading) {
8626 var canvas = this.get('canvas');
8627 if (loading === false && this.get('toDraw') === true) {
8628 this.__cfg.loading = false;
8629 canvas.draw();
8630 }
8631 return loading;
8632 },
8633 _setAttrImg: function _setAttrImg(img) {
8634 var self = this;
8635 var attrs = self.__attrs;
8636 if (Util.isString(img)) {
8637 var image = new Image();
8638 image.onload = function () {
8639 if (self.get('destroyed')) return false;
8640 self.attr('imgSrc', img);
8641 self.attr('img', image);
8642 var callback = self.get('callback');
8643 if (callback) {
8644 callback.call(self);
8645 }
8646 self.set('loading', false);
8647 };
8648 image.src = img;
8649 image.crossOrigin = 'Anonymous';
8650 self.set('loading', true);
8651 } else if (img instanceof Image) {
8652 if (!attrs.width) {
8653 self.attr('width', img.width);
8654 }
8655
8656 if (!attrs.height) {
8657 self.attr('height', img.height);
8658 }
8659 return img;
8660 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
8661 if (!attrs.width) {
8662 self.attr('width', Number(img.getAttribute('width')));
8663 }
8664
8665 if (!attrs.height) {
8666 self.attr('height', Number(img.getAttribute('height')));
8667 }
8668 return img;
8669 } else if (img instanceof ImageData) {
8670 if (!attrs.width) {
8671 self.attr('width', img.width);
8672 }
8673
8674 if (!attrs.height) {
8675 self.attr('height', img.height);
8676 }
8677 return img;
8678 } else {
8679 return null;
8680 }
8681 },
8682 drawInner: function drawInner(context) {
8683 if (this.get('loading')) {
8684 this.set('toDraw', true);
8685 return;
8686 }
8687 this._drawImage(context);
8688 },
8689 _drawImage: function _drawImage(context) {
8690 var attrs = this.__attrs;
8691 var x = attrs.x;
8692 var y = attrs.y;
8693 var image = attrs.img;
8694 var width = attrs.width;
8695 var height = attrs.height;
8696 var sx = attrs.sx;
8697 var sy = attrs.sy;
8698 var swidth = attrs.swidth;
8699 var sheight = attrs.sheight;
8700 this.set('toDraw', false);
8701
8702 var img = image;
8703 if (img instanceof ImageData) {
8704 img = new Image();
8705 img.src = image;
8706 }
8707 if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
8708 if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) {
8709 context.drawImage(img, x, y, width, height);
8710 return;
8711 }
8712 if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) {
8713 context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);
8714 return;
8715 }
8716 }
8717 return;
8718 }
8719});
8720
8721module.exports = CImage;
8722
8723/***/ }),
8724/* 76 */
8725/***/ (function(module, exports, __webpack_require__) {
8726
8727var Util = __webpack_require__(0);
8728var Shape = __webpack_require__(1);
8729var Inside = __webpack_require__(3);
8730
8731var Polygon = function Polygon(cfg) {
8732 Polygon.superclass.constructor.call(this, cfg);
8733};
8734
8735Polygon.ATTRS = {
8736 points: null,
8737 lineWidth: 1
8738};
8739
8740Util.extend(Polygon, Shape);
8741
8742Util.augment(Polygon, {
8743 canFill: true,
8744 canStroke: true,
8745 type: 'polygon',
8746 getDefaultAttrs: function getDefaultAttrs() {
8747 return {
8748 lineWidth: 1
8749 };
8750 },
8751 calculateBox: function calculateBox() {
8752 var self = this;
8753 var attrs = self.__attrs;
8754 var points = attrs.points;
8755 var lineWidth = this.getHitLineWidth();
8756 if (!points || points.length === 0) {
8757 return null;
8758 }
8759 var minX = Infinity;
8760 var minY = Infinity;
8761 var maxX = -Infinity;
8762 var maxY = -Infinity;
8763
8764 Util.each(points, function (point) {
8765 var x = point[0];
8766 var y = point[1];
8767 if (x < minX) {
8768 minX = x;
8769 }
8770 if (x > maxX) {
8771 maxX = x;
8772 }
8773
8774 if (y < minY) {
8775 minY = y;
8776 }
8777
8778 if (y > maxY) {
8779 maxY = y;
8780 }
8781 });
8782
8783 var halfWidth = lineWidth / 2;
8784 return {
8785 minX: minX - halfWidth,
8786 minY: minY - halfWidth,
8787 maxX: maxX + halfWidth,
8788 maxY: maxY + halfWidth
8789 };
8790 },
8791 isPointInPath: function isPointInPath(x, y) {
8792 var self = this;
8793 var fill = self.hasFill();
8794 var stroke = self.hasStroke();
8795
8796 if (fill && stroke) {
8797 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
8798 }
8799
8800 if (fill) {
8801 return self._isPointInFill(x, y);
8802 }
8803
8804 if (stroke) {
8805 return self._isPointInStroke(x, y);
8806 }
8807
8808 return false;
8809 },
8810 _isPointInFill: function _isPointInFill(x, y) {
8811 var self = this;
8812 var context = self.get('context');
8813 self.createPath();
8814 return context.isPointInPath(x, y);
8815 },
8816 _isPointInStroke: function _isPointInStroke(x, y) {
8817 var self = this;
8818 var attrs = self.__attrs;
8819 var points = attrs.points;
8820 if (points.length < 2) {
8821 return false;
8822 }
8823 var lineWidth = this.getHitLineWidth();
8824 var outPoints = points.slice(0);
8825 if (points.length >= 3) {
8826 outPoints.push(points[0]);
8827 }
8828
8829 return Inside.polyline(outPoints, lineWidth, x, y);
8830 },
8831 createPath: function createPath(context) {
8832 var self = this;
8833 var attrs = self.__attrs;
8834 var points = attrs.points;
8835 if (points.length < 2) {
8836 return;
8837 }
8838 context = context || self.get('context');
8839 context.beginPath();
8840 Util.each(points, function (point, index) {
8841 if (index === 0) {
8842 context.moveTo(point[0], point[1]);
8843 } else {
8844 context.lineTo(point[0], point[1]);
8845 }
8846 });
8847 context.closePath();
8848 }
8849});
8850
8851module.exports = Polygon;
8852
8853/***/ }),
8854/* 77 */
8855/***/ (function(module, exports, __webpack_require__) {
8856
8857var Util = __webpack_require__(0);
8858var Shape = __webpack_require__(1);
8859var Inside = __webpack_require__(3);
8860var Arrow = __webpack_require__(7);
8861var LineMath = __webpack_require__(28);
8862
8863var Polyline = function Polyline(cfg) {
8864 Polyline.superclass.constructor.call(this, cfg);
8865};
8866
8867Polyline.ATTRS = {
8868 points: null,
8869 lineWidth: 1,
8870 startArrow: false,
8871 endArrow: false,
8872 tCache: null
8873};
8874
8875Util.extend(Polyline, Shape);
8876
8877Util.augment(Polyline, {
8878 canStroke: true,
8879 type: 'polyline',
8880 tCache: null, // 缓存各点的t
8881 getDefaultAttrs: function getDefaultAttrs() {
8882 return {
8883 lineWidth: 1,
8884 startArrow: false,
8885 endArrow: false
8886 };
8887 },
8888 calculateBox: function calculateBox() {
8889 var self = this;
8890 var attrs = self.__attrs;
8891 var lineWidth = this.getHitLineWidth();
8892 var points = attrs.points;
8893 if (!points || points.length === 0) {
8894 return null;
8895 }
8896 var minX = Infinity;
8897 var minY = Infinity;
8898 var maxX = -Infinity;
8899 var maxY = -Infinity;
8900
8901 Util.each(points, function (point) {
8902 var x = point[0];
8903 var y = point[1];
8904 if (x < minX) {
8905 minX = x;
8906 }
8907 if (x > maxX) {
8908 maxX = x;
8909 }
8910
8911 if (y < minY) {
8912 minY = y;
8913 }
8914
8915 if (y > maxY) {
8916 maxY = y;
8917 }
8918 });
8919
8920 var halfWidth = lineWidth / 2;
8921 return {
8922 minX: minX - halfWidth,
8923 minY: minY - halfWidth,
8924 maxX: maxX + halfWidth,
8925 maxY: maxY + halfWidth
8926 };
8927 },
8928 _setTcache: function _setTcache() {
8929 var self = this;
8930 var attrs = self.__attrs;
8931 var points = attrs.points;
8932 var totalLength = 0;
8933 var tempLength = 0;
8934 var tCache = [];
8935 var segmentT = void 0;
8936 var segmentL = void 0;
8937 if (!points || points.length === 0) {
8938 return;
8939 }
8940
8941 Util.each(points, function (p, i) {
8942 if (points[i + 1]) {
8943 totalLength += LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
8944 }
8945 });
8946 if (totalLength <= 0) {
8947 return;
8948 }
8949 Util.each(points, function (p, i) {
8950 if (points[i + 1]) {
8951 segmentT = [];
8952 segmentT[0] = tempLength / totalLength;
8953 segmentL = LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
8954 tempLength += segmentL;
8955 segmentT[1] = tempLength / totalLength;
8956 tCache.push(segmentT);
8957 }
8958 });
8959 this.tCache = tCache;
8960 },
8961 isPointInPath: function isPointInPath(x, y) {
8962 var self = this;
8963 var attrs = self.__attrs;
8964 if (self.hasStroke()) {
8965 var points = attrs.points;
8966 if (points.length < 2) {
8967 return false;
8968 }
8969 var lineWidth = attrs.lineWidth;
8970 return Inside.polyline(points, lineWidth, x, y);
8971 }
8972 return false;
8973 },
8974 createPath: function createPath(context) {
8975 var self = this;
8976 var attrs = self.__attrs;
8977 var points = attrs.points;
8978 var l = void 0;
8979 var i = void 0;
8980
8981 if (points.length < 2) {
8982 return;
8983 }
8984 context = context || self.get('context');
8985 context.beginPath();
8986
8987 context.moveTo(points[0][0], points[0][1]);
8988 for (i = 1, l = points.length - 1; i < l; i++) {
8989 context.lineTo(points[i][0], points[i][1]);
8990 }
8991 context.lineTo(points[l][0], points[l][1]);
8992 },
8993 getStartTangent: function getStartTangent() {
8994 var points = this.__attrs.points;
8995 var result = [];
8996 result.push([points[1][0], points[1][1]]);
8997 result.push([points[0][0], points[0][1]]);
8998 return result;
8999 },
9000 getEndTangent: function getEndTangent() {
9001 var points = this.__attrs.points;
9002 var l = points.length - 1;
9003 var result = [];
9004 result.push([points[l - 1][0], points[l - 1][1]]);
9005 result.push([points[l][0], points[l][1]]);
9006 return result;
9007 },
9008 afterPath: function afterPath(context) {
9009 var self = this;
9010 var attrs = self.__attrs;
9011 var points = attrs.points;
9012 var l = points.length - 1;
9013 context = context || self.get('context');
9014
9015 if (attrs.startArrow) {
9016 Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]);
9017 }
9018 if (attrs.endArrow) {
9019 Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]);
9020 }
9021 },
9022 getPoint: function getPoint(t) {
9023 var attrs = this.__attrs;
9024 var points = attrs.points;
9025 var tCache = this.tCache;
9026 var subt = void 0;
9027 var index = void 0;
9028 if (!tCache) {
9029 this._setTcache();
9030 tCache = this.tCache;
9031 }
9032 Util.each(tCache, function (v, i) {
9033 if (t >= v[0] && t <= v[1]) {
9034 subt = (t - v[0]) / (v[1] - v[0]);
9035 index = i;
9036 }
9037 });
9038 return {
9039 x: LineMath.at(points[index][0], points[index + 1][0], subt),
9040 y: LineMath.at(points[index][1], points[index + 1][1], subt)
9041 };
9042 }
9043});
9044
9045module.exports = Polyline;
9046
9047/***/ }),
9048/* 78 */
9049/***/ (function(module, exports, __webpack_require__) {
9050
9051var Util = __webpack_require__(0);
9052var Shape = __webpack_require__(1);
9053var Inside = __webpack_require__(3);
9054var ArcMath = __webpack_require__(30);
9055var Arrow = __webpack_require__(7);
9056
9057function _getArcX(x, radius, angle) {
9058 return x + radius * Math.cos(angle);
9059}
9060function _getArcY(y, radius, angle) {
9061 return y + radius * Math.sin(angle);
9062}
9063
9064var Arc = function Arc(cfg) {
9065 Arc.superclass.constructor.call(this, cfg);
9066};
9067
9068Arc.ATTRS = {
9069 x: 0,
9070 y: 0,
9071 r: 0,
9072 startAngle: 0,
9073 endAngle: 0,
9074 clockwise: false,
9075 lineWidth: 1,
9076 startArrow: false,
9077 endArrow: false
9078};
9079
9080Util.extend(Arc, Shape);
9081
9082Util.augment(Arc, {
9083 canStroke: true,
9084 type: 'arc',
9085 getDefaultAttrs: function getDefaultAttrs() {
9086 return {
9087 x: 0,
9088 y: 0,
9089 r: 0,
9090 startAngle: 0,
9091 endAngle: 0,
9092 clockwise: false,
9093 lineWidth: 1,
9094 startArrow: false,
9095 endArrow: false
9096 };
9097 },
9098 calculateBox: function calculateBox() {
9099 var attrs = this.__attrs;
9100 var x = attrs.x,
9101 y = attrs.y,
9102 r = attrs.r,
9103 startAngle = attrs.startAngle,
9104 endAngle = attrs.endAngle,
9105 clockwise = attrs.clockwise;
9106
9107 var lineWidth = this.getHitLineWidth();
9108 var halfWidth = lineWidth / 2;
9109 var box = ArcMath.box(x, y, r, startAngle, endAngle, clockwise);
9110 box.minX -= halfWidth;
9111 box.minY -= halfWidth;
9112 box.maxX += halfWidth;
9113 box.maxY += halfWidth;
9114 return box;
9115 },
9116 getStartTangent: function getStartTangent() {
9117 var attrs = this.__attrs;
9118 var x = attrs.x,
9119 y = attrs.y,
9120 startAngle = attrs.startAngle,
9121 r = attrs.r,
9122 clockwise = attrs.clockwise;
9123
9124 var diff = Math.PI / 180;
9125 if (clockwise) {
9126 diff *= -1;
9127 }
9128 var result = [];
9129 var x1 = _getArcX(x, r, startAngle + diff);
9130 var y1 = _getArcY(y, r, startAngle + diff);
9131 var x2 = _getArcX(x, r, startAngle);
9132 var y2 = _getArcY(y, r, startAngle);
9133 result.push([x1, y1]);
9134 result.push([x2, y2]);
9135 return result;
9136 },
9137 getEndTangent: function getEndTangent() {
9138 var attrs = this.__attrs;
9139 var x = attrs.x,
9140 y = attrs.y,
9141 endAngle = attrs.endAngle,
9142 r = attrs.r,
9143 clockwise = attrs.clockwise;
9144
9145 var diff = Math.PI / 180;
9146 var result = [];
9147 if (clockwise) {
9148 diff *= -1;
9149 }
9150 var x1 = _getArcX(x, r, endAngle + diff);
9151 var y1 = _getArcY(y, r, endAngle + diff);
9152 var x2 = _getArcX(x, r, endAngle);
9153 var y2 = _getArcY(y, r, endAngle);
9154 result.push([x2, y2]);
9155 result.push([x1, y1]);
9156 return result;
9157 },
9158 isPointInPath: function isPointInPath(x, y) {
9159 var attrs = this.__attrs;
9160 var cx = attrs.x;
9161 var cy = attrs.y;
9162 var r = attrs.r,
9163 startAngle = attrs.startAngle,
9164 endAngle = attrs.endAngle,
9165 clockwise = attrs.clockwise;
9166
9167 var lineWidth = this.getHitLineWidth();
9168 if (this.hasStroke()) {
9169 return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y);
9170 }
9171 return false;
9172 },
9173 createPath: function createPath(context) {
9174 var attrs = this.__attrs;
9175 var x = attrs.x,
9176 y = attrs.y,
9177 r = attrs.r,
9178 startAngle = attrs.startAngle,
9179 endAngle = attrs.endAngle,
9180 clockwise = attrs.clockwise;
9181
9182 context = context || self.get('context');
9183
9184 context.beginPath();
9185 context.arc(x, y, r, startAngle, endAngle, clockwise);
9186 },
9187 afterPath: function afterPath(context) {
9188 var attrs = this.__attrs;
9189 context = context || this.get('context');
9190
9191 if (attrs.startArrow) {
9192 var startPoints = this.getStartTangent();
9193 Arrow.addStartArrow(context, attrs, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]);
9194 }
9195
9196 if (attrs.endArrow) {
9197 var endPoints = this.getEndTangent();
9198 Arrow.addEndArrow(context, attrs, endPoints[0][0], endPoints[0][1], endPoints[1][0], endPoints[1][1]);
9199 }
9200 }
9201});
9202
9203module.exports = Arc;
9204
9205/***/ }),
9206/* 79 */
9207/***/ (function(module, exports, __webpack_require__) {
9208
9209var Util = __webpack_require__(0);
9210var Shape = __webpack_require__(1);
9211var Inside = __webpack_require__(3);
9212var ArcMath = __webpack_require__(30);
9213var vec2 = __webpack_require__(2).vec2;
9214
9215var Fan = function Fan(cfg) {
9216 Fan.superclass.constructor.call(this, cfg);
9217};
9218
9219Fan.ATTRS = {
9220 x: 0,
9221 y: 0,
9222 rs: 0,
9223 re: 0,
9224 startAngle: 0,
9225 endAngle: 0,
9226 clockwise: false,
9227 lineWidth: 1
9228};
9229
9230Util.extend(Fan, Shape);
9231
9232Util.augment(Fan, {
9233 canFill: true,
9234 canStroke: true,
9235 type: 'fan',
9236 getDefaultAttrs: function getDefaultAttrs() {
9237 return {
9238 clockwise: false,
9239 lineWidth: 1,
9240 rs: 0,
9241 re: 0
9242 };
9243 },
9244 calculateBox: function calculateBox() {
9245 var self = this;
9246 var attrs = self.__attrs;
9247 var cx = attrs.x;
9248 var cy = attrs.y;
9249 var rs = attrs.rs;
9250 var re = attrs.re;
9251 var startAngle = attrs.startAngle;
9252 var endAngle = attrs.endAngle;
9253 var clockwise = attrs.clockwise;
9254 var lineWidth = this.getHitLineWidth();
9255
9256 var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise);
9257 var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise);
9258 var minX = Math.min(boxs.minX, boxe.minX);
9259 var minY = Math.min(boxs.minY, boxe.minY);
9260 var maxX = Math.max(boxs.maxX, boxe.maxX);
9261 var maxY = Math.max(boxs.maxY, boxe.maxY);
9262
9263 var halfWidth = lineWidth / 2;
9264 return {
9265 minX: minX - halfWidth,
9266 minY: minY - halfWidth,
9267 maxX: maxX + halfWidth,
9268 maxY: maxY + halfWidth
9269 };
9270 },
9271 isPointInPath: function isPointInPath(x, y) {
9272 var fill = this.hasFill();
9273 var stroke = this.hasStroke();
9274
9275 if (fill && stroke) {
9276 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
9277 }
9278
9279 if (fill) {
9280 return this._isPointInFill(x, y);
9281 }
9282
9283 if (stroke) {
9284 return this._isPointInStroke(x, y);
9285 }
9286 return false;
9287 },
9288 _isPointInFill: function _isPointInFill(x, y) {
9289 var attrs = this.__attrs;
9290 var cx = attrs.x;
9291 var cy = attrs.y;
9292 var rs = attrs.rs;
9293 var re = attrs.re;
9294 var startAngle = attrs.startAngle;
9295 var endAngle = attrs.endAngle;
9296 var clockwise = attrs.clockwise;
9297 var v1 = [1, 0];
9298 var subv = [x - cx, y - cy];
9299 var angle = vec2.angleTo(v1, subv);
9300
9301 var angle1 = ArcMath.nearAngle(angle, startAngle, endAngle, clockwise);
9302
9303 if (Util.isNumberEqual(angle, angle1)) {
9304 var ls = vec2.squaredLength(subv);
9305 if (rs * rs <= ls && ls <= re * re) {
9306 return true;
9307 }
9308 }
9309 return false;
9310 },
9311 _isPointInStroke: function _isPointInStroke(x, y) {
9312 var attrs = this.__attrs;
9313 var cx = attrs.x;
9314 var cy = attrs.y;
9315 var rs = attrs.rs;
9316 var re = attrs.re;
9317 var startAngle = attrs.startAngle;
9318 var endAngle = attrs.endAngle;
9319 var clockwise = attrs.clockwise;
9320 var lineWidth = this.getHitLineWidth();
9321
9322 var ssp = {
9323 x: Math.cos(startAngle) * rs + cx,
9324 y: Math.sin(startAngle) * rs + cy
9325 };
9326 var sep = {
9327 x: Math.cos(startAngle) * re + cx,
9328 y: Math.sin(startAngle) * re + cy
9329 };
9330 var esp = {
9331 x: Math.cos(endAngle) * rs + cx,
9332 y: Math.sin(endAngle) * rs + cy
9333 };
9334 var eep = {
9335 x: Math.cos(endAngle) * re + cx,
9336 y: Math.sin(endAngle) * re + cy
9337 };
9338
9339 if (Inside.line(ssp.x, ssp.y, sep.x, sep.y, lineWidth, x, y)) {
9340 return true;
9341 }
9342
9343 if (Inside.line(esp.x, esp.y, eep.x, eep.y, lineWidth, x, y)) {
9344 return true;
9345 }
9346
9347 if (Inside.arcline(cx, cy, rs, startAngle, endAngle, clockwise, lineWidth, x, y)) {
9348 return true;
9349 }
9350
9351 if (Inside.arcline(cx, cy, re, startAngle, endAngle, clockwise, lineWidth, x, y)) {
9352 return true;
9353 }
9354
9355 return false;
9356 },
9357 createPath: function createPath(context) {
9358 var attrs = this.__attrs;
9359 var cx = attrs.x;
9360 var cy = attrs.y;
9361 var rs = attrs.rs;
9362 var re = attrs.re;
9363 var startAngle = attrs.startAngle;
9364 var endAngle = attrs.endAngle;
9365 var clockwise = attrs.clockwise;
9366
9367 var ssp = {
9368 x: Math.cos(startAngle) * rs + cx,
9369 y: Math.sin(startAngle) * rs + cy
9370 };
9371 var sep = {
9372 x: Math.cos(startAngle) * re + cx,
9373 y: Math.sin(startAngle) * re + cy
9374 };
9375 var esp = {
9376 x: Math.cos(endAngle) * rs + cx,
9377 y: Math.sin(endAngle) * rs + cy
9378 };
9379
9380 context = context || self.get('context');
9381 context.beginPath();
9382 context.moveTo(ssp.x, ssp.y);
9383 context.lineTo(sep.x, sep.y);
9384 context.arc(cx, cy, re, startAngle, endAngle, clockwise);
9385 context.lineTo(esp.x, esp.y);
9386 context.arc(cx, cy, rs, endAngle, startAngle, !clockwise);
9387 context.closePath();
9388 }
9389});
9390
9391module.exports = Fan;
9392
9393/***/ }),
9394/* 80 */
9395/***/ (function(module, exports, __webpack_require__) {
9396
9397var Util = __webpack_require__(0);
9398var Shape = __webpack_require__(1);
9399var Inside = __webpack_require__(3);
9400var Arrow = __webpack_require__(7);
9401var CubicMath = __webpack_require__(16);
9402
9403var Cubic = function Cubic(cfg) {
9404 Cubic.superclass.constructor.call(this, cfg);
9405};
9406
9407Cubic.ATTRS = {
9408 p1: null, // 起始点
9409 p2: null, // 第一个控制点
9410 p3: null, // 第二个控制点
9411 p4: null, // 终点
9412 lineWidth: 1,
9413 startArrow: false,
9414 endArrow: false
9415};
9416
9417Util.extend(Cubic, Shape);
9418
9419Util.augment(Cubic, {
9420 canStroke: true,
9421 type: 'cubic',
9422 getDefaultAttrs: function getDefaultAttrs() {
9423 return {
9424 lineWidth: 1,
9425 startArrow: false,
9426 endArrow: false
9427 };
9428 },
9429 calculateBox: function calculateBox() {
9430 var attrs = this.__attrs;
9431 var p1 = attrs.p1,
9432 p2 = attrs.p2,
9433 p3 = attrs.p3,
9434 p4 = attrs.p4;
9435
9436 var lineWidth = this.getHitLineWidth();
9437 var i = void 0;
9438 var l = void 0;
9439
9440 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
9441 return null;
9442 }
9443 var halfWidth = lineWidth / 2;
9444
9445 var xDim = CubicMath.extrema(p1[0], p2[0], p3[0], p4[0]);
9446 for (i = 0, l = xDim.length; i < l; i++) {
9447 xDim[i] = CubicMath.at(p1[0], p2[0], p3[0], p4[0], xDim[i]);
9448 }
9449 var yDim = CubicMath.extrema(p1[1], p2[1], p3[1], p4[1]);
9450 for (i = 0, l = yDim.length; i < l; i++) {
9451 yDim[i] = CubicMath.at(p1[1], p2[1], p3[1], p4[1], yDim[i]);
9452 }
9453 xDim.push(p1[0], p4[0]);
9454 yDim.push(p1[1], p4[1]);
9455
9456 return {
9457 minX: Math.min.apply(Math, xDim) - halfWidth,
9458 maxX: Math.max.apply(Math, xDim) + halfWidth,
9459 minY: Math.min.apply(Math, yDim) - halfWidth,
9460 maxY: Math.max.apply(Math, yDim) + halfWidth
9461 };
9462 },
9463 isPointInPath: function isPointInPath(x, y) {
9464 var attrs = this.__attrs;
9465 var p1 = attrs.p1,
9466 p2 = attrs.p2,
9467 p3 = attrs.p3,
9468 p4 = attrs.p4;
9469
9470 var lineWidth = this.getHitLineWidth();
9471 return Inside.cubicline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], p4[0], p4[1], lineWidth, x, y);
9472 },
9473 createPath: function createPath(context) {
9474 var attrs = this.__attrs;
9475 var p1 = attrs.p1,
9476 p2 = attrs.p2,
9477 p3 = attrs.p3,
9478 p4 = attrs.p4;
9479
9480 context = context || self.get('context');
9481 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
9482 return;
9483 }
9484 context.beginPath();
9485 context.moveTo(p1[0], p1[1]);
9486 context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]);
9487 },
9488 afterPath: function afterPath(context) {
9489 var attrs = this.__attrs;
9490 var p1 = attrs.p1,
9491 p2 = attrs.p2,
9492 p3 = attrs.p3,
9493 p4 = attrs.p4;
9494
9495 context = context || this.get('context');
9496 if (attrs.startArrow) {
9497 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
9498 }
9499 if (attrs.endArrow) {
9500 Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]);
9501 }
9502 },
9503 getPoint: function getPoint(t) {
9504 var attrs = this.__attrs;
9505 return {
9506 x: CubicMath.at(attrs.p4[0], attrs.p3[0], attrs.p2[0], attrs.p1[0], t),
9507 y: CubicMath.at(attrs.p4[1], attrs.p3[1], attrs.p2[1], attrs.p1[1], t)
9508 };
9509 }
9510});
9511
9512module.exports = Cubic;
9513
9514/***/ }),
9515/* 81 */
9516/***/ (function(module, exports, __webpack_require__) {
9517
9518var Util = __webpack_require__(0);
9519var Shape = __webpack_require__(1);
9520var Inside = __webpack_require__(3);
9521var Arrow = __webpack_require__(7);
9522var QuadraticMath = __webpack_require__(29);
9523
9524var Quadratic = function Quadratic(cfg) {
9525 Quadratic.superclass.constructor.call(this, cfg);
9526};
9527
9528Quadratic.ATTRS = {
9529 p1: null, // 起始点
9530 p2: null, // 控制点
9531 p3: null, // 结束点
9532 lineWidth: 1,
9533 startArrow: false,
9534 endArrow: false
9535};
9536
9537Util.extend(Quadratic, Shape);
9538
9539Util.augment(Quadratic, {
9540 canStroke: true,
9541 type: 'quadratic',
9542 getDefaultAttrs: function getDefaultAttrs() {
9543 return {
9544 lineWidth: 1,
9545 startArrow: false,
9546 endArrow: false
9547 };
9548 },
9549 calculateBox: function calculateBox() {
9550 var self = this;
9551 var attrs = self.__attrs;
9552 var p1 = attrs.p1,
9553 p2 = attrs.p2,
9554 p3 = attrs.p3;
9555
9556 var lineWidth = this.getHitLineWidth();
9557 var i = void 0;
9558 var l = void 0;
9559
9560 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
9561 return null;
9562 }
9563 var halfWidth = lineWidth / 2;
9564 var xDims = QuadraticMath.extrema(p1[0], p2[0], p3[0]);
9565 for (i = 0, l = xDims.length; i < l; i++) {
9566 xDims[i] = QuadraticMath.at(p1[0], p2[0], p3[0], xDims[i]);
9567 }
9568 xDims.push(p1[0], p3[0]);
9569 var yDims = QuadraticMath.extrema(p1[1], p2[1], p3[1]);
9570 for (i = 0, l = yDims.length; i < l; i++) {
9571 yDims[i] = QuadraticMath.at(p1[1], p2[1], p3[1], yDims[i]);
9572 }
9573 yDims.push(p1[1], p3[1]);
9574
9575 return {
9576 minX: Math.min.apply(Math, xDims) - halfWidth,
9577 maxX: Math.max.apply(Math, xDims) + halfWidth,
9578 minY: Math.min.apply(Math, yDims) - halfWidth,
9579 maxY: Math.max.apply(Math, yDims) + halfWidth
9580 };
9581 },
9582 isPointInPath: function isPointInPath(x, y) {
9583 var self = this;
9584 var attrs = self.__attrs;
9585 var p1 = attrs.p1,
9586 p2 = attrs.p2,
9587 p3 = attrs.p3;
9588
9589 var lineWidth = this.getHitLineWidth();
9590
9591 return Inside.quadraticline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], lineWidth, x, y);
9592 },
9593 createPath: function createPath(context) {
9594 var self = this;
9595 var attrs = self.__attrs;
9596 var p1 = attrs.p1,
9597 p2 = attrs.p2,
9598 p3 = attrs.p3;
9599
9600 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
9601 return;
9602 }
9603 context = context || self.get('context');
9604 context.beginPath();
9605 context.moveTo(p1[0], p1[1]);
9606 context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]);
9607 },
9608 afterPath: function afterPath(context) {
9609 var self = this;
9610 var attrs = self.__attrs;
9611 var p1 = attrs.p1,
9612 p2 = attrs.p2,
9613 p3 = attrs.p3;
9614
9615 context = context || self.get('context');
9616
9617 if (attrs.startArrow) {
9618 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
9619 }
9620
9621 if (attrs.endArrow) {
9622 Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]);
9623 }
9624 },
9625 getPoint: function getPoint(t) {
9626 var attrs = this.__attrs;
9627 return {
9628 x: QuadraticMath.at(attrs.p1[0], attrs.p2[0], attrs.p3[0], t),
9629 y: QuadraticMath.at(attrs.p1[1], attrs.p2[1], attrs.p3[1], t)
9630 };
9631 }
9632});
9633
9634module.exports = Quadratic;
9635
9636/***/ }),
9637/* 82 */
9638/***/ (function(module, exports, __webpack_require__) {
9639
9640var Util = __webpack_require__(0);
9641var Shape = __webpack_require__(1);
9642var Inside = __webpack_require__(3);
9643var Format = __webpack_require__(27);
9644var PathSegment = __webpack_require__(31);
9645
9646var Marker = function Marker(cfg) {
9647 Marker.superclass.constructor.call(this, cfg);
9648};
9649
9650Marker.Symbols = {
9651 // 圆
9652 circle: function circle(x, y, r) {
9653 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]];
9654 },
9655
9656 // 正方形
9657 square: function square(x, y, r) {
9658 return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];
9659 },
9660
9661 // 菱形
9662 diamond: function diamond(x, y, r) {
9663 return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];
9664 },
9665
9666 // 三角形
9667 triangle: function triangle(x, y, r) {
9668 var diffY = r * Math.sin(1 / 3 * Math.PI);
9669 return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['z']];
9670 },
9671
9672 // 倒三角形
9673 'triangle-down': function triangleDown(x, y, r) {
9674 var diffY = r * Math.sin(1 / 3 * Math.PI);
9675 return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];
9676 }
9677};
9678
9679Marker.ATTRS = {
9680 path: null,
9681 lineWidth: 1
9682};
9683
9684Util.extend(Marker, Shape);
9685
9686Util.augment(Marker, {
9687 type: 'marker',
9688 canFill: true,
9689 canStroke: true,
9690 getDefaultAttrs: function getDefaultAttrs() {
9691 return {
9692 x: 0,
9693 y: 0,
9694 lineWidth: 1
9695 };
9696 },
9697 calculateBox: function calculateBox() {
9698 var attrs = this.__attrs;
9699 var cx = attrs.x;
9700 var cy = attrs.y;
9701 var r = attrs.radius;
9702 var lineWidth = this.getHitLineWidth();
9703 var halfWidth = lineWidth / 2 + r;
9704 return {
9705 minX: cx - halfWidth,
9706 minY: cy - halfWidth,
9707 maxX: cx + halfWidth,
9708 maxY: cy + halfWidth
9709 };
9710 },
9711 isPointInPath: function isPointInPath(x, y) {
9712 var attrs = this.__attrs;
9713 var cx = attrs.x;
9714 var cy = attrs.y;
9715 var r = attrs.radius || attrs.r;
9716 var lineWidth = this.getHitLineWidth();
9717 return Inside.circle(cx, cy, r + lineWidth / 2, x, y);
9718 },
9719 createPath: function createPath(context) {
9720 var attrs = this.__attrs;
9721 var x = attrs.x;
9722 var y = attrs.y;
9723 var r = attrs.radius || attrs.r;
9724 var symbol = attrs.symbol || 'circle';
9725 var method = void 0;
9726 if (Util.isFunction(symbol)) {
9727 method = symbol;
9728 } else {
9729 method = Marker.Symbols[symbol];
9730 }
9731 var path = method(x, y, r);
9732 path = Format.parsePath(path);
9733 context.beginPath();
9734 var preSegment = void 0;
9735 for (var i = 0; i < path.length; i++) {
9736 var item = path[i];
9737 preSegment = new PathSegment(item, preSegment, i === path.length - 1);
9738 preSegment.draw(context);
9739 }
9740 }
9741});
9742
9743module.exports = Marker;
9744
9745/***/ }),
9746/* 83 */
9747/***/ (function(module, exports, __webpack_require__) {
9748
9749/**
9750 * @fileOverview Interaction
9751 * @author leungwensen@gmail.com
9752 */
9753
9754var Interactions = {
9755 Base: __webpack_require__(8),
9756 Brush: __webpack_require__(155),
9757 Drag: __webpack_require__(156),
9758 ShapeSelect: __webpack_require__(157),
9759 Zoom: __webpack_require__(158),
9760 helper: {
9761 bindInteraction: __webpack_require__(159)
9762 }
9763};
9764
9765module.exports = Interactions;
9766
9767/***/ }),
9768/* 84 */
9769/***/ (function(module, exports, __webpack_require__) {
9770
9771module.exports = {
9772 Canvas: __webpack_require__(85),
9773 Group: __webpack_require__(43),
9774 Shape: __webpack_require__(4),
9775 Rect: __webpack_require__(46),
9776 Circle: __webpack_require__(47),
9777 Ellipse: __webpack_require__(48),
9778 Path: __webpack_require__(49),
9779 Text: __webpack_require__(50),
9780 Line: __webpack_require__(51),
9781 Image: __webpack_require__(52),
9782 Polygon: __webpack_require__(53),
9783 Marker: __webpack_require__(54),
9784 Dom: __webpack_require__(55),
9785 Fan: __webpack_require__(56),
9786 Event: __webpack_require__(42)
9787};
9788
9789/***/ }),
9790/* 85 */
9791/***/ (function(module, exports, __webpack_require__) {
9792
9793var Util = __webpack_require__(0);
9794var Event = __webpack_require__(42);
9795var Group = __webpack_require__(43);
9796var Defs = __webpack_require__(117);
9797var Timeline = __webpack_require__(57);
9798
9799var Canvas = function Canvas(cfg) {
9800 Canvas.superclass.constructor.call(this, cfg);
9801};
9802
9803Canvas.CFG = {
9804 eventEnable: true,
9805 /**
9806 * 像素宽度
9807 * @type {Number}
9808 */
9809 width: null,
9810 /**
9811 * 像素高度
9812 * @type {Number}
9813 */
9814 height: null,
9815 /**
9816 * 画布宽度
9817 * @type {Number}
9818 */
9819 widthCanvas: null,
9820 /**
9821 * 画布高度
9822 * @type {Number}
9823 */
9824 heightCanvas: null,
9825 /**
9826 * CSS宽
9827 * CSS宽
9828 * @type {String}
9829 */
9830 widthStyle: null,
9831 /**
9832 * CSS高
9833 * @type {String}
9834 */
9835 heightStyle: null,
9836 /**
9837 * 容器DOM
9838 * @type {Object}
9839 */
9840 containerDOM: null,
9841 /**
9842 * 当前Canvas的DOM
9843 * @type {Object}
9844 */
9845 canvasDOM: null,
9846 /**
9847 * 屏幕像素比
9848 * @type {Number}
9849 */
9850 pixelRatio: Util.getRatio()
9851};
9852
9853Util.extend(Canvas, Group);
9854
9855Util.augment(Canvas, {
9856 init: function init() {
9857 Canvas.superclass.init.call(this);
9858 this._setDOM();
9859 this._setInitSize();
9860 // this._scale();
9861 if (this.get('eventEnable')) {
9862 this._registEvents();
9863 }
9864 },
9865 getEmitter: function getEmitter(element, event) {
9866 if (element) {
9867 if (Util.isEmpty(element._getEvents())) {
9868 var parent = element.get('parent');
9869 if (parent && !event.propagationStopped) {
9870 return this.getEmitter(parent, event);
9871 }
9872 } else {
9873 return element;
9874 }
9875 }
9876 },
9877 _getEventObj: function _getEventObj(type, e, point, target) {
9878 var event = new Event(type, e, true, true);
9879 event.x = point.x;
9880 event.y = point.y;
9881 event.clientX = e.clientX;
9882 event.clientY = e.clientY;
9883 event.currentTarget = target;
9884 event.target = target;
9885 return event;
9886 },
9887 _triggerEvent: function _triggerEvent(type, e) {
9888 var point = this.getPointByClient(e.clientX, e.clientY);
9889 var shape = this.findShape(e.srcElement);
9890 var emitObj = void 0;
9891 if (type === 'mousemove') {
9892 var preShape = this.get('preShape');
9893 if (preShape && preShape !== shape) {
9894 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
9895 emitObj = this.getEmitter(preShape, e);
9896 emitObj && emitObj.emit('mouseleave', mouseleave);
9897 }
9898
9899 if (shape) {
9900 var mousemove = this._getEventObj('mousemove', e, point, shape);
9901 emitObj = this.getEmitter(shape, e);
9902 emitObj && emitObj.emit('mousemove', mousemove);
9903
9904 if (preShape !== shape) {
9905 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
9906 emitObj && emitObj.emit('mouseenter', mouseenter, e);
9907 }
9908 } else {
9909 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
9910 this.emit('mousemove', canvasmousemove);
9911 }
9912 this.set('preShape', shape);
9913 } else {
9914 var event = this._getEventObj(type, e, point, shape || this);
9915 emitObj = this.getEmitter(shape, e);
9916 if (emitObj && emitObj !== this) {
9917 emitObj.emit(type, event);
9918 }
9919 this.emit(type, event);
9920 }
9921
9922 var el = this.get('el');
9923 if (shape && !shape.get('destroyed')) {
9924 el.style.cursor = shape.attr('cursor') || 'default';
9925 }
9926 },
9927 _registEvents: function _registEvents() {
9928 var self = this;
9929 var el = self.get('el');
9930 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
9931
9932 Util.each(events, function (event) {
9933 el.addEventListener(event, function (e) {
9934 self._triggerEvent(event, e);
9935 }, false);
9936 });
9937 el.addEventListener('touchstart', function (e) {
9938 if (!Util.isEmpty(e.touches)) {
9939 self._triggerEvent('touchstart', e.touches[0]);
9940 }
9941 }, false);
9942
9943 el.addEventListener('touchmove', function (e) {
9944 if (!Util.isEmpty(e.touches)) {
9945 self._triggerEvent('touchmove', e.touches[0]);
9946 }
9947 }, false);
9948
9949 el.addEventListener('touchend', function (e) {
9950 if (!Util.isEmpty(e.changedTouches)) {
9951 self._triggerEvent('touchend', e.changedTouches[0]);
9952 }
9953 }, false);
9954 },
9955 _setDOM: function _setDOM() {
9956 this._setContainer();
9957 this._setLayer();
9958 },
9959 _setContainer: function _setContainer() {
9960 var containerId = this.get('containerId');
9961 var containerDOM = this.get('containerDOM');
9962 if (!containerDOM) {
9963 containerDOM = document.getElementById(containerId);
9964 this.set('containerDOM', containerDOM);
9965 }
9966 Util.modifyCSS(containerDOM, {
9967 position: 'relative'
9968 });
9969 },
9970 _setLayer: function _setLayer() {
9971 var containerDOM = this.get('containerDOM');
9972 var canvasId = Util.uniqueId('svg_');
9973 if (containerDOM) {
9974 var _canvasDOM = Util.createDom('<svg id="' + canvasId + '"></svg>');
9975 containerDOM.appendChild(_canvasDOM);
9976 var defs = new Defs();
9977 _canvasDOM.appendChild(defs.get('el'));
9978 this.set('canvasDOM', _canvasDOM);
9979 this.set('el', _canvasDOM);
9980 this.set('defs', defs);
9981 this.set('canvas', this);
9982 }
9983 var canvasDOM = this.get('canvasDOM');
9984 var timeline = new Timeline();
9985 this.setSilent('timeline', timeline);
9986 this.set('context', canvasDOM);
9987 },
9988 _setInitSize: function _setInitSize() {
9989 this.changeSize(this.get('width'), this.get('height'));
9990 this.set('pixelRatio', 1);
9991 },
9992 _resize: function _resize() {
9993 var canvasDOM = this.get('canvasDOM');
9994 var widthCanvas = this.get('widthCanvas');
9995 var heightCanvas = this.get('heightCanvas');
9996 var widthStyle = this.get('widthStyle');
9997 var heightStyle = this.get('heightStyle');
9998
9999 canvasDOM.style.width = widthStyle;
10000 canvasDOM.style.height = heightStyle;
10001 canvasDOM.setAttribute('width', widthCanvas);
10002 canvasDOM.setAttribute('height', heightCanvas);
10003 },
10004 getWidth: function getWidth() {
10005 return this.get('width');
10006 },
10007 getHeight: function getHeight() {
10008 return this.get('height');
10009 },
10010 changeSize: function changeSize(width, height) {
10011 this.set('widthCanvas', width);
10012 this.set('heightCanvas', height);
10013 this.set('widthStyle', width + 'px');
10014 this.set('heightStyle', height + 'px');
10015 this.set('width', width);
10016 this.set('height', height);
10017 this._resize();
10018 },
10019
10020 /**
10021 * 将窗口坐标转变成 canvas 坐标
10022 * @param {Number} clientX 窗口x坐标
10023 * @param {Number} clientY 窗口y坐标
10024 * @return {Object} canvas坐标
10025 */
10026 getPointByClient: function getPointByClient(clientX, clientY) {
10027 var el = this.get('el');
10028 var bbox = el.getBoundingClientRect();
10029 return {
10030 x: clientX - bbox.left,
10031 y: clientY - bbox.top
10032 };
10033 },
10034 getClientByPoint: function getClientByPoint(x, y) {
10035 var el = this.get('el');
10036 var bbox = el.getBoundingClientRect();
10037 return {
10038 clientX: x + bbox.left,
10039 clientY: y + bbox.top
10040 };
10041 },
10042 beforeDraw: function beforeDraw() {
10043 var el = this.get('el');
10044 // canvas版本用盖一个canvas大小的矩阵清空画布,svg换成清空html
10045 el.innerHTML = '';
10046 },
10047 _beginDraw: function _beginDraw() {
10048 this.setSilent('toDraw', true);
10049 },
10050 _endDraw: function _endDraw() {
10051 this.setSilent('toDraw', false);
10052 },
10053
10054 // svg实时渲染,兼容canvas版本留个空接口
10055 draw: function draw() {},
10056 destroy: function destroy() {
10057 var containerDOM = this.get('containerDOM');
10058 var canvasDOM = this.get('canvasDOM');
10059 if (canvasDOM && containerDOM) {
10060 containerDOM.removeChild(canvasDOM);
10061 }
10062 Canvas.superclass.destroy.call(this);
10063 }
10064});
10065
10066module.exports = Canvas;
10067
10068/***/ }),
10069/* 86 */
10070/***/ (function(module, exports, __webpack_require__) {
10071
10072var isArrayLike = __webpack_require__(5);
10073
10074var arrayProto = Array.prototype;
10075var slice = arrayProto.slice;
10076var indexOf = arrayProto.indexOf;
10077var splice = arrayProto.splice;
10078
10079function contains(arr, value) {
10080 if (!isArrayLike(arr)) {
10081 return false;
10082 }
10083 return indexOf.call(arr, value) > -1;
10084}
10085
10086function uniq(arr) {
10087 var resultArr = [];
10088 arr.forEach(function (item) {
10089 if (!contains(resultArr, item)) {
10090 resultArr.push(item);
10091 }
10092 });
10093 return resultArr;
10094}
10095
10096function pull(arr) {
10097 /**
10098 * const arr = [ 'a', 'b', 'c', 'a', 'b', 'c' ]
10099 * pull(arr, 'a', 'c')
10100 * console.log(arr) // => [ 'b', 'b' ]
10101 */
10102 var values = slice.call(arguments, 1);
10103 for (var i = 0; i < values.length; i++) {
10104 var value = values[i];
10105 var fromIndex = -1;
10106 while ((fromIndex = indexOf.call(arr, value)) > -1) {
10107 splice.call(arr, fromIndex, 1);
10108 }
10109 }
10110 return arr;
10111}
10112
10113function pullAt(arr, indexes) {
10114 if (!isArrayLike(arr)) {
10115 return [];
10116 }
10117 var length = arr ? indexes.length : 0;
10118 var last = length - 1;
10119
10120 while (length--) {
10121 var previous = void 0;
10122 var index = indexes[length];
10123 if (length === last || index !== previous) {
10124 previous = index;
10125 splice.call(arr, index, 1);
10126 }
10127 }
10128 return arr;
10129}
10130
10131function remove(arr, predicate) {
10132 /**
10133 * const arr = [1, 2, 3, 4]
10134 * const evens = remove(arr, n => n % 2 == 0)
10135 * console.log(arr) // => [1, 3]
10136 * console.log(evens) // => [2, 4]
10137 */
10138 var result = [];
10139 if (!isArrayLike(arr)) {
10140 return result;
10141 }
10142 var i = -1;
10143 var indexes = [];
10144 var length = arr.length;
10145
10146 while (++i < length) {
10147 var value = arr[i];
10148 if (predicate(value, i, arr)) {
10149 result.push(value);
10150 indexes.push(i);
10151 }
10152 }
10153 pullAt(arr, indexes);
10154 return result;
10155}
10156
10157var arrayUtil = {
10158 contains: contains,
10159 pull: pull,
10160 pullAll: pull,
10161 pullAt: pullAt,
10162 remove: remove,
10163 uniq: uniq
10164};
10165
10166module.exports = arrayUtil;
10167
10168/***/ }),
10169/* 87 */
10170/***/ (function(module, exports) {
10171
10172/**
10173 * 获取封装的事件
10174 * @protected
10175 * @param {Object} obj 对象
10176 * @param {String} action 事件名称
10177 * @return {Function} 返回事件处理函数
10178 */
10179function getWrapBehavior(obj, action) {
10180 return obj['_wrap_' + action];
10181}
10182
10183module.exports = getWrapBehavior;
10184
10185/***/ }),
10186/* 88 */
10187/***/ (function(module, exports) {
10188
10189/**
10190 * 封装事件,便于使用上下文this,和便于解除事件时使用
10191 * @protected
10192 * @param {Object} obj 对象
10193 * @param {String} action 事件名称
10194 * @return {Function} 返回事件处理函数
10195 */
10196function wrapBehavior(obj, action) {
10197 if (obj['_wrap_' + action]) {
10198 return obj['_wrap_' + action];
10199 }
10200 var method = function method(e) {
10201 obj[action](e);
10202 };
10203 obj['_wrap_' + action] = method;
10204 return method;
10205}
10206
10207module.exports = wrapBehavior;
10208
10209/***/ }),
10210/* 89 */
10211/***/ (function(module, exports, __webpack_require__) {
10212
10213var isNumber = __webpack_require__(90);
10214var PRECISION = 0.00001; // numbers less than this is considered as 0
10215var RADIAN = Math.PI / 180;
10216var DEGREE = 180 / Math.PI;
10217
10218function toInteger(str, radix) {
10219 return parseInt(str, radix || 10);
10220}
10221
10222var mathUtil = {
10223 clamp: function clamp(a, min, max) {
10224 if (a < min) {
10225 return min;
10226 } else if (a > max) {
10227 return max;
10228 }
10229 return a;
10230 },
10231 isDecimal: function isDecimal(num) {
10232 return isNumber(num) && num % 1 !== 0;
10233 },
10234 isEven: function isEven(num) {
10235 return isNumber(num) && num % 2 === 0;
10236 },
10237
10238 isFinite: isFinite,
10239 isInteger: Number.isInteger ? Number.isInteger : function (num) {
10240 return isNumber(num) && num % 1 === 0;
10241 },
10242 isNaN: isNaN,
10243 isNegative: function isNegative(num) {
10244 return isNumber(num) && num < 0;
10245 },
10246 isNumberEqual: function isNumberEqual(a, b) {
10247 return Math.abs(a - b) < PRECISION;
10248 },
10249 isOdd: function isOdd(num) {
10250 return isNumber(num) && num % 2 !== 0;
10251 },
10252 isPositive: function isPositive(num) {
10253 return isNumber(num) && num > 0;
10254 },
10255 mod: function mod(n, m) {
10256 return (n % m + m) % m;
10257 },
10258 toFloat: function toFloat(str) {
10259 return parseFloat(str);
10260 },
10261 toDegree: function toDegree(radian) {
10262 return DEGREE * radian;
10263 },
10264
10265 toInt: toInteger,
10266 toInteger: toInteger,
10267 toRadian: function toRadian(degree) {
10268 return RADIAN * degree;
10269 },
10270 fixedBase: function fixedBase(v, base) {
10271 var str = base.toString();
10272 var index = str.indexOf('.');
10273 if (index === -1) {
10274 return Math.round(v);
10275 }
10276 var length = str.substr(index + 1).length;
10277 if (length > 20) {
10278 length = 20;
10279 }
10280 return parseFloat(v.toFixed(length));
10281 }
10282};
10283
10284module.exports = mathUtil;
10285
10286/***/ }),
10287/* 90 */
10288/***/ (function(module, exports, __webpack_require__) {
10289
10290/**
10291 * 判断是否数字
10292 * @return {Boolean} 是否数字
10293 */
10294var isType = __webpack_require__(10);
10295
10296var isNumber = function isNumber(value) {
10297 return isType(value, 'Number');
10298};
10299module.exports = isNumber;
10300
10301/***/ }),
10302/* 91 */
10303/***/ (function(module, exports) {
10304
10305
10306function toString(value) {
10307 return value.toString();
10308}
10309
10310function upperCase(value) {
10311 return toString(value).toUpperCase();
10312}
10313
10314function lowerCase(value) {
10315 return toString(value).toLowerCase();
10316}
10317
10318var strUtil = {
10319 lc: lowerCase,
10320 lowerCase: lowerCase,
10321 lowerFirst: function lowerFirst(value) {
10322 value = toString(value);
10323 return lowerCase(value.charAt(0)) + value.substring(1);
10324 },
10325
10326 uc: upperCase,
10327 upperCase: upperCase,
10328 upperFirst: function upperFirst(value) {
10329 value = toString(value);
10330 return upperCase(value.charAt(0)) + value.substring(1);
10331 }
10332};
10333
10334module.exports = strUtil;
10335
10336/***/ }),
10337/* 92 */
10338/***/ (function(module, exports) {
10339
10340var _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; };
10341
10342var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
10343 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
10344} : function (obj) {
10345 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
10346};
10347
10348var toString = {}.toString;
10349var objectProto = Object.prototype;
10350var isType = function isType(value, type) {
10351 return toString.call(value) === '[object ' + type + ']';
10352};
10353
10354function isNull(value) {
10355 return value === null;
10356}
10357function isUndefined(value) {
10358 return value === undefined;
10359}
10360function isObject(value) {
10361 /**
10362 * isObject({}) => true
10363 * isObject([1, 2, 3]) => true
10364 * isObject(Function) => true
10365 * isObject(null) => false
10366 */
10367 var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
10368 return value !== null && type === 'object' || type === 'function';
10369}
10370function isObjectLike(value) {
10371 /**
10372 * isObjectLike({}) => true
10373 * isObjectLike([1, 2, 3]) => true
10374 * isObjectLike(Function) => false
10375 * isObjectLike(null) => false
10376 */
10377 return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
10378}
10379
10380var checkType = {
10381 getType: function getType(value) {
10382 return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
10383 },
10384
10385 isArray: Array.isArray ? Array.isArray : function (value) {
10386 return isType(value, 'Array');
10387 },
10388 isArrayLike: function isArrayLike(value) {
10389 /**
10390 * isArrayLike([1, 2, 3]) => true
10391 * isArrayLike(document.body.children) => true
10392 * isArrayLike('abc') => true
10393 * isArrayLike(Function) => false
10394 */
10395 return value !== null && typeof value !== 'function' && isFinite(value.length);
10396 },
10397
10398 // isFinite,
10399 isNil: function isNil(value) {
10400 /**
10401 * isNil(null) => true
10402 * isNil() => true
10403 */
10404 return isUndefined(value) || isNull(value);
10405 },
10406
10407 isNull: isNull,
10408 isType: isType,
10409 isObject: isObject,
10410 isObjectLike: isObjectLike,
10411 isPlainObject: function isPlainObject(value) {
10412 /**
10413 * isObjectLike(new Foo) => false
10414 * isObjectLike([1, 2, 3]) => false
10415 * isObjectLike({ x: 0, y: 0 }) => true
10416 * isObjectLike(Object.create(null)) => true
10417 */
10418 if (!isObjectLike(value) || !isType(value, 'Object')) {
10419 return false;
10420 }
10421 if (Object.getPrototypeOf(value) === null) {
10422 return true;
10423 }
10424 var proto = value;
10425 while (Object.getPrototypeOf(proto) !== null) {
10426 proto = Object.getPrototypeOf(proto);
10427 }
10428 return Object.getPrototypeOf(value) === proto;
10429 },
10430 isPrototype: function isPrototype(value) {
10431 var Ctor = value && value.constructor;
10432 var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
10433 return value === proto;
10434 },
10435
10436 isUndefined: isUndefined
10437};
10438
10439// common types
10440['Arguments', 'Boolean', 'Date', 'Error', 'Function', 'Number', 'RegExp', 'String'].forEach(function (type) {
10441 checkType['is' + type] = function (value) {
10442 return isType(value, type);
10443 };
10444});
10445
10446module.exports = checkType;
10447
10448/***/ }),
10449/* 93 */
10450/***/ (function(module, exports) {
10451
10452var _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; };
10453
10454var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
10455 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
10456} : function (obj) {
10457 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
10458};
10459
10460var isObject = function isObject(value) {
10461 /**
10462 * isObject({}) => true
10463 * isObject([1, 2, 3]) => true
10464 * isObject(Function) => true
10465 * isObject(null) => false
10466 */
10467 var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
10468 return value !== null && type === 'object' || type === 'function';
10469};
10470
10471module.exports = isObject;
10472
10473/***/ }),
10474/* 94 */
10475/***/ (function(module, exports, __webpack_require__) {
10476
10477var isFunction = __webpack_require__(14);
10478var toArray = __webpack_require__(35);
10479var mix = __webpack_require__(18);
10480
10481var augment = function augment(c) {
10482 var args = toArray(arguments);
10483 for (var i = 1; i < args.length; i++) {
10484 var obj = args[i];
10485 if (isFunction(obj)) {
10486 obj = obj.prototype;
10487 }
10488 mix(c.prototype, obj);
10489 }
10490};
10491
10492module.exports = augment;
10493
10494/***/ }),
10495/* 95 */
10496/***/ (function(module, exports, __webpack_require__) {
10497
10498var _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; };
10499
10500var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
10501 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
10502} : function (obj) {
10503 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
10504};
10505
10506var isArray = __webpack_require__(12);
10507
10508var clone = function clone(obj) {
10509 if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
10510 return obj;
10511 }
10512 var rst = void 0;
10513 if (isArray(obj)) {
10514 rst = [];
10515 for (var i = 0, l = obj.length; i < l; i++) {
10516 if (_typeof(obj[i]) === 'object' && obj[i] != null) {
10517 rst[i] = clone(obj[i]);
10518 } else {
10519 rst[i] = obj[i];
10520 }
10521 }
10522 } else {
10523 rst = {};
10524 for (var k in obj) {
10525 if (_typeof(obj[k]) === 'object' && obj[k] != null) {
10526 rst[k] = clone(obj[k]);
10527 } else {
10528 rst[k] = obj[k];
10529 }
10530 }
10531 }
10532
10533 return rst;
10534};
10535
10536module.exports = clone;
10537
10538/***/ }),
10539/* 96 */
10540/***/ (function(module, exports, __webpack_require__) {
10541
10542var isPlainObject = __webpack_require__(36);
10543var isArray = __webpack_require__(12);
10544
10545var MAX_MIX_LEVEL = 5;
10546
10547function _deepMix(dist, src, level, maxLevel) {
10548 level = level || 0;
10549 maxLevel = maxLevel || MAX_MIX_LEVEL;
10550 for (var key in src) {
10551 if (src.hasOwnProperty(key)) {
10552 var value = src[key];
10553 if (value !== null && isPlainObject(value)) {
10554 if (!isPlainObject(dist[key])) {
10555 dist[key] = {};
10556 }
10557 if (level < maxLevel) {
10558 _deepMix(dist[key], value, level + 1, maxLevel);
10559 } else {
10560 dist[key] = src[key];
10561 }
10562 } else if (isArray(value)) {
10563 dist[key] = [];
10564 dist[key] = dist[key].concat(value);
10565 } else if (value !== undefined) {
10566 dist[key] = value;
10567 }
10568 }
10569 }
10570}
10571
10572var deepMix = function deepMix() {
10573 var args = new Array(arguments.length);
10574 var length = args.length;
10575 for (var i = 0; i < length; i++) {
10576 args[i] = arguments[i];
10577 }
10578 var rst = args[0];
10579 for (var _i = 1; _i < length; _i++) {
10580 _deepMix(rst, args[_i]);
10581 }
10582 return rst;
10583};
10584
10585module.exports = deepMix;
10586
10587/***/ }),
10588/* 97 */
10589/***/ (function(module, exports, __webpack_require__) {
10590
10591var isFunction = __webpack_require__(14);
10592var mix = __webpack_require__(18);
10593
10594var extend = function extend(subclass, superclass, overrides, staticOverrides) {
10595 // 如果只提供父类构造函数,则自动生成子类构造函数
10596 if (!isFunction(superclass)) {
10597 overrides = superclass;
10598 superclass = subclass;
10599 subclass = function subclass() {};
10600 }
10601
10602 var create = Object.create ? function (proto, c) {
10603 return Object.create(proto, {
10604 constructor: {
10605 value: c
10606 }
10607 });
10608 } : function (proto, c) {
10609 function Tmp() {}
10610 Tmp.prototype = proto;
10611 var o = new Tmp();
10612 o.constructor = c;
10613 return o;
10614 };
10615
10616 var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
10617 subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
10618 subclass.superclass = create(superclass.prototype, superclass);
10619 mix(superObj, overrides);
10620 mix(subclass, staticOverrides);
10621 return subclass;
10622};
10623
10624module.exports = extend;
10625
10626/***/ }),
10627/* 98 */
10628/***/ (function(module, exports, __webpack_require__) {
10629
10630var each = __webpack_require__(11);
10631var isArrayLike = __webpack_require__(5);
10632
10633var filter = function filter(arr, func) {
10634 if (!isArrayLike(arr)) {
10635 return arr;
10636 }
10637 var result = [];
10638 each(arr, function (value, index) {
10639 if (func(value, index)) {
10640 result.push(value);
10641 }
10642 });
10643 return result;
10644};
10645
10646module.exports = filter;
10647
10648/***/ }),
10649/* 99 */
10650/***/ (function(module, exports, __webpack_require__) {
10651
10652var groupToMap = __webpack_require__(38);
10653
10654var group = function group(data, condition) {
10655 if (!condition) {
10656 return [data];
10657 }
10658 var groups = groupToMap(data, condition);
10659 var array = [];
10660 for (var i in groups) {
10661 array.push(groups[i]);
10662 }
10663 return array;
10664};
10665
10666module.exports = group;
10667
10668/***/ }),
10669/* 100 */
10670/***/ (function(module, exports, __webpack_require__) {
10671
10672var isArrayLike = __webpack_require__(5);
10673
10674var indexOf = function indexOf(arr, obj) {
10675 if (!isArrayLike(arr)) {
10676 return -1;
10677 }
10678 var m = Array.prototype.indexOf;
10679 if (m) {
10680 return m.call(arr, obj);
10681 }
10682 var index = -1;
10683
10684 for (var i = 0; i < arr.length; i++) {
10685 if (arr[i] === obj) {
10686 index = i;
10687 break;
10688 }
10689 }
10690 return index;
10691};
10692
10693module.exports = indexOf;
10694
10695/***/ }),
10696/* 101 */
10697/***/ (function(module, exports, __webpack_require__) {
10698
10699var isNil = __webpack_require__(102);
10700var isArrayLike = __webpack_require__(5);
10701var getType = __webpack_require__(103);
10702var isPrototype = __webpack_require__(104);
10703var hasOwnProperty = Object.prototype.hasOwnProperty;
10704
10705function isEmpty(value) {
10706 /**
10707 * isEmpty(null) => true
10708 * isEmpty() => true
10709 * isEmpty(true) => true
10710 * isEmpty(1) => true
10711 * isEmpty([1, 2, 3]) => false
10712 * isEmpty('abc') => false
10713 * isEmpty({ a: 1 }) => false
10714 */
10715 if (isNil(value)) {
10716 return true;
10717 }
10718 if (isArrayLike(value)) {
10719 return !value.length;
10720 }
10721 var type = getType(value);
10722 if (type === 'Map' || type === 'Set') {
10723 return !value.size;
10724 }
10725 if (isPrototype(value)) {
10726 return !Object.keys(value).length;
10727 }
10728 for (var key in value) {
10729 if (hasOwnProperty.call(value, key)) {
10730 return false;
10731 }
10732 }
10733 return true;
10734}
10735
10736module.exports = isEmpty;
10737
10738/***/ }),
10739/* 102 */
10740/***/ (function(module, exports) {
10741
10742// isFinite,
10743var isNil = function isNil(value) {
10744 /**
10745 * isNil(null) => true
10746 * isNil() => true
10747 */
10748 return value === null || value === undefined;
10749};
10750
10751module.exports = isNil;
10752
10753/***/ }),
10754/* 103 */
10755/***/ (function(module, exports) {
10756
10757var toString = {}.toString;
10758
10759var getType = function getType(value) {
10760 return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
10761};
10762
10763module.exports = getType;
10764
10765/***/ }),
10766/* 104 */
10767/***/ (function(module, exports) {
10768
10769var objectProto = Object.prototype;
10770var isPrototype = function isPrototype(value) {
10771 var Ctor = value && value.constructor;
10772 var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
10773 return value === proto;
10774};
10775
10776module.exports = isPrototype;
10777
10778/***/ }),
10779/* 105 */
10780/***/ (function(module, exports, __webpack_require__) {
10781
10782var isType = __webpack_require__(10);
10783
10784var isString = function isString(str) {
10785 return isType(str, 'String');
10786};
10787
10788module.exports = isString;
10789
10790/***/ }),
10791/* 106 */
10792/***/ (function(module, exports, __webpack_require__) {
10793
10794var isFunction = __webpack_require__(14);
10795var isEqual = __webpack_require__(40);
10796/**
10797 * @param {*} value The value to compare.
10798 * @param {*} other The other value to compare.
10799 * @param {Function} [fn] The function to customize comparisons.
10800 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
10801 * @example
10802 *
10803 * function isGreeting(value) {
10804 * return /^h(?:i|ello)$/.test(value);
10805 * }
10806 *
10807 * function customizer(objValue, othValue) {
10808 * if (isGreeting(objValue) && isGreeting(othValue)) {
10809 * return true;
10810 * }
10811 * }
10812 *
10813 * var array = ['hello', 'goodbye'];
10814 * var other = ['hi', 'goodbye'];
10815 *
10816 * _.isEqualWith(array, other, customizer); // => true
10817 */
10818
10819var isEqualWith = function isEqualWith(value, other, fn) {
10820 if (!isFunction(fn)) {
10821 return isEqual(value, other);
10822 }
10823 return !!fn(value, other);
10824};
10825
10826module.exports = isEqualWith;
10827
10828/***/ }),
10829/* 107 */
10830/***/ (function(module, exports, __webpack_require__) {
10831
10832var each = __webpack_require__(11);
10833var isArrayLike = __webpack_require__(5);
10834
10835var map = function map(arr, func) {
10836 if (!isArrayLike(arr)) {
10837 return arr;
10838 }
10839 var result = [];
10840 each(arr, function (value, index) {
10841 result.push(func(value, index));
10842 });
10843 return result;
10844};
10845
10846module.exports = map;
10847
10848/***/ }),
10849/* 108 */
10850/***/ (function(module, exports, __webpack_require__) {
10851
10852var each = __webpack_require__(11);
10853var isPlaineObject = __webpack_require__(36);
10854
10855var hasOwnProperty = Object.prototype.hasOwnProperty;
10856/**
10857 * Creates an object composed of the picked `object` properties.
10858 *
10859 * @param {Object} object The source object.
10860 * @param {...(string|string[])} [paths] The property paths to pick.
10861 * @returns {Object} Returns the new object.
10862 * @example
10863 *
10864 * var object = { 'a': 1, 'b': '2', 'c': 3 };
10865 * pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
10866 */
10867
10868var pick = function pick(object, keys) {
10869 if (object === null || !isPlaineObject(object)) {
10870 return {};
10871 }
10872 var result = {};
10873 each(keys, function (key) {
10874 if (hasOwnProperty.call(object, key)) {
10875 result[key] = object[key];
10876 }
10877 });
10878 return result;
10879};
10880
10881module.exports = pick;
10882
10883/***/ }),
10884/* 109 */
10885/***/ (function(module, exports) {
10886
10887
10888function toString(value) {
10889 return value.toString();
10890}
10891
10892module.exports = toString;
10893
10894/***/ }),
10895/* 110 */
10896/***/ (function(module, exports) {
10897
10898var uniqueId = function () {
10899 var map = {};
10900 return function (prefix) {
10901 prefix = prefix || 'g';
10902 if (!map[prefix]) {
10903 map[prefix] = 1;
10904 } else {
10905 map[prefix] += 1;
10906 }
10907 return prefix + map[prefix];
10908 };
10909}();
10910
10911module.exports = uniqueId;
10912
10913/***/ }),
10914/* 111 */
10915/***/ (function(module, exports, __webpack_require__) {
10916
10917var Util = __webpack_require__(0);
10918
10919var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
10920var CAPITALIZED_ATTRS_MAP = {
10921 r: 'R',
10922 opacity: 'Opacity',
10923 lineWidth: 'LineWidth',
10924 clip: 'Clip',
10925 stroke: 'Stroke',
10926 fill: 'Fill',
10927 strokeOpacity: 'Stroke',
10928 fillOpacity: 'Fill',
10929 x: 'X',
10930 y: 'Y',
10931 rx: 'Rx',
10932 ry: 'Ry',
10933 re: 'Re',
10934 rs: 'Rs',
10935 width: 'Width',
10936 height: 'Height',
10937 img: 'Img',
10938 x1: 'X1',
10939 x2: 'X2',
10940 y1: 'Y1',
10941 y2: 'Y2',
10942 points: 'Points',
10943 p1: 'P1',
10944 p2: 'P2',
10945 p3: 'P3',
10946 p4: 'P4',
10947 text: 'Text',
10948 radius: 'Radius',
10949 textAlign: 'TextAlign',
10950 textBaseline: 'TextBaseline',
10951 font: 'Font',
10952 fontSize: 'FontSize',
10953 fontStyle: 'FontStyle',
10954 fontVariant: 'FontVariant',
10955 fontWeight: 'FontWeight',
10956 fontFamily: 'FontFamily',
10957 clockwise: 'Clockwise',
10958 startAngle: 'StartAngle',
10959 endAngle: 'EndAngle',
10960 path: 'Path',
10961 outline: 'Outline',
10962 html: 'Html'
10963};
10964var SVG_ATTR_MAP = {
10965 opacity: 'opacity',
10966 clip: 'clip',
10967 stroke: 'stroke',
10968 fill: 'fill',
10969 strokeOpacity: 'stroke-opacity',
10970 fillOpacity: 'fill-opacity',
10971 strokeStyle: 'stroke',
10972 fillStyle: 'fill',
10973 x: 'x',
10974 y: 'y',
10975 r: 'r',
10976 rx: 'rx',
10977 ry: 'ry',
10978 re: 're',
10979 rs: 'rs',
10980 width: 'width',
10981 height: 'height',
10982 image: 'href',
10983 x1: 'x1',
10984 x2: 'x2',
10985 y1: 'y1',
10986 y2: 'y2',
10987 lineCap: 'stroke-linecap',
10988 lineJoin: 'stroke-linejoin',
10989 lineWidth: 'stroke-width',
10990 lineDash: 'stroke-dasharray',
10991 miterLimit: 'stroke-miterlimit',
10992 font: 'font',
10993 fontSize: 'font-size',
10994 fontStyle: 'font-style',
10995 fontVariant: 'font-variant',
10996 fontWeight: 'font-weight',
10997 fontFamily: 'font-family',
10998 startArrow: 'marker-start',
10999 endArrow: 'marker-end',
11000 preserveAspectRatio: 'preserveAspectRatio'
11001};
11002var ALIAS_ATTRS_MAP = {
11003 stroke: 'strokeStyle',
11004 fill: 'fillStyle',
11005 opacity: 'globalAlpha'
11006};
11007
11008module.exports = {
11009 canFill: false,
11010 canStroke: false,
11011 initAttrs: function initAttrs(attrs) {
11012 this.__attrs = {
11013 opacity: 1,
11014 fillOpacity: 1,
11015 strokeOpacity: 1
11016 };
11017 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
11018 return this;
11019 },
11020 getDefaultAttrs: function getDefaultAttrs() {
11021 return {};
11022 },
11023
11024 /**
11025 * 设置或者设置属性,有以下 4 种情形:
11026 * - name 不存在, 则返回属性集合
11027 * - name 为字符串,value 为空,获取属性值
11028 * - name 为字符串,value 不为空,设置属性值,返回 this
11029 * - name 为键值对,value 为空,设置属性值
11030 *
11031 * @param {String | Object} name 属性名
11032 * @param {*} value 属性值
11033 * @return {*} 属性值
11034 */
11035 attr: function attr(name, value) {
11036 var self = this;
11037 if (arguments.length === 0) {
11038 return self.__attrs;
11039 }
11040 if (Util.isObject(name)) {
11041 for (var k in name) {
11042 if (ALIAS_ATTRS.indexOf(k) === -1) {
11043 var v = name[k];
11044 self._setAttr(k, v);
11045 }
11046 }
11047 if (self._afterSetAttrAll) {
11048 self._afterSetAttrAll(name);
11049 }
11050 // self.setSilent('box', null);
11051 self.clearBBox();
11052 return self;
11053 }
11054 if (arguments.length === 2) {
11055 self._setAttr(name, value);
11056 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
11057 if (CAPITALIZED_ATTRS_MAP[name] && self[m]) {
11058 self[m](value);
11059 }
11060 self.clearBBox();
11061 return self;
11062 }
11063 return self._getAttr(name);
11064 },
11065 clearBBox: function clearBBox() {
11066 this.setSilent('box', null);
11067 },
11068 _afterSetAttrAll: function _afterSetAttrAll() {},
11069
11070 // 属性获取触发函数
11071 _getAttr: function _getAttr(name) {
11072 return this.__attrs[name];
11073 },
11074
11075 // 属性设置触发函数
11076 _setAttr: function _setAttr(name, value) {
11077 var self = this;
11078 var el = self.get('el');
11079
11080 if (name === 'clip') {
11081 self._setAttrClip(name, value);
11082 return;
11083 }
11084 self.__attrs[name] = value;
11085 if (typeof value === 'number' && isNaN(value)) {
11086 return;
11087 }
11088 if (self.get('destroyed')) {
11089 return;
11090 }
11091 if (name === 'transform' || name === 'rotate') {
11092 self._setAttrTrans(name, value);
11093 } else if (~name.indexOf('shadow')) {
11094 self._setAttrShadow(name, value);
11095 } else if (~['stroke', 'strokeStyle', 'fill', 'fillStyle'].indexOf(name) && el) {
11096 if (!value) {
11097 el.setAttribute(SVG_ATTR_MAP[name], 'none');
11098 } else if (/^[r,R,L,l]{1}[\s]*\(/.test(value.trim())) {
11099 self._setAttrGradients(name, value.trim());
11100 } else {
11101 el.setAttribute(SVG_ATTR_MAP[name], value);
11102 }
11103 } else if (~name.toLowerCase().indexOf('arrow')) {
11104 if (!value) {
11105 return self;
11106 }
11107 self._setAttrArrow(name, value);
11108 } else {
11109 // 先存好属性,然后对一些svg和canvas中不同的属性进行特判
11110 if (~['circle', 'ellipse', 'marker'].indexOf(self.type) && ~['x', 'y'].indexOf(name)) {
11111 /**
11112 * 本来考虑想写到对应图形里面的,但是x,y又是svg通用属性,这样会同时存在x,y, cx,cy
11113 * 如果在下面svgAttr设置的时候还是要特判,不如就在这边特殊处理一下吧
11114 */
11115 if (self.type !== 'marker' && typeof value === 'number') {
11116 el.setAttribute('c' + name, value);
11117 }
11118 } else {
11119 var svgAttr = SVG_ATTR_MAP[name];
11120 if (el && svgAttr) {
11121 el.setAttribute(svgAttr, value);
11122 }
11123 var alias = ALIAS_ATTRS_MAP[name];
11124 if (alias) {
11125 svgAttr = SVG_ATTR_MAP[alias];
11126 if (el && svgAttr) {
11127 el.setAttribute(svgAttr, value);
11128 }
11129 self.__attrs[alias] = value;
11130 }
11131 }
11132 }
11133 return self;
11134 },
11135 hasFill: function hasFill() {
11136 return this.canFill && this.__attrs.fillStyle;
11137 },
11138 hasStroke: function hasStroke() {
11139 return this.canStroke && this.__attrs.strokeStyle;
11140 },
11141 _setAttrArrow: function _setAttrArrow(name, value) {
11142 var self = this;
11143 var el = self.get('el');
11144 var defs = self.get('defs');
11145 if (!defs) {
11146 var canvas = self.get('canvas');
11147 if (!canvas) {
11148 this._setAttrDependency(name, value);
11149 return this;
11150 }
11151 defs = canvas.get('defs');
11152 }
11153 name = SVG_ATTR_MAP[name];
11154 if (!name) {
11155 return this;
11156 }
11157 if (!value) {
11158 el.removeAttribute(name);
11159 return this;
11160 }
11161 var id = defs.find(name, { value: value, stroke: self.__attrs.stroke });
11162 if (!id) {
11163 id = defs.addArrow(name, value, self.__attrs.stroke);
11164 }
11165 self.__cfg[name] = id;
11166 self.get('el').setAttribute(name, 'url(#' + id + ')');
11167 },
11168 _setAttrShadow: function _setAttrShadow(name, value) {
11169 var attrs = this.__attrs;
11170 var filter = this.get('filter');
11171 var defs = this.get('defs');
11172 if (!value) {
11173 this.get('el').removeAttribute('filter');
11174 return this;
11175 }
11176 if (filter) {
11177 defs.findById(filter).update(name, value);
11178 return this;
11179 }
11180 if (!defs) {
11181 var canvas = this.get('canvas');
11182 if (!canvas) {
11183 this._setAttrDependency(name, value);
11184 return this;
11185 }
11186 defs = canvas.get('defs');
11187 }
11188 var cfg = {
11189 dx: attrs.shadowOffsetX,
11190 dy: attrs.shadowOffsetY,
11191 blur: attrs.shadowBlur,
11192 color: attrs.shadowColor
11193 };
11194 if (isNaN(Number(cfg.dx)) || isNaN(Number(cfg.dy))) {
11195 return this;
11196 }
11197 var id = defs.find('filter', cfg);
11198 if (!id) {
11199 id = defs.addShadow(cfg, this);
11200 }
11201 this.__cfg.filter = id;
11202 this.get('el').setAttribute('filter', 'url(#' + id + ')');
11203 },
11204 _setAttrGradients: function _setAttrGradients(name, value) {
11205 name = name.replace('Style', '');
11206 var defs = this.get('defs');
11207 if (!value) {
11208 this.get('el').removeAttribute('gradient');
11209 return this;
11210 }
11211 if (!defs) {
11212 var canvas = this.get('canvas');
11213 if (!canvas) {
11214 this._setAttrDependency(name, value);
11215 return this;
11216 }
11217 defs = canvas.get('defs');
11218 }
11219 var id = defs.find('gradient', value);
11220 if (!id) {
11221 id = defs.addGradient(value, this);
11222 }
11223 this.get('el').setAttribute(name, 'url(#' + id + ')');
11224 },
11225 _setAttrDependency: function _setAttrDependency(name, value) {
11226 var dependencies = this.get('dependencies');
11227 if (!dependencies) {
11228 dependencies = {};
11229 }
11230 dependencies[name] = value;
11231 this.__cfg.dependencies = dependencies;
11232 return this;
11233 },
11234 _setAttrClip: function _setAttrClip(name, value) {
11235 var defs = this.get('defs');
11236 var canvas = this.get('canvas');
11237 if (!value) {
11238 this.get('el').removeAttribute('clip-path');
11239 return this;
11240 }
11241 if (!defs) {
11242 var _canvas = this.get('canvas');
11243 if (!_canvas) {
11244 this._setAttrDependency(name, value);
11245 return this;
11246 }
11247 defs = _canvas.get('defs');
11248 }
11249 value.__cfg.canvas = canvas;
11250 var id = defs.addClip(value);
11251 this.get('el').setAttribute('clip-path', 'url(#' + id + ')');
11252 },
11253 _setAttrTrans: function _setAttrTrans(name, value) {
11254 var attrs = this.__attrs;
11255 if (!value) {
11256 this.get('el').removeAttribute('transform');
11257 }
11258 if (!attrs.matrix) {
11259 this.initTransform();
11260 }
11261 if (name === 'transform') {
11262 this.transform(value);
11263 } else {
11264 if (typeof attrs.x === 'undefined' || typeof attrs.y === 'undefined') {
11265 this._setAttrDependency(name, value);
11266 return this;
11267 }
11268 this.rotateAtStart(value);
11269 }
11270 return this;
11271 }
11272};
11273
11274/***/ }),
11275/* 112 */
11276/***/ (function(module, exports, __webpack_require__) {
11277
11278var Util = __webpack_require__(0);
11279var mat3 = __webpack_require__(2).mat3;
11280var vec3 = __webpack_require__(2).vec3;
11281
11282// 是否未改变
11283function isUnchanged(m) {
11284 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
11285}
11286
11287// 是否仅仅是scale
11288function isScale(m) {
11289 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
11290}
11291
11292/* function multiple(m1, m2) {
11293 if (!isUnchanged(m2)) {
11294 if (isScale(m2)) {
11295 m1[0] *= m2[0];
11296 m1[4] *= m2[4];
11297 } else {
11298 mat3.multiply(m1, m1, m2);
11299 mat3.multiply(m1, m1, m2);
11300 }
11301 }
11302}*/
11303
11304module.exports = {
11305 initTransform: function initTransform() {
11306 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
11307 },
11308 translate: function translate(tx, ty, perform) {
11309 var matrix = this.attr('matrix');
11310 mat3.translate(matrix, matrix, [tx, ty]);
11311 this.attr('matrix', matrix);
11312 if (arguments.length === 2 || perform) {
11313 this._performTransform();
11314 }
11315 return this;
11316 },
11317 rotate: function rotate(radian, perform) {
11318 var matrix = this.attr('matrix');
11319 if (Math.abs(radian) > Math.PI * 2) {
11320 radian = radian / 180 * Math.PI;
11321 }
11322 mat3.rotate(matrix, matrix, radian);
11323 this.attr('matrix', matrix);
11324 if (arguments.length === 1 || perform) {
11325 this._performTransform();
11326 }
11327 return this;
11328 },
11329
11330 /**
11331 * 绕起始点旋转
11332 * @param {Number} rotate 0~360
11333 */
11334 rotateAtStart: function rotateAtStart(rotate) {
11335 var x = this.attr('x');
11336 var y = this.attr('y');
11337 if (Math.abs(rotate) > Math.PI * 2) {
11338 rotate = rotate / 180 * Math.PI;
11339 }
11340 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
11341 },
11342 scale: function scale(s1, s2, perform) {
11343 var matrix = this.attr('matrix');
11344 mat3.scale(matrix, matrix, [s1, s2]);
11345 this.attr('matrix', matrix);
11346 if (arguments.length === 2 || perform) {
11347 this._performTransform();
11348 }
11349 return this;
11350 },
11351
11352 /**
11353 * 移动的到位置
11354 * @param {Number} x 移动到x
11355 * @param {Number} y 移动到y
11356 */
11357 move: function move(x, y) {
11358 var cx = this.get('x') || 0; // 当前的x
11359 var cy = this.get('y') || 0; // 当前的y
11360 this.translate(x - cx, y - cy);
11361 this.set('x', x);
11362 this.set('y', y);
11363 },
11364 _performTransform: function _performTransform() {
11365 var matrix = this.__attrs.matrix;
11366 var transform = [];
11367 for (var i = 0; i < 9; i += 3) {
11368 transform.push(matrix[i] + ',' + matrix[i + 1]);
11369 }
11370 var el = this.get('el');
11371 if (el) {
11372 el.setAttribute('transform', 'matrix(' + transform.join(',') + ')');
11373 }
11374 },
11375 transform: function transform(ts) {
11376 var self = this;
11377 var matrix = self.attr('matrix');
11378 Util.each(ts, function (t) {
11379 switch (t[0]) {
11380 case 't':
11381 self.translate(t[1], t[2], false);
11382 break;
11383 case 's':
11384 self.scale(t[1], t[2], false);
11385 break;
11386 case 'r':
11387 self.rotate(t[1], false);
11388 break;
11389 case 'm':
11390 self.attr('matrix', mat3.multiply([], matrix, t[1]));
11391 break;
11392 default:
11393 break;
11394 }
11395 });
11396 this._performTransform();
11397 return self;
11398 },
11399 setTransform: function setTransform(ts) {
11400 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
11401 return this.transform(ts);
11402 },
11403 getMatrix: function getMatrix() {
11404 return this.attr('matrix');
11405 },
11406 setMatrix: function setMatrix(m) {
11407 this.attr('matrix', m);
11408 this._performTransform();
11409 this.clearTotalMatrix();
11410 return this;
11411 },
11412 apply: function apply(v, root) {
11413 var m = void 0;
11414 if (root) {
11415 m = this._getMatrixByRoot(root);
11416 } else {
11417 m = this.attr('matrix');
11418 }
11419 vec3.transformMat3(v, v, m);
11420 return this;
11421 },
11422 invert: function invert(v) {
11423 var m = this.attr('matrix');
11424 // 单精屏幕下大多数矩阵没变化
11425 if (isScale(m)) {
11426 v[0] /= m[0];
11427 v[1] /= m[4];
11428 } else {
11429 var inm = mat3.invert([], m);
11430 if (inm) {
11431 vec3.transformMat3(v, v, inm);
11432 }
11433 }
11434 return this;
11435 },
11436 resetTransform: function resetTransform(context) {
11437 var mo = this.attr('matrix');
11438 // 不改变时
11439 if (!isUnchanged(mo)) {
11440 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
11441 }
11442 }
11443};
11444
11445/***/ }),
11446/* 113 */
11447/***/ (function(module, exports, __webpack_require__) {
11448
11449
11450
11451Object.defineProperty(exports, "__esModule", {
11452 value: true
11453});
11454exports.sub = exports.mul = undefined;
11455exports.create = create;
11456exports.fromMat4 = fromMat4;
11457exports.clone = clone;
11458exports.copy = copy;
11459exports.fromValues = fromValues;
11460exports.set = set;
11461exports.identity = identity;
11462exports.transpose = transpose;
11463exports.invert = invert;
11464exports.adjoint = adjoint;
11465exports.determinant = determinant;
11466exports.multiply = multiply;
11467exports.translate = translate;
11468exports.rotate = rotate;
11469exports.scale = scale;
11470exports.fromTranslation = fromTranslation;
11471exports.fromRotation = fromRotation;
11472exports.fromScaling = fromScaling;
11473exports.fromMat2d = fromMat2d;
11474exports.fromQuat = fromQuat;
11475exports.normalFromMat4 = normalFromMat4;
11476exports.projection = projection;
11477exports.str = str;
11478exports.frob = frob;
11479exports.add = add;
11480exports.subtract = subtract;
11481exports.multiplyScalar = multiplyScalar;
11482exports.multiplyScalarAndAdd = multiplyScalarAndAdd;
11483exports.exactEquals = exactEquals;
11484exports.equals = equals;
11485
11486var _common = __webpack_require__(20);
11487
11488var glMatrix = _interopRequireWildcard(_common);
11489
11490function _interopRequireWildcard(obj) {
11491 if (obj && obj.__esModule) {
11492 return obj;
11493 } else {
11494 var newObj = {};if (obj != null) {
11495 for (var key in obj) {
11496 if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
11497 }
11498 }newObj.default = obj;return newObj;
11499 }
11500}
11501
11502/**
11503 * 3x3 Matrix
11504 * @module mat3
11505 */
11506
11507/**
11508 * Creates a new identity mat3
11509 *
11510 * @returns {mat3} a new 3x3 matrix
11511 */
11512function create() {
11513 var out = new glMatrix.ARRAY_TYPE(9);
11514 if (glMatrix.ARRAY_TYPE != Float32Array) {
11515 out[1] = 0;
11516 out[2] = 0;
11517 out[3] = 0;
11518 out[5] = 0;
11519 out[6] = 0;
11520 out[7] = 0;
11521 }
11522 out[0] = 1;
11523 out[4] = 1;
11524 out[8] = 1;
11525 return out;
11526}
11527
11528/**
11529 * Copies the upper-left 3x3 values into the given mat3.
11530 *
11531 * @param {mat3} out the receiving 3x3 matrix
11532 * @param {mat4} a the source 4x4 matrix
11533 * @returns {mat3} out
11534 */
11535function fromMat4(out, a) {
11536 out[0] = a[0];
11537 out[1] = a[1];
11538 out[2] = a[2];
11539 out[3] = a[4];
11540 out[4] = a[5];
11541 out[5] = a[6];
11542 out[6] = a[8];
11543 out[7] = a[9];
11544 out[8] = a[10];
11545 return out;
11546}
11547
11548/**
11549 * Creates a new mat3 initialized with values from an existing matrix
11550 *
11551 * @param {mat3} a matrix to clone
11552 * @returns {mat3} a new 3x3 matrix
11553 */
11554function clone(a) {
11555 var out = new glMatrix.ARRAY_TYPE(9);
11556 out[0] = a[0];
11557 out[1] = a[1];
11558 out[2] = a[2];
11559 out[3] = a[3];
11560 out[4] = a[4];
11561 out[5] = a[5];
11562 out[6] = a[6];
11563 out[7] = a[7];
11564 out[8] = a[8];
11565 return out;
11566}
11567
11568/**
11569 * Copy the values from one mat3 to another
11570 *
11571 * @param {mat3} out the receiving matrix
11572 * @param {mat3} a the source matrix
11573 * @returns {mat3} out
11574 */
11575function copy(out, a) {
11576 out[0] = a[0];
11577 out[1] = a[1];
11578 out[2] = a[2];
11579 out[3] = a[3];
11580 out[4] = a[4];
11581 out[5] = a[5];
11582 out[6] = a[6];
11583 out[7] = a[7];
11584 out[8] = a[8];
11585 return out;
11586}
11587
11588/**
11589 * Create a new mat3 with the given values
11590 *
11591 * @param {Number} m00 Component in column 0, row 0 position (index 0)
11592 * @param {Number} m01 Component in column 0, row 1 position (index 1)
11593 * @param {Number} m02 Component in column 0, row 2 position (index 2)
11594 * @param {Number} m10 Component in column 1, row 0 position (index 3)
11595 * @param {Number} m11 Component in column 1, row 1 position (index 4)
11596 * @param {Number} m12 Component in column 1, row 2 position (index 5)
11597 * @param {Number} m20 Component in column 2, row 0 position (index 6)
11598 * @param {Number} m21 Component in column 2, row 1 position (index 7)
11599 * @param {Number} m22 Component in column 2, row 2 position (index 8)
11600 * @returns {mat3} A new mat3
11601 */
11602function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
11603 var out = new glMatrix.ARRAY_TYPE(9);
11604 out[0] = m00;
11605 out[1] = m01;
11606 out[2] = m02;
11607 out[3] = m10;
11608 out[4] = m11;
11609 out[5] = m12;
11610 out[6] = m20;
11611 out[7] = m21;
11612 out[8] = m22;
11613 return out;
11614}
11615
11616/**
11617 * Set the components of a mat3 to the given values
11618 *
11619 * @param {mat3} out the receiving matrix
11620 * @param {Number} m00 Component in column 0, row 0 position (index 0)
11621 * @param {Number} m01 Component in column 0, row 1 position (index 1)
11622 * @param {Number} m02 Component in column 0, row 2 position (index 2)
11623 * @param {Number} m10 Component in column 1, row 0 position (index 3)
11624 * @param {Number} m11 Component in column 1, row 1 position (index 4)
11625 * @param {Number} m12 Component in column 1, row 2 position (index 5)
11626 * @param {Number} m20 Component in column 2, row 0 position (index 6)
11627 * @param {Number} m21 Component in column 2, row 1 position (index 7)
11628 * @param {Number} m22 Component in column 2, row 2 position (index 8)
11629 * @returns {mat3} out
11630 */
11631function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
11632 out[0] = m00;
11633 out[1] = m01;
11634 out[2] = m02;
11635 out[3] = m10;
11636 out[4] = m11;
11637 out[5] = m12;
11638 out[6] = m20;
11639 out[7] = m21;
11640 out[8] = m22;
11641 return out;
11642}
11643
11644/**
11645 * Set a mat3 to the identity matrix
11646 *
11647 * @param {mat3} out the receiving matrix
11648 * @returns {mat3} out
11649 */
11650function identity(out) {
11651 out[0] = 1;
11652 out[1] = 0;
11653 out[2] = 0;
11654 out[3] = 0;
11655 out[4] = 1;
11656 out[5] = 0;
11657 out[6] = 0;
11658 out[7] = 0;
11659 out[8] = 1;
11660 return out;
11661}
11662
11663/**
11664 * Transpose the values of a mat3
11665 *
11666 * @param {mat3} out the receiving matrix
11667 * @param {mat3} a the source matrix
11668 * @returns {mat3} out
11669 */
11670function transpose(out, a) {
11671 // If we are transposing ourselves we can skip a few steps but have to cache some values
11672 if (out === a) {
11673 var a01 = a[1],
11674 a02 = a[2],
11675 a12 = a[5];
11676 out[1] = a[3];
11677 out[2] = a[6];
11678 out[3] = a01;
11679 out[5] = a[7];
11680 out[6] = a02;
11681 out[7] = a12;
11682 } else {
11683 out[0] = a[0];
11684 out[1] = a[3];
11685 out[2] = a[6];
11686 out[3] = a[1];
11687 out[4] = a[4];
11688 out[5] = a[7];
11689 out[6] = a[2];
11690 out[7] = a[5];
11691 out[8] = a[8];
11692 }
11693
11694 return out;
11695}
11696
11697/**
11698 * Inverts a mat3
11699 *
11700 * @param {mat3} out the receiving matrix
11701 * @param {mat3} a the source matrix
11702 * @returns {mat3} out
11703 */
11704function invert(out, a) {
11705 var a00 = a[0],
11706 a01 = a[1],
11707 a02 = a[2];
11708 var a10 = a[3],
11709 a11 = a[4],
11710 a12 = a[5];
11711 var a20 = a[6],
11712 a21 = a[7],
11713 a22 = a[8];
11714
11715 var b01 = a22 * a11 - a12 * a21;
11716 var b11 = -a22 * a10 + a12 * a20;
11717 var b21 = a21 * a10 - a11 * a20;
11718
11719 // Calculate the determinant
11720 var det = a00 * b01 + a01 * b11 + a02 * b21;
11721
11722 if (!det) {
11723 return null;
11724 }
11725 det = 1.0 / det;
11726
11727 out[0] = b01 * det;
11728 out[1] = (-a22 * a01 + a02 * a21) * det;
11729 out[2] = (a12 * a01 - a02 * a11) * det;
11730 out[3] = b11 * det;
11731 out[4] = (a22 * a00 - a02 * a20) * det;
11732 out[5] = (-a12 * a00 + a02 * a10) * det;
11733 out[6] = b21 * det;
11734 out[7] = (-a21 * a00 + a01 * a20) * det;
11735 out[8] = (a11 * a00 - a01 * a10) * det;
11736 return out;
11737}
11738
11739/**
11740 * Calculates the adjugate of a mat3
11741 *
11742 * @param {mat3} out the receiving matrix
11743 * @param {mat3} a the source matrix
11744 * @returns {mat3} out
11745 */
11746function adjoint(out, a) {
11747 var a00 = a[0],
11748 a01 = a[1],
11749 a02 = a[2];
11750 var a10 = a[3],
11751 a11 = a[4],
11752 a12 = a[5];
11753 var a20 = a[6],
11754 a21 = a[7],
11755 a22 = a[8];
11756
11757 out[0] = a11 * a22 - a12 * a21;
11758 out[1] = a02 * a21 - a01 * a22;
11759 out[2] = a01 * a12 - a02 * a11;
11760 out[3] = a12 * a20 - a10 * a22;
11761 out[4] = a00 * a22 - a02 * a20;
11762 out[5] = a02 * a10 - a00 * a12;
11763 out[6] = a10 * a21 - a11 * a20;
11764 out[7] = a01 * a20 - a00 * a21;
11765 out[8] = a00 * a11 - a01 * a10;
11766 return out;
11767}
11768
11769/**
11770 * Calculates the determinant of a mat3
11771 *
11772 * @param {mat3} a the source matrix
11773 * @returns {Number} determinant of a
11774 */
11775function determinant(a) {
11776 var a00 = a[0],
11777 a01 = a[1],
11778 a02 = a[2];
11779 var a10 = a[3],
11780 a11 = a[4],
11781 a12 = a[5];
11782 var a20 = a[6],
11783 a21 = a[7],
11784 a22 = a[8];
11785
11786 return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
11787}
11788
11789/**
11790 * Multiplies two mat3's
11791 *
11792 * @param {mat3} out the receiving matrix
11793 * @param {mat3} a the first operand
11794 * @param {mat3} b the second operand
11795 * @returns {mat3} out
11796 */
11797function multiply(out, a, b) {
11798 var a00 = a[0],
11799 a01 = a[1],
11800 a02 = a[2];
11801 var a10 = a[3],
11802 a11 = a[4],
11803 a12 = a[5];
11804 var a20 = a[6],
11805 a21 = a[7],
11806 a22 = a[8];
11807
11808 var b00 = b[0],
11809 b01 = b[1],
11810 b02 = b[2];
11811 var b10 = b[3],
11812 b11 = b[4],
11813 b12 = b[5];
11814 var b20 = b[6],
11815 b21 = b[7],
11816 b22 = b[8];
11817
11818 out[0] = b00 * a00 + b01 * a10 + b02 * a20;
11819 out[1] = b00 * a01 + b01 * a11 + b02 * a21;
11820 out[2] = b00 * a02 + b01 * a12 + b02 * a22;
11821
11822 out[3] = b10 * a00 + b11 * a10 + b12 * a20;
11823 out[4] = b10 * a01 + b11 * a11 + b12 * a21;
11824 out[5] = b10 * a02 + b11 * a12 + b12 * a22;
11825
11826 out[6] = b20 * a00 + b21 * a10 + b22 * a20;
11827 out[7] = b20 * a01 + b21 * a11 + b22 * a21;
11828 out[8] = b20 * a02 + b21 * a12 + b22 * a22;
11829 return out;
11830}
11831
11832/**
11833 * Translate a mat3 by the given vector
11834 *
11835 * @param {mat3} out the receiving matrix
11836 * @param {mat3} a the matrix to translate
11837 * @param {vec2} v vector to translate by
11838 * @returns {mat3} out
11839 */
11840function translate(out, a, v) {
11841 var a00 = a[0],
11842 a01 = a[1],
11843 a02 = a[2],
11844 a10 = a[3],
11845 a11 = a[4],
11846 a12 = a[5],
11847 a20 = a[6],
11848 a21 = a[7],
11849 a22 = a[8],
11850 x = v[0],
11851 y = v[1];
11852
11853 out[0] = a00;
11854 out[1] = a01;
11855 out[2] = a02;
11856
11857 out[3] = a10;
11858 out[4] = a11;
11859 out[5] = a12;
11860
11861 out[6] = x * a00 + y * a10 + a20;
11862 out[7] = x * a01 + y * a11 + a21;
11863 out[8] = x * a02 + y * a12 + a22;
11864 return out;
11865}
11866
11867/**
11868 * Rotates a mat3 by the given angle
11869 *
11870 * @param {mat3} out the receiving matrix
11871 * @param {mat3} a the matrix to rotate
11872 * @param {Number} rad the angle to rotate the matrix by
11873 * @returns {mat3} out
11874 */
11875function rotate(out, a, rad) {
11876 var a00 = a[0],
11877 a01 = a[1],
11878 a02 = a[2],
11879 a10 = a[3],
11880 a11 = a[4],
11881 a12 = a[5],
11882 a20 = a[6],
11883 a21 = a[7],
11884 a22 = a[8],
11885 s = Math.sin(rad),
11886 c = Math.cos(rad);
11887
11888 out[0] = c * a00 + s * a10;
11889 out[1] = c * a01 + s * a11;
11890 out[2] = c * a02 + s * a12;
11891
11892 out[3] = c * a10 - s * a00;
11893 out[4] = c * a11 - s * a01;
11894 out[5] = c * a12 - s * a02;
11895
11896 out[6] = a20;
11897 out[7] = a21;
11898 out[8] = a22;
11899 return out;
11900};
11901
11902/**
11903 * Scales the mat3 by the dimensions in the given vec2
11904 *
11905 * @param {mat3} out the receiving matrix
11906 * @param {mat3} a the matrix to rotate
11907 * @param {vec2} v the vec2 to scale the matrix by
11908 * @returns {mat3} out
11909 **/
11910function scale(out, a, v) {
11911 var x = v[0],
11912 y = v[1];
11913
11914 out[0] = x * a[0];
11915 out[1] = x * a[1];
11916 out[2] = x * a[2];
11917
11918 out[3] = y * a[3];
11919 out[4] = y * a[4];
11920 out[5] = y * a[5];
11921
11922 out[6] = a[6];
11923 out[7] = a[7];
11924 out[8] = a[8];
11925 return out;
11926}
11927
11928/**
11929 * Creates a matrix from a vector translation
11930 * This is equivalent to (but much faster than):
11931 *
11932 * mat3.identity(dest);
11933 * mat3.translate(dest, dest, vec);
11934 *
11935 * @param {mat3} out mat3 receiving operation result
11936 * @param {vec2} v Translation vector
11937 * @returns {mat3} out
11938 */
11939function fromTranslation(out, v) {
11940 out[0] = 1;
11941 out[1] = 0;
11942 out[2] = 0;
11943 out[3] = 0;
11944 out[4] = 1;
11945 out[5] = 0;
11946 out[6] = v[0];
11947 out[7] = v[1];
11948 out[8] = 1;
11949 return out;
11950}
11951
11952/**
11953 * Creates a matrix from a given angle
11954 * This is equivalent to (but much faster than):
11955 *
11956 * mat3.identity(dest);
11957 * mat3.rotate(dest, dest, rad);
11958 *
11959 * @param {mat3} out mat3 receiving operation result
11960 * @param {Number} rad the angle to rotate the matrix by
11961 * @returns {mat3} out
11962 */
11963function fromRotation(out, rad) {
11964 var s = Math.sin(rad),
11965 c = Math.cos(rad);
11966
11967 out[0] = c;
11968 out[1] = s;
11969 out[2] = 0;
11970
11971 out[3] = -s;
11972 out[4] = c;
11973 out[5] = 0;
11974
11975 out[6] = 0;
11976 out[7] = 0;
11977 out[8] = 1;
11978 return out;
11979}
11980
11981/**
11982 * Creates a matrix from a vector scaling
11983 * This is equivalent to (but much faster than):
11984 *
11985 * mat3.identity(dest);
11986 * mat3.scale(dest, dest, vec);
11987 *
11988 * @param {mat3} out mat3 receiving operation result
11989 * @param {vec2} v Scaling vector
11990 * @returns {mat3} out
11991 */
11992function fromScaling(out, v) {
11993 out[0] = v[0];
11994 out[1] = 0;
11995 out[2] = 0;
11996
11997 out[3] = 0;
11998 out[4] = v[1];
11999 out[5] = 0;
12000
12001 out[6] = 0;
12002 out[7] = 0;
12003 out[8] = 1;
12004 return out;
12005}
12006
12007/**
12008 * Copies the values from a mat2d into a mat3
12009 *
12010 * @param {mat3} out the receiving matrix
12011 * @param {mat2d} a the matrix to copy
12012 * @returns {mat3} out
12013 **/
12014function fromMat2d(out, a) {
12015 out[0] = a[0];
12016 out[1] = a[1];
12017 out[2] = 0;
12018
12019 out[3] = a[2];
12020 out[4] = a[3];
12021 out[5] = 0;
12022
12023 out[6] = a[4];
12024 out[7] = a[5];
12025 out[8] = 1;
12026 return out;
12027}
12028
12029/**
12030* Calculates a 3x3 matrix from the given quaternion
12031*
12032* @param {mat3} out mat3 receiving operation result
12033* @param {quat} q Quaternion to create matrix from
12034*
12035* @returns {mat3} out
12036*/
12037function fromQuat(out, q) {
12038 var x = q[0],
12039 y = q[1],
12040 z = q[2],
12041 w = q[3];
12042 var x2 = x + x;
12043 var y2 = y + y;
12044 var z2 = z + z;
12045
12046 var xx = x * x2;
12047 var yx = y * x2;
12048 var yy = y * y2;
12049 var zx = z * x2;
12050 var zy = z * y2;
12051 var zz = z * z2;
12052 var wx = w * x2;
12053 var wy = w * y2;
12054 var wz = w * z2;
12055
12056 out[0] = 1 - yy - zz;
12057 out[3] = yx - wz;
12058 out[6] = zx + wy;
12059
12060 out[1] = yx + wz;
12061 out[4] = 1 - xx - zz;
12062 out[7] = zy - wx;
12063
12064 out[2] = zx - wy;
12065 out[5] = zy + wx;
12066 out[8] = 1 - xx - yy;
12067
12068 return out;
12069}
12070
12071/**
12072* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
12073*
12074* @param {mat3} out mat3 receiving operation result
12075* @param {mat4} a Mat4 to derive the normal matrix from
12076*
12077* @returns {mat3} out
12078*/
12079function normalFromMat4(out, a) {
12080 var a00 = a[0],
12081 a01 = a[1],
12082 a02 = a[2],
12083 a03 = a[3];
12084 var a10 = a[4],
12085 a11 = a[5],
12086 a12 = a[6],
12087 a13 = a[7];
12088 var a20 = a[8],
12089 a21 = a[9],
12090 a22 = a[10],
12091 a23 = a[11];
12092 var a30 = a[12],
12093 a31 = a[13],
12094 a32 = a[14],
12095 a33 = a[15];
12096
12097 var b00 = a00 * a11 - a01 * a10;
12098 var b01 = a00 * a12 - a02 * a10;
12099 var b02 = a00 * a13 - a03 * a10;
12100 var b03 = a01 * a12 - a02 * a11;
12101 var b04 = a01 * a13 - a03 * a11;
12102 var b05 = a02 * a13 - a03 * a12;
12103 var b06 = a20 * a31 - a21 * a30;
12104 var b07 = a20 * a32 - a22 * a30;
12105 var b08 = a20 * a33 - a23 * a30;
12106 var b09 = a21 * a32 - a22 * a31;
12107 var b10 = a21 * a33 - a23 * a31;
12108 var b11 = a22 * a33 - a23 * a32;
12109
12110 // Calculate the determinant
12111 var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
12112
12113 if (!det) {
12114 return null;
12115 }
12116 det = 1.0 / det;
12117
12118 out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
12119 out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
12120 out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
12121
12122 out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
12123 out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
12124 out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
12125
12126 out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
12127 out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
12128 out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
12129
12130 return out;
12131}
12132
12133/**
12134 * Generates a 2D projection matrix with the given bounds
12135 *
12136 * @param {mat3} out mat3 frustum matrix will be written into
12137 * @param {number} width Width of your gl context
12138 * @param {number} height Height of gl context
12139 * @returns {mat3} out
12140 */
12141function projection(out, width, height) {
12142 out[0] = 2 / width;
12143 out[1] = 0;
12144 out[2] = 0;
12145 out[3] = 0;
12146 out[4] = -2 / height;
12147 out[5] = 0;
12148 out[6] = -1;
12149 out[7] = 1;
12150 out[8] = 1;
12151 return out;
12152}
12153
12154/**
12155 * Returns a string representation of a mat3
12156 *
12157 * @param {mat3} a matrix to represent as a string
12158 * @returns {String} string representation of the matrix
12159 */
12160function str(a) {
12161 return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
12162}
12163
12164/**
12165 * Returns Frobenius norm of a mat3
12166 *
12167 * @param {mat3} a the matrix to calculate Frobenius norm of
12168 * @returns {Number} Frobenius norm
12169 */
12170function frob(a) {
12171 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));
12172}
12173
12174/**
12175 * Adds two mat3's
12176 *
12177 * @param {mat3} out the receiving matrix
12178 * @param {mat3} a the first operand
12179 * @param {mat3} b the second operand
12180 * @returns {mat3} out
12181 */
12182function add(out, a, b) {
12183 out[0] = a[0] + b[0];
12184 out[1] = a[1] + b[1];
12185 out[2] = a[2] + b[2];
12186 out[3] = a[3] + b[3];
12187 out[4] = a[4] + b[4];
12188 out[5] = a[5] + b[5];
12189 out[6] = a[6] + b[6];
12190 out[7] = a[7] + b[7];
12191 out[8] = a[8] + b[8];
12192 return out;
12193}
12194
12195/**
12196 * Subtracts matrix b from matrix a
12197 *
12198 * @param {mat3} out the receiving matrix
12199 * @param {mat3} a the first operand
12200 * @param {mat3} b the second operand
12201 * @returns {mat3} out
12202 */
12203function subtract(out, a, b) {
12204 out[0] = a[0] - b[0];
12205 out[1] = a[1] - b[1];
12206 out[2] = a[2] - b[2];
12207 out[3] = a[3] - b[3];
12208 out[4] = a[4] - b[4];
12209 out[5] = a[5] - b[5];
12210 out[6] = a[6] - b[6];
12211 out[7] = a[7] - b[7];
12212 out[8] = a[8] - b[8];
12213 return out;
12214}
12215
12216/**
12217 * Multiply each element of the matrix by a scalar.
12218 *
12219 * @param {mat3} out the receiving matrix
12220 * @param {mat3} a the matrix to scale
12221 * @param {Number} b amount to scale the matrix's elements by
12222 * @returns {mat3} out
12223 */
12224function multiplyScalar(out, a, b) {
12225 out[0] = a[0] * b;
12226 out[1] = a[1] * b;
12227 out[2] = a[2] * b;
12228 out[3] = a[3] * b;
12229 out[4] = a[4] * b;
12230 out[5] = a[5] * b;
12231 out[6] = a[6] * b;
12232 out[7] = a[7] * b;
12233 out[8] = a[8] * b;
12234 return out;
12235}
12236
12237/**
12238 * Adds two mat3's after multiplying each element of the second operand by a scalar value.
12239 *
12240 * @param {mat3} out the receiving vector
12241 * @param {mat3} a the first operand
12242 * @param {mat3} b the second operand
12243 * @param {Number} scale the amount to scale b's elements by before adding
12244 * @returns {mat3} out
12245 */
12246function multiplyScalarAndAdd(out, a, b, scale) {
12247 out[0] = a[0] + b[0] * scale;
12248 out[1] = a[1] + b[1] * scale;
12249 out[2] = a[2] + b[2] * scale;
12250 out[3] = a[3] + b[3] * scale;
12251 out[4] = a[4] + b[4] * scale;
12252 out[5] = a[5] + b[5] * scale;
12253 out[6] = a[6] + b[6] * scale;
12254 out[7] = a[7] + b[7] * scale;
12255 out[8] = a[8] + b[8] * scale;
12256 return out;
12257}
12258
12259/**
12260 * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
12261 *
12262 * @param {mat3} a The first matrix.
12263 * @param {mat3} b The second matrix.
12264 * @returns {Boolean} True if the matrices are equal, false otherwise.
12265 */
12266function exactEquals(a, b) {
12267 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];
12268}
12269
12270/**
12271 * Returns whether or not the matrices have approximately the same elements in the same position.
12272 *
12273 * @param {mat3} a The first matrix.
12274 * @param {mat3} b The second matrix.
12275 * @returns {Boolean} True if the matrices are equal, false otherwise.
12276 */
12277function equals(a, b) {
12278 var a0 = a[0],
12279 a1 = a[1],
12280 a2 = a[2],
12281 a3 = a[3],
12282 a4 = a[4],
12283 a5 = a[5],
12284 a6 = a[6],
12285 a7 = a[7],
12286 a8 = a[8];
12287 var b0 = b[0],
12288 b1 = b[1],
12289 b2 = b[2],
12290 b3 = b[3],
12291 b4 = b[4],
12292 b5 = b[5],
12293 b6 = b[6],
12294 b7 = b[7],
12295 b8 = b[8];
12296 return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
12297}
12298
12299/**
12300 * Alias for {@link mat3.multiply}
12301 * @function
12302 */
12303var mul = exports.mul = multiply;
12304
12305/**
12306 * Alias for {@link mat3.subtract}
12307 * @function
12308 */
12309var sub = exports.sub = subtract;
12310
12311/***/ }),
12312/* 114 */
12313/***/ (function(module, exports, __webpack_require__) {
12314
12315
12316
12317Object.defineProperty(exports, "__esModule", {
12318 value: true
12319});
12320exports.forEach = exports.sqrLen = exports.len = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = undefined;
12321exports.create = create;
12322exports.clone = clone;
12323exports.length = length;
12324exports.fromValues = fromValues;
12325exports.copy = copy;
12326exports.set = set;
12327exports.add = add;
12328exports.subtract = subtract;
12329exports.multiply = multiply;
12330exports.divide = divide;
12331exports.ceil = ceil;
12332exports.floor = floor;
12333exports.min = min;
12334exports.max = max;
12335exports.round = round;
12336exports.scale = scale;
12337exports.scaleAndAdd = scaleAndAdd;
12338exports.distance = distance;
12339exports.squaredDistance = squaredDistance;
12340exports.squaredLength = squaredLength;
12341exports.negate = negate;
12342exports.inverse = inverse;
12343exports.normalize = normalize;
12344exports.dot = dot;
12345exports.cross = cross;
12346exports.lerp = lerp;
12347exports.hermite = hermite;
12348exports.bezier = bezier;
12349exports.random = random;
12350exports.transformMat4 = transformMat4;
12351exports.transformMat3 = transformMat3;
12352exports.transformQuat = transformQuat;
12353exports.rotateX = rotateX;
12354exports.rotateY = rotateY;
12355exports.rotateZ = rotateZ;
12356exports.angle = angle;
12357exports.str = str;
12358exports.exactEquals = exactEquals;
12359exports.equals = equals;
12360
12361var _common = __webpack_require__(20);
12362
12363var glMatrix = _interopRequireWildcard(_common);
12364
12365function _interopRequireWildcard(obj) {
12366 if (obj && obj.__esModule) {
12367 return obj;
12368 } else {
12369 var newObj = {};if (obj != null) {
12370 for (var key in obj) {
12371 if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
12372 }
12373 }newObj.default = obj;return newObj;
12374 }
12375}
12376
12377/**
12378 * 3 Dimensional Vector
12379 * @module vec3
12380 */
12381
12382/**
12383 * Creates a new, empty vec3
12384 *
12385 * @returns {vec3} a new 3D vector
12386 */
12387function create() {
12388 var out = new glMatrix.ARRAY_TYPE(3);
12389 if (glMatrix.ARRAY_TYPE != Float32Array) {
12390 out[0] = 0;
12391 out[1] = 0;
12392 out[2] = 0;
12393 }
12394 return out;
12395}
12396
12397/**
12398 * Creates a new vec3 initialized with values from an existing vector
12399 *
12400 * @param {vec3} a vector to clone
12401 * @returns {vec3} a new 3D vector
12402 */
12403function clone(a) {
12404 var out = new glMatrix.ARRAY_TYPE(3);
12405 out[0] = a[0];
12406 out[1] = a[1];
12407 out[2] = a[2];
12408 return out;
12409}
12410
12411/**
12412 * Calculates the length of a vec3
12413 *
12414 * @param {vec3} a vector to calculate length of
12415 * @returns {Number} length of a
12416 */
12417function length(a) {
12418 var x = a[0];
12419 var y = a[1];
12420 var z = a[2];
12421 return Math.sqrt(x * x + y * y + z * z);
12422}
12423
12424/**
12425 * Creates a new vec3 initialized with the given values
12426 *
12427 * @param {Number} x X component
12428 * @param {Number} y Y component
12429 * @param {Number} z Z component
12430 * @returns {vec3} a new 3D vector
12431 */
12432function fromValues(x, y, z) {
12433 var out = new glMatrix.ARRAY_TYPE(3);
12434 out[0] = x;
12435 out[1] = y;
12436 out[2] = z;
12437 return out;
12438}
12439
12440/**
12441 * Copy the values from one vec3 to another
12442 *
12443 * @param {vec3} out the receiving vector
12444 * @param {vec3} a the source vector
12445 * @returns {vec3} out
12446 */
12447function copy(out, a) {
12448 out[0] = a[0];
12449 out[1] = a[1];
12450 out[2] = a[2];
12451 return out;
12452}
12453
12454/**
12455 * Set the components of a vec3 to the given values
12456 *
12457 * @param {vec3} out the receiving vector
12458 * @param {Number} x X component
12459 * @param {Number} y Y component
12460 * @param {Number} z Z component
12461 * @returns {vec3} out
12462 */
12463function set(out, x, y, z) {
12464 out[0] = x;
12465 out[1] = y;
12466 out[2] = z;
12467 return out;
12468}
12469
12470/**
12471 * Adds two vec3's
12472 *
12473 * @param {vec3} out the receiving vector
12474 * @param {vec3} a the first operand
12475 * @param {vec3} b the second operand
12476 * @returns {vec3} out
12477 */
12478function add(out, a, b) {
12479 out[0] = a[0] + b[0];
12480 out[1] = a[1] + b[1];
12481 out[2] = a[2] + b[2];
12482 return out;
12483}
12484
12485/**
12486 * Subtracts vector b from vector a
12487 *
12488 * @param {vec3} out the receiving vector
12489 * @param {vec3} a the first operand
12490 * @param {vec3} b the second operand
12491 * @returns {vec3} out
12492 */
12493function subtract(out, a, b) {
12494 out[0] = a[0] - b[0];
12495 out[1] = a[1] - b[1];
12496 out[2] = a[2] - b[2];
12497 return out;
12498}
12499
12500/**
12501 * Multiplies two vec3's
12502 *
12503 * @param {vec3} out the receiving vector
12504 * @param {vec3} a the first operand
12505 * @param {vec3} b the second operand
12506 * @returns {vec3} out
12507 */
12508function multiply(out, a, b) {
12509 out[0] = a[0] * b[0];
12510 out[1] = a[1] * b[1];
12511 out[2] = a[2] * b[2];
12512 return out;
12513}
12514
12515/**
12516 * Divides two vec3's
12517 *
12518 * @param {vec3} out the receiving vector
12519 * @param {vec3} a the first operand
12520 * @param {vec3} b the second operand
12521 * @returns {vec3} out
12522 */
12523function divide(out, a, b) {
12524 out[0] = a[0] / b[0];
12525 out[1] = a[1] / b[1];
12526 out[2] = a[2] / b[2];
12527 return out;
12528}
12529
12530/**
12531 * Math.ceil the components of a vec3
12532 *
12533 * @param {vec3} out the receiving vector
12534 * @param {vec3} a vector to ceil
12535 * @returns {vec3} out
12536 */
12537function ceil(out, a) {
12538 out[0] = Math.ceil(a[0]);
12539 out[1] = Math.ceil(a[1]);
12540 out[2] = Math.ceil(a[2]);
12541 return out;
12542}
12543
12544/**
12545 * Math.floor the components of a vec3
12546 *
12547 * @param {vec3} out the receiving vector
12548 * @param {vec3} a vector to floor
12549 * @returns {vec3} out
12550 */
12551function floor(out, a) {
12552 out[0] = Math.floor(a[0]);
12553 out[1] = Math.floor(a[1]);
12554 out[2] = Math.floor(a[2]);
12555 return out;
12556}
12557
12558/**
12559 * Returns the minimum of two vec3's
12560 *
12561 * @param {vec3} out the receiving vector
12562 * @param {vec3} a the first operand
12563 * @param {vec3} b the second operand
12564 * @returns {vec3} out
12565 */
12566function min(out, a, b) {
12567 out[0] = Math.min(a[0], b[0]);
12568 out[1] = Math.min(a[1], b[1]);
12569 out[2] = Math.min(a[2], b[2]);
12570 return out;
12571}
12572
12573/**
12574 * Returns the maximum of two vec3's
12575 *
12576 * @param {vec3} out the receiving vector
12577 * @param {vec3} a the first operand
12578 * @param {vec3} b the second operand
12579 * @returns {vec3} out
12580 */
12581function max(out, a, b) {
12582 out[0] = Math.max(a[0], b[0]);
12583 out[1] = Math.max(a[1], b[1]);
12584 out[2] = Math.max(a[2], b[2]);
12585 return out;
12586}
12587
12588/**
12589 * Math.round the components of a vec3
12590 *
12591 * @param {vec3} out the receiving vector
12592 * @param {vec3} a vector to round
12593 * @returns {vec3} out
12594 */
12595function round(out, a) {
12596 out[0] = Math.round(a[0]);
12597 out[1] = Math.round(a[1]);
12598 out[2] = Math.round(a[2]);
12599 return out;
12600}
12601
12602/**
12603 * Scales a vec3 by a scalar number
12604 *
12605 * @param {vec3} out the receiving vector
12606 * @param {vec3} a the vector to scale
12607 * @param {Number} b amount to scale the vector by
12608 * @returns {vec3} out
12609 */
12610function scale(out, a, b) {
12611 out[0] = a[0] * b;
12612 out[1] = a[1] * b;
12613 out[2] = a[2] * b;
12614 return out;
12615}
12616
12617/**
12618 * Adds two vec3's after scaling the second operand by a scalar value
12619 *
12620 * @param {vec3} out the receiving vector
12621 * @param {vec3} a the first operand
12622 * @param {vec3} b the second operand
12623 * @param {Number} scale the amount to scale b by before adding
12624 * @returns {vec3} out
12625 */
12626function scaleAndAdd(out, a, b, scale) {
12627 out[0] = a[0] + b[0] * scale;
12628 out[1] = a[1] + b[1] * scale;
12629 out[2] = a[2] + b[2] * scale;
12630 return out;
12631}
12632
12633/**
12634 * Calculates the euclidian distance between two vec3's
12635 *
12636 * @param {vec3} a the first operand
12637 * @param {vec3} b the second operand
12638 * @returns {Number} distance between a and b
12639 */
12640function distance(a, b) {
12641 var x = b[0] - a[0];
12642 var y = b[1] - a[1];
12643 var z = b[2] - a[2];
12644 return Math.sqrt(x * x + y * y + z * z);
12645}
12646
12647/**
12648 * Calculates the squared euclidian distance between two vec3's
12649 *
12650 * @param {vec3} a the first operand
12651 * @param {vec3} b the second operand
12652 * @returns {Number} squared distance between a and b
12653 */
12654function squaredDistance(a, b) {
12655 var x = b[0] - a[0];
12656 var y = b[1] - a[1];
12657 var z = b[2] - a[2];
12658 return x * x + y * y + z * z;
12659}
12660
12661/**
12662 * Calculates the squared length of a vec3
12663 *
12664 * @param {vec3} a vector to calculate squared length of
12665 * @returns {Number} squared length of a
12666 */
12667function squaredLength(a) {
12668 var x = a[0];
12669 var y = a[1];
12670 var z = a[2];
12671 return x * x + y * y + z * z;
12672}
12673
12674/**
12675 * Negates the components of a vec3
12676 *
12677 * @param {vec3} out the receiving vector
12678 * @param {vec3} a vector to negate
12679 * @returns {vec3} out
12680 */
12681function negate(out, a) {
12682 out[0] = -a[0];
12683 out[1] = -a[1];
12684 out[2] = -a[2];
12685 return out;
12686}
12687
12688/**
12689 * Returns the inverse of the components of a vec3
12690 *
12691 * @param {vec3} out the receiving vector
12692 * @param {vec3} a vector to invert
12693 * @returns {vec3} out
12694 */
12695function inverse(out, a) {
12696 out[0] = 1.0 / a[0];
12697 out[1] = 1.0 / a[1];
12698 out[2] = 1.0 / a[2];
12699 return out;
12700}
12701
12702/**
12703 * Normalize a vec3
12704 *
12705 * @param {vec3} out the receiving vector
12706 * @param {vec3} a vector to normalize
12707 * @returns {vec3} out
12708 */
12709function normalize(out, a) {
12710 var x = a[0];
12711 var y = a[1];
12712 var z = a[2];
12713 var len = x * x + y * y + z * z;
12714 if (len > 0) {
12715 //TODO: evaluate use of glm_invsqrt here?
12716 len = 1 / Math.sqrt(len);
12717 out[0] = a[0] * len;
12718 out[1] = a[1] * len;
12719 out[2] = a[2] * len;
12720 }
12721 return out;
12722}
12723
12724/**
12725 * Calculates the dot product of two vec3's
12726 *
12727 * @param {vec3} a the first operand
12728 * @param {vec3} b the second operand
12729 * @returns {Number} dot product of a and b
12730 */
12731function dot(a, b) {
12732 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
12733}
12734
12735/**
12736 * Computes the cross product of two vec3's
12737 *
12738 * @param {vec3} out the receiving vector
12739 * @param {vec3} a the first operand
12740 * @param {vec3} b the second operand
12741 * @returns {vec3} out
12742 */
12743function cross(out, a, b) {
12744 var ax = a[0],
12745 ay = a[1],
12746 az = a[2];
12747 var bx = b[0],
12748 by = b[1],
12749 bz = b[2];
12750
12751 out[0] = ay * bz - az * by;
12752 out[1] = az * bx - ax * bz;
12753 out[2] = ax * by - ay * bx;
12754 return out;
12755}
12756
12757/**
12758 * Performs a linear interpolation between two vec3's
12759 *
12760 * @param {vec3} out the receiving vector
12761 * @param {vec3} a the first operand
12762 * @param {vec3} b the second operand
12763 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
12764 * @returns {vec3} out
12765 */
12766function lerp(out, a, b, t) {
12767 var ax = a[0];
12768 var ay = a[1];
12769 var az = a[2];
12770 out[0] = ax + t * (b[0] - ax);
12771 out[1] = ay + t * (b[1] - ay);
12772 out[2] = az + t * (b[2] - az);
12773 return out;
12774}
12775
12776/**
12777 * Performs a hermite interpolation with two control points
12778 *
12779 * @param {vec3} out the receiving vector
12780 * @param {vec3} a the first operand
12781 * @param {vec3} b the second operand
12782 * @param {vec3} c the third operand
12783 * @param {vec3} d the fourth operand
12784 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
12785 * @returns {vec3} out
12786 */
12787function hermite(out, a, b, c, d, t) {
12788 var factorTimes2 = t * t;
12789 var factor1 = factorTimes2 * (2 * t - 3) + 1;
12790 var factor2 = factorTimes2 * (t - 2) + t;
12791 var factor3 = factorTimes2 * (t - 1);
12792 var factor4 = factorTimes2 * (3 - 2 * t);
12793
12794 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
12795 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
12796 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
12797
12798 return out;
12799}
12800
12801/**
12802 * Performs a bezier interpolation with two control points
12803 *
12804 * @param {vec3} out the receiving vector
12805 * @param {vec3} a the first operand
12806 * @param {vec3} b the second operand
12807 * @param {vec3} c the third operand
12808 * @param {vec3} d the fourth operand
12809 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
12810 * @returns {vec3} out
12811 */
12812function bezier(out, a, b, c, d, t) {
12813 var inverseFactor = 1 - t;
12814 var inverseFactorTimesTwo = inverseFactor * inverseFactor;
12815 var factorTimes2 = t * t;
12816 var factor1 = inverseFactorTimesTwo * inverseFactor;
12817 var factor2 = 3 * t * inverseFactorTimesTwo;
12818 var factor3 = 3 * factorTimes2 * inverseFactor;
12819 var factor4 = factorTimes2 * t;
12820
12821 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
12822 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
12823 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
12824
12825 return out;
12826}
12827
12828/**
12829 * Generates a random vector with the given scale
12830 *
12831 * @param {vec3} out the receiving vector
12832 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
12833 * @returns {vec3} out
12834 */
12835function random(out, scale) {
12836 scale = scale || 1.0;
12837
12838 var r = glMatrix.RANDOM() * 2.0 * Math.PI;
12839 var z = glMatrix.RANDOM() * 2.0 - 1.0;
12840 var zScale = Math.sqrt(1.0 - z * z) * scale;
12841
12842 out[0] = Math.cos(r) * zScale;
12843 out[1] = Math.sin(r) * zScale;
12844 out[2] = z * scale;
12845 return out;
12846}
12847
12848/**
12849 * Transforms the vec3 with a mat4.
12850 * 4th vector component is implicitly '1'
12851 *
12852 * @param {vec3} out the receiving vector
12853 * @param {vec3} a the vector to transform
12854 * @param {mat4} m matrix to transform with
12855 * @returns {vec3} out
12856 */
12857function transformMat4(out, a, m) {
12858 var x = a[0],
12859 y = a[1],
12860 z = a[2];
12861 var w = m[3] * x + m[7] * y + m[11] * z + m[15];
12862 w = w || 1.0;
12863 out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
12864 out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
12865 out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
12866 return out;
12867}
12868
12869/**
12870 * Transforms the vec3 with a mat3.
12871 *
12872 * @param {vec3} out the receiving vector
12873 * @param {vec3} a the vector to transform
12874 * @param {mat3} m the 3x3 matrix to transform with
12875 * @returns {vec3} out
12876 */
12877function transformMat3(out, a, m) {
12878 var x = a[0],
12879 y = a[1],
12880 z = a[2];
12881 out[0] = x * m[0] + y * m[3] + z * m[6];
12882 out[1] = x * m[1] + y * m[4] + z * m[7];
12883 out[2] = x * m[2] + y * m[5] + z * m[8];
12884 return out;
12885}
12886
12887/**
12888 * Transforms the vec3 with a quat
12889 * Can also be used for dual quaternions. (Multiply it with the real part)
12890 *
12891 * @param {vec3} out the receiving vector
12892 * @param {vec3} a the vector to transform
12893 * @param {quat} q quaternion to transform with
12894 * @returns {vec3} out
12895 */
12896function transformQuat(out, a, q) {
12897 // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
12898 var qx = q[0],
12899 qy = q[1],
12900 qz = q[2],
12901 qw = q[3];
12902 var x = a[0],
12903 y = a[1],
12904 z = a[2];
12905 // var qvec = [qx, qy, qz];
12906 // var uv = vec3.cross([], qvec, a);
12907 var uvx = qy * z - qz * y,
12908 uvy = qz * x - qx * z,
12909 uvz = qx * y - qy * x;
12910 // var uuv = vec3.cross([], qvec, uv);
12911 var uuvx = qy * uvz - qz * uvy,
12912 uuvy = qz * uvx - qx * uvz,
12913 uuvz = qx * uvy - qy * uvx;
12914 // vec3.scale(uv, uv, 2 * w);
12915 var w2 = qw * 2;
12916 uvx *= w2;
12917 uvy *= w2;
12918 uvz *= w2;
12919 // vec3.scale(uuv, uuv, 2);
12920 uuvx *= 2;
12921 uuvy *= 2;
12922 uuvz *= 2;
12923 // return vec3.add(out, a, vec3.add(out, uv, uuv));
12924 out[0] = x + uvx + uuvx;
12925 out[1] = y + uvy + uuvy;
12926 out[2] = z + uvz + uuvz;
12927 return out;
12928}
12929
12930/**
12931 * Rotate a 3D vector around the x-axis
12932 * @param {vec3} out The receiving vec3
12933 * @param {vec3} a The vec3 point to rotate
12934 * @param {vec3} b The origin of the rotation
12935 * @param {Number} c The angle of rotation
12936 * @returns {vec3} out
12937 */
12938function rotateX(out, a, b, c) {
12939 var p = [],
12940 r = [];
12941 //Translate point to the origin
12942 p[0] = a[0] - b[0];
12943 p[1] = a[1] - b[1];
12944 p[2] = a[2] - b[2];
12945
12946 //perform rotation
12947 r[0] = p[0];
12948 r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
12949 r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
12950
12951 //translate to correct position
12952 out[0] = r[0] + b[0];
12953 out[1] = r[1] + b[1];
12954 out[2] = r[2] + b[2];
12955
12956 return out;
12957}
12958
12959/**
12960 * Rotate a 3D vector around the y-axis
12961 * @param {vec3} out The receiving vec3
12962 * @param {vec3} a The vec3 point to rotate
12963 * @param {vec3} b The origin of the rotation
12964 * @param {Number} c The angle of rotation
12965 * @returns {vec3} out
12966 */
12967function rotateY(out, a, b, c) {
12968 var p = [],
12969 r = [];
12970 //Translate point to the origin
12971 p[0] = a[0] - b[0];
12972 p[1] = a[1] - b[1];
12973 p[2] = a[2] - b[2];
12974
12975 //perform rotation
12976 r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
12977 r[1] = p[1];
12978 r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
12979
12980 //translate to correct position
12981 out[0] = r[0] + b[0];
12982 out[1] = r[1] + b[1];
12983 out[2] = r[2] + b[2];
12984
12985 return out;
12986}
12987
12988/**
12989 * Rotate a 3D vector around the z-axis
12990 * @param {vec3} out The receiving vec3
12991 * @param {vec3} a The vec3 point to rotate
12992 * @param {vec3} b The origin of the rotation
12993 * @param {Number} c The angle of rotation
12994 * @returns {vec3} out
12995 */
12996function rotateZ(out, a, b, c) {
12997 var p = [],
12998 r = [];
12999 //Translate point to the origin
13000 p[0] = a[0] - b[0];
13001 p[1] = a[1] - b[1];
13002 p[2] = a[2] - b[2];
13003
13004 //perform rotation
13005 r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
13006 r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
13007 r[2] = p[2];
13008
13009 //translate to correct position
13010 out[0] = r[0] + b[0];
13011 out[1] = r[1] + b[1];
13012 out[2] = r[2] + b[2];
13013
13014 return out;
13015}
13016
13017/**
13018 * Get the angle between two 3D vectors
13019 * @param {vec3} a The first operand
13020 * @param {vec3} b The second operand
13021 * @returns {Number} The angle in radians
13022 */
13023function angle(a, b) {
13024 var tempA = fromValues(a[0], a[1], a[2]);
13025 var tempB = fromValues(b[0], b[1], b[2]);
13026
13027 normalize(tempA, tempA);
13028 normalize(tempB, tempB);
13029
13030 var cosine = dot(tempA, tempB);
13031
13032 if (cosine > 1.0) {
13033 return 0;
13034 } else if (cosine < -1.0) {
13035 return Math.PI;
13036 } else {
13037 return Math.acos(cosine);
13038 }
13039}
13040
13041/**
13042 * Returns a string representation of a vector
13043 *
13044 * @param {vec3} a vector to represent as a string
13045 * @returns {String} string representation of the vector
13046 */
13047function str(a) {
13048 return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
13049}
13050
13051/**
13052 * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
13053 *
13054 * @param {vec3} a The first vector.
13055 * @param {vec3} b The second vector.
13056 * @returns {Boolean} True if the vectors are equal, false otherwise.
13057 */
13058function exactEquals(a, b) {
13059 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
13060}
13061
13062/**
13063 * Returns whether or not the vectors have approximately the same elements in the same position.
13064 *
13065 * @param {vec3} a The first vector.
13066 * @param {vec3} b The second vector.
13067 * @returns {Boolean} True if the vectors are equal, false otherwise.
13068 */
13069function equals(a, b) {
13070 var a0 = a[0],
13071 a1 = a[1],
13072 a2 = a[2];
13073 var b0 = b[0],
13074 b1 = b[1],
13075 b2 = b[2];
13076 return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2));
13077}
13078
13079/**
13080 * Alias for {@link vec3.subtract}
13081 * @function
13082 */
13083var sub = exports.sub = subtract;
13084
13085/**
13086 * Alias for {@link vec3.multiply}
13087 * @function
13088 */
13089var mul = exports.mul = multiply;
13090
13091/**
13092 * Alias for {@link vec3.divide}
13093 * @function
13094 */
13095var div = exports.div = divide;
13096
13097/**
13098 * Alias for {@link vec3.distance}
13099 * @function
13100 */
13101var dist = exports.dist = distance;
13102
13103/**
13104 * Alias for {@link vec3.squaredDistance}
13105 * @function
13106 */
13107var sqrDist = exports.sqrDist = squaredDistance;
13108
13109/**
13110 * Alias for {@link vec3.length}
13111 * @function
13112 */
13113var len = exports.len = length;
13114
13115/**
13116 * Alias for {@link vec3.squaredLength}
13117 * @function
13118 */
13119var sqrLen = exports.sqrLen = squaredLength;
13120
13121/**
13122 * Perform some operation over an array of vec3s.
13123 *
13124 * @param {Array} a the array of vectors to iterate over
13125 * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
13126 * @param {Number} offset Number of elements to skip at the beginning of the array
13127 * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
13128 * @param {Function} fn Function to call for each vector in the array
13129 * @param {Object} [arg] additional argument to pass to fn
13130 * @returns {Array} a
13131 * @function
13132 */
13133var forEach = exports.forEach = function () {
13134 var vec = create();
13135
13136 return function (a, stride, offset, count, fn, arg) {
13137 var i = void 0,
13138 l = void 0;
13139 if (!stride) {
13140 stride = 3;
13141 }
13142
13143 if (!offset) {
13144 offset = 0;
13145 }
13146
13147 if (count) {
13148 l = Math.min(count * stride + offset, a.length);
13149 } else {
13150 l = a.length;
13151 }
13152
13153 for (i = offset; i < l; i += stride) {
13154 vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
13155 fn(vec, vec, arg);
13156 a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
13157 }
13158
13159 return a;
13160 };
13161}();
13162
13163/***/ }),
13164/* 115 */
13165/***/ (function(module, exports, __webpack_require__) {
13166
13167
13168
13169Object.defineProperty(exports, "__esModule", {
13170 value: true
13171});
13172exports.forEach = exports.sqrLen = exports.sqrDist = exports.dist = exports.div = exports.mul = exports.sub = exports.len = undefined;
13173exports.create = create;
13174exports.clone = clone;
13175exports.fromValues = fromValues;
13176exports.copy = copy;
13177exports.set = set;
13178exports.add = add;
13179exports.subtract = subtract;
13180exports.multiply = multiply;
13181exports.divide = divide;
13182exports.ceil = ceil;
13183exports.floor = floor;
13184exports.min = min;
13185exports.max = max;
13186exports.round = round;
13187exports.scale = scale;
13188exports.scaleAndAdd = scaleAndAdd;
13189exports.distance = distance;
13190exports.squaredDistance = squaredDistance;
13191exports.length = length;
13192exports.squaredLength = squaredLength;
13193exports.negate = negate;
13194exports.inverse = inverse;
13195exports.normalize = normalize;
13196exports.dot = dot;
13197exports.cross = cross;
13198exports.lerp = lerp;
13199exports.random = random;
13200exports.transformMat2 = transformMat2;
13201exports.transformMat2d = transformMat2d;
13202exports.transformMat3 = transformMat3;
13203exports.transformMat4 = transformMat4;
13204exports.rotate = rotate;
13205exports.angle = angle;
13206exports.str = str;
13207exports.exactEquals = exactEquals;
13208exports.equals = equals;
13209
13210var _common = __webpack_require__(20);
13211
13212var glMatrix = _interopRequireWildcard(_common);
13213
13214function _interopRequireWildcard(obj) {
13215 if (obj && obj.__esModule) {
13216 return obj;
13217 } else {
13218 var newObj = {};if (obj != null) {
13219 for (var key in obj) {
13220 if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key];
13221 }
13222 }newObj.default = obj;return newObj;
13223 }
13224}
13225
13226/**
13227 * 2 Dimensional Vector
13228 * @module vec2
13229 */
13230
13231/**
13232 * Creates a new, empty vec2
13233 *
13234 * @returns {vec2} a new 2D vector
13235 */
13236function create() {
13237 var out = new glMatrix.ARRAY_TYPE(2);
13238 if (glMatrix.ARRAY_TYPE != Float32Array) {
13239 out[0] = 0;
13240 out[1] = 0;
13241 }
13242 return out;
13243}
13244
13245/**
13246 * Creates a new vec2 initialized with values from an existing vector
13247 *
13248 * @param {vec2} a vector to clone
13249 * @returns {vec2} a new 2D vector
13250 */
13251function clone(a) {
13252 var out = new glMatrix.ARRAY_TYPE(2);
13253 out[0] = a[0];
13254 out[1] = a[1];
13255 return out;
13256}
13257
13258/**
13259 * Creates a new vec2 initialized with the given values
13260 *
13261 * @param {Number} x X component
13262 * @param {Number} y Y component
13263 * @returns {vec2} a new 2D vector
13264 */
13265function fromValues(x, y) {
13266 var out = new glMatrix.ARRAY_TYPE(2);
13267 out[0] = x;
13268 out[1] = y;
13269 return out;
13270}
13271
13272/**
13273 * Copy the values from one vec2 to another
13274 *
13275 * @param {vec2} out the receiving vector
13276 * @param {vec2} a the source vector
13277 * @returns {vec2} out
13278 */
13279function copy(out, a) {
13280 out[0] = a[0];
13281 out[1] = a[1];
13282 return out;
13283}
13284
13285/**
13286 * Set the components of a vec2 to the given values
13287 *
13288 * @param {vec2} out the receiving vector
13289 * @param {Number} x X component
13290 * @param {Number} y Y component
13291 * @returns {vec2} out
13292 */
13293function set(out, x, y) {
13294 out[0] = x;
13295 out[1] = y;
13296 return out;
13297}
13298
13299/**
13300 * Adds two vec2's
13301 *
13302 * @param {vec2} out the receiving vector
13303 * @param {vec2} a the first operand
13304 * @param {vec2} b the second operand
13305 * @returns {vec2} out
13306 */
13307function add(out, a, b) {
13308 out[0] = a[0] + b[0];
13309 out[1] = a[1] + b[1];
13310 return out;
13311}
13312
13313/**
13314 * Subtracts vector b from vector a
13315 *
13316 * @param {vec2} out the receiving vector
13317 * @param {vec2} a the first operand
13318 * @param {vec2} b the second operand
13319 * @returns {vec2} out
13320 */
13321function subtract(out, a, b) {
13322 out[0] = a[0] - b[0];
13323 out[1] = a[1] - b[1];
13324 return out;
13325}
13326
13327/**
13328 * Multiplies two vec2's
13329 *
13330 * @param {vec2} out the receiving vector
13331 * @param {vec2} a the first operand
13332 * @param {vec2} b the second operand
13333 * @returns {vec2} out
13334 */
13335function multiply(out, a, b) {
13336 out[0] = a[0] * b[0];
13337 out[1] = a[1] * b[1];
13338 return out;
13339}
13340
13341/**
13342 * Divides two vec2's
13343 *
13344 * @param {vec2} out the receiving vector
13345 * @param {vec2} a the first operand
13346 * @param {vec2} b the second operand
13347 * @returns {vec2} out
13348 */
13349function divide(out, a, b) {
13350 out[0] = a[0] / b[0];
13351 out[1] = a[1] / b[1];
13352 return out;
13353}
13354
13355/**
13356 * Math.ceil the components of a vec2
13357 *
13358 * @param {vec2} out the receiving vector
13359 * @param {vec2} a vector to ceil
13360 * @returns {vec2} out
13361 */
13362function ceil(out, a) {
13363 out[0] = Math.ceil(a[0]);
13364 out[1] = Math.ceil(a[1]);
13365 return out;
13366}
13367
13368/**
13369 * Math.floor the components of a vec2
13370 *
13371 * @param {vec2} out the receiving vector
13372 * @param {vec2} a vector to floor
13373 * @returns {vec2} out
13374 */
13375function floor(out, a) {
13376 out[0] = Math.floor(a[0]);
13377 out[1] = Math.floor(a[1]);
13378 return out;
13379}
13380
13381/**
13382 * Returns the minimum of two vec2's
13383 *
13384 * @param {vec2} out the receiving vector
13385 * @param {vec2} a the first operand
13386 * @param {vec2} b the second operand
13387 * @returns {vec2} out
13388 */
13389function min(out, a, b) {
13390 out[0] = Math.min(a[0], b[0]);
13391 out[1] = Math.min(a[1], b[1]);
13392 return out;
13393}
13394
13395/**
13396 * Returns the maximum of two vec2's
13397 *
13398 * @param {vec2} out the receiving vector
13399 * @param {vec2} a the first operand
13400 * @param {vec2} b the second operand
13401 * @returns {vec2} out
13402 */
13403function max(out, a, b) {
13404 out[0] = Math.max(a[0], b[0]);
13405 out[1] = Math.max(a[1], b[1]);
13406 return out;
13407}
13408
13409/**
13410 * Math.round the components of a vec2
13411 *
13412 * @param {vec2} out the receiving vector
13413 * @param {vec2} a vector to round
13414 * @returns {vec2} out
13415 */
13416function round(out, a) {
13417 out[0] = Math.round(a[0]);
13418 out[1] = Math.round(a[1]);
13419 return out;
13420}
13421
13422/**
13423 * Scales a vec2 by a scalar number
13424 *
13425 * @param {vec2} out the receiving vector
13426 * @param {vec2} a the vector to scale
13427 * @param {Number} b amount to scale the vector by
13428 * @returns {vec2} out
13429 */
13430function scale(out, a, b) {
13431 out[0] = a[0] * b;
13432 out[1] = a[1] * b;
13433 return out;
13434}
13435
13436/**
13437 * Adds two vec2's after scaling the second operand by a scalar value
13438 *
13439 * @param {vec2} out the receiving vector
13440 * @param {vec2} a the first operand
13441 * @param {vec2} b the second operand
13442 * @param {Number} scale the amount to scale b by before adding
13443 * @returns {vec2} out
13444 */
13445function scaleAndAdd(out, a, b, scale) {
13446 out[0] = a[0] + b[0] * scale;
13447 out[1] = a[1] + b[1] * scale;
13448 return out;
13449}
13450
13451/**
13452 * Calculates the euclidian distance between two vec2's
13453 *
13454 * @param {vec2} a the first operand
13455 * @param {vec2} b the second operand
13456 * @returns {Number} distance between a and b
13457 */
13458function distance(a, b) {
13459 var x = b[0] - a[0],
13460 y = b[1] - a[1];
13461 return Math.sqrt(x * x + y * y);
13462}
13463
13464/**
13465 * Calculates the squared euclidian distance between two vec2's
13466 *
13467 * @param {vec2} a the first operand
13468 * @param {vec2} b the second operand
13469 * @returns {Number} squared distance between a and b
13470 */
13471function squaredDistance(a, b) {
13472 var x = b[0] - a[0],
13473 y = b[1] - a[1];
13474 return x * x + y * y;
13475}
13476
13477/**
13478 * Calculates the length of a vec2
13479 *
13480 * @param {vec2} a vector to calculate length of
13481 * @returns {Number} length of a
13482 */
13483function length(a) {
13484 var x = a[0],
13485 y = a[1];
13486 return Math.sqrt(x * x + y * y);
13487}
13488
13489/**
13490 * Calculates the squared length of a vec2
13491 *
13492 * @param {vec2} a vector to calculate squared length of
13493 * @returns {Number} squared length of a
13494 */
13495function squaredLength(a) {
13496 var x = a[0],
13497 y = a[1];
13498 return x * x + y * y;
13499}
13500
13501/**
13502 * Negates the components of a vec2
13503 *
13504 * @param {vec2} out the receiving vector
13505 * @param {vec2} a vector to negate
13506 * @returns {vec2} out
13507 */
13508function negate(out, a) {
13509 out[0] = -a[0];
13510 out[1] = -a[1];
13511 return out;
13512}
13513
13514/**
13515 * Returns the inverse of the components of a vec2
13516 *
13517 * @param {vec2} out the receiving vector
13518 * @param {vec2} a vector to invert
13519 * @returns {vec2} out
13520 */
13521function inverse(out, a) {
13522 out[0] = 1.0 / a[0];
13523 out[1] = 1.0 / a[1];
13524 return out;
13525}
13526
13527/**
13528 * Normalize a vec2
13529 *
13530 * @param {vec2} out the receiving vector
13531 * @param {vec2} a vector to normalize
13532 * @returns {vec2} out
13533 */
13534function normalize(out, a) {
13535 var x = a[0],
13536 y = a[1];
13537 var len = x * x + y * y;
13538 if (len > 0) {
13539 //TODO: evaluate use of glm_invsqrt here?
13540 len = 1 / Math.sqrt(len);
13541 out[0] = a[0] * len;
13542 out[1] = a[1] * len;
13543 }
13544 return out;
13545}
13546
13547/**
13548 * Calculates the dot product of two vec2's
13549 *
13550 * @param {vec2} a the first operand
13551 * @param {vec2} b the second operand
13552 * @returns {Number} dot product of a and b
13553 */
13554function dot(a, b) {
13555 return a[0] * b[0] + a[1] * b[1];
13556}
13557
13558/**
13559 * Computes the cross product of two vec2's
13560 * Note that the cross product must by definition produce a 3D vector
13561 *
13562 * @param {vec3} out the receiving vector
13563 * @param {vec2} a the first operand
13564 * @param {vec2} b the second operand
13565 * @returns {vec3} out
13566 */
13567function cross(out, a, b) {
13568 var z = a[0] * b[1] - a[1] * b[0];
13569 out[0] = out[1] = 0;
13570 out[2] = z;
13571 return out;
13572}
13573
13574/**
13575 * Performs a linear interpolation between two vec2's
13576 *
13577 * @param {vec2} out the receiving vector
13578 * @param {vec2} a the first operand
13579 * @param {vec2} b the second operand
13580 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13581 * @returns {vec2} out
13582 */
13583function lerp(out, a, b, t) {
13584 var ax = a[0],
13585 ay = a[1];
13586 out[0] = ax + t * (b[0] - ax);
13587 out[1] = ay + t * (b[1] - ay);
13588 return out;
13589}
13590
13591/**
13592 * Generates a random vector with the given scale
13593 *
13594 * @param {vec2} out the receiving vector
13595 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
13596 * @returns {vec2} out
13597 */
13598function random(out, scale) {
13599 scale = scale || 1.0;
13600 var r = glMatrix.RANDOM() * 2.0 * Math.PI;
13601 out[0] = Math.cos(r) * scale;
13602 out[1] = Math.sin(r) * scale;
13603 return out;
13604}
13605
13606/**
13607 * Transforms the vec2 with a mat2
13608 *
13609 * @param {vec2} out the receiving vector
13610 * @param {vec2} a the vector to transform
13611 * @param {mat2} m matrix to transform with
13612 * @returns {vec2} out
13613 */
13614function transformMat2(out, a, m) {
13615 var x = a[0],
13616 y = a[1];
13617 out[0] = m[0] * x + m[2] * y;
13618 out[1] = m[1] * x + m[3] * y;
13619 return out;
13620}
13621
13622/**
13623 * Transforms the vec2 with a mat2d
13624 *
13625 * @param {vec2} out the receiving vector
13626 * @param {vec2} a the vector to transform
13627 * @param {mat2d} m matrix to transform with
13628 * @returns {vec2} out
13629 */
13630function transformMat2d(out, a, m) {
13631 var x = a[0],
13632 y = a[1];
13633 out[0] = m[0] * x + m[2] * y + m[4];
13634 out[1] = m[1] * x + m[3] * y + m[5];
13635 return out;
13636}
13637
13638/**
13639 * Transforms the vec2 with a mat3
13640 * 3rd vector component is implicitly '1'
13641 *
13642 * @param {vec2} out the receiving vector
13643 * @param {vec2} a the vector to transform
13644 * @param {mat3} m matrix to transform with
13645 * @returns {vec2} out
13646 */
13647function transformMat3(out, a, m) {
13648 var x = a[0],
13649 y = a[1];
13650 out[0] = m[0] * x + m[3] * y + m[6];
13651 out[1] = m[1] * x + m[4] * y + m[7];
13652 return out;
13653}
13654
13655/**
13656 * Transforms the vec2 with a mat4
13657 * 3rd vector component is implicitly '0'
13658 * 4th vector component is implicitly '1'
13659 *
13660 * @param {vec2} out the receiving vector
13661 * @param {vec2} a the vector to transform
13662 * @param {mat4} m matrix to transform with
13663 * @returns {vec2} out
13664 */
13665function transformMat4(out, a, m) {
13666 var x = a[0];
13667 var y = a[1];
13668 out[0] = m[0] * x + m[4] * y + m[12];
13669 out[1] = m[1] * x + m[5] * y + m[13];
13670 return out;
13671}
13672
13673/**
13674 * Rotate a 2D vector
13675 * @param {vec2} out The receiving vec2
13676 * @param {vec2} a The vec2 point to rotate
13677 * @param {vec2} b The origin of the rotation
13678 * @param {Number} c The angle of rotation
13679 * @returns {vec2} out
13680 */
13681function rotate(out, a, b, c) {
13682 //Translate point to the origin
13683 var p0 = a[0] - b[0],
13684 p1 = a[1] - b[1],
13685 sinC = Math.sin(c),
13686 cosC = Math.cos(c);
13687
13688 //perform rotation and translate to correct position
13689 out[0] = p0 * cosC - p1 * sinC + b[0];
13690 out[1] = p0 * sinC + p1 * cosC + b[1];
13691
13692 return out;
13693}
13694
13695/**
13696 * Get the angle between two 2D vectors
13697 * @param {vec2} a The first operand
13698 * @param {vec2} b The second operand
13699 * @returns {Number} The angle in radians
13700 */
13701function angle(a, b) {
13702 var x1 = a[0],
13703 y1 = a[1],
13704 x2 = b[0],
13705 y2 = b[1];
13706
13707 var len1 = x1 * x1 + y1 * y1;
13708 if (len1 > 0) {
13709 //TODO: evaluate use of glm_invsqrt here?
13710 len1 = 1 / Math.sqrt(len1);
13711 }
13712
13713 var len2 = x2 * x2 + y2 * y2;
13714 if (len2 > 0) {
13715 //TODO: evaluate use of glm_invsqrt here?
13716 len2 = 1 / Math.sqrt(len2);
13717 }
13718
13719 var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
13720
13721 if (cosine > 1.0) {
13722 return 0;
13723 } else if (cosine < -1.0) {
13724 return Math.PI;
13725 } else {
13726 return Math.acos(cosine);
13727 }
13728}
13729
13730/**
13731 * Returns a string representation of a vector
13732 *
13733 * @param {vec2} a vector to represent as a string
13734 * @returns {String} string representation of the vector
13735 */
13736function str(a) {
13737 return 'vec2(' + a[0] + ', ' + a[1] + ')';
13738}
13739
13740/**
13741 * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
13742 *
13743 * @param {vec2} a The first vector.
13744 * @param {vec2} b The second vector.
13745 * @returns {Boolean} True if the vectors are equal, false otherwise.
13746 */
13747function exactEquals(a, b) {
13748 return a[0] === b[0] && a[1] === b[1];
13749}
13750
13751/**
13752 * Returns whether or not the vectors have approximately the same elements in the same position.
13753 *
13754 * @param {vec2} a The first vector.
13755 * @param {vec2} b The second vector.
13756 * @returns {Boolean} True if the vectors are equal, false otherwise.
13757 */
13758function equals(a, b) {
13759 var a0 = a[0],
13760 a1 = a[1];
13761 var b0 = b[0],
13762 b1 = b[1];
13763 return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1));
13764}
13765
13766/**
13767 * Alias for {@link vec2.length}
13768 * @function
13769 */
13770var len = exports.len = length;
13771
13772/**
13773 * Alias for {@link vec2.subtract}
13774 * @function
13775 */
13776var sub = exports.sub = subtract;
13777
13778/**
13779 * Alias for {@link vec2.multiply}
13780 * @function
13781 */
13782var mul = exports.mul = multiply;
13783
13784/**
13785 * Alias for {@link vec2.divide}
13786 * @function
13787 */
13788var div = exports.div = divide;
13789
13790/**
13791 * Alias for {@link vec2.distance}
13792 * @function
13793 */
13794var dist = exports.dist = distance;
13795
13796/**
13797 * Alias for {@link vec2.squaredDistance}
13798 * @function
13799 */
13800var sqrDist = exports.sqrDist = squaredDistance;
13801
13802/**
13803 * Alias for {@link vec2.squaredLength}
13804 * @function
13805 */
13806var sqrLen = exports.sqrLen = squaredLength;
13807
13808/**
13809 * Perform some operation over an array of vec2s.
13810 *
13811 * @param {Array} a the array of vectors to iterate over
13812 * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
13813 * @param {Number} offset Number of elements to skip at the beginning of the array
13814 * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
13815 * @param {Function} fn Function to call for each vector in the array
13816 * @param {Object} [arg] additional argument to pass to fn
13817 * @returns {Array} a
13818 * @function
13819 */
13820var forEach = exports.forEach = function () {
13821 var vec = create();
13822
13823 return function (a, stride, offset, count, fn, arg) {
13824 var i = void 0,
13825 l = void 0;
13826 if (!stride) {
13827 stride = 2;
13828 }
13829
13830 if (!offset) {
13831 offset = 0;
13832 }
13833
13834 if (count) {
13835 l = Math.min(count * stride + offset, a.length);
13836 } else {
13837 l = a.length;
13838 }
13839
13840 for (i = offset; i < l; i += stride) {
13841 vec[0] = a[i];vec[1] = a[i + 1];
13842 fn(vec, vec, arg);
13843 a[i] = vec[0];a[i + 1] = vec[1];
13844 }
13845
13846 return a;
13847 };
13848}();
13849
13850/***/ }),
13851/* 116 */
13852/***/ (function(module, exports, __webpack_require__) {
13853
13854var Shape = __webpack_require__(4);
13855Shape.Rect = __webpack_require__(46);
13856Shape.Circle = __webpack_require__(47);
13857Shape.Ellipse = __webpack_require__(48);
13858Shape.Path = __webpack_require__(49);
13859Shape.Text = __webpack_require__(50);
13860Shape.Line = __webpack_require__(51);
13861Shape.Image = __webpack_require__(52);
13862Shape.Polygon = __webpack_require__(53);
13863Shape.Marker = __webpack_require__(54);
13864Shape.Dom = __webpack_require__(55);
13865Shape.Fa = __webpack_require__(56);
13866
13867module.exports = Shape;
13868
13869/***/ }),
13870/* 117 */
13871/***/ (function(module, exports, __webpack_require__) {
13872
13873/**
13874 * Created by Elaine on 2018/5/9.
13875 */
13876var Util = __webpack_require__(0);
13877var Element = __webpack_require__(19);
13878var Gradient = __webpack_require__(118);
13879var Shadow = __webpack_require__(119);
13880var Arrow = __webpack_require__(120);
13881var Clip = __webpack_require__(121);
13882
13883var Defs = function Defs(cfg) {
13884 Defs.superclass.constructor.call(this, cfg);
13885 this.set('children', []);
13886};
13887
13888Util.extend(Defs, Element);
13889
13890Util.augment(Defs, {
13891 isGroup: false,
13892 canFill: false,
13893 canStroke: false,
13894 capture: false,
13895 visible: false,
13896 init: function init() {
13897 var el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
13898 var id = Util.uniqueId('defs_');
13899 el.setAttribute('id', id);
13900 this.set('el', el);
13901 this.set('children', []);
13902 },
13903 find: function find(type, attr) {
13904 var children = this.get('children');
13905 var result = null;
13906 for (var i = 0; i < children.length; i++) {
13907 if (children[i].match(type, attr)) {
13908 result = children[i].__cfg.id;
13909 break;
13910 }
13911 }
13912 return result;
13913 },
13914 findById: function findById(id) {
13915 var children = this.get('children');
13916 var flag = null;
13917 for (var i = 0; i < children.length; i++) {
13918 if (children[i].__cfg.id === id) {
13919 flag = children[i];
13920 break;
13921 }
13922 }
13923 return flag;
13924 },
13925 add: function add(items) {
13926 var el = this.get('el');
13927 var self = this;
13928 var children = this.get('children');
13929 if (Util.isArray(items)) {
13930 Util.each(items, function (item) {
13931 var parent = item.get('parent');
13932 if (parent) {
13933 parent.removeChild(item, false);
13934 self._setContext(item);
13935 }
13936 el.appendChild(item.get('el'));
13937 });
13938 children.push.apply(children, items);
13939 return self;
13940 }
13941 if (self.findById(items.get('id'))) {
13942 return self;
13943 }
13944 var parent = items.get('parent');
13945 if (parent) {
13946 parent.removeChild(items, false);
13947 }
13948 self._add(items);
13949 el.appendChild(items.get('el'));
13950 return self;
13951 },
13952 _add: function _add(item) {
13953 this.get('el').appendChild(item.__cfg.el);
13954 this.get('children').push(item);
13955 item.__cfg.parent = this;
13956 item.__cfg.defs = this;
13957 item.__cfg.canvas = this.__cfg.canvas;
13958 },
13959 addGradient: function addGradient(cfg) {
13960 var gradient = new Gradient(cfg);
13961 this._add(gradient);
13962 return gradient.__cfg.id;
13963 },
13964 addShadow: function addShadow(cfg) {
13965 var shadow = new Shadow(cfg);
13966 this._add(shadow);
13967 return shadow.__cfg.id;
13968 },
13969 addArrow: function addArrow(name, cfg, stroke) {
13970 var arrow = new Arrow(name, cfg, stroke);
13971 this._add(arrow);
13972 return arrow.__cfg.id;
13973 },
13974 addClip: function addClip(cfg) {
13975 var clip = new Clip(cfg);
13976 this._add(clip);
13977 return clip.__cfg.id;
13978 }
13979});
13980
13981module.exports = Defs;
13982
13983/***/ }),
13984/* 118 */
13985/***/ (function(module, exports, __webpack_require__) {
13986
13987/**
13988 * Created by Elaine on 2018/5/9.
13989 */
13990var Util = __webpack_require__(0);
13991
13992var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
13993var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
13994var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
13995
13996function addStop(steps) {
13997 var arr = steps.match(regexColorStop);
13998 if (!arr) {
13999 return '';
14000 }
14001 var stops = '';
14002 arr.sort(function (a, b) {
14003 a = a.split(':');
14004 b = b.split(':');
14005 return Number(a[0]) - Number(b[0]);
14006 });
14007 Util.each(arr, function (item) {
14008 item = item.split(':');
14009 stops += '<stop offset="' + item[0] + '" stop-color="' + item[1] + '"></stop>';
14010 });
14011 return stops;
14012}
14013
14014function parseLineGradient(color, el) {
14015 var arr = regexLG.exec(color);
14016 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
14017 var steps = arr[2];
14018 var start = void 0;
14019 var end = void 0;
14020
14021 if (angle >= 0 && angle < 0.5 * Math.PI) {
14022 start = {
14023 x: 0,
14024 y: 0
14025 };
14026 end = {
14027 x: 1,
14028 y: 1
14029 };
14030 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
14031 start = {
14032 x: 1,
14033 y: 0
14034 };
14035 end = {
14036 x: 0,
14037 y: 1
14038 };
14039 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
14040 start = {
14041 x: 1,
14042 y: 1
14043 };
14044 end = {
14045 x: 0,
14046 y: 0
14047 };
14048 } else {
14049 start = {
14050 x: 0,
14051 y: 1
14052 };
14053 end = {
14054 x: 1,
14055 y: 0
14056 };
14057 }
14058
14059 var tanTheta = Math.tan(angle);
14060 var tanTheta2 = tanTheta * tanTheta;
14061
14062 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
14063 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
14064 el.setAttribute('x1', start.x);
14065 el.setAttribute('y1', start.y);
14066 el.setAttribute('x2', x);
14067 el.setAttribute('y2', y);
14068 el.innerHTML = addStop(steps);
14069}
14070
14071function parseRadialGradient(color, self) {
14072 var arr = regexRG.exec(color);
14073 var cx = parseFloat(arr[1]);
14074 var cy = parseFloat(arr[2]);
14075 var r = parseFloat(arr[3]);
14076 var steps = arr[4];
14077 self.setAttribute('cx', cx);
14078 self.setAttribute('cy', cy);
14079 self.setAttribute('r', r);
14080 self.innerHTML = addStop(steps);
14081}
14082
14083var Gradient = function Gradient(cfg) {
14084 var el = null;
14085 var id = Util.uniqueId('gradient_');
14086 if (cfg.toLowerCase()[0] === 'l') {
14087 el = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');
14088 parseLineGradient(cfg, el);
14089 } else {
14090 el = document.createElementNS('http://www.w3.org/2000/svg', 'radialGradient');
14091 parseRadialGradient(cfg, el);
14092 }
14093 el.setAttribute('id', id);
14094 this.__cfg = { el: el, id: id };
14095 this.__attrs = { config: cfg };
14096 return this;
14097};
14098
14099Util.augment(Gradient, {
14100 type: 'gradient',
14101 match: function match(type, attr) {
14102 return this.type === type && this.__attrs.config === attr;
14103 }
14104});
14105
14106module.exports = Gradient;
14107
14108/***/ }),
14109/* 119 */
14110/***/ (function(module, exports, __webpack_require__) {
14111
14112/**
14113 * Created by Elaine on 2018/5/10.
14114 */
14115var Util = __webpack_require__(0);
14116
14117var ATTR_MAP = {
14118 shadowColor: 'color',
14119 shadowOpacity: 'opacity',
14120 shadowBlur: 'blur',
14121 shadowOffsetX: 'dx',
14122 shadowOffsetY: 'dy'
14123};
14124
14125function parseShadow(config, el) {
14126 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 />';
14127 el.innerHTML = child;
14128}
14129
14130var Shadow = function Shadow(cfg) {
14131 var el = document.createElementNS('http://www.w3.org/2000/svg', 'filter');
14132 var id = Util.uniqueId('filter_');
14133 el.setAttribute('id', id);
14134 parseShadow(cfg, el);
14135 this.__cfg = { el: el, id: id };
14136 this.__attrs = { config: cfg };
14137 return this;
14138};
14139Util.augment(Shadow, {
14140 type: 'filter',
14141 match: function match(type, cfg) {
14142 if (this.type !== type) {
14143 return false;
14144 }
14145 var flag = false;
14146 var config = this.__attrs.config;
14147 Util.each(Object.keys(config), function (attr) {
14148 if (!flag) {
14149 flag = config[attr] === cfg[attr];
14150 }
14151 });
14152 return flag;
14153 },
14154 update: function update(name, value) {
14155 var config = this.__attrs.config;
14156 config[ATTR_MAP[name]] = value;
14157 parseShadow(config, this.__cfg.el);
14158 return this;
14159 }
14160});
14161
14162module.exports = Shadow;
14163
14164/***/ }),
14165/* 120 */
14166/***/ (function(module, exports, __webpack_require__) {
14167
14168var _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; };
14169
14170var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
14171 return typeof obj === "undefined" ? "undefined" : _typeof2(obj);
14172} : function (obj) {
14173 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof2(obj);
14174};
14175
14176/**
14177 * Created by Elaine on 2018/5/11.
14178 */
14179var Util = __webpack_require__(0);
14180
14181function setDefaultPath(parent, name, stroke) {
14182 var el = document.createElementNS('http://www.w3.org/2000/svg', 'path');
14183 el.setAttribute('d', 'M0,0 L6,3 L0,6 L3,3Z');
14184 el.setAttribute('stroke', 'none');
14185 el.setAttribute('fill', stroke || '#000');
14186 parent.appendChild(el);
14187 parent.setAttribute('refX', 3);
14188 parent.setAttribute('refY', 3);
14189
14190 return el;
14191}
14192
14193function setMarker(shape, parent, name, stroke) {
14194 if (!shape) {
14195 return setDefaultPath(parent, name);
14196 }
14197 if (shape.type !== 'marker') {
14198 throw new TypeError('the shape of an arrow should be an instance of Marker');
14199 }
14200 shape.attr({ stroke: 'none', fill: stroke });
14201 parent.append(shape.get('el'));
14202 var width = shape.__attrs.x;
14203 var height = shape.__attrs.y;
14204 parent.setAttribute('refX', width);
14205 parent.setAttribute('refY', height);
14206 return shape;
14207}
14208
14209var Arrow = function Arrow(name, cfg, stroke) {
14210 var el = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
14211 var id = Util.uniqueId('marker_');
14212 el.setAttribute('id', id);
14213 el.setAttribute('overflow', 'visible');
14214 el.setAttribute('orient', 'auto-start-reverse');
14215 this.__cfg = { el: el, id: id, stroke: stroke || '#000' };
14216 this.__cfg[name] = true;
14217 var child = null;
14218 if (typeof cfg === 'boolean' && cfg) {
14219 child = setDefaultPath(el, name, stroke);
14220 this._setChild(child, true);
14221 } else if ((typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) === 'object') {
14222 child = setMarker(cfg, el, name, stroke);
14223 this._setChild(child, false);
14224 }
14225 this.__attrs = { config: cfg };
14226 return this;
14227};
14228
14229Util.augment(Arrow, {
14230 type: 'arrow',
14231 match: function match(type, attr) {
14232 if (!this.__cfg[type]) {
14233 return false;
14234 }
14235 if (_typeof(attr.value) === 'object') {
14236 return false;
14237 }
14238 if (attr.stroke !== '#000') {
14239 return false;
14240 }
14241 if (typeof attr.value === 'boolean' && !this.__cfg.default) {
14242 return false;
14243 }
14244 return true;
14245 },
14246 _setChild: function _setChild(child, isDefault) {
14247 this.__cfg.child = child;
14248 this.__cfg.default = isDefault;
14249 },
14250 update: function update(fill) {
14251 var child = this.__cfg.child;
14252 this.__cfg.default = false;
14253 if (child.attr) {
14254 child.attr('fill', fill);
14255 } else {
14256 child.setAttribute('fill', fill);
14257 }
14258 }
14259});
14260
14261module.exports = Arrow;
14262
14263/***/ }),
14264/* 121 */
14265/***/ (function(module, exports, __webpack_require__) {
14266
14267/**
14268 * Created by Elaine on 2018/5/14.
14269 */
14270var Util = __webpack_require__(0);
14271
14272var Clip = function Clip(cfg) {
14273 var el = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
14274 var id = Util.uniqueId('clip_');
14275 if (cfg.get('el')) {
14276 el.appendChild(cfg.get('el'));
14277 } else if (Util.isString(cfg.nodeName)) {
14278 el.appendChild(cfg);
14279 } else {
14280 throw 'clip element should be a instance of Shape or a SVG node';
14281 }
14282 el.setAttribute('id', id);
14283 this.__cfg = { el: el, id: id };
14284 this.__attrs = { config: cfg };
14285 return this;
14286};
14287
14288Util.augment(Clip, {
14289 type: 'clip',
14290 match: function match() {
14291 return false;
14292 }
14293});
14294
14295module.exports = Clip;
14296
14297/***/ }),
14298/* 122 */
14299/***/ (function(module, __webpack_exports__, __webpack_require__) {
14300
14301"use strict";
14302Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14303/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_timer__ = __webpack_require__(22);
14304/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "now", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["b"]; });
14305/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["c"]; });
14306/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timerFlush", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["d"]; });
14307/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_timeout__ = __webpack_require__(123);
14308/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timeout", function() { return __WEBPACK_IMPORTED_MODULE_1__src_timeout__["a"]; });
14309/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_interval__ = __webpack_require__(124);
14310/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interval", function() { return __WEBPACK_IMPORTED_MODULE_2__src_interval__["a"]; });
14311
14312
14313
14314
14315
14316
14317/***/ }),
14318/* 123 */
14319/***/ (function(module, __webpack_exports__, __webpack_require__) {
14320
14321"use strict";
14322/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(22);
14323
14324
14325/* harmony default export */ __webpack_exports__["a"] = (function (callback, delay, time) {
14326 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */]();
14327 delay = delay == null ? 0 : +delay;
14328 t.restart(function (elapsed) {
14329 t.stop();
14330 callback(elapsed + delay);
14331 }, delay, time);
14332 return t;
14333});
14334
14335/***/ }),
14336/* 124 */
14337/***/ (function(module, __webpack_exports__, __webpack_require__) {
14338
14339"use strict";
14340/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(22);
14341
14342
14343/* harmony default export */ __webpack_exports__["a"] = (function (callback, delay, time) {
14344 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */](),
14345 total = delay;
14346 if (delay == null) return t.restart(callback, delay, time), t;
14347 delay = +delay, time = time == null ? Object(__WEBPACK_IMPORTED_MODULE_0__timer__["b" /* now */])() : +time;
14348 t.restart(function tick(elapsed) {
14349 elapsed += total;
14350 t.restart(tick, total += delay, time);
14351 callback(elapsed);
14352 }, delay, time);
14353 return t;
14354});
14355
14356/***/ }),
14357/* 125 */
14358/***/ (function(module, __webpack_exports__, __webpack_require__) {
14359
14360"use strict";
14361Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14362/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_linear__ = __webpack_require__(126);
14363/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeLinear", function() { return __WEBPACK_IMPORTED_MODULE_0__src_linear__["a"]; });
14364/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_quad__ = __webpack_require__(127);
14365/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuad", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; });
14366/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadIn", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["a"]; });
14367/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadOut", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["c"]; });
14368/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadInOut", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; });
14369/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_cubic__ = __webpack_require__(128);
14370/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubic", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; });
14371/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicIn", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["a"]; });
14372/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicOut", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["c"]; });
14373/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicInOut", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; });
14374/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_poly__ = __webpack_require__(129);
14375/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePoly", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; });
14376/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyIn", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["a"]; });
14377/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyOut", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["c"]; });
14378/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyInOut", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; });
14379/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_sin__ = __webpack_require__(130);
14380/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSin", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; });
14381/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinIn", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["a"]; });
14382/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinOut", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["c"]; });
14383/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinInOut", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; });
14384/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_exp__ = __webpack_require__(131);
14385/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExp", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; });
14386/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpIn", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["a"]; });
14387/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpOut", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["c"]; });
14388/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpInOut", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; });
14389/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_circle__ = __webpack_require__(132);
14390/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircle", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; });
14391/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleIn", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["a"]; });
14392/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleOut", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["c"]; });
14393/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleInOut", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; });
14394/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_bounce__ = __webpack_require__(133);
14395/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounce", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; });
14396/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceIn", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["a"]; });
14397/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceOut", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; });
14398/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceInOut", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["b"]; });
14399/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_back__ = __webpack_require__(134);
14400/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBack", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; });
14401/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackIn", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["a"]; });
14402/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackOut", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["c"]; });
14403/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackInOut", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; });
14404/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_elastic__ = __webpack_require__(135);
14405/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElastic", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; });
14406/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticIn", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["a"]; });
14407/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticOut", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; });
14408/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticInOut", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["b"]; });
14409
14410
14411
14412
14413
14414
14415
14416
14417
14418
14419
14420
14421
14422
14423
14424
14425
14426
14427
14428
14429/***/ }),
14430/* 126 */
14431/***/ (function(module, __webpack_exports__, __webpack_require__) {
14432
14433"use strict";
14434/* harmony export (immutable) */ __webpack_exports__["a"] = linear;
14435function linear(t) {
14436 return +t;
14437}
14438
14439/***/ }),
14440/* 127 */
14441/***/ (function(module, __webpack_exports__, __webpack_require__) {
14442
14443"use strict";
14444/* harmony export (immutable) */ __webpack_exports__["a"] = quadIn;
14445/* harmony export (immutable) */ __webpack_exports__["c"] = quadOut;
14446/* harmony export (immutable) */ __webpack_exports__["b"] = quadInOut;
14447function quadIn(t) {
14448 return t * t;
14449}
14450
14451function quadOut(t) {
14452 return t * (2 - t);
14453}
14454
14455function quadInOut(t) {
14456 return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
14457}
14458
14459/***/ }),
14460/* 128 */
14461/***/ (function(module, __webpack_exports__, __webpack_require__) {
14462
14463"use strict";
14464/* harmony export (immutable) */ __webpack_exports__["a"] = cubicIn;
14465/* harmony export (immutable) */ __webpack_exports__["c"] = cubicOut;
14466/* harmony export (immutable) */ __webpack_exports__["b"] = cubicInOut;
14467function cubicIn(t) {
14468 return t * t * t;
14469}
14470
14471function cubicOut(t) {
14472 return --t * t * t + 1;
14473}
14474
14475function cubicInOut(t) {
14476 return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
14477}
14478
14479/***/ }),
14480/* 129 */
14481/***/ (function(module, __webpack_exports__, __webpack_require__) {
14482
14483"use strict";
14484/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return polyIn; });
14485/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return polyOut; });
14486/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return polyInOut; });
14487var exponent = 3;
14488
14489var polyIn = function custom(e) {
14490 e = +e;
14491
14492 function polyIn(t) {
14493 return Math.pow(t, e);
14494 }
14495
14496 polyIn.exponent = custom;
14497
14498 return polyIn;
14499}(exponent);
14500
14501var polyOut = function custom(e) {
14502 e = +e;
14503
14504 function polyOut(t) {
14505 return 1 - Math.pow(1 - t, e);
14506 }
14507
14508 polyOut.exponent = custom;
14509
14510 return polyOut;
14511}(exponent);
14512
14513var polyInOut = function custom(e) {
14514 e = +e;
14515
14516 function polyInOut(t) {
14517 return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
14518 }
14519
14520 polyInOut.exponent = custom;
14521
14522 return polyInOut;
14523}(exponent);
14524
14525/***/ }),
14526/* 130 */
14527/***/ (function(module, __webpack_exports__, __webpack_require__) {
14528
14529"use strict";
14530/* harmony export (immutable) */ __webpack_exports__["a"] = sinIn;
14531/* harmony export (immutable) */ __webpack_exports__["c"] = sinOut;
14532/* harmony export (immutable) */ __webpack_exports__["b"] = sinInOut;
14533var pi = Math.PI,
14534 halfPi = pi / 2;
14535
14536function sinIn(t) {
14537 return 1 - Math.cos(t * halfPi);
14538}
14539
14540function sinOut(t) {
14541 return Math.sin(t * halfPi);
14542}
14543
14544function sinInOut(t) {
14545 return (1 - Math.cos(pi * t)) / 2;
14546}
14547
14548/***/ }),
14549/* 131 */
14550/***/ (function(module, __webpack_exports__, __webpack_require__) {
14551
14552"use strict";
14553/* harmony export (immutable) */ __webpack_exports__["a"] = expIn;
14554/* harmony export (immutable) */ __webpack_exports__["c"] = expOut;
14555/* harmony export (immutable) */ __webpack_exports__["b"] = expInOut;
14556function expIn(t) {
14557 return Math.pow(2, 10 * t - 10);
14558}
14559
14560function expOut(t) {
14561 return 1 - Math.pow(2, -10 * t);
14562}
14563
14564function expInOut(t) {
14565 return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
14566}
14567
14568/***/ }),
14569/* 132 */
14570/***/ (function(module, __webpack_exports__, __webpack_require__) {
14571
14572"use strict";
14573/* harmony export (immutable) */ __webpack_exports__["a"] = circleIn;
14574/* harmony export (immutable) */ __webpack_exports__["c"] = circleOut;
14575/* harmony export (immutable) */ __webpack_exports__["b"] = circleInOut;
14576function circleIn(t) {
14577 return 1 - Math.sqrt(1 - t * t);
14578}
14579
14580function circleOut(t) {
14581 return Math.sqrt(1 - --t * t);
14582}
14583
14584function circleInOut(t) {
14585 return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
14586}
14587
14588/***/ }),
14589/* 133 */
14590/***/ (function(module, __webpack_exports__, __webpack_require__) {
14591
14592"use strict";
14593/* harmony export (immutable) */ __webpack_exports__["a"] = bounceIn;
14594/* harmony export (immutable) */ __webpack_exports__["c"] = bounceOut;
14595/* harmony export (immutable) */ __webpack_exports__["b"] = bounceInOut;
14596var b1 = 4 / 11,
14597 b2 = 6 / 11,
14598 b3 = 8 / 11,
14599 b4 = 3 / 4,
14600 b5 = 9 / 11,
14601 b6 = 10 / 11,
14602 b7 = 15 / 16,
14603 b8 = 21 / 22,
14604 b9 = 63 / 64,
14605 b0 = 1 / b1 / b1;
14606
14607function bounceIn(t) {
14608 return 1 - bounceOut(1 - t);
14609}
14610
14611function bounceOut(t) {
14612 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;
14613}
14614
14615function bounceInOut(t) {
14616 return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
14617}
14618
14619/***/ }),
14620/* 134 */
14621/***/ (function(module, __webpack_exports__, __webpack_require__) {
14622
14623"use strict";
14624/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return backIn; });
14625/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return backOut; });
14626/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return backInOut; });
14627var overshoot = 1.70158;
14628
14629var backIn = function custom(s) {
14630 s = +s;
14631
14632 function backIn(t) {
14633 return t * t * ((s + 1) * t - s);
14634 }
14635
14636 backIn.overshoot = custom;
14637
14638 return backIn;
14639}(overshoot);
14640
14641var backOut = function custom(s) {
14642 s = +s;
14643
14644 function backOut(t) {
14645 return --t * t * ((s + 1) * t + s) + 1;
14646 }
14647
14648 backOut.overshoot = custom;
14649
14650 return backOut;
14651}(overshoot);
14652
14653var backInOut = function custom(s) {
14654 s = +s;
14655
14656 function backInOut(t) {
14657 return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
14658 }
14659
14660 backInOut.overshoot = custom;
14661
14662 return backInOut;
14663}(overshoot);
14664
14665/***/ }),
14666/* 135 */
14667/***/ (function(module, __webpack_exports__, __webpack_require__) {
14668
14669"use strict";
14670/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return elasticIn; });
14671/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return elasticOut; });
14672/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return elasticInOut; });
14673var tau = 2 * Math.PI,
14674 amplitude = 1,
14675 period = 0.3;
14676
14677var elasticIn = function custom(a, p) {
14678 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14679
14680 function elasticIn(t) {
14681 return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
14682 }
14683
14684 elasticIn.amplitude = function (a) {
14685 return custom(a, p * tau);
14686 };
14687 elasticIn.period = function (p) {
14688 return custom(a, p);
14689 };
14690
14691 return elasticIn;
14692}(amplitude, period);
14693
14694var elasticOut = function custom(a, p) {
14695 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14696
14697 function elasticOut(t) {
14698 return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
14699 }
14700
14701 elasticOut.amplitude = function (a) {
14702 return custom(a, p * tau);
14703 };
14704 elasticOut.period = function (p) {
14705 return custom(a, p);
14706 };
14707
14708 return elasticOut;
14709}(amplitude, period);
14710
14711var elasticInOut = function custom(a, p) {
14712 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14713
14714 function elasticInOut(t) {
14715 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;
14716 }
14717
14718 elasticInOut.amplitude = function (a) {
14719 return custom(a, p * tau);
14720 };
14721 elasticInOut.period = function (p) {
14722 return custom(a, p);
14723 };
14724
14725 return elasticInOut;
14726}(amplitude, period);
14727
14728/***/ }),
14729/* 136 */
14730/***/ (function(module, __webpack_exports__, __webpack_require__) {
14731
14732"use strict";
14733Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14734/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_value__ = __webpack_require__(23);
14735/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolate", function() { return __WEBPACK_IMPORTED_MODULE_0__src_value__["a"]; });
14736/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_array__ = __webpack_require__(62);
14737/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateArray", function() { return __WEBPACK_IMPORTED_MODULE_1__src_array__["a"]; });
14738/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_basis__ = __webpack_require__(26);
14739/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasis", function() { return __WEBPACK_IMPORTED_MODULE_2__src_basis__["b"]; });
14740/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__ = __webpack_require__(60);
14741/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__["a"]; });
14742/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_date__ = __webpack_require__(63);
14743/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateDate", function() { return __WEBPACK_IMPORTED_MODULE_4__src_date__["a"]; });
14744/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_number__ = __webpack_require__(15);
14745/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateNumber", function() { return __WEBPACK_IMPORTED_MODULE_5__src_number__["a"]; });
14746/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_object__ = __webpack_require__(64);
14747/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateObject", function() { return __WEBPACK_IMPORTED_MODULE_6__src_object__["a"]; });
14748/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_round__ = __webpack_require__(139);
14749/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRound", function() { return __WEBPACK_IMPORTED_MODULE_7__src_round__["a"]; });
14750/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_string__ = __webpack_require__(65);
14751/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateString", function() { return __WEBPACK_IMPORTED_MODULE_8__src_string__["a"]; });
14752/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_transform_index__ = __webpack_require__(140);
14753/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformCss", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["a"]; });
14754/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformSvg", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["b"]; });
14755/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_zoom__ = __webpack_require__(143);
14756/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateZoom", function() { return __WEBPACK_IMPORTED_MODULE_10__src_zoom__["a"]; });
14757/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_rgb__ = __webpack_require__(59);
14758/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgb", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["a"]; });
14759/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasis", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["b"]; });
14760/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["c"]; });
14761/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_hsl__ = __webpack_require__(144);
14762/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHsl", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["a"]; });
14763/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHslLong", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["b"]; });
14764/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_lab__ = __webpack_require__(145);
14765/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateLab", function() { return __WEBPACK_IMPORTED_MODULE_13__src_lab__["a"]; });
14766/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_hcl__ = __webpack_require__(146);
14767/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHcl", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["a"]; });
14768/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHclLong", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["b"]; });
14769/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__ = __webpack_require__(147);
14770/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelix", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["b"]; });
14771/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelixLong", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["a"]; });
14772/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_quantize__ = __webpack_require__(148);
14773/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "quantize", function() { return __WEBPACK_IMPORTED_MODULE_16__src_quantize__["a"]; });
14774
14775
14776
14777
14778
14779
14780
14781
14782
14783
14784
14785
14786
14787
14788
14789
14790
14791
14792/***/ }),
14793/* 137 */
14794/***/ (function(module, __webpack_exports__, __webpack_require__) {
14795
14796"use strict";
14797/* unused harmony export gray */
14798/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
14799/* unused harmony export Lab */
14800/* unused harmony export lch */
14801/* harmony export (immutable) */ __webpack_exports__["b"] = hcl;
14802/* unused harmony export Hcl */
14803/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(25);
14804/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(24);
14805/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(58);
14806
14807
14808
14809
14810// https://beta.observablehq.com/@mbostock/lab-and-rgb
14811var K = 18,
14812 Xn = 0.96422,
14813 Yn = 1,
14814 Zn = 0.82521,
14815 t0 = 4 / 29,
14816 t1 = 6 / 29,
14817 t2 = 3 * t1 * t1,
14818 t3 = t1 * t1 * t1;
14819
14820function labConvert(o) {
14821 if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
14822 if (o instanceof Hcl) {
14823 if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
14824 var h = o.h * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */];
14825 return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
14826 }
14827 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
14828 var r = rgb2lrgb(o.r),
14829 g = rgb2lrgb(o.g),
14830 b = rgb2lrgb(o.b),
14831 y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn),
14832 x,
14833 z;
14834 if (r === g && g === b) x = z = y;else {
14835 x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
14836 z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
14837 }
14838 return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
14839}
14840
14841function gray(l, opacity) {
14842 return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
14843}
14844
14845function lab(l, a, b, opacity) {
14846 return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
14847}
14848
14849function Lab(l, a, b, opacity) {
14850 this.l = +l;
14851 this.a = +a;
14852 this.b = +b;
14853 this.opacity = +opacity;
14854}
14855
14856Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Lab, lab, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14857 brighter: function brighter(k) {
14858 return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
14859 },
14860 darker: function darker(k) {
14861 return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
14862 },
14863 rgb: function rgb() {
14864 var y = (this.l + 16) / 116,
14865 x = isNaN(this.a) ? y : y + this.a / 500,
14866 z = isNaN(this.b) ? y : y - this.b / 200;
14867 x = Xn * lab2xyz(x);
14868 y = Yn * lab2xyz(y);
14869 z = Zn * lab2xyz(z);
14870 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);
14871 }
14872}));
14873
14874function xyz2lab(t) {
14875 return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
14876}
14877
14878function lab2xyz(t) {
14879 return t > t1 ? t * t * t : t2 * (t - t0);
14880}
14881
14882function lrgb2rgb(x) {
14883 return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
14884}
14885
14886function rgb2lrgb(x) {
14887 return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
14888}
14889
14890function hclConvert(o) {
14891 if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
14892 if (!(o instanceof Lab)) o = labConvert(o);
14893 if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0, o.l, o.opacity);
14894 var h = Math.atan2(o.b, o.a) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */];
14895 return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
14896}
14897
14898function lch(l, c, h, opacity) {
14899 return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
14900}
14901
14902function hcl(h, c, l, opacity) {
14903 return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
14904}
14905
14906function Hcl(h, c, l, opacity) {
14907 this.h = +h;
14908 this.c = +c;
14909 this.l = +l;
14910 this.opacity = +opacity;
14911}
14912
14913Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hcl, hcl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14914 brighter: function brighter(k) {
14915 return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
14916 },
14917 darker: function darker(k) {
14918 return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
14919 },
14920 rgb: function rgb() {
14921 return labConvert(this).rgb();
14922 }
14923}));
14924
14925/***/ }),
14926/* 138 */
14927/***/ (function(module, __webpack_exports__, __webpack_require__) {
14928
14929"use strict";
14930/* harmony export (immutable) */ __webpack_exports__["a"] = cubehelix;
14931/* unused harmony export Cubehelix */
14932/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(25);
14933/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(24);
14934/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(58);
14935
14936
14937
14938
14939var A = -0.14861,
14940 B = +1.78277,
14941 C = -0.29227,
14942 D = -0.90649,
14943 E = +1.97294,
14944 ED = E * D,
14945 EB = E * B,
14946 BC_DA = B * C - D * A;
14947
14948function cubehelixConvert(o) {
14949 if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
14950 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
14951 var r = o.r / 255,
14952 g = o.g / 255,
14953 b = o.b / 255,
14954 l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
14955 bl = b - l,
14956 k = (E * (g - l) - C * bl) / D,
14957 s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)),
14958 // NaN if l=0 or l=1
14959 h = s ? Math.atan2(k, bl) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */] - 120 : NaN;
14960 return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
14961}
14962
14963function cubehelix(h, s, l, opacity) {
14964 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
14965}
14966
14967function Cubehelix(h, s, l, opacity) {
14968 this.h = +h;
14969 this.s = +s;
14970 this.l = +l;
14971 this.opacity = +opacity;
14972}
14973
14974Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Cubehelix, cubehelix, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14975 brighter: function brighter(k) {
14976 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */], k);
14977 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
14978 },
14979 darker: function darker(k) {
14980 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */], k);
14981 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
14982 },
14983 rgb: function rgb() {
14984 var h = isNaN(this.h) ? 0 : (this.h + 120) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */],
14985 l = +this.l,
14986 a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
14987 cosh = Math.cos(h),
14988 sinh = Math.sin(h);
14989 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);
14990 }
14991}));
14992
14993/***/ }),
14994/* 139 */
14995/***/ (function(module, __webpack_exports__, __webpack_require__) {
14996
14997"use strict";
14998/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
14999 return a = +a, b -= a, function (t) {
15000 return Math.round(a + b * t);
15001 };
15002});
15003
15004/***/ }),
15005/* 140 */
15006/***/ (function(module, __webpack_exports__, __webpack_require__) {
15007
15008"use strict";
15009/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return interpolateTransformCss; });
15010/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return interpolateTransformSvg; });
15011/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(15);
15012/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(141);
15013
15014
15015
15016function interpolateTransform(parse, pxComma, pxParen, degParen) {
15017
15018 function pop(s) {
15019 return s.length ? s.pop() + " " : "";
15020 }
15021
15022 function translate(xa, ya, xb, yb, s, q) {
15023 if (xa !== xb || ya !== yb) {
15024 var i = s.push("translate(", null, pxComma, null, pxParen);
15025 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) });
15026 } else if (xb || yb) {
15027 s.push("translate(" + xb + pxComma + yb + pxParen);
15028 }
15029 }
15030
15031 function rotate(a, b, s, q) {
15032 if (a !== b) {
15033 if (a - b > 180) b += 360;else if (b - a > 180) a += 360; // shortest path
15034 q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
15035 } else if (b) {
15036 s.push(pop(s) + "rotate(" + b + degParen);
15037 }
15038 }
15039
15040 function skewX(a, b, s, q) {
15041 if (a !== b) {
15042 q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
15043 } else if (b) {
15044 s.push(pop(s) + "skewX(" + b + degParen);
15045 }
15046 }
15047
15048 function scale(xa, ya, xb, yb, s, q) {
15049 if (xa !== xb || ya !== yb) {
15050 var i = s.push(pop(s) + "scale(", null, ",", null, ")");
15051 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) });
15052 } else if (xb !== 1 || yb !== 1) {
15053 s.push(pop(s) + "scale(" + xb + "," + yb + ")");
15054 }
15055 }
15056
15057 return function (a, b) {
15058 var s = [],
15059 // string constants and placeholders
15060 q = []; // number interpolators
15061 a = parse(a), b = parse(b);
15062 translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
15063 rotate(a.rotate, b.rotate, s, q);
15064 skewX(a.skewX, b.skewX, s, q);
15065 scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
15066 a = b = null; // gc
15067 return function (t) {
15068 var i = -1,
15069 n = q.length,
15070 o;
15071 while (++i < n) {
15072 s[(o = q[i]).i] = o.x(t);
15073 }return s.join("");
15074 };
15075 };
15076}
15077
15078var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)");
15079var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")");
15080
15081/***/ }),
15082/* 141 */
15083/***/ (function(module, __webpack_exports__, __webpack_require__) {
15084
15085"use strict";
15086/* harmony export (immutable) */ __webpack_exports__["a"] = parseCss;
15087/* harmony export (immutable) */ __webpack_exports__["b"] = parseSvg;
15088/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(142);
15089
15090
15091var cssNode, cssRoot, cssView, svgNode;
15092
15093function parseCss(value) {
15094 if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
15095 if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
15096 cssNode.style.transform = value;
15097 value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
15098 cssRoot.removeChild(cssNode);
15099 value = value.slice(7, -1).split(",");
15100 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
15101}
15102
15103function parseSvg(value) {
15104 if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
15105 if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
15106 svgNode.setAttribute("transform", value);
15107 if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
15108 value = value.matrix;
15109 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f);
15110}
15111
15112/***/ }),
15113/* 142 */
15114/***/ (function(module, __webpack_exports__, __webpack_require__) {
15115
15116"use strict";
15117/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return identity; });
15118var degrees = 180 / Math.PI;
15119
15120var identity = {
15121 translateX: 0,
15122 translateY: 0,
15123 rotate: 0,
15124 skewX: 0,
15125 scaleX: 1,
15126 scaleY: 1
15127};
15128
15129/* harmony default export */ __webpack_exports__["a"] = (function (a, b, c, d, e, f) {
15130 var scaleX, scaleY, skewX;
15131 if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
15132 if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
15133 if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
15134 if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
15135 return {
15136 translateX: e,
15137 translateY: f,
15138 rotate: Math.atan2(b, a) * degrees,
15139 skewX: Math.atan(skewX) * degrees,
15140 scaleX: scaleX,
15141 scaleY: scaleY
15142 };
15143});
15144
15145/***/ }),
15146/* 143 */
15147/***/ (function(module, __webpack_exports__, __webpack_require__) {
15148
15149"use strict";
15150var rho = Math.SQRT2,
15151 rho2 = 2,
15152 rho4 = 4,
15153 epsilon2 = 1e-12;
15154
15155function cosh(x) {
15156 return ((x = Math.exp(x)) + 1 / x) / 2;
15157}
15158
15159function sinh(x) {
15160 return ((x = Math.exp(x)) - 1 / x) / 2;
15161}
15162
15163function tanh(x) {
15164 return ((x = Math.exp(2 * x)) - 1) / (x + 1);
15165}
15166
15167// p0 = [ux0, uy0, w0]
15168// p1 = [ux1, uy1, w1]
15169/* harmony default export */ __webpack_exports__["a"] = (function (p0, p1) {
15170 var ux0 = p0[0],
15171 uy0 = p0[1],
15172 w0 = p0[2],
15173 ux1 = p1[0],
15174 uy1 = p1[1],
15175 w1 = p1[2],
15176 dx = ux1 - ux0,
15177 dy = uy1 - uy0,
15178 d2 = dx * dx + dy * dy,
15179 i,
15180 S;
15181
15182 // Special case for u0 ≅ u1.
15183 if (d2 < epsilon2) {
15184 S = Math.log(w1 / w0) / rho;
15185 i = function i(t) {
15186 return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
15187 };
15188 }
15189
15190 // General case.
15191 else {
15192 var d1 = Math.sqrt(d2),
15193 b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
15194 b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
15195 r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
15196 r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
15197 S = (r1 - r0) / rho;
15198 i = function i(t) {
15199 var s = t * S,
15200 coshr0 = cosh(r0),
15201 u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
15202 return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)];
15203 };
15204 }
15205
15206 i.duration = S * 1000;
15207
15208 return i;
15209});
15210
15211/***/ }),
15212/* 144 */
15213/***/ (function(module, __webpack_exports__, __webpack_require__) {
15214
15215"use strict";
15216/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hslLong; });
15217/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(6);
15218/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(13);
15219
15220
15221
15222function hsl(hue) {
15223 return function (start, end) {
15224 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),
15225 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
15226 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15227 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15228 return function (t) {
15229 start.h = h(t);
15230 start.s = s(t);
15231 start.l = l(t);
15232 start.opacity = opacity(t);
15233 return start + "";
15234 };
15235 };
15236}
15237
15238/* harmony default export */ __webpack_exports__["a"] = (hsl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15239var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15240
15241/***/ }),
15242/* 145 */
15243/***/ (function(module, __webpack_exports__, __webpack_require__) {
15244
15245"use strict";
15246/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
15247/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(6);
15248/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(13);
15249
15250
15251
15252function lab(start, end) {
15253 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),
15254 a = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a),
15255 b = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b),
15256 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15257 return function (t) {
15258 start.l = l(t);
15259 start.a = a(t);
15260 start.b = b(t);
15261 start.opacity = opacity(t);
15262 return start + "";
15263 };
15264}
15265
15266/***/ }),
15267/* 146 */
15268/***/ (function(module, __webpack_exports__, __webpack_require__) {
15269
15270"use strict";
15271/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hclLong; });
15272/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(6);
15273/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(13);
15274
15275
15276
15277function hcl(hue) {
15278 return function (start, end) {
15279 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),
15280 c = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c),
15281 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15282 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15283 return function (t) {
15284 start.h = h(t);
15285 start.c = c(t);
15286 start.l = l(t);
15287 start.opacity = opacity(t);
15288 return start + "";
15289 };
15290 };
15291}
15292
15293/* harmony default export */ __webpack_exports__["a"] = (hcl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15294var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15295
15296/***/ }),
15297/* 147 */
15298/***/ (function(module, __webpack_exports__, __webpack_require__) {
15299
15300"use strict";
15301/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cubehelixLong; });
15302/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(6);
15303/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(13);
15304
15305
15306
15307function cubehelix(hue) {
15308 return function cubehelixGamma(y) {
15309 y = +y;
15310
15311 function cubehelix(start, end) {
15312 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),
15313 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
15314 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15315 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15316 return function (t) {
15317 start.h = h(t);
15318 start.s = s(t);
15319 start.l = l(Math.pow(t, y));
15320 start.opacity = opacity(t);
15321 return start + "";
15322 };
15323 }
15324
15325 cubehelix.gamma = cubehelixGamma;
15326
15327 return cubehelix;
15328 }(1);
15329}
15330
15331/* harmony default export */ __webpack_exports__["b"] = (cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15332var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15333
15334/***/ }),
15335/* 148 */
15336/***/ (function(module, __webpack_exports__, __webpack_require__) {
15337
15338"use strict";
15339/* harmony default export */ __webpack_exports__["a"] = (function (interpolator, n) {
15340 var samples = new Array(n);
15341 for (var i = 0; i < n; ++i) {
15342 samples[i] = interpolator(i / (n - 1));
15343 }return samples;
15344});
15345
15346/***/ }),
15347/* 149 */
15348/***/ (function(module, exports, __webpack_require__) {
15349
15350module.exports = {
15351 Canvas: __webpack_require__(150),
15352 Group: __webpack_require__(67),
15353 Shape: __webpack_require__(1),
15354 Rect: __webpack_require__(69),
15355 Circle: __webpack_require__(70),
15356 Ellipse: __webpack_require__(71),
15357 Path: __webpack_require__(72),
15358 Text: __webpack_require__(73),
15359 Line: __webpack_require__(74),
15360 Image: __webpack_require__(75),
15361 Polygon: __webpack_require__(76),
15362 Polyline: __webpack_require__(77),
15363 Arc: __webpack_require__(78),
15364 Fan: __webpack_require__(79),
15365 Cubic: __webpack_require__(80),
15366 Quadratic: __webpack_require__(81),
15367 Marker: __webpack_require__(82),
15368 PathSegment: __webpack_require__(31),
15369 Event: __webpack_require__(66)
15370};
15371
15372/***/ }),
15373/* 150 */
15374/***/ (function(module, exports, __webpack_require__) {
15375
15376var Util = __webpack_require__(0);
15377var Event = __webpack_require__(66);
15378var Group = __webpack_require__(67);
15379var Timeline = __webpack_require__(57);
15380
15381var Canvas = function Canvas(cfg) {
15382 Canvas.superclass.constructor.call(this, cfg);
15383};
15384
15385Canvas.CFG = {
15386 eventEnable: true,
15387 /**
15388 * 像素宽度
15389 * @type {Number}
15390 */
15391 width: null,
15392 /**
15393 * 像素高度
15394 * @type {Number}
15395 */
15396 height: null,
15397 /**
15398 * 画布宽度
15399 * @type {Number}
15400 */
15401 widthCanvas: null,
15402 /**
15403 * 画布高度
15404 * @type {Number}
15405 */
15406 heightCanvas: null,
15407 /**
15408 * CSS宽
15409 * @type {String}
15410 */
15411 widthStyle: null,
15412 /**
15413 * CSS高
15414 * @type {String}
15415 */
15416 heightStyle: null,
15417 /**
15418 * 容器DOM
15419 * @type {Object}
15420 */
15421 containerDOM: null,
15422 /**
15423 * 当前Canvas的DOM
15424 * @type {Object}
15425 */
15426 canvasDOM: null,
15427 /**
15428 * 屏幕像素比
15429 * @type {Number}
15430 */
15431 pixelRatio: null
15432};
15433
15434Util.extend(Canvas, Group);
15435
15436Util.augment(Canvas, {
15437 init: function init() {
15438 Canvas.superclass.init.call(this);
15439 this._setGlobalParam();
15440 this._setDOM();
15441 this._setInitSize();
15442 this._setCanvas();
15443 this._scale();
15444 if (this.get('eventEnable')) {
15445 this._registEvents();
15446 }
15447 },
15448 getEmitter: function getEmitter(element, event) {
15449 if (element) {
15450 if (Util.isEmpty(element._getEvents())) {
15451 var parent = element.get('parent');
15452 if (parent && !event.propagationStopped) {
15453 return this.getEmitter(parent, event);
15454 }
15455 } else {
15456 return element;
15457 }
15458 }
15459 },
15460 _getEventObj: function _getEventObj(type, e, point, target) {
15461 var event = new Event(type, e, true, true);
15462 event.x = point.x;
15463 event.y = point.y;
15464 event.clientX = e.clientX;
15465 event.clientY = e.clientY;
15466 event.currentTarget = target;
15467 event.target = target;
15468 return event;
15469 },
15470 _triggerEvent: function _triggerEvent(type, e) {
15471 var point = this.getPointByClient(e.clientX, e.clientY);
15472 var shape = this.getShape(point.x, point.y);
15473 var emitObj = void 0;
15474 if (type === 'mousemove') {
15475 var preShape = this.get('preShape');
15476 if (preShape && preShape !== shape) {
15477 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
15478 emitObj = this.getEmitter(preShape, e);
15479 emitObj && emitObj.emit('mouseleave', mouseleave);
15480 }
15481
15482 if (shape) {
15483 var mousemove = this._getEventObj('mousemove', e, point, shape);
15484 emitObj = this.getEmitter(shape, e);
15485 emitObj && emitObj.emit('mousemove', mousemove);
15486
15487 if (preShape !== shape) {
15488 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
15489 emitObj && emitObj.emit('mouseenter', mouseenter, e);
15490 }
15491 } else {
15492 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
15493 this.emit('mousemove', canvasmousemove);
15494 }
15495
15496 this.set('preShape', shape);
15497 } else {
15498 var event = this._getEventObj(type, e, point, shape || this);
15499 emitObj = this.getEmitter(shape, e);
15500 if (emitObj && emitObj !== this) {
15501 emitObj.emit(type, event);
15502 }
15503 this.emit(type, event);
15504 }
15505
15506 var el = this.get('el');
15507 if (shape && !shape.get('destroyed')) {
15508 el.style.cursor = shape.attr('cursor') || 'default';
15509 }
15510 },
15511 _registEvents: function _registEvents() {
15512 var self = this;
15513 var el = self.get('el');
15514 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
15515 Util.each(events, function (event) {
15516 el.addEventListener(event, function (e) {
15517 self._triggerEvent(event, e);
15518 }, false);
15519 });
15520 // special cases
15521 el.addEventListener('mouseout', function (e) {
15522 self._triggerEvent('mouseleave', e);
15523 }, false);
15524 el.addEventListener('mouseover', function (e) {
15525 self._triggerEvent('mouseenter', e);
15526 }, false);
15527
15528 el.addEventListener('touchstart', function (e) {
15529 if (!Util.isEmpty(e.touches)) {
15530 self._triggerEvent('touchstart', e.touches[0]);
15531 }
15532 }, false);
15533
15534 el.addEventListener('touchmove', function (e) {
15535 if (!Util.isEmpty(e.touches)) {
15536 self._triggerEvent('touchmove', e.touches[0]);
15537 }
15538 }, false);
15539
15540 el.addEventListener('touchend', function (e) {
15541 if (!Util.isEmpty(e.changedTouches)) {
15542 self._triggerEvent('touchend', e.changedTouches[0]);
15543 }
15544 }, false);
15545 },
15546 _scale: function _scale() {
15547 var pixelRatio = this.get('pixelRatio');
15548 this.scale(pixelRatio, pixelRatio);
15549 },
15550 _setCanvas: function _setCanvas() {
15551 var canvasDOM = this.get('canvasDOM');
15552 var timeline = new Timeline();
15553 this.setSilent('el', canvasDOM);
15554 this.setSilent('timeline', timeline);
15555 this.setSilent('context', canvasDOM.getContext('2d'));
15556 this.setSilent('canvas', this);
15557 },
15558 _setGlobalParam: function _setGlobalParam() {
15559 var pixelRatio = this.get('pixelRatio');
15560 if (!pixelRatio) {
15561 this.set('pixelRatio', Util.getRatio());
15562 }
15563 return;
15564 },
15565 _setDOM: function _setDOM() {
15566 this._setContainer();
15567 this._setLayer();
15568 },
15569 _setContainer: function _setContainer() {
15570 var containerId = this.get('containerId');
15571 var containerDOM = this.get('containerDOM');
15572 if (!containerDOM) {
15573 containerDOM = document.getElementById(containerId);
15574 this.set('containerDOM', containerDOM);
15575 }
15576 Util.modifyCSS(containerDOM, {
15577 position: 'relative'
15578 });
15579 },
15580 _setLayer: function _setLayer() {
15581 var containerDOM = this.get('containerDOM');
15582 var canvasId = Util.uniqueId('canvas_');
15583 if (containerDOM) {
15584 var canvasDOM = Util.createDom('<canvas id="' + canvasId + '"></canvas>');
15585 containerDOM.appendChild(canvasDOM);
15586 this.set('canvasDOM', canvasDOM);
15587 }
15588 },
15589 _setInitSize: function _setInitSize() {
15590 this.changeSize(this.get('width'), this.get('height'));
15591 },
15592 _resize: function _resize() {
15593 var canvasDOM = this.get('canvasDOM');
15594 var widthCanvas = this.get('widthCanvas');
15595 var heightCanvas = this.get('heightCanvas');
15596 var widthStyle = this.get('widthStyle');
15597 var heightStyle = this.get('heightStyle');
15598
15599 canvasDOM.style.width = widthStyle;
15600 canvasDOM.style.height = heightStyle;
15601 canvasDOM.setAttribute('width', widthCanvas);
15602 canvasDOM.setAttribute('height', heightCanvas);
15603 },
15604 getWidth: function getWidth() {
15605 var pixelRatio = this.get('pixelRatio');
15606 var width = this.get('width');
15607 return width * pixelRatio;
15608 },
15609 getHeight: function getHeight() {
15610 var pixelRatio = this.get('pixelRatio');
15611 var height = this.get('height');
15612 return height * pixelRatio;
15613 },
15614 changeSize: function changeSize(width, height) {
15615 var pixelRatio = this.get('pixelRatio');
15616 var widthCanvas = width * pixelRatio;
15617 var heightCanvas = height * pixelRatio;
15618
15619 this.set('widthCanvas', widthCanvas);
15620 this.set('heightCanvas', heightCanvas);
15621 this.set('widthStyle', width + 'px');
15622 this.set('heightStyle', height + 'px');
15623 this.set('width', width);
15624 this.set('height', height);
15625 this._resize();
15626 },
15627
15628 /**
15629 * 将窗口坐标转变成 canvas 坐标
15630 * @param {Number} clientX 窗口x坐标
15631 * @param {Number} clientY 窗口y坐标
15632 * @return {Object} canvas坐标
15633 */
15634 getPointByClient: function getPointByClient(clientX, clientY) {
15635 var el = this.get('el');
15636 var bbox = el.getBoundingClientRect();
15637 var width = bbox.right - bbox.left;
15638 var height = bbox.bottom - bbox.top;
15639 return {
15640 x: (clientX - bbox.left) * (el.width / width),
15641 y: (clientY - bbox.top) * (el.height / height)
15642 };
15643 },
15644 getClientByPoint: function getClientByPoint(x, y) {
15645 var el = this.get('el');
15646 var bbox = el.getBoundingClientRect();
15647 var width = bbox.right - bbox.left;
15648 var height = bbox.bottom - bbox.top;
15649 return {
15650 clientX: x / (el.width / width) + bbox.left,
15651 clientY: y / (el.height / height) + bbox.top
15652 };
15653 },
15654 beforeDraw: function beforeDraw() {
15655 var context = this.get('context');
15656 var el = this.get('el');
15657 context && context.clearRect(0, 0, el.width, el.height);
15658 },
15659 _beginDraw: function _beginDraw() {
15660 this.setSilent('toDraw', true);
15661 },
15662 _endDraw: function _endDraw() {
15663 this.setSilent('toDraw', false);
15664 },
15665 draw: function draw() {
15666 var self = this;
15667 function drawInner() {
15668 self.setSilent('animateHandler', Util.requestAnimationFrame(function () {
15669 self.setSilent('animateHandler', undefined);
15670 if (self.get('toDraw')) {
15671 drawInner();
15672 }
15673 }));
15674 self.beforeDraw();
15675 try {
15676 var context = self.get('context');
15677 Canvas.superclass.draw.call(self, context);
15678 // self._drawCanvas();
15679 } catch (ev) {
15680 // 绘制时异常,中断重绘
15681 console.warn('error in draw canvas, detail as:');
15682 console.warn(ev);
15683 self._endDraw();
15684 }
15685 self._endDraw();
15686 }
15687
15688 if (self.get('destroyed')) {
15689 return;
15690 }
15691 if (self.get('animateHandler')) {
15692 this._beginDraw();
15693 } else {
15694 drawInner();
15695 }
15696 },
15697 destroy: function destroy() {
15698 var containerDOM = this.get('containerDOM');
15699 var canvasDOM = this.get('canvasDOM');
15700 if (canvasDOM && containerDOM) {
15701 containerDOM.removeChild(canvasDOM);
15702 }
15703 Canvas.superclass.destroy.call(this);
15704 }
15705});
15706
15707module.exports = Canvas;
15708
15709/***/ }),
15710/* 151 */
15711/***/ (function(module, exports, __webpack_require__) {
15712
15713var Util = __webpack_require__(0);
15714
15715var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
15716var CLIP_SHAPES = ['circle', 'ellipse', 'fan', 'polygon', 'rect', 'path'];
15717var CAPITALIZED_ATTRS_MAP = {
15718 r: 'R',
15719 opacity: 'Opacity',
15720 lineWidth: 'LineWidth',
15721 clip: 'Clip',
15722 stroke: 'Stroke',
15723 fill: 'Fill',
15724 strokeOpacity: 'Stroke',
15725 fillOpacity: 'Fill',
15726 x: 'X',
15727 y: 'Y',
15728 rx: 'Rx',
15729 ry: 'Ry',
15730 re: 'Re',
15731 rs: 'Rs',
15732 width: 'Width',
15733 height: 'Height',
15734 img: 'Img',
15735 x1: 'X1',
15736 x2: 'X2',
15737 y1: 'Y1',
15738 y2: 'Y2',
15739 points: 'Points',
15740 p1: 'P1',
15741 p2: 'P2',
15742 p3: 'P3',
15743 p4: 'P4',
15744 text: 'Text',
15745 radius: 'Radius',
15746 textAlign: 'TextAlign',
15747 textBaseline: 'TextBaseline',
15748 font: 'Font',
15749 fontSize: 'FontSize',
15750 fontStyle: 'FontStyle',
15751 fontVariant: 'FontVariant',
15752 fontWeight: 'FontWeight',
15753 fontFamily: 'FontFamily',
15754 clockwise: 'Clockwise',
15755 startAngle: 'StartAngle',
15756 endAngle: 'EndAngle',
15757 path: 'Path'
15758};
15759var ALIAS_ATTRS_MAP = {
15760 stroke: 'strokeStyle',
15761 fill: 'fillStyle',
15762 opacity: 'globalAlpha'
15763};
15764
15765module.exports = {
15766 canFill: false,
15767 canStroke: false,
15768 initAttrs: function initAttrs(attrs) {
15769 this.__attrs = {
15770 opacity: 1,
15771 fillOpacity: 1,
15772 strokeOpacity: 1
15773 };
15774 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
15775 return this;
15776 },
15777 getDefaultAttrs: function getDefaultAttrs() {
15778 return {};
15779 },
15780
15781 /**
15782 * 设置或者设置属性,有以下 4 种情形:
15783 * - name 不存在, 则返回属性集合
15784 * - name 为字符串,value 为空,获取属性值
15785 * - name 为字符串,value 不为空,设置属性值,返回 this
15786 * - name 为键值对,value 为空,设置属性值
15787 *
15788 * @param {String | Object} name 属性名
15789 * @param {*} value 属性值
15790 * @return {*} 属性值
15791 */
15792 attr: function attr(name, value) {
15793 var self = this;
15794 if (arguments.length === 0) {
15795 return self.__attrs;
15796 }
15797
15798 if (Util.isObject(name)) {
15799 for (var k in name) {
15800 if (ALIAS_ATTRS.indexOf(k) === -1) {
15801 var v = name[k];
15802 self._setAttr(k, v);
15803 }
15804 }
15805 if (self._afterSetAttrAll) {
15806 self._afterSetAttrAll(name);
15807 }
15808 // self.setSilent('box', null);
15809 self.clearBBox();
15810 return self;
15811 }
15812 if (arguments.length === 2) {
15813 if (self._setAttr(name, value) !== false) {
15814 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
15815 if (self[m]) {
15816 self[m](value);
15817 }
15818 }
15819 // self.setSilent('box', null);
15820 self.clearBBox();
15821 return self;
15822 }
15823 return self._getAttr(name);
15824 },
15825 clearBBox: function clearBBox() {
15826 this.setSilent('box', null);
15827 },
15828 _afterSetAttrAll: function _afterSetAttrAll() {},
15829
15830 // 属性获取触发函数
15831 _getAttr: function _getAttr(name) {
15832 return this.__attrs[name];
15833 },
15834
15835 // 属性设置触发函数
15836 _setAttr: function _setAttr(name, value) {
15837 var self = this;
15838 if (name === 'clip') {
15839 self._setAttrClip(value);
15840 self.__attrs.clip = value;
15841 } else if (name === 'transform') {
15842 self._setAttrTrans(value);
15843 } else {
15844 self.__attrs[name] = value;
15845 var alias = ALIAS_ATTRS_MAP[name];
15846 if (alias) {
15847 self.__attrs[alias] = value;
15848 }
15849 }
15850 return self;
15851 },
15852 hasFill: function hasFill() {
15853 return this.canFill && this.__attrs.fillStyle;
15854 },
15855 hasStroke: function hasStroke() {
15856 return this.canStroke && this.__attrs.strokeStyle;
15857 },
15858
15859 // 设置透明度
15860 _setAttrOpacity: function _setAttrOpacity(v) {
15861 this.__attrs.globalAlpha = v;
15862 return v;
15863 },
15864 _setAttrClip: function _setAttrClip(clip) {
15865 var self = this;
15866 if (clip && CLIP_SHAPES.indexOf(clip.type) > -1) {
15867 if (clip.get('canvas') === null) {
15868 clip = Util.clone(clip);
15869 }
15870 clip.set('parent', self.get('parent'));
15871 clip.set('canvas', self.get('canvas'));
15872 clip.set('context', self.get('context'));
15873 clip.inside = function (x, y) {
15874 var v = [x, y, 1];
15875 clip.invert(v, self.get('canvas')); // 已经在外面转换
15876 return clip._isPointInFill(v[0], v[1]);
15877 };
15878 return clip;
15879 }
15880 return null;
15881 },
15882 _setAttrTrans: function _setAttrTrans(value) {
15883 return this.transform(value);
15884 }
15885};
15886
15887/***/ }),
15888/* 152 */
15889/***/ (function(module, exports, __webpack_require__) {
15890
15891var Util = __webpack_require__(0);
15892var mat3 = __webpack_require__(2).mat3;
15893var vec3 = __webpack_require__(2).vec3;
15894
15895// 是否未改变
15896function isUnchanged(m) {
15897 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
15898}
15899
15900// 是否仅仅是scale
15901function isScale(m) {
15902 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
15903}
15904
15905function multiple(m1, m2) {
15906 if (!isUnchanged(m2)) {
15907 if (isScale(m2)) {
15908 m1[0] *= m2[0];
15909 m1[4] *= m2[4];
15910 } else {
15911 mat3.multiply(m1, m1, m2);
15912 }
15913 }
15914}
15915
15916module.exports = {
15917 initTransform: function initTransform() {
15918 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
15919 },
15920 translate: function translate(tx, ty) {
15921 var matrix = this.attr('matrix');
15922 mat3.translate(matrix, matrix, [tx, ty]);
15923 this.clearTotalMatrix();
15924 this.attr('matrix', matrix);
15925 return this;
15926 },
15927 rotate: function rotate(radian) {
15928 var matrix = this.attr('matrix');
15929 mat3.rotate(matrix, matrix, radian);
15930 this.clearTotalMatrix();
15931 this.attr('matrix', matrix);
15932 return this;
15933 },
15934 scale: function scale(s1, s2) {
15935 var matrix = this.attr('matrix');
15936 mat3.scale(matrix, matrix, [s1, s2]);
15937 this.clearTotalMatrix();
15938 this.attr('matrix', matrix);
15939 return this;
15940 },
15941
15942 /**
15943 * 绕起始点旋转
15944 * @param {Number} rotate 0~360
15945 */
15946 rotateAtStart: function rotateAtStart(rotate) {
15947 var x = this.attr('x');
15948 var y = this.attr('y');
15949 if (Math.abs(rotate) > Math.PI * 2) {
15950 rotate = rotate / 180 * Math.PI;
15951 }
15952 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
15953 },
15954
15955 /**
15956 * 移动的到位置
15957 * @param {Number} x 移动到x
15958 * @param {Number} y 移动到y
15959 */
15960 move: function move(x, y) {
15961 var cx = this.get('x') || 0; // 当前的x
15962 var cy = this.get('y') || 0; // 当前的y
15963 this.translate(x - cx, y - cy);
15964 this.set('x', x);
15965 this.set('y', y);
15966 },
15967 transform: function transform(ts) {
15968 var self = this;
15969 var matrix = self.attr('matrix');
15970
15971 Util.each(ts, function (t) {
15972 switch (t[0]) {
15973 case 't':
15974 self.translate(t[1], t[2]);
15975 break;
15976 case 's':
15977 self.scale(t[1], t[2]);
15978 break;
15979 case 'r':
15980 self.rotate(t[1]);
15981 break;
15982 case 'm':
15983 self.attr('matrix', mat3.multiply([], matrix, t[1]));
15984 self.clearTotalMatrix();
15985 break;
15986 default:
15987 break;
15988 }
15989 });
15990 return self;
15991 },
15992 setTransform: function setTransform(ts) {
15993 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
15994 return this.transform(ts);
15995 },
15996 getMatrix: function getMatrix() {
15997 return this.attr('matrix');
15998 },
15999 setMatrix: function setMatrix(m) {
16000 this.attr('matrix', m);
16001 this.clearTotalMatrix();
16002 return this;
16003 },
16004 apply: function apply(v, root) {
16005 var m = void 0;
16006 if (root) {
16007 m = this._getMatrixByRoot(root);
16008 } else {
16009 m = this.attr('matrix');
16010 }
16011 vec3.transformMat3(v, v, m);
16012 return this;
16013 },
16014
16015 // 获取到达指定根节点的矩阵
16016 _getMatrixByRoot: function _getMatrixByRoot(root) {
16017 var self = this;
16018 root = root || self;
16019 var parent = self;
16020 var parents = [];
16021
16022 while (parent !== root) {
16023 parents.unshift(parent);
16024 parent = parent.get('parent');
16025 }
16026 parents.unshift(parent);
16027
16028 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
16029 Util.each(parents, function (child) {
16030 mat3.multiply(m, child.attr('matrix'), m);
16031 });
16032 return m;
16033 },
16034
16035 /**
16036 * 应用到当前元素上的总的矩阵
16037 * @return {Matrix} 矩阵
16038 */
16039 getTotalMatrix: function getTotalMatrix() {
16040 var m = this.__cfg.totalMatrix;
16041 if (!m) {
16042 m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
16043 var parent = this.__cfg.parent;
16044 if (parent) {
16045 var pm = parent.getTotalMatrix();
16046 multiple(m, pm);
16047 }
16048
16049 multiple(m, this.attr('matrix'));
16050 this.__cfg.totalMatrix = m;
16051 }
16052 return m;
16053 },
16054
16055 // 清除当前的矩阵
16056 clearTotalMatrix: function clearTotalMatrix() {
16057 // this.__cfg.totalMatrix = null;
16058 },
16059 invert: function invert(v) {
16060 var m = this.getTotalMatrix();
16061 // 单精屏幕下大多数矩阵没变化
16062 if (isScale(m)) {
16063 v[0] /= m[0];
16064 v[1] /= m[4];
16065 } else {
16066 var inm = mat3.invert([], m);
16067 if (inm) {
16068 vec3.transformMat3(v, v, inm);
16069 }
16070 }
16071 return this;
16072 },
16073 resetTransform: function resetTransform(context) {
16074 var mo = this.attr('matrix');
16075 // 不改变时
16076 if (!isUnchanged(mo)) {
16077 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
16078 }
16079 }
16080};
16081
16082/***/ }),
16083/* 153 */
16084/***/ (function(module, exports, __webpack_require__) {
16085
16086var Shape = __webpack_require__(1);
16087Shape.Rect = __webpack_require__(69);
16088Shape.Circle = __webpack_require__(70);
16089Shape.Ellipse = __webpack_require__(71);
16090Shape.Path = __webpack_require__(72);
16091Shape.Text = __webpack_require__(73);
16092Shape.Line = __webpack_require__(74);
16093Shape.Image = __webpack_require__(75);
16094Shape.Polygon = __webpack_require__(76);
16095Shape.Polyline = __webpack_require__(77);
16096Shape.Arc = __webpack_require__(78);
16097Shape.Fan = __webpack_require__(79);
16098Shape.Cubic = __webpack_require__(80);
16099Shape.Quadratic = __webpack_require__(81);
16100Shape.Marker = __webpack_require__(82);
16101
16102module.exports = Shape;
16103
16104/***/ }),
16105/* 154 */
16106/***/ (function(module, exports) {
16107
16108module.exports = {
16109 xAt: function xAt(psi, rx, ry, cx, t) {
16110 return rx * Math.cos(psi) * Math.cos(t) - ry * Math.sin(psi) * Math.sin(t) + cx;
16111 },
16112 yAt: function yAt(psi, rx, ry, cy, t) {
16113 return rx * Math.sin(psi) * Math.cos(t) + ry * Math.cos(psi) * Math.sin(t) + cy;
16114 },
16115 xExtrema: function xExtrema(psi, rx, ry) {
16116 return Math.atan(-ry / rx * Math.tan(psi));
16117 },
16118 yExtrema: function yExtrema(psi, rx, ry) {
16119 return Math.atan(ry / (rx * Math.tan(psi)));
16120 }
16121};
16122
16123/***/ }),
16124/* 155 */
16125/***/ (function(module, exports, __webpack_require__) {
16126
16127function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16128
16129function _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; }
16130
16131function _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; }
16132
16133var Util = __webpack_require__(17);
16134var Interaction = __webpack_require__(8);
16135// const G2 = require('../core.js');
16136
16137var BRUSH_TYPES = ['X', 'Y', 'XY', 'POLYGON'];
16138var DEFAULT_TYPE = 'XY';
16139
16140var Brush = function (_Interaction) {
16141 _inherits(Brush, _Interaction);
16142
16143 Brush.prototype.getDefaultCfg = function getDefaultCfg() {
16144 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
16145 return Util.mix({}, cfg, {
16146 type: DEFAULT_TYPE,
16147 startPoint: null,
16148 brushing: false,
16149 dragging: false,
16150 brushShape: null,
16151 container: null,
16152 polygonPath: null,
16153 style: {
16154 fill: '#C5D4EB',
16155 opacity: 0.3,
16156 lineWidth: 1,
16157 stroke: '#82A6DD'
16158 },
16159 draggable: false,
16160 dragOffX: 0,
16161 dragOffY: 0,
16162 inPlot: true,
16163 xField: null,
16164 yField: null
16165 });
16166 };
16167
16168 function Brush(cfg, view) {
16169 _classCallCheck(this, Brush);
16170
16171 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
16172
16173 var me = _this;
16174 me.filter = !me.draggable;
16175 me.type = me.type.toUpperCase();
16176 me.chart = view;
16177
16178 if (BRUSH_TYPES.indexOf(me.type) === -1) {
16179 me.type = DEFAULT_TYPE;
16180 }
16181 var canvas = me.canvas;
16182 if (canvas) {
16183 var plotRange = void 0;
16184 canvas.get('children').map(function (child) {
16185 if (child.get('type') === 'plotBack') {
16186 plotRange = child.get('plotRange');
16187 return false;
16188 }
16189 return child;
16190 });
16191 me.plot = {
16192 start: plotRange.bl,
16193 end: plotRange.tr
16194 };
16195 }
16196 if (view) {
16197 var coord = view.get('coord');
16198 me.plot = {
16199 start: coord.start,
16200 end: coord.end
16201 };
16202 var xScales = view._getScales('x');
16203 var yScales = view._getScales('y');
16204 me.xScale = me.xField ? xScales[me.xField] : view.getXScale();
16205 me.yScale = me.yField ? yScales[me.yField] : view.getYScales()[0];
16206 }
16207 return _this;
16208 }
16209
16210 // onBurshstart() { }
16211 // onBrushmove() { }
16212 // onBrushend() {}
16213 // onDragstart() {}
16214 // onDragmove() {}
16215 // onDragend() {}
16216
16217 Brush.prototype.start = function start(ev) {
16218 var me = this;
16219 var canvas = me.canvas,
16220 type = me.type,
16221 brushShape = me.brushShape;
16222
16223
16224 if (!type) return;
16225
16226 var startPoint = { x: ev.offsetX, y: ev.offsetY };
16227 if (!startPoint.x) return;
16228 var isInPlot = me.plot && me.inPlot;
16229 var canvasDOM = canvas.get('canvasDOM');
16230 var pixelRatio = canvas.get('pixelRatio');
16231
16232 if (me.selection) me.selection = null;
16233
16234 if (me.draggable && brushShape && !brushShape.get('destroyed')) {
16235 // allow drag the brushShape
16236 if (brushShape.isHit(startPoint.x * pixelRatio, startPoint.y * pixelRatio)) {
16237 canvasDOM.style.cursor = 'move';
16238 me.selection = brushShape;
16239 me.dragging = true;
16240 if (type === 'X') {
16241 me.dragoffX = startPoint.x - brushShape.attr('x');
16242 me.dragoffY = 0;
16243 } else if (type === 'Y') {
16244 me.dragoffX = 0;
16245 me.dragoffY = startPoint.y - brushShape.attr('y');
16246 } else if (type === 'XY') {
16247 me.dragoffX = startPoint.x - brushShape.attr('x');
16248 me.dragoffY = startPoint.y - brushShape.attr('y');
16249 } else if (type === 'POLYGON') {
16250 var box = brushShape.getBBox();
16251 me.dragoffX = startPoint.x - box.minX;
16252 me.dragoffY = startPoint.y - box.minY;
16253 }
16254
16255 if (isInPlot) {
16256 me.selection.attr('clip', canvas.addShape('rect', {
16257 attrs: {
16258 x: this.plot.start.x,
16259 y: this.plot.end.y,
16260 width: this.plot.end.x - this.plot.start.x,
16261 height: this.plot.start.y - this.plot.end.y,
16262 fill: '#fff',
16263 fillOpacity: 0
16264 }
16265 }));
16266 }
16267 me.onDragstart && me.onDragstart(ev);
16268 }
16269 me.prePoint = startPoint;
16270 }
16271
16272 if (!me.dragging) {
16273 // brush start
16274 me.onBrushstart && me.onBrushstart(startPoint);
16275 var container = me.container;
16276 if (isInPlot) {
16277 var _me$plot = me.plot,
16278 start = _me$plot.start,
16279 end = _me$plot.end;
16280
16281 if (startPoint.x < start.x || startPoint.x > end.x || startPoint.y < end.y || startPoint.y > start.y) return;
16282 }
16283 canvasDOM.style.cursor = 'crosshair';
16284 me.startPoint = startPoint;
16285 me.brushShape = null;
16286 me.brushing = true;
16287
16288 if (!container) {
16289 container = canvas.addGroup({
16290 zIndex: 5 // upper
16291 });
16292 container.initTransform();
16293 } else {
16294 container.clear();
16295 }
16296 me.container = container;
16297
16298 if (type === 'POLYGON') me.polygonPath = 'M ' + startPoint.x + ' ' + startPoint.y;
16299 }
16300 };
16301
16302 Brush.prototype.process = function process(ev) {
16303 var me = this;
16304 var brushing = me.brushing,
16305 dragging = me.dragging,
16306 type = me.type,
16307 plot = me.plot,
16308 startPoint = me.startPoint,
16309 xScale = me.xScale,
16310 yScale = me.yScale,
16311 canvas = me.canvas;
16312
16313
16314 if (!brushing && !dragging) {
16315 return;
16316 }
16317 var currentPoint = {
16318 x: ev.offsetX,
16319 y: ev.offsetY
16320 };
16321 var canvasDOM = canvas.get('canvasDOM');
16322
16323 if (brushing) {
16324 canvasDOM.style.cursor = 'crosshair';
16325 var start = plot.start,
16326 end = plot.end;
16327
16328 var polygonPath = me.polygonPath;
16329 var brushShape = me.brushShape;
16330 var container = me.container;
16331 if (me.plot && me.inPlot) {
16332 currentPoint = me._limitCoordScope(currentPoint);
16333 }
16334
16335 var rectStartX = void 0;
16336 var rectStartY = void 0;
16337 var rectWidth = void 0;
16338 var rectHeight = void 0;
16339
16340 if (type === 'Y') {
16341 rectStartX = start.x;
16342 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16343 rectWidth = Math.abs(start.x - end.x);
16344 rectHeight = Math.abs(startPoint.y - currentPoint.y);
16345 } else if (type === 'X') {
16346 rectStartX = currentPoint.x >= startPoint.x ? startPoint.x : currentPoint.x;
16347 rectStartY = end.y;
16348 rectWidth = Math.abs(startPoint.x - currentPoint.x);
16349 rectHeight = Math.abs(end.y - start.y);
16350 } else if (type === 'XY') {
16351 if (currentPoint.x >= startPoint.x) {
16352 rectStartX = startPoint.x;
16353 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16354 } else {
16355 rectStartX = currentPoint.x;
16356 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16357 }
16358 rectWidth = Math.abs(startPoint.x - currentPoint.x);
16359 rectHeight = Math.abs(startPoint.y - currentPoint.y);
16360 } else if (type === 'POLYGON') {
16361 polygonPath += 'L ' + currentPoint.x + ' ' + currentPoint.y;
16362 me.polygonPath = polygonPath;
16363 if (!brushShape) {
16364 brushShape = container.addShape('path', {
16365 attrs: Util.mix(me.style, {
16366 path: polygonPath
16367 })
16368 });
16369 } else {
16370 !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape._attrs, {
16371 path: polygonPath
16372 }));
16373 }
16374 }
16375 if (type !== 'POLYGON') {
16376 if (!brushShape) {
16377 brushShape = container.addShape('rect', {
16378 attrs: Util.mix(me.style, {
16379 x: rectStartX,
16380 y: rectStartY,
16381 width: rectWidth,
16382 height: rectHeight
16383 })
16384 });
16385 } else {
16386 !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape._attrs, {
16387 x: rectStartX,
16388 y: rectStartY,
16389 width: rectWidth,
16390 height: rectHeight
16391 }));
16392 }
16393 }
16394
16395 me.brushShape = brushShape;
16396 } else if (dragging) {
16397 canvasDOM.style.cursor = 'move';
16398 var selection = me.selection;
16399 if (selection && !selection.get('destroyed')) {
16400 if (type === 'POLYGON') {
16401 var prePoint = me.prePoint;
16402 me.selection.translate(currentPoint.x - prePoint.x, currentPoint.y - prePoint.y);
16403 } else {
16404 me.dragoffX && selection.attr('x', currentPoint.x - me.dragoffX);
16405 me.dragoffY && selection.attr('y', currentPoint.y - me.dragoffY);
16406 }
16407 }
16408 }
16409
16410 me.prePoint = currentPoint;
16411 canvas.draw();
16412
16413 var _me$_getSelected = me._getSelected(),
16414 data = _me$_getSelected.data,
16415 shapes = _me$_getSelected.shapes,
16416 xValues = _me$_getSelected.xValues,
16417 yValues = _me$_getSelected.yValues;
16418
16419 var eventObj = {
16420 data: data,
16421 shapes: shapes,
16422 x: currentPoint.x,
16423 y: currentPoint.y
16424 };
16425
16426 if (xScale) {
16427 eventObj[xScale.field] = xValues;
16428 }
16429 if (yScale) {
16430 eventObj[yScale.field] = yValues;
16431 }
16432 me.onDragmove && me.onDragmove(eventObj);
16433 me.onBrushmove && me.onBrushmove(eventObj);
16434 };
16435
16436 Brush.prototype.end = function end(ev) {
16437 var me = this;
16438 var data = me.data,
16439 shapes = me.shapes,
16440 xValues = me.xValues,
16441 yValues = me.yValues,
16442 canvas = me.canvas,
16443 type = me.type,
16444 startPoint = me.startPoint,
16445 chart = me.chart,
16446 container = me.container,
16447 xScale = me.xScale,
16448 yScale = me.yScale;
16449 var offsetX = ev.offsetX,
16450 offsetY = ev.offsetY;
16451
16452 var canvasDOM = canvas.get('canvasDOM');
16453 canvasDOM.style.cursor = 'default';
16454
16455 if (Math.abs(startPoint.x - offsetX) <= 1 && Math.abs(startPoint.y - offsetY) <= 1) {
16456 // 防止点击事件
16457 me.brushing = false;
16458 me.dragging = false;
16459 return;
16460 }
16461
16462 var eventObj = {
16463 data: data,
16464 shapes: shapes,
16465 x: offsetX,
16466 y: offsetY
16467 };
16468 if (xScale) {
16469 eventObj[xScale.field] = xValues;
16470 }
16471 if (yScale) {
16472 eventObj[yScale.field] = yValues;
16473 }
16474
16475 if (me.dragging) {
16476 me.dragging = false;
16477 me.onDragend && me.onDragend(eventObj);
16478 } else if (me.brushing) {
16479 me.brushing = false;
16480 var brushShape = me.brushShape;
16481 var polygonPath = me.polygonPath;
16482
16483 if (type === 'POLYGON') {
16484 polygonPath += 'z';
16485
16486 brushShape && !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape._attrs, {
16487 path: polygonPath
16488 }));
16489 me.polygonPath = polygonPath;
16490 canvas.draw();
16491 }
16492
16493 if (me.onBrushend) {
16494 me.onBrushend(eventObj);
16495 } else if (chart && me.filter) {
16496 container.clear(); // clear the brush
16497 // filter data
16498 if (type === 'X') {
16499 xScale && chart.filter(xScale.field, function (val) {
16500 return xValues.indexOf(val) > -1;
16501 });
16502 } else if (type === 'Y') {
16503 yScale && chart.filter(yScale.field, function (val) {
16504 return yValues.indexOf(val) > -1;
16505 });
16506 } else {
16507 xScale && chart.filter(xScale.field, function (val) {
16508 return xValues.indexOf(val) > -1;
16509 });
16510 yScale && chart.filter(yScale.field, function (val) {
16511 return yValues.indexOf(val) > -1;
16512 });
16513 }
16514 chart.repaint();
16515 }
16516 }
16517 };
16518
16519 Brush.prototype.reset = function reset() {
16520 var me = this;
16521 var chart = me.chart,
16522 filter = me.filter;
16523
16524 if (chart && filter) {
16525 chart.get('options').filters = {};
16526 chart.repaint();
16527 }
16528 };
16529
16530 Brush.prototype._limitCoordScope = function _limitCoordScope(point) {
16531 var plot = this.plot;
16532 var start = plot.start,
16533 end = plot.end;
16534
16535
16536 if (point.x < start.x) {
16537 point.x = start.x;
16538 }
16539 if (point.x > end.x) {
16540 point.x = end.x;
16541 }
16542 if (point.y < end.y) {
16543 point.y = end.y;
16544 }
16545 if (point.y > start.y) {
16546 point.y = start.y;
16547 }
16548 return point;
16549 };
16550
16551 Brush.prototype._getSelected = function _getSelected() {
16552 var me = this;
16553 var chart = me.chart,
16554 xScale = me.xScale,
16555 yScale = me.yScale,
16556 brushShape = me.brushShape,
16557 canvas = me.canvas;
16558
16559 var pixelRatio = canvas.get('pixelRatio');
16560 var selectedShapes = [];
16561 var xValues = [];
16562 var yValues = [];
16563 var selectedData = [];
16564 if (chart) {
16565 var geoms = chart.get('geoms');
16566 geoms.map(function (geom) {
16567 var shapes = geom.getShapes();
16568 shapes.map(function (shape) {
16569 var shapeData = shape.get('origin');
16570 if (!Array.isArray(shapeData)) {
16571 // 线图、区域图等
16572 shapeData = [shapeData];
16573 }
16574
16575 shapeData.map(function (each) {
16576 if (brushShape.isHit(each.x * pixelRatio, each.y * pixelRatio)) {
16577 selectedShapes.push(shape);
16578 var origin = each._origin;
16579 selectedData.push(origin);
16580 xScale && xValues.push(origin[xScale.field]);
16581 yScale && yValues.push(origin[yScale.field]);
16582 }
16583 return each;
16584 });
16585
16586 return shape;
16587 });
16588 return geom;
16589 });
16590 }
16591 me.shapes = selectedShapes;
16592 me.xValues = xValues;
16593 me.yValues = yValues;
16594 me.data = selectedData;
16595 return {
16596 data: selectedData,
16597 xValues: xValues,
16598 yValues: yValues,
16599 shapes: selectedShapes
16600 };
16601 };
16602
16603 return Brush;
16604}(Interaction);
16605
16606// G2.registerInteraction('brush', Brush);
16607// G2.registerInteraction('Brush', Brush);
16608
16609module.exports = Brush;
16610
16611/***/ }),
16612/* 156 */
16613/***/ (function(module, exports, __webpack_require__) {
16614
16615function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16616
16617function _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; }
16618
16619function _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; }
16620
16621var Util = __webpack_require__(17);
16622var Interaction = __webpack_require__(8);
16623// const G2 = require('../core.js');
16624
16625var DRAGGING_TYPES = ['X', 'Y', 'XY'];
16626var DEFAULT_TYPE = 'X';
16627
16628var Drag = function (_Interaction) {
16629 _inherits(Drag, _Interaction);
16630
16631 Drag.prototype.getDefaultCfg = function getDefaultCfg() {
16632 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
16633 return Util.mix({}, cfg, {
16634 type: DEFAULT_TYPE,
16635 stepRatio: 0.05,
16636 stepByField: {},
16637 originScaleDefsByField: {},
16638 previousPoint: null,
16639 isDragging: false
16640 });
16641 };
16642
16643 function Drag(cfg, view) {
16644 _classCallCheck(this, Drag);
16645
16646 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
16647
16648 var me = _this;
16649 me.type = me.type.toUpperCase();
16650 me.chart = view;
16651
16652 var scales = view.getYScales();
16653 var xScale = view.getXScale();
16654 scales.push(xScale);
16655 var scaleController = view.get('scaleController');
16656 scales.forEach(function (scale) {
16657 var field = scale.field;
16658 var def = scaleController.defs[field];
16659 me.originScaleDefsByField[field] = Util.mix(def, {
16660 nice: !!def.nice
16661 });
16662 if (scale.isLinear) {
16663 me.stepByField[field] = (scale.max - scale.min) * me.stepRatio;
16664 }
16665 });
16666
16667 if (DRAGGING_TYPES.indexOf(me.type) === -1) {
16668 me.type = DEFAULT_TYPE;
16669 }
16670 return _this;
16671 }
16672
16673 // onDragstart() { }
16674 // onDrag() { }
16675 // onDragend() { }
16676
16677 Drag.prototype._applyTranslate = function _applyTranslate(scale) {
16678 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
16679
16680 var me = this;
16681 var chart = me.chart;
16682 var min = scale.min,
16683 max = scale.max,
16684 field = scale.field;
16685
16686 var range = max - min;
16687 chart.scale(field, {
16688 nice: false,
16689 min: min - offset * range,
16690 max: max - offset * range
16691 });
16692 };
16693
16694 Drag.prototype.start = function start(ev) {
16695 var me = this;
16696 var chart = me.chart,
16697 canvas = me.canvas;
16698
16699 var canvasDOM = canvas.get('canvasDOM');
16700 canvasDOM.style.cursor = 'pointer';
16701 var coord = chart.get('coord');
16702 me.isDragging = true;
16703 me.previousPoint = coord.invertPoint(ev);
16704 };
16705
16706 Drag.prototype.process = function process(ev) {
16707 var me = this;
16708 if (me.isDragging) {
16709 var chart = me.chart,
16710 type = me.type,
16711 canvas = me.canvas;
16712
16713 var canvasDOM = canvas.get('canvasDOM');
16714 canvasDOM.style.cursor = 'move';
16715 var coord = chart.get('coord');
16716 var previousPoint = me.previousPoint;
16717 var currentPoint = coord.invertPoint(ev);
16718 if (type.indexOf('X') > -1) {
16719 me._applyTranslate(chart.getXScale(), currentPoint.x - previousPoint.x);
16720 }
16721 if (type.indexOf('Y') > -1) {
16722 var yScales = chart.getYScales();
16723 yScales.forEach(function (yScale) {
16724 me._applyTranslate(yScale, currentPoint.y - previousPoint.y);
16725 });
16726 }
16727 me.previousPoint = currentPoint;
16728 chart.repaint();
16729 }
16730 };
16731
16732 Drag.prototype.end = function end() {
16733 var me = this;
16734 me.isDragging = false;
16735 var canvas = me.canvas;
16736
16737 var canvasDOM = canvas.get('canvasDOM');
16738 canvasDOM.style.cursor = 'default';
16739 };
16740
16741 Drag.prototype.reset = function reset() {
16742 var me = this;
16743 var view = me.view,
16744 originScaleDefsByField = me.originScaleDefsByField;
16745
16746 var scales = view.getYScales();
16747 var xScale = view.getXScale();
16748 scales.push(xScale);
16749 scales.forEach(function (scale) {
16750 if (scale.isLinear) {
16751 var field = scale.field;
16752 view.scale(field, originScaleDefsByField[field]);
16753 }
16754 });
16755 view.repaint();
16756 };
16757
16758 return Drag;
16759}(Interaction);
16760
16761module.exports = Drag;
16762
16763/***/ }),
16764/* 157 */
16765/***/ (function(module, exports, __webpack_require__) {
16766
16767function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16768
16769function _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; }
16770
16771function _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; }
16772
16773var Util = __webpack_require__(17);
16774var Interaction = __webpack_require__(8);
16775
16776function getOriginalAttrs(attrs, styles) {
16777 var origin = {};
16778 for (var style in styles) {
16779 origin[style] = attrs[style];
16780 }
16781 return origin;
16782}
16783
16784var Select = function (_Interaction) {
16785 _inherits(Select, _Interaction);
16786
16787 function Select() {
16788 _classCallCheck(this, Select);
16789
16790 return _possibleConstructorReturn(this, _Interaction.apply(this, arguments));
16791 }
16792
16793 Select.prototype.getDefaultCfg = function getDefaultCfg() {
16794 var defaultCfg = _Interaction.prototype.getDefaultCfg.call(this);
16795 return Util.mix({}, defaultCfg, {
16796 startEvent: 'mouseup',
16797 processEvent: null,
16798 selectStyle: {
16799 fillOpacity: 1
16800 },
16801 unSelectStyle: {
16802 fillOpacity: 0.1
16803 },
16804 cancelable: true
16805 });
16806 };
16807
16808 Select.prototype.start = function start(ev) {
16809 var self = this;
16810 var chart = self.view;
16811
16812 var selectedShape = void 0;
16813 var unSelectedShapes = [];
16814 chart.eachShape(function (obj, shape) {
16815 if (shape.isPointInPath(ev.x, ev.y)) {
16816 selectedShape = shape;
16817 } else {
16818 unSelectedShapes.push(shape);
16819 }
16820 });
16821
16822 if (!selectedShape) {
16823 self.reset();
16824 return;
16825 }
16826
16827 if (selectedShape.get('_selected')) {
16828 // 已经被选中
16829 if (!self.cancelable) {
16830 // 不允许取消选中则不处理
16831 return;
16832 }
16833 self.reset(); // 允许取消选中
16834 } else {
16835 // 未被选中
16836 var selectStyle = self.selectStyle,
16837 unSelectStyle = self.unSelectStyle;
16838 // 获取选中效果对应的本来效果,保存下来
16839
16840 var originAttrs = getOriginalAttrs(selectedShape.attr(), selectedShape);
16841 selectedShape.set('_originAttrs', originAttrs);
16842 selectedShape.attr(selectStyle);
16843
16844 Util.each(unSelectedShapes, function (child) {
16845 var originAttrs = child.get('_originAttrs');
16846 // 先恢复到默认状态下
16847 if (originAttrs) {
16848 child.attr(originAttrs);
16849 }
16850 child.set('_selected', false);
16851 // 保存未选中效果对应的原始效果
16852 if (unSelectStyle) {
16853 originAttrs = getOriginalAttrs(child.attr(), unSelectStyle);
16854 child.set('_originAttrs', originAttrs);
16855 child.attr(unSelectStyle);
16856 }
16857 });
16858
16859 selectedShape.set('_selected', true);
16860 self.selectedShape = selectedShape;
16861 self.canvas.draw();
16862 }
16863 };
16864
16865 Select.prototype.end = function end(ev) {
16866 var selectedShape = this.selectedShape;
16867 if (selectedShape && !selectedShape.get('destroyed') && selectedShape.get('origin')) {
16868 ev.data = selectedShape.get('origin')._origin; // 绘制数据,包含原始数据啊
16869 ev.shapeInfo = selectedShape.get('origin');
16870 ev.shape = selectedShape;
16871 ev.selected = !!selectedShape.get('_selected'); // 返回选中的状态
16872 }
16873 };
16874
16875 Select.prototype.reset = function reset() {
16876 var self = this;
16877 if (!self.selectedShape) {
16878 return;
16879 }
16880 var chart = self.view;
16881 var geom = chart.get('geoms')[0];
16882 var container = geom.get('container').get('children')[0];
16883 var children = container.get('children');
16884
16885 Util.each(children, function (child) {
16886 var originAttrs = child.get('_originAttrs');
16887 if (originAttrs) {
16888 child._attrs = originAttrs;
16889 child.set('_originAttrs', null);
16890 }
16891 child.set('_selected', false);
16892 });
16893 self.canvas.draw();
16894 };
16895
16896 return Select;
16897}(Interaction);
16898
16899module.exports = Select;
16900
16901/***/ }),
16902/* 158 */
16903/***/ (function(module, exports, __webpack_require__) {
16904
16905function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16906
16907function _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; }
16908
16909function _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; }
16910
16911var Util = __webpack_require__(17);
16912var Interaction = __webpack_require__(8);
16913// const G2 = require('../core.js');
16914
16915var ZOOMING_TYPES = ['X', 'Y', 'XY'];
16916var DEFAULT_TYPE = 'X';
16917
16918// TODO zoom with center point
16919
16920var Zoom = function (_Interaction) {
16921 _inherits(Zoom, _Interaction);
16922
16923 Zoom.prototype.getDefaultCfg = function getDefaultCfg() {
16924 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
16925 return Util.mix({}, cfg, {
16926 processEvent: 'mousewheel',
16927 type: DEFAULT_TYPE,
16928 stepRatio: 0.05,
16929 stepByField: {},
16930 originScaleDefsByField: {}
16931 });
16932 };
16933
16934 function Zoom(cfg, view) {
16935 _classCallCheck(this, Zoom);
16936
16937 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
16938
16939 var me = _this;
16940 me.chart = view;
16941 me.type = me.type.toUpperCase();
16942
16943 var scales = view.getYScales();
16944 var xScale = view.getXScale();
16945 scales.push(xScale);
16946 var scaleController = view.get('scaleController');
16947 scales.forEach(function (scale) {
16948 var field = scale.field;
16949 var def = scaleController.defs[field] || {};
16950 me.originScaleDefsByField[field] = Util.mix(def, {
16951 nice: !!def.nice
16952 });
16953 if (scale.isLinear) {
16954 me.stepByField[field] = (scale.max - scale.min) * me.stepRatio;
16955 }
16956 });
16957
16958 if (ZOOMING_TYPES.indexOf(me.type) === -1) {
16959 me.type = DEFAULT_TYPE;
16960 }
16961 return _this;
16962 }
16963
16964 // onZoom() { }
16965 // onZoomin() { }
16966 // onZoomout() { }
16967
16968 Zoom.prototype._applyScale = function _applyScale(scale, delta) {
16969 var minOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
16970
16971 var me = this;
16972 var chart = me.chart,
16973 stepByField = me.stepByField;
16974
16975 if (scale.isLinear) {
16976 var min = scale.min,
16977 max = scale.max,
16978 field = scale.field;
16979
16980 var maxOffset = 1 - minOffset;
16981 var step = stepByField[field] * delta;
16982 var newMin = min + step * minOffset;
16983 var newMax = max - step * maxOffset;
16984 if (newMax > newMin) {
16985 chart.scale(field, {
16986 nice: false,
16987 min: newMin,
16988 max: newMax
16989 });
16990 }
16991 }
16992 };
16993
16994 Zoom.prototype.process = function process(ev) {
16995 var me = this;
16996 var chart = me.chart,
16997 type = me.type;
16998
16999 var coord = chart.get('coord');
17000 var deltaY = ev.deltaY;
17001 var offsetPoint = coord.invertPoint(ev);
17002 if (deltaY) {
17003 me.onZoom && me.onZoom(deltaY, offsetPoint, me);
17004 if (deltaY > 0) {
17005 me.onZoomin && me.onZoomin(deltaY, offsetPoint, me);
17006 } else {
17007 me.onZoomout && me.onZoomout(deltaY, offsetPoint, me);
17008 }
17009 var delta = deltaY / Math.abs(deltaY);
17010 if (type.indexOf('X') > -1) {
17011 me._applyScale(chart.getXScale(), delta, offsetPoint.x);
17012 }
17013 if (type.indexOf('Y') > -1) {
17014 var yScales = chart.getYScales();
17015 yScales.forEach(function (yScale) {
17016 me._applyScale(yScale, delta, offsetPoint.y);
17017 });
17018 }
17019 }
17020 chart.repaint();
17021 };
17022
17023 Zoom.prototype.reset = function reset() {
17024 var me = this;
17025 var view = me.view,
17026 originScaleDefsByField = me.originScaleDefsByField;
17027
17028 var scales = view.getYScales();
17029 var xScale = view.getXScale();
17030 scales.push(xScale);
17031 scales.forEach(function (scale) {
17032 if (scale.isLinear) {
17033 var field = scale.field;
17034 view.scale(field, originScaleDefsByField[field]);
17035 }
17036 });
17037 view.repaint();
17038 };
17039
17040 return Zoom;
17041}(Interaction);
17042
17043// G2.registerInteraction('zoom', Zoom);
17044// G2.registerInteraction('Zoom', Zoom);
17045
17046module.exports = Zoom;
17047
17048/***/ }),
17049/* 159 */
17050/***/ (function(module, exports, __webpack_require__) {
17051
17052var G = __webpack_require__(32);
17053var CommonUtil = G.CommonUtil;
17054
17055function bindInteraction(Lib, View) {
17056 // binding on Library
17057 Lib._Interactions = {};
17058 Lib.registerInteraction = function (type, constructor) {
17059 Lib._Interactions[type] = constructor;
17060 };
17061 Lib.getInteraction = function (type) {
17062 return G2._Interactions[type];
17063 };
17064
17065 // binding on View
17066 View.prototype.getInteractions = function () {
17067 var me = this;
17068 if (!me._interactions) {
17069 me._interactions = {};
17070 }
17071 return me._interactions;
17072 };
17073 View.prototype._setInteraction = function (type, interaction) {
17074 var me = this;
17075 var interactions = me.getInteractions();
17076 if (interactions[type] && interactions[type] !== interaction) {
17077 // only one interaction for a key
17078 interactions[type].destroy();
17079 }
17080 interactions[type] = interaction;
17081 };
17082 View.prototype.clearInteraction = function (type) {
17083 var me = this;
17084 var interactions = me.getInteractions();
17085 if (type) {
17086 interactions[type] && interactions[type].destroy();
17087 delete interactions[type];
17088 } else {
17089 CommonUtil.each(interactions, function (interaction, key) {
17090 interaction.destroy();
17091 delete interactions[key];
17092 });
17093 }
17094 };
17095 View.prototype.interact = View.prototype.interaction = function (type, cfg) {
17096 var me = this;
17097 var Ctor = G2.getInteraction(type);
17098 var interaction = new Ctor(cfg, me);
17099 me._setInteraction(type, interaction);
17100 return me;
17101 };
17102}
17103
17104module.exports = bindInteraction;
17105
17106/***/ })
17107/******/ ]);
17108});
17109//# sourceMappingURL=interaction.js.map
\No newline at end of file