UNPKG

485 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 = 68);
74/******/ })
75/************************************************************************/
76/******/ ([
77/* 0 */
78/***/ (function(module, exports, __webpack_require__) {
79
80var CommonUtil = __webpack_require__(7);
81var DomUtil = __webpack_require__(29);
82
83var Util = {};
84
85CommonUtil.merge(Util, CommonUtil, DomUtil, {
86 mixin: function mixin(c, mixins) {
87 var Param = c.CFG ? 'CFG' : 'ATTRS';
88 if (c && mixins) {
89 c._mixins = mixins;
90 c[Param] = c[Param] || {};
91 var temp = {};
92 Util.each(mixins, function (mixin) {
93 Util.augment(c, mixin);
94 var attrs = mixin[Param];
95 if (attrs) {
96 Util.merge(temp, attrs);
97 }
98 });
99 c[Param] = Util.merge(temp, c[Param]);
100 }
101 }
102});
103
104module.exports = Util;
105
106/***/ }),
107/* 1 */
108/***/ (function(module, exports, __webpack_require__) {
109
110var Util = __webpack_require__(0);
111var Element = __webpack_require__(55);
112var Inside = __webpack_require__(3);
113
114var Shape = function Shape(cfg) {
115 Shape.superclass.constructor.call(this, cfg);
116};
117
118Shape.ATTRS = {};
119
120Util.extend(Shape, Element);
121
122Util.augment(Shape, {
123 isShape: true,
124 createPath: function createPath() {},
125 afterPath: function afterPath() {},
126 drawInner: function drawInner(context) {
127 var self = this;
128 var attrs = self.__attrs;
129 self.createPath(context);
130 var originOpacity = context.globalAlpha;
131 if (self.hasFill()) {
132 var fillOpacity = attrs.fillOpacity;
133 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
134 context.globalAlpha = fillOpacity;
135 context.fill();
136 context.globalAlpha = originOpacity;
137 } else {
138 context.fill();
139 }
140 }
141 if (self.hasStroke()) {
142 var lineWidth = self.__attrs.lineWidth;
143 if (lineWidth > 0) {
144 var strokeOpacity = attrs.strokeOpacity;
145 if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
146 context.globalAlpha = strokeOpacity;
147 }
148 context.stroke();
149 }
150 }
151 self.afterPath(context);
152 },
153
154 /**
155 * 节点是否在图形中
156 * @param {Number} x x 坐标
157 * @param {Number} y y 坐标
158 * @return {Boolean} 是否在图形中
159 */
160 isPointInPath: function isPointInPath() {
161 return false;
162 },
163
164 /**
165 * 击中图形时是否进行包围盒判断
166 * @return {Boolean} [description]
167 */
168 isHitBox: function isHitBox() {
169 return true;
170 },
171
172 /**
173 * 节点是否能够被击中
174 * @param {Number} x x坐标
175 * @param {Number} y y坐标
176 * @return {Boolean} 是否在图形中
177 */
178 isHit: function isHit(x, y) {
179 var self = this;
180 var v = [x, y, 1];
181 self.invert(v); // canvas
182
183 if (self.isHitBox()) {
184 var box = self.getBBox();
185 if (box && !Inside.box(box.minX, box.maxX, box.minY, box.maxY, v[0], v[1])) {
186 return false;
187 }
188 }
189 var clip = self.__attrs.clip;
190 if (clip) {
191 if (clip.inside(x, y)) {
192 return self.isPointInPath(v[0], v[1]);
193 }
194 } else {
195 return self.isPointInPath(v[0], v[1]);
196 }
197 return false;
198 },
199
200 /**
201 * @protected
202 * 计算包围盒
203 * @return {Object} 包围盒
204 */
205 calculateBox: function calculateBox() {
206 return null;
207 },
208
209 // 获取拾取时线的宽度,需要考虑附加的线的宽度
210 getHitLineWidth: function getHitLineWidth() {
211 var attrs = this.__attrs;
212 // if (!attrs.stroke) {
213 // return 0;
214 // }
215 var lineAppendWidth = attrs.lineAppendWidth || 0;
216 var lineWidth = attrs.lineWidth || 0;
217 return lineWidth + lineAppendWidth;
218 },
219
220 // 清除当前的矩阵
221 clearTotalMatrix: function clearTotalMatrix() {
222 this.__cfg.totalMatrix = null;
223 this.__cfg.region = null;
224 },
225 clearBBox: function clearBBox() {
226 this.__cfg.box = null;
227 this.__cfg.region = null;
228 },
229 getBBox: function getBBox() {
230 var box = this.__cfg.box;
231 // 延迟计算
232 if (!box) {
233 box = this.calculateBox();
234 if (box) {
235 box.x = box.minX;
236 box.y = box.minY;
237 box.width = box.maxX - box.minX;
238 box.height = box.maxY - box.minY;
239 }
240 this.__cfg.box = box;
241 }
242 return box;
243 }
244});
245
246module.exports = Shape;
247
248/***/ }),
249/* 2 */
250/***/ (function(module, exports, __webpack_require__) {
251
252var CommonUtil = __webpack_require__(7);
253var mat3 = __webpack_require__(74);
254var vec3 = __webpack_require__(75);
255var vec2 = __webpack_require__(76);
256
257vec2.angle = function (v1, v2) {
258 var theta = vec2.dot(v1, v2) / (vec2.length(v1) * vec2.length(v2));
259 return Math.acos(CommonUtil.clamp(theta, -1, 1));
260};
261/**
262 * 向量 v1 到 向量 v2 夹角的方向
263 * @param {Array} v1 向量
264 * @param {Array} v2 向量
265 * @return {Boolean} >= 0 顺时针 < 0 逆时针
266 */
267vec2.direction = function (v1, v2) {
268 return v1[0] * v2[1] - v2[0] * v1[1];
269};
270vec2.angleTo = function (v1, v2, direct) {
271 var angle = vec2.angle(v1, v2);
272 var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
273 if (direct) {
274 if (angleLargeThanPI) {
275 return Math.PI * 2 - angle;
276 }
277
278 return angle;
279 }
280
281 if (angleLargeThanPI) {
282 return angle;
283 }
284 return Math.PI * 2 - angle;
285};
286vec2.vertical = function (out, v, flag) {
287 if (flag) {
288 out[0] = v[1];
289 out[1] = -1 * v[0];
290 } else {
291 out[0] = -1 * v[1];
292 out[1] = v[0];
293 }
294
295 return out;
296};
297
298mat3.translate = function (out, a, v) {
299 var transMat = new Array(9);
300 mat3.fromTranslation(transMat, v);
301 return mat3.multiply(out, transMat, a);
302};
303
304mat3.rotate = function (out, a, rad) {
305 var rotateMat = new Array(9);
306 mat3.fromRotation(rotateMat, rad);
307 return mat3.multiply(out, rotateMat, a);
308};
309
310mat3.scale = function (out, a, v) {
311 var scaleMat = new Array(9);
312 mat3.fromScaling(scaleMat, v);
313 return mat3.multiply(out, scaleMat, a);
314};
315
316module.exports = {
317 mat3: mat3,
318 vec2: vec2,
319 vec3: vec3,
320 transform: function transform(m, ts) {
321 m = CommonUtil.clone(m);
322 CommonUtil.each(ts, function (t) {
323 switch (t[0]) {
324 case 't':
325 mat3.translate(m, m, [t[1], t[2]]);
326 break;
327 case 's':
328 mat3.scale(m, m, [t[1], t[2]]);
329 break;
330 case 'r':
331 mat3.rotate(m, m, t[1]);
332 break;
333 case 'm':
334 mat3.multiply(m, m, t[1]);
335 break;
336 default:
337 return false;
338 }
339 });
340 return m;
341 }
342};
343
344/***/ }),
345/* 3 */
346/***/ (function(module, exports, __webpack_require__) {
347
348var Line = __webpack_require__(22);
349var Quadratic = __webpack_require__(23);
350var Cubic = __webpack_require__(12);
351var Arc = __webpack_require__(24);
352
353module.exports = {
354 line: function line(x1, y1, x2, y2, lineWidth, x, y) {
355 var box = Line.box(x1, y1, x2, y2, lineWidth);
356
357 if (!this.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
358 return false;
359 }
360
361 var d = Line.pointDistance(x1, y1, x2, y2, x, y);
362 if (isNaN(d)) {
363 return false;
364 }
365 return d <= lineWidth / 2;
366 },
367 polyline: function polyline(points, lineWidth, x, y) {
368 var l = points.length - 1;
369 if (l < 1) {
370 return false;
371 }
372 for (var i = 0; i < l; i++) {
373 var x1 = points[i][0];
374 var y1 = points[i][1];
375 var x2 = points[i + 1][0];
376 var y2 = points[i + 1][1];
377
378 if (this.line(x1, y1, x2, y2, lineWidth, x, y)) {
379 return true;
380 }
381 }
382
383 return false;
384 },
385 cubicline: function cubicline(x1, y1, x2, y2, x3, y3, x4, y4, lineWidth, x, y) {
386 return Cubic.pointDistance(x1, y1, x2, y2, x3, y3, x4, y4, x, y) <= lineWidth / 2;
387 },
388 quadraticline: function quadraticline(x1, y1, x2, y2, x3, y3, lineWidth, x, y) {
389 return Quadratic.pointDistance(x1, y1, x2, y2, x3, y3, x, y) <= lineWidth / 2;
390 },
391 arcline: function arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y) {
392 return Arc.pointDistance(cx, cy, r, startAngle, endAngle, clockwise, x, y) <= lineWidth / 2;
393 },
394 rect: function rect(rx, ry, width, height, x, y) {
395 return rx <= x && x <= rx + width && ry <= y && y <= ry + height;
396 },
397 circle: function circle(cx, cy, r, x, y) {
398 return Math.pow(x - cx, 2) + Math.pow(y - cy, 2) <= Math.pow(r, 2);
399 },
400 box: function box(minX, maxX, minY, maxY, x, y) {
401 return minX <= x && x <= maxX && minY <= y && y <= maxY;
402 }
403};
404
405/***/ }),
406/* 4 */
407/***/ (function(module, exports, __webpack_require__) {
408
409var Util = __webpack_require__(0);
410var Element = __webpack_require__(13);
411
412var SHAPES = {
413 rect: 'rect',
414 circle: 'circle',
415 line: 'line',
416 path: 'path',
417 marker: 'marker',
418 text: 'text',
419 polygon: 'polygon',
420 image: 'image',
421 ellipse: 'ellipse',
422 dom: 'foreignObject',
423 fan: 'path'
424};
425
426var Shape = function Shape(cfg) {
427 Shape.superclass.constructor.call(this, cfg);
428};
429
430Shape.ATTRS = {};
431
432Util.extend(Shape, Element);
433
434Util.augment(Shape, {
435 isShape: true,
436 createPath: function createPath() {},
437 init: function init(id) {
438 Shape.superclass.init.call(this);
439 var type = SHAPES[this.type];
440 if (type) {
441 var shape = document.createElementNS('http://www.w3.org/2000/svg', type);
442 id = id || Util.uniqueId(this.type + '_');
443 shape.setAttribute('id', id);
444 this.setSilent('el', shape);
445 this.setSilent('id', id);
446 }
447 },
448
449 /**
450 * 节点是否在图形中
451 * @param {Number} x x 坐标
452 * @param {Number} y y 坐标
453 * @return {Boolean} 是否在图形中
454 */
455 isPointInPath: function isPointInPath() {
456 return false;
457 },
458
459 /**
460 * 击中图形时是否进行包围盒判断
461 * @return {Boolean} [description]
462 */
463 isHitBox: function isHitBox() {
464 return true;
465 },
466
467 /**
468 * 节点是否能够被击中
469 * @return {Boolean} 是否在图形中
470 */
471 isHit: function isHit() {
472 return false;
473 },
474
475 /**
476 * @protected
477 * @protected
478 * 计算包围盒
479 * @return {Object} 包围盒
480 */
481 calculateBox: function calculateBox() {
482 return null;
483 },
484
485 // 获取拾取时线的宽度,需要考虑附加的线的宽度
486 getHitLineWidth: function getHitLineWidth() {
487 var attrs = this.__attrs;
488 // if (!attrs.stroke) {
489 // return 0;
490 // }
491 var lineAppendWidth = attrs.lineAppendWidth || 0;
492 var lineWidth = attrs.lineWidth || 0;
493 return lineWidth + lineAppendWidth;
494 },
495
496 // 清除当前的矩阵
497 clearTotalMatrix: function clearTotalMatrix() {
498 this.__cfg.totalMatrix = null;
499 this.__cfg.region = null;
500 },
501 clearBBox: function clearBBox() {
502 this.__cfg.box = null;
503 this.__cfg.region = null;
504 }
505});
506
507module.exports = Shape;
508
509/***/ }),
510/* 5 */
511/***/ (function(module, __webpack_exports__, __webpack_require__) {
512
513"use strict";
514/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_color__ = __webpack_require__(18);
515/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["e"]; });
516/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["g"]; });
517/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return __WEBPACK_IMPORTED_MODULE_0__src_color__["f"]; });
518/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_lab__ = __webpack_require__(92);
519/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["a"]; });
520/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return __WEBPACK_IMPORTED_MODULE_1__src_lab__["b"]; });
521/* unused harmony reexport lch */
522/* unused harmony reexport gray */
523/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__ = __webpack_require__(93);
524/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubehelix__["a"]; });
525
526
527
528
529/***/ }),
530/* 6 */
531/***/ (function(module, exports, __webpack_require__) {
532
533var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
534
535var Marker = __webpack_require__(27);
536var Util = __webpack_require__(0);
537
538var PI = Math.PI;
539var sin = Math.sin;
540var cos = Math.cos;
541var atan2 = Math.atan2;
542var DEFAULT_LENGTH = 10;
543var DEFAULT_ANGLE = PI / 3;
544
545function _addArrow(ctx, attrs, x1, y1, x2, y2) {
546 var leftX = void 0;
547 var leftY = void 0;
548 var rightX = void 0;
549 var rightY = void 0;
550 var offsetX = void 0;
551 var offsetY = void 0;
552 var angle = void 0;
553
554 if (!attrs.fill) {
555 // 闭合的不绘制箭头
556 var arrowLength = attrs.arrowLength || DEFAULT_LENGTH;
557 var arrowAngle = attrs.arrowAngle ? attrs.arrowAngle * PI / 180 : DEFAULT_ANGLE; // 转换为弧
558 // Calculate angle
559 angle = atan2(y2 - y1, x2 - x1);
560 // Adjust angle correctly
561 angle -= PI;
562 // Calculate offset to place arrow at edge of path
563 offsetX = attrs.lineWidth * cos(angle);
564 offsetY = attrs.lineWidth * sin(angle);
565
566 // Calculate coordinates for left half of arrow
567 leftX = x2 + arrowLength * cos(angle + arrowAngle / 2);
568 leftY = y2 + arrowLength * sin(angle + arrowAngle / 2);
569 // Calculate coordinates for right half of arrow
570 rightX = x2 + arrowLength * cos(angle - arrowAngle / 2);
571 rightY = y2 + arrowLength * sin(angle - arrowAngle / 2);
572 ctx.beginPath();
573 // Draw left half of arrow
574 ctx.moveTo(leftX - offsetX, leftY - offsetY);
575 ctx.lineTo(x2 - offsetX, y2 - offsetY);
576 // Draw right half of arrow
577 ctx.lineTo(rightX - offsetX, rightY - offsetY);
578
579 // Visually connect arrow to path
580 ctx.moveTo(x2 - offsetX, y2 - offsetY);
581 ctx.lineTo(x2 + offsetX, y2 + offsetY);
582 // Move back to end of path
583 ctx.moveTo(x2, y2);
584 ctx.stroke();
585 }
586}
587
588function _addMarker(ctx, attrs, x1, y1, x2, y2, shape) {
589 var marker = shape.__attrs;
590 var method = marker.symbol;
591 var markerX = marker.x || x2;
592 var markerY = marker.y || y2;
593 var markerR = marker.r || attrs.lineWidth;
594 if (!Util.isFunction(method)) {
595 method = Marker.Symbols[method || 'triangle'];
596 }
597 var deg = 0;
598 var x = x1 - x2;
599 var y = y1 - y2;
600 if (y === 0) {
601 if (x < 0) {
602 deg = Math.PI / 2;
603 } else {
604 deg = 270 * Math.PI / 180;
605 }
606 } else if (x >= 0 && y > 0) {
607 deg = -Math.atan(x / y);
608 } else if (x <= 0 && y < 0) {
609 deg = Math.PI - Math.atan(x / y);
610 } else if (x > 0 && y < 0) {
611 deg = Math.PI + Math.atan(-x / y);
612 } else if (x < 0 && y > 0) {
613 deg = Math.atan(x / -y);
614 }
615 ctx.save();
616 ctx.beginPath();
617 ctx.translate(markerX, markerY);
618 ctx.rotate(deg);
619 ctx.translate(-markerX, -markerY);
620 method(markerX, markerY, markerR, ctx, shape);
621 ctx.setTransform(1, 0, 0, 1, 0, 0);
622 ctx.fillStyle = shape.attr('fill') || ctx.strokeStyle;
623 ctx.fill();
624 ctx.restore();
625}
626
627module.exports = {
628 addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) {
629 if (_typeof(attrs.startArrow) === 'object') {
630 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.startArrow);
631 } else if (attrs.startArrow) {
632 _addArrow(ctx, attrs, x1, y1, x2, y2);
633 }
634 },
635 addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) {
636 if (_typeof(attrs.endArrow) === 'object') {
637 _addMarker(ctx, attrs, x1, y1, x2, y2, attrs.endArrow);
638 } else if (attrs.endArrow) {
639 _addArrow(ctx, attrs, x1, y1, x2, y2);
640 }
641 }
642};
643
644/***/ }),
645/* 7 */
646/***/ (function(module, exports, __webpack_require__) {
647
648var Util = __webpack_require__(10);
649
650module.exports = {
651 isFunction: Util.isFunction,
652 isObject: Util.isObject,
653 isBoolean: Util.isBoolean,
654 isNil: Util.isNil,
655 isString: Util.isString,
656 isArray: Util.isArray,
657 isNumber: Util.isNumber,
658 isEmpty: Util.isEmpty, // isBlank
659 uniqueId: Util.uniqueId,
660 clone: Util.clone,
661 assign: Util.mix, // simpleMix
662 merge: Util.deepMix, // mix
663 upperFirst: Util.upperFirst, // ucfirst
664 each: Util.each,
665 isEqual: Util.isEqual,
666 toArray: Util.toArray,
667 extend: Util.extend,
668 augment: Util.augment,
669 remove: Util.arrayUtil.pull,
670 isNumberEqual: Util.isNumberEqual,
671 toRadian: Util.toRadian,
672 toDegree: Util.toDegree,
673 mod: Util.mod,
674 clamp: Util.clamp
675};
676
677/***/ }),
678/* 8 */
679/***/ (function(module, __webpack_exports__, __webpack_require__) {
680
681"use strict";
682/* harmony export (immutable) */ __webpack_exports__["c"] = hue;
683/* harmony export (immutable) */ __webpack_exports__["b"] = gamma;
684/* harmony export (immutable) */ __webpack_exports__["a"] = nogamma;
685/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__constant__ = __webpack_require__(36);
686
687
688function linear(a, d) {
689 return function (t) {
690 return a + t * d;
691 };
692}
693
694function exponential(a, b, y) {
695 return a = Math.pow(a, y), b = Math.pow(b, y) - a, y = 1 / y, function (t) {
696 return Math.pow(a + t * b, y);
697 };
698}
699
700function hue(a, b) {
701 var d = b - a;
702 return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
703}
704
705function gamma(y) {
706 return (y = +y) === 1 ? nogamma : function (a, b) {
707 return b - a ? exponential(a, b, y) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
708 };
709}
710
711function nogamma(a, b) {
712 var d = b - a;
713 return d ? linear(a, d) : Object(__WEBPACK_IMPORTED_MODULE_0__constant__["a" /* default */])(isNaN(a) ? b : a);
714}
715
716/***/ }),
717/* 9 */
718/***/ (function(module, exports, __webpack_require__) {
719
720function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
721
722// const Global = require('../global');
723var G = __webpack_require__(28);
724var EventUtil = __webpack_require__(116);
725var DomUtil = G.DomUtil;
726var CommonUtil = G.CommonUtil;
727// const View = require('../chart/view');
728// const G2 = require('../core.js');
729
730var assign = CommonUtil.assign;
731
732var EVENT_TYPES = ['start', 'process', 'end', 'reset'];
733
734var Interaction = function () {
735 Interaction.prototype.getDefaultCfg = function getDefaultCfg() {
736 return {
737 startEvent: 'mousedown',
738 processEvent: 'mousemove',
739 endEvent: 'mouseup',
740 resetEvent: 'dblclick'
741 };
742 };
743
744 Interaction.prototype._start = function _start(ev) {
745 var me = this;
746 me.preStart && me.preStart(ev);
747 me.start(ev);
748 me.onStart && me.onStart(ev);
749 };
750
751 Interaction.prototype._process = function _process(ev) {
752 var me = this;
753 me.preProcess && me.preProcess(ev);
754 me.process(ev);
755 me.onProcess && me.onProcess(ev);
756 };
757
758 Interaction.prototype._end = function _end(ev) {
759 var me = this;
760 me.preEnd && me.preEnd(ev);
761 me.end(ev);
762 me.onEnd && me.onEnd(ev);
763 };
764
765 Interaction.prototype._reset = function _reset(ev) {
766 var me = this;
767 me.preReset && me.preReset(ev);
768 me.reset(ev);
769 me.onReset && me.onReset(ev);
770 };
771
772 Interaction.prototype.start = function start() {
773 // TODO override
774 };
775
776 Interaction.prototype.process = function process() {
777 // TODO override
778 };
779
780 Interaction.prototype.end = function end() {
781 // TODO override
782 };
783
784 Interaction.prototype.reset = function reset() {
785 // TODO override
786 };
787
788 function Interaction(cfg, view) {
789 _classCallCheck(this, Interaction);
790
791 var me = this;
792 var defaultCfg = me.getDefaultCfg();
793 assign(me, defaultCfg, cfg);
794 me.view = view;
795 me.canvas = view.get('canvas');
796 me._bindEvents();
797 }
798
799 Interaction.prototype._bindEvents = function _bindEvents() {
800 var me = this;
801 var canvas = me.canvas;
802 var canvasDOM = canvas.get('canvasDOM');
803 me._clearEvents();
804 CommonUtil.each(EVENT_TYPES, function (type) {
805 var ucType = CommonUtil.upperFirst(type);
806 me['_on' + ucType + 'Listener'] = DomUtil.addEventListener(canvasDOM, me[type + 'Event'], EventUtil.wrapBehavior(me, '_' + type));
807 });
808 };
809
810 Interaction.prototype._clearEvents = function _clearEvents() {
811 var me = this;
812 CommonUtil.each(EVENT_TYPES, function (type) {
813 var listenerName = '_on' + CommonUtil.upperFirst(type) + 'Listener';
814 me[listenerName] && me[listenerName].remove();
815 });
816 };
817
818 Interaction.prototype.destroy = function destroy() {
819 this._clearEvents();
820 };
821
822 return Interaction;
823}();
824
825module.exports = Interaction;
826
827/***/ }),
828/* 10 */
829/***/ (function(module, exports, __webpack_require__) {
830
831/* WEBPACK VAR INJECTION */(function(module) {var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;var _typeof2 = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
832
833(function webpackUniversalModuleDefinition(root, factory) {
834 if (( false ? 'undefined' : _typeof2(exports)) === 'object' && ( false ? 'undefined' : _typeof2(module)) === 'object') module.exports = factory();else if (true) !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
835 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
836 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
837 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));else if ((typeof exports === 'undefined' ? 'undefined' : _typeof2(exports)) === 'object') exports["Util"] = factory();else root["Util"] = factory();
838})(this, function () {
839 return (/******/function (modules) {
840 // webpackBootstrap
841 /******/ // The module cache
842 /******/var installedModules = {};
843 /******/
844 /******/ // The require function
845 /******/function __webpack_require__(moduleId) {
846 /******/
847 /******/ // Check if module is in cache
848 /******/if (installedModules[moduleId]) {
849 /******/return installedModules[moduleId].exports;
850 /******/
851 }
852 /******/ // Create a new module (and put it into the cache)
853 /******/var module = installedModules[moduleId] = {
854 /******/i: moduleId,
855 /******/l: false,
856 /******/exports: {}
857 /******/ };
858 /******/
859 /******/ // Execute the module function
860 /******/modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
861 /******/
862 /******/ // Flag the module as loaded
863 /******/module.l = true;
864 /******/
865 /******/ // Return the exports of the module
866 /******/return module.exports;
867 /******/
868 }
869 /******/
870 /******/
871 /******/ // expose the modules object (__webpack_modules__)
872 /******/__webpack_require__.m = modules;
873 /******/
874 /******/ // expose the module cache
875 /******/__webpack_require__.c = installedModules;
876 /******/
877 /******/ // define getter function for harmony exports
878 /******/__webpack_require__.d = function (exports, name, getter) {
879 /******/if (!__webpack_require__.o(exports, name)) {
880 /******/Object.defineProperty(exports, name, {
881 /******/configurable: false,
882 /******/enumerable: true,
883 /******/get: getter
884 /******/ });
885 /******/
886 }
887 /******/
888 };
889 /******/
890 /******/ // getDefaultExport function for compatibility with non-harmony modules
891 /******/__webpack_require__.n = function (module) {
892 /******/var getter = module && module.__esModule ?
893 /******/function getDefault() {
894 return module['default'];
895 } :
896 /******/function getModuleExports() {
897 return module;
898 };
899 /******/__webpack_require__.d(getter, 'a', getter);
900 /******/return getter;
901 /******/
902 };
903 /******/
904 /******/ // Object.prototype.hasOwnProperty.call
905 /******/__webpack_require__.o = function (object, property) {
906 return Object.prototype.hasOwnProperty.call(object, property);
907 };
908 /******/
909 /******/ // __webpack_public_path__
910 /******/__webpack_require__.p = "";
911 /******/
912 /******/ // Load entry module and return exports
913 /******/return __webpack_require__(__webpack_require__.s = 22);
914 /******/
915 }(
916 /************************************************************************/
917 /******/[
918 /* 0 */
919 /***/function (module, exports, __webpack_require__) {
920
921 var isType = __webpack_require__(3);
922
923 var isArray = Array.isArray ? Array.isArray : function (value) {
924 return isType(value, 'Array');
925 };
926
927 module.exports = isArray;
928
929 /***/
930 },
931 /* 1 */
932 /***/function (module, exports, __webpack_require__) {
933
934 var isObject = __webpack_require__(12);
935 var isArray = __webpack_require__(0);
936
937 var each = function each(elements, func) {
938 if (!elements) {
939 return;
940 }
941 var rst = void 0;
942 if (isArray(elements)) {
943 for (var i = 0, len = elements.length; i < len; i++) {
944 rst = func(elements[i], i);
945 if (rst === false) {
946 break;
947 }
948 }
949 } else if (isObject(elements)) {
950 for (var k in elements) {
951 if (elements.hasOwnProperty(k)) {
952 rst = func(elements[k], k);
953 if (rst === false) {
954 break;
955 }
956 }
957 }
958 }
959 };
960
961 module.exports = each;
962
963 /***/
964 },
965 /* 2 */
966 /***/function (module, exports) {
967
968 var isArrayLike = function isArrayLike(value) {
969 /**
970 * isArrayLike([1, 2, 3]) => true
971 * isArrayLike(document.body.children) => true
972 * isArrayLike('abc') => true
973 * isArrayLike(Function) => false
974 */
975 return value !== null && typeof value !== 'function' && isFinite(value.length);
976 };
977
978 module.exports = isArrayLike;
979
980 /***/
981 },
982 /* 3 */
983 /***/function (module, exports) {
984
985 var toString = {}.toString;
986 var isType = function isType(value, type) {
987 return toString.call(value) === '[object ' + type + ']';
988 };
989
990 module.exports = isType;
991
992 /***/
993 },
994 /* 4 */
995 /***/function (module, exports, __webpack_require__) {
996
997 /**
998 * 判断是否数字
999 * @return {Boolean} 是否数字
1000 */
1001 var isType = __webpack_require__(3);
1002
1003 var isNumber = function isNumber(value) {
1004 return isType(value, 'Number');
1005 };
1006 module.exports = isNumber;
1007
1008 /***/
1009 },
1010 /* 5 */
1011 /***/function (module, exports, __webpack_require__) {
1012
1013 /**
1014 * 是否为函数
1015 * @param {*} fn 对象
1016 * @return {Boolean} 是否函数
1017 */
1018 var isType = __webpack_require__(3);
1019
1020 var isFunction = function isFunction(value) {
1021 return isType(value, 'Function');
1022 };
1023
1024 module.exports = isFunction;
1025
1026 /***/
1027 },
1028 /* 6 */
1029 /***/function (module, exports) {
1030
1031 // isFinite,
1032 var isNil = function isNil(value) {
1033 /**
1034 * isNil(null) => true
1035 * isNil() => true
1036 */
1037 return value === null || value === undefined;
1038 };
1039
1040 module.exports = isNil;
1041
1042 /***/
1043 },
1044 /* 7 */
1045 /***/function (module, exports, __webpack_require__) {
1046
1047 var isObjectLike = __webpack_require__(8);
1048 var isType = __webpack_require__(3);
1049
1050 var isPlainObject = function isPlainObject(value) {
1051 /**
1052 * isObjectLike(new Foo) => false
1053 * isObjectLike([1, 2, 3]) => false
1054 * isObjectLike({ x: 0, y: 0 }) => true
1055 * isObjectLike(Object.create(null)) => true
1056 */
1057 if (!isObjectLike(value) || !isType(value, 'Object')) {
1058 return false;
1059 }
1060 if (Object.getPrototypeOf(value) === null) {
1061 return true;
1062 }
1063 var proto = value;
1064 while (Object.getPrototypeOf(proto) !== null) {
1065 proto = Object.getPrototypeOf(proto);
1066 }
1067 return Object.getPrototypeOf(value) === proto;
1068 };
1069
1070 module.exports = isPlainObject;
1071
1072 /***/
1073 },
1074 /* 8 */
1075 /***/function (module, exports) {
1076
1077 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
1078 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1079 } : function (obj) {
1080 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1081 };
1082
1083 var isObjectLike = function isObjectLike(value) {
1084 /**
1085 * isObjectLike({}) => true
1086 * isObjectLike([1, 2, 3]) => true
1087 * isObjectLike(Function) => false
1088 * isObjectLike(null) => false
1089 */
1090 return (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object' && value !== null;
1091 };
1092
1093 module.exports = isObjectLike;
1094
1095 /***/
1096 },
1097 /* 9 */
1098 /***/function (module, exports, __webpack_require__) {
1099
1100 var isArrayLike = __webpack_require__(2);
1101
1102 function toArray(value) {
1103 return isArrayLike(value) ? Array.prototype.slice.call(value) : [];
1104 }
1105
1106 module.exports = toArray;
1107
1108 /***/
1109 },
1110 /* 10 */
1111 /***/function (module, exports) {
1112
1113 function _mix(dist, obj) {
1114 for (var key in obj) {
1115 if (obj.hasOwnProperty(key) && key !== 'constructor' && obj[key] !== undefined) {
1116 dist[key] = obj[key];
1117 }
1118 }
1119 }
1120
1121 var mix = function mix(dist, src1, src2, src3) {
1122 if (src1) _mix(dist, src1);
1123 if (src2) _mix(dist, src2);
1124 if (src3) _mix(dist, src3);
1125 return dist;
1126 };
1127
1128 module.exports = mix;
1129
1130 /***/
1131 },
1132 /* 11 */
1133 /***/function (module, exports, __webpack_require__) {
1134
1135 var isArrayLike = __webpack_require__(2);
1136
1137 var indexOf = Array.prototype.indexOf;
1138
1139 var contains = function contains(arr, value) {
1140 if (!isArrayLike(arr)) {
1141 return false;
1142 }
1143 return indexOf.call(arr, value) > -1;
1144 };
1145
1146 module.exports = contains;
1147
1148 /***/
1149 },
1150 /* 12 */
1151 /***/function (module, exports) {
1152
1153 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
1154 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1155 } : function (obj) {
1156 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
1157 };
1158
1159 var isObject = function isObject(value) {
1160 /**
1161 * isObject({}) => true
1162 * isObject([1, 2, 3]) => true
1163 * isObject(Function) => true
1164 * isObject(null) => false
1165 */
1166 var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
1167 return value !== null && type === 'object' || type === 'function';
1168 };
1169
1170 module.exports = isObject;
1171
1172 /***/
1173 },
1174 /* 13 */
1175 /***/function (module, exports, __webpack_require__) {
1176
1177 var each = __webpack_require__(1);
1178 var isArrayLike = __webpack_require__(2);
1179
1180 var filter = function filter(arr, func) {
1181 if (!isArrayLike(arr)) {
1182 return arr;
1183 }
1184 var result = [];
1185 each(arr, function (value, index) {
1186 if (func(value, index)) {
1187 result.push(value);
1188 }
1189 });
1190 return result;
1191 };
1192
1193 module.exports = filter;
1194
1195 /***/
1196 },
1197 /* 14 */
1198 /***/function (module, exports, __webpack_require__) {
1199
1200 var isArrayLike = __webpack_require__(2);
1201
1202 var splice = Array.prototype.splice;
1203
1204 var pullAt = function pullAt(arr, indexes) {
1205 if (!isArrayLike(arr)) {
1206 return [];
1207 }
1208 var length = arr ? indexes.length : 0;
1209 var last = length - 1;
1210
1211 while (length--) {
1212 var previous = void 0;
1213 var index = indexes[length];
1214 if (length === last || index !== previous) {
1215 previous = index;
1216 splice.call(arr, index, 1);
1217 }
1218 }
1219 return arr;
1220 };
1221
1222 module.exports = pullAt;
1223
1224 /***/
1225 },
1226 /* 15 */
1227 /***/function (module, exports) {
1228
1229 module.exports = parseInt;
1230
1231 /***/
1232 },
1233 /* 16 */
1234 /***/function (module, exports) {
1235
1236 var toString = {}.toString;
1237
1238 var getType = function getType(value) {
1239 return toString.call(value).replace(/^\[object /, '').replace(/\]$/, '');
1240 };
1241
1242 module.exports = getType;
1243
1244 /***/
1245 },
1246 /* 17 */
1247 /***/function (module, exports) {
1248
1249 var objectProto = Object.prototype;
1250 var isPrototype = function isPrototype(value) {
1251 var Ctor = value && value.constructor;
1252 var proto = typeof Ctor === 'function' && Ctor.prototype || objectProto;
1253 return value === proto;
1254 };
1255
1256 module.exports = isPrototype;
1257
1258 /***/
1259 },
1260 /* 18 */
1261 /***/function (module, exports, __webpack_require__) {
1262
1263 var isType = __webpack_require__(3);
1264
1265 var isString = function isString(str) {
1266 return isType(str, 'String');
1267 };
1268
1269 module.exports = isString;
1270
1271 /***/
1272 },
1273 /* 19 */
1274 /***/function (module, exports, __webpack_require__) {
1275
1276 var isFunction = __webpack_require__(5);
1277 var isArray = __webpack_require__(0);
1278 var groupBy = __webpack_require__(20);
1279
1280 var groupToMap = function groupToMap(data, condition) {
1281 if (!condition) {
1282 return {
1283 0: data
1284 };
1285 }
1286 if (!isFunction(condition)) {
1287 var paramsCondition = isArray(condition) ? condition : condition.replace(/\s+/g, '').split('*');
1288 condition = function condition(row) {
1289 var unique = '_'; // 避免出现数字作为Key的情况,会进行按照数字的排序
1290 for (var i = 0, l = paramsCondition.length; i < l; i++) {
1291 unique += row[paramsCondition[i]] && row[paramsCondition[i]].toString();
1292 }
1293 return unique;
1294 };
1295 }
1296 var groups = groupBy(data, condition);
1297 return groups;
1298 };
1299
1300 module.exports = groupToMap;
1301
1302 /***/
1303 },
1304 /* 20 */
1305 /***/function (module, exports, __webpack_require__) {
1306
1307 var each = __webpack_require__(1);
1308 var isArray = __webpack_require__(0);
1309 var hasOwnProperty = Object.prototype.hasOwnProperty;
1310 var groupBy = function groupBy(data, condition) {
1311 if (!condition || !isArray(data)) {
1312 return data;
1313 }
1314 var result = {};
1315 var key = null;
1316 each(data, function (item) {
1317 key = condition(item);
1318 if (hasOwnProperty.call(result, key)) {
1319 result[key].push(item);
1320 } else {
1321 result[key] = [item];
1322 }
1323 });
1324 return result;
1325 };
1326
1327 module.exports = groupBy;
1328
1329 /***/
1330 },
1331 /* 21 */
1332 /***/function (module, exports, __webpack_require__) {
1333
1334 var isObjectLike = __webpack_require__(8);
1335 var isArrayLike = __webpack_require__(2);
1336 var isString = __webpack_require__(18);
1337
1338 var isEqual = function isEqual(value, other) {
1339 if (value === other) {
1340 return true;
1341 }
1342 if (!value || !other) {
1343 return false;
1344 }
1345 if (isString(value) || isString(other)) {
1346 return false;
1347 }
1348 if (isArrayLike(value) || isArrayLike(other)) {
1349 if (value.length !== other.length) {
1350 return false;
1351 }
1352 var rst = true;
1353 for (var i = 0; i < value.length; i++) {
1354 rst = isEqual(value[i], other[i]);
1355 if (!rst) {
1356 break;
1357 }
1358 }
1359 return rst;
1360 }
1361 if (isObjectLike(value) || isObjectLike(other)) {
1362 var valueKeys = Object.keys(value);
1363 var otherKeys = Object.keys(other);
1364 if (valueKeys.length !== otherKeys.length) {
1365 return false;
1366 }
1367 var _rst = true;
1368 for (var _i = 0; _i < valueKeys.length; _i++) {
1369 _rst = isEqual(value[valueKeys[_i]], other[valueKeys[_i]]);
1370 if (!_rst) {
1371 break;
1372 }
1373 }
1374 return _rst;
1375 }
1376 return false;
1377 };
1378
1379 module.exports = isEqual;
1380
1381 /***/
1382 },
1383 /* 22 */
1384 /***/function (module, exports, __webpack_require__) {
1385
1386 var arrayUtil = __webpack_require__(23);
1387 var eventUtil = __webpack_require__(34);
1388 var mathUtil = __webpack_require__(37);
1389 var stringUtil = __webpack_require__(52);
1390 var typeUtil = __webpack_require__(53);
1391 var each = __webpack_require__(1);
1392 var mix = __webpack_require__(10);
1393
1394 var util = {
1395 // collections
1396 arrayUtil: arrayUtil,
1397 eventUtil: eventUtil,
1398 mathUtil: mathUtil,
1399 stringUtil: stringUtil,
1400 typeUtil: typeUtil,
1401 // others
1402 augment: __webpack_require__(58),
1403 clone: __webpack_require__(59),
1404 deepMix: __webpack_require__(60),
1405 each: each,
1406 extend: __webpack_require__(61),
1407 filter: __webpack_require__(13),
1408 group: __webpack_require__(62),
1409 groupBy: __webpack_require__(20),
1410 groupToMap: __webpack_require__(19),
1411 indexOf: __webpack_require__(63),
1412 isEmpty: __webpack_require__(64),
1413 isEqual: __webpack_require__(21),
1414 isEqualWith: __webpack_require__(65),
1415 map: __webpack_require__(66),
1416 mix: mix,
1417 pick: __webpack_require__(67),
1418 toArray: __webpack_require__(9),
1419 uniqueId: __webpack_require__(68)
1420 };
1421
1422 each([arrayUtil, eventUtil, mathUtil, stringUtil, typeUtil], function (collection) {
1423 mix(util, collection);
1424 });
1425
1426 module.exports = util;
1427
1428 /***/
1429 },
1430 /* 23 */
1431 /***/function (module, exports, __webpack_require__) {
1432
1433 module.exports = {
1434 contains: __webpack_require__(11),
1435 firstValue: __webpack_require__(24),
1436 flatten: __webpack_require__(25),
1437 getRange: __webpack_require__(26),
1438 merge: __webpack_require__(27),
1439 pull: __webpack_require__(28),
1440 pullAt: __webpack_require__(14),
1441 reduce: __webpack_require__(29),
1442 remove: __webpack_require__(30),
1443 union: __webpack_require__(31),
1444 uniq: __webpack_require__(32),
1445 values: __webpack_require__(33)
1446 };
1447
1448 /***/
1449 },
1450 /* 24 */
1451 /***/function (module, exports, __webpack_require__) {
1452
1453 var isNil = __webpack_require__(6);
1454 var isArray = __webpack_require__(0);
1455
1456 var firstValue = function firstValue(data, name) {
1457 var rst = null;
1458 for (var i = 0; i < data.length; i++) {
1459 var obj = data[i];
1460 var value = obj[name];
1461 if (!isNil(value)) {
1462 if (isArray(value)) {
1463 rst = value[0];
1464 } else {
1465 rst = value;
1466 }
1467 break;
1468 }
1469 }
1470 return rst;
1471 };
1472
1473 module.exports = firstValue;
1474
1475 /***/
1476 },
1477 /* 25 */
1478 /***/function (module, exports, __webpack_require__) {
1479
1480 var isArray = __webpack_require__(0);
1481 var each = __webpack_require__(1);
1482
1483 /**
1484 * Flattens `array` a single level deep.
1485 *
1486 * @param {Array} arr The array to flatten.
1487 * @return {Array} Returns the new flattened array.
1488 * @example
1489 *
1490 * _.flatten([1, [2, [3, [4]], 5]]); // => [1, 2, [3, [4]], 5]
1491 */
1492 var flatten = function flatten(arr) {
1493 if (!isArray(arr)) {
1494 return arr;
1495 }
1496 var result = [];
1497 each(arr, function (item) {
1498 if (isArray(item)) {
1499 each(item, function (subItem) {
1500 result.push(subItem);
1501 });
1502 } else {
1503 result.push(item);
1504 }
1505 });
1506 return result;
1507 };
1508
1509 module.exports = flatten;
1510
1511 /***/
1512 },
1513 /* 26 */
1514 /***/function (module, exports, __webpack_require__) {
1515
1516 var filter = __webpack_require__(13);
1517 var isArray = __webpack_require__(0);
1518
1519 var getRange = function getRange(values) {
1520 // 存在 NaN 时,min,max 判定会出问题
1521 values = filter(values, function (v) {
1522 return !isNaN(v);
1523 });
1524 if (!values.length) {
1525 // 如果没有数值则直接返回0
1526 return {
1527 min: 0,
1528 max: 0
1529 };
1530 }
1531 if (isArray(values[0])) {
1532 var tmp = [];
1533 for (var i = 0; i < values.length; i++) {
1534 tmp = tmp.concat(values[i]);
1535 }
1536 values = tmp;
1537 }
1538 var max = Math.max.apply(null, values);
1539 var min = Math.min.apply(null, values);
1540 return {
1541 min: min,
1542 max: max
1543 };
1544 };
1545
1546 module.exports = getRange;
1547
1548 /***/
1549 },
1550 /* 27 */
1551 /***/function (module, exports) {
1552
1553 var merge = function merge(dataArray) {
1554 var rst = [];
1555 for (var i = 0; i < dataArray.length; i++) {
1556 rst = rst.concat(dataArray[i]);
1557 }
1558 return rst;
1559 };
1560
1561 module.exports = merge;
1562
1563 /***/
1564 },
1565 /* 28 */
1566 /***/function (module, exports) {
1567
1568 var arrPrototype = Array.prototype;
1569 var splice = arrPrototype.splice;
1570 var indexOf = arrPrototype.indexOf;
1571 var slice = arrPrototype.slice;
1572
1573 var pull = function pull(arr) {
1574 var values = slice.call(arguments, 1);
1575 for (var i = 0; i < values.length; i++) {
1576 var value = values[i];
1577 var fromIndex = -1;
1578 while ((fromIndex = indexOf.call(arr, value)) > -1) {
1579 splice.call(arr, fromIndex, 1);
1580 }
1581 }
1582 return arr;
1583 };
1584
1585 module.exports = pull;
1586
1587 /***/
1588 },
1589 /* 29 */
1590 /***/function (module, exports, __webpack_require__) {
1591
1592 var isArray = __webpack_require__(0);
1593 var isPlainObject = __webpack_require__(7);
1594 var each = __webpack_require__(1);
1595
1596 var reduce = function reduce(arr, fn, init) {
1597 if (!isArray(arr) && !isPlainObject(arr)) {
1598 return arr;
1599 }
1600 var result = init;
1601 each(arr, function (data, i) {
1602 result = fn(result, data, i);
1603 });
1604 return result;
1605 };
1606
1607 module.exports = reduce;
1608
1609 /***/
1610 },
1611 /* 30 */
1612 /***/function (module, exports, __webpack_require__) {
1613
1614 var isArrayLike = __webpack_require__(2);
1615 var pullAt = __webpack_require__(14);
1616
1617 var remove = function remove(arr, predicate) {
1618 /**
1619 * const arr = [1, 2, 3, 4]
1620 * const evens = remove(arr, n => n % 2 == 0)
1621 * console.log(arr) // => [1, 3]
1622 * console.log(evens) // => [2, 4]
1623 */
1624 var result = [];
1625 if (!isArrayLike(arr)) {
1626 return result;
1627 }
1628 var i = -1;
1629 var indexes = [];
1630 var length = arr.length;
1631
1632 while (++i < length) {
1633 var value = arr[i];
1634 if (predicate(value, i, arr)) {
1635 result.push(value);
1636 indexes.push(i);
1637 }
1638 }
1639 pullAt(arr, indexes);
1640 return result;
1641 };
1642
1643 module.exports = remove;
1644
1645 /***/
1646 },
1647 /* 31 */
1648 /***/function (module, exports, __webpack_require__) {
1649
1650 var each = __webpack_require__(1);
1651 var toArray = __webpack_require__(9);
1652
1653 var union = function union() {
1654 var result = new Set();
1655 var values = [];
1656 each(arguments, function (arg) {
1657 values = toArray(arg);
1658 each(values, function (val) {
1659 result.add(val);
1660 });
1661 });
1662 return Array.from(result);
1663 };
1664
1665 module.exports = union;
1666
1667 /***/
1668 },
1669 /* 32 */
1670 /***/function (module, exports, __webpack_require__) {
1671
1672 var contains = __webpack_require__(11);
1673
1674 var uniq = function uniq(arr) {
1675 var resultArr = [];
1676 arr.forEach(function (item) {
1677 if (!contains(resultArr, item)) {
1678 resultArr.push(item);
1679 }
1680 });
1681 return resultArr;
1682 };
1683
1684 module.exports = uniq;
1685
1686 /***/
1687 },
1688 /* 33 */
1689 /***/function (module, exports, __webpack_require__) {
1690
1691 var each = __webpack_require__(1);
1692 var isNil = __webpack_require__(6);
1693 var isArray = __webpack_require__(0);
1694
1695 var values = function values(data, name) {
1696 var rst = [];
1697 var tmpMap = {};
1698 for (var i = 0; i < data.length; i++) {
1699 var obj = data[i];
1700 var value = obj[name];
1701 if (!isNil(value)) {
1702 if (!isArray(value)) {
1703 value = [value];
1704 }
1705 each(value, function (val) {
1706 if (!tmpMap[val]) {
1707 rst.push(val);
1708 tmpMap[val] = true;
1709 }
1710 });
1711 }
1712 }
1713 return rst;
1714 };
1715
1716 module.exports = values;
1717
1718 /***/
1719 },
1720 /* 34 */
1721 /***/function (module, exports, __webpack_require__) {
1722
1723 module.exports = {
1724 getWrapBehavior: __webpack_require__(35),
1725 wrapBehavior: __webpack_require__(36)
1726 };
1727
1728 /***/
1729 },
1730 /* 35 */
1731 /***/function (module, exports) {
1732
1733 /**
1734 * 获取封装的事件
1735 * @protected
1736 * @param {Object} obj 对象
1737 * @param {String} action 事件名称
1738 * @return {Function} 返回事件处理函数
1739 */
1740 function getWrapBehavior(obj, action) {
1741 return obj['_wrap_' + action];
1742 }
1743
1744 module.exports = getWrapBehavior;
1745
1746 /***/
1747 },
1748 /* 36 */
1749 /***/function (module, exports) {
1750
1751 /**
1752 * 封装事件,便于使用上下文this,和便于解除事件时使用
1753 * @protected
1754 * @param {Object} obj 对象
1755 * @param {String} action 事件名称
1756 * @return {Function} 返回事件处理函数
1757 */
1758 function wrapBehavior(obj, action) {
1759 if (obj['_wrap_' + action]) {
1760 return obj['_wrap_' + action];
1761 }
1762 var method = function method(e) {
1763 obj[action](e);
1764 };
1765 obj['_wrap_' + action] = method;
1766 return method;
1767 }
1768
1769 module.exports = wrapBehavior;
1770
1771 /***/
1772 },
1773 /* 37 */
1774 /***/function (module, exports, __webpack_require__) {
1775
1776 module.exports = {
1777 clamp: __webpack_require__(38),
1778 fixedBase: __webpack_require__(39),
1779 isDecimal: __webpack_require__(40),
1780 isEven: __webpack_require__(41),
1781 isInteger: __webpack_require__(42),
1782 isNegative: __webpack_require__(43),
1783 isNumberEqual: __webpack_require__(44),
1784 isOdd: __webpack_require__(45),
1785 isPositive: __webpack_require__(46),
1786 maxBy: __webpack_require__(47),
1787 minBy: __webpack_require__(48),
1788 mod: __webpack_require__(49),
1789 toDegree: __webpack_require__(50),
1790 toInt: __webpack_require__(15),
1791 toInteger: __webpack_require__(15),
1792 toRadian: __webpack_require__(51)
1793 };
1794
1795 /***/
1796 },
1797 /* 38 */
1798 /***/function (module, exports) {
1799
1800 var clamp = function clamp(a, min, max) {
1801 if (a < min) {
1802 return min;
1803 } else if (a > max) {
1804 return max;
1805 }
1806 return a;
1807 };
1808
1809 module.exports = clamp;
1810
1811 /***/
1812 },
1813 /* 39 */
1814 /***/function (module, exports) {
1815
1816 var fixedBase = function fixedBase(v, base) {
1817 var str = base.toString();
1818 var index = str.indexOf('.');
1819 if (index === -1) {
1820 return Math.round(v);
1821 }
1822 var length = str.substr(index + 1).length;
1823 if (length > 20) {
1824 length = 20;
1825 }
1826 return parseFloat(v.toFixed(length));
1827 };
1828
1829 module.exports = fixedBase;
1830
1831 /***/
1832 },
1833 /* 40 */
1834 /***/function (module, exports, __webpack_require__) {
1835
1836 var isNumber = __webpack_require__(4);
1837
1838 var isDecimal = function isDecimal(num) {
1839 return isNumber(num) && num % 1 !== 0;
1840 };
1841
1842 module.exports = isDecimal;
1843
1844 /***/
1845 },
1846 /* 41 */
1847 /***/function (module, exports, __webpack_require__) {
1848
1849 var isNumber = __webpack_require__(4);
1850
1851 var isEven = function isEven(num) {
1852 return isNumber(num) && num % 2 === 0;
1853 };
1854
1855 module.exports = isEven;
1856
1857 /***/
1858 },
1859 /* 42 */
1860 /***/function (module, exports, __webpack_require__) {
1861
1862 var isNumber = __webpack_require__(4);
1863
1864 var isInteger = Number.isInteger ? Number.isInteger : function (num) {
1865 return isNumber(num) && num % 1 === 0;
1866 };
1867
1868 module.exports = isInteger;
1869
1870 /***/
1871 },
1872 /* 43 */
1873 /***/function (module, exports, __webpack_require__) {
1874
1875 var isNumber = __webpack_require__(4);
1876
1877 var isNagative = function isNagative(num) {
1878 return isNumber(num) && num < 0;
1879 };
1880
1881 module.exports = isNagative;
1882
1883 /***/
1884 },
1885 /* 44 */
1886 /***/function (module, exports) {
1887
1888 var PRECISION = 0.00001; // numbers less than this is considered as 0
1889
1890 var isNumberEqual = function isNumberEqual(a, b) {
1891 return Math.abs(a - b) < PRECISION;
1892 };
1893
1894 module.exports = isNumberEqual;
1895
1896 /***/
1897 },
1898 /* 45 */
1899 /***/function (module, exports, __webpack_require__) {
1900
1901 var isNumber = __webpack_require__(4);
1902
1903 var isOdd = function isOdd(num) {
1904 return isNumber(num) && num % 2 !== 0;
1905 };
1906
1907 module.exports = isOdd;
1908
1909 /***/
1910 },
1911 /* 46 */
1912 /***/function (module, exports, __webpack_require__) {
1913
1914 var isNumber = __webpack_require__(4);
1915
1916 var isPositive = function isPositive(num) {
1917 return isNumber(num) && num > 0;
1918 };
1919
1920 module.exports = isPositive;
1921
1922 /***/
1923 },
1924 /* 47 */
1925 /***/function (module, exports, __webpack_require__) {
1926
1927 var isArray = __webpack_require__(0);
1928 var isFunction = __webpack_require__(5);
1929 var each = __webpack_require__(1);
1930 /**
1931 * @param {Array} arr The array to iterate over.
1932 * @param {Function} [fn] The iteratee invoked per element.
1933 * @return {*} Returns the maximum value.
1934 * @example
1935 *
1936 * var objects = [{ 'n': 1 }, { 'n': 2 }];
1937 *
1938 * maxBy(objects, function(o) { return o.n; });
1939 * // => { 'n': 2 }
1940 *
1941 * maxBy(objects, 'n');
1942 * // => { 'n': 2 }
1943 */
1944 var maxBy = function maxBy(arr, fn) {
1945 if (!isArray(arr)) {
1946 return undefined;
1947 }
1948 var max = arr[0];
1949 var maxData = void 0;
1950 if (isFunction(fn)) {
1951 maxData = fn(arr[0]);
1952 } else {
1953 maxData = arr[0][fn];
1954 }
1955 var data = void 0;
1956 each(arr, function (val) {
1957 if (isFunction(fn)) {
1958 data = fn(val);
1959 } else {
1960 data = val[fn];
1961 }
1962 if (data > maxData) {
1963 max = val;
1964 maxData = data;
1965 }
1966 });
1967 return max;
1968 };
1969
1970 module.exports = maxBy;
1971
1972 /***/
1973 },
1974 /* 48 */
1975 /***/function (module, exports, __webpack_require__) {
1976
1977 var isArray = __webpack_require__(0);
1978 var isFunction = __webpack_require__(5);
1979 var each = __webpack_require__(1);
1980 /**
1981 * @param {Array} arr The array to iterate over.
1982 * @param {Function} [fn] The iteratee invoked per element.
1983 * @return {*} Returns the minimum value.
1984 * @example
1985 *
1986 * var objects = [{ 'n': 1 }, { 'n': 2 }];
1987 *
1988 * minBy(objects, function(o) { return o.n; });
1989 * // => { 'n': 1 }
1990 *
1991 * minBy(objects, 'n');
1992 * // => { 'n': 1 }
1993 */
1994 var minBy = function minBy(arr, fn) {
1995 if (!isArray(arr)) {
1996 return undefined;
1997 }
1998 var min = arr[0];
1999 var minData = void 0;
2000 if (isFunction(fn)) {
2001 minData = fn(arr[0]);
2002 } else {
2003 minData = arr[0][fn];
2004 }
2005 var data = void 0;
2006 each(arr, function (val) {
2007 if (isFunction(fn)) {
2008 data = fn(val);
2009 } else {
2010 data = val[fn];
2011 }
2012 if (data < minData) {
2013 min = val;
2014 minData = data;
2015 }
2016 });
2017 return min;
2018 };
2019
2020 module.exports = minBy;
2021
2022 /***/
2023 },
2024 /* 49 */
2025 /***/function (module, exports) {
2026
2027 var mod = function mod(n, m) {
2028 return (n % m + m) % m;
2029 };
2030
2031 module.exports = mod;
2032
2033 /***/
2034 },
2035 /* 50 */
2036 /***/function (module, exports) {
2037
2038 var DEGREE = 180 / Math.PI;
2039
2040 var toDegree = function toDegree(radian) {
2041 return DEGREE * radian;
2042 };
2043
2044 module.exports = toDegree;
2045
2046 /***/
2047 },
2048 /* 51 */
2049 /***/function (module, exports) {
2050
2051 var RADIAN = Math.PI / 180;
2052
2053 var toRadian = function toRadian(degree) {
2054 return RADIAN * degree;
2055 };
2056
2057 module.exports = toRadian;
2058
2059 /***/
2060 },
2061 /* 52 */
2062 /***/function (module, exports) {
2063
2064 function toString(value) {
2065 return value.toString();
2066 }
2067
2068 function upperCase(value) {
2069 return toString(value).toUpperCase();
2070 }
2071
2072 function lowerCase(value) {
2073 return toString(value).toLowerCase();
2074 }
2075
2076 var strUtil = {
2077 lc: lowerCase,
2078 lowerCase: lowerCase,
2079 lowerFirst: function lowerFirst(value) {
2080 value = toString(value);
2081 return lowerCase(value.charAt(0)) + value.substring(1);
2082 },
2083
2084 uc: upperCase,
2085 upperCase: upperCase,
2086 upperFirst: function upperFirst(value) {
2087 value = toString(value);
2088 return upperCase(value.charAt(0)) + value.substring(1);
2089 }
2090 };
2091
2092 module.exports = strUtil;
2093
2094 /***/
2095 },
2096 /* 53 */
2097 /***/function (module, exports, __webpack_require__) {
2098
2099 var isType = __webpack_require__(3);
2100
2101 var checkType = {
2102 getType: __webpack_require__(16),
2103 isArray: __webpack_require__(0),
2104 isArrayLike: __webpack_require__(2),
2105 isBoolean: __webpack_require__(54),
2106 isFunction: __webpack_require__(5),
2107 isNil: __webpack_require__(6),
2108 isNull: __webpack_require__(55),
2109 isNumber: __webpack_require__(4),
2110 isObject: __webpack_require__(12),
2111 isObjectLike: __webpack_require__(8),
2112 isPlainObject: __webpack_require__(7),
2113 isPrototype: __webpack_require__(17),
2114 isType: isType,
2115 isUndefined: __webpack_require__(56),
2116 isString: __webpack_require__(18),
2117 isRegExp: __webpack_require__(57)
2118 };
2119
2120 ['Arguments', 'Date', 'Error'].forEach(function (type) {
2121 checkType['is' + type] = function (value) {
2122 return isType(value, type);
2123 };
2124 });
2125
2126 module.exports = checkType;
2127
2128 /***/
2129 },
2130 /* 54 */
2131 /***/function (module, exports, __webpack_require__) {
2132
2133 /**
2134 * 是否是布尔类型
2135 *
2136 * @param {Object} value 测试的值
2137 * @return {Boolean}
2138 */
2139 var isType = __webpack_require__(3);
2140
2141 var isBoolean = function isBoolean(value) {
2142 return isType(value, 'Boolean');
2143 };
2144
2145 module.exports = isBoolean;
2146
2147 /***/
2148 },
2149 /* 55 */
2150 /***/function (module, exports) {
2151
2152 var isNull = function isNull(value) {
2153 return value === null;
2154 };
2155
2156 module.exports = isNull;
2157
2158 /***/
2159 },
2160 /* 56 */
2161 /***/function (module, exports) {
2162
2163 var isUndefined = function isUndefined(value) {
2164 return value === undefined;
2165 };
2166
2167 module.exports = isUndefined;
2168
2169 /***/
2170 },
2171 /* 57 */
2172 /***/function (module, exports, __webpack_require__) {
2173
2174 var isType = __webpack_require__(3);
2175
2176 var isRegExp = function isRegExp(str) {
2177 return isType(str, 'RegExp');
2178 };
2179
2180 module.exports = isRegExp;
2181
2182 /***/
2183 },
2184 /* 58 */
2185 /***/function (module, exports, __webpack_require__) {
2186
2187 var isFunction = __webpack_require__(5);
2188 var toArray = __webpack_require__(9);
2189 var mix = __webpack_require__(10);
2190
2191 var augment = function augment(c) {
2192 var args = toArray(arguments);
2193 for (var i = 1; i < args.length; i++) {
2194 var obj = args[i];
2195 if (isFunction(obj)) {
2196 obj = obj.prototype;
2197 }
2198 mix(c.prototype, obj);
2199 }
2200 };
2201
2202 module.exports = augment;
2203
2204 /***/
2205 },
2206 /* 59 */
2207 /***/function (module, exports, __webpack_require__) {
2208
2209 var _typeof = typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol" ? function (obj) {
2210 return typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
2211 } : function (obj) {
2212 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj === 'undefined' ? 'undefined' : _typeof2(obj);
2213 };
2214
2215 var isArray = __webpack_require__(0);
2216
2217 var clone = function clone(obj) {
2218 if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object' || obj === null) {
2219 return obj;
2220 }
2221 var rst = void 0;
2222 if (isArray(obj)) {
2223 rst = [];
2224 for (var i = 0, l = obj.length; i < l; i++) {
2225 if (_typeof(obj[i]) === 'object' && obj[i] != null) {
2226 rst[i] = clone(obj[i]);
2227 } else {
2228 rst[i] = obj[i];
2229 }
2230 }
2231 } else {
2232 rst = {};
2233 for (var k in obj) {
2234 if (_typeof(obj[k]) === 'object' && obj[k] != null) {
2235 rst[k] = clone(obj[k]);
2236 } else {
2237 rst[k] = obj[k];
2238 }
2239 }
2240 }
2241
2242 return rst;
2243 };
2244
2245 module.exports = clone;
2246
2247 /***/
2248 },
2249 /* 60 */
2250 /***/function (module, exports, __webpack_require__) {
2251
2252 var isPlainObject = __webpack_require__(7);
2253 var isArray = __webpack_require__(0);
2254
2255 var MAX_MIX_LEVEL = 5;
2256
2257 function _deepMix(dist, src, level, maxLevel) {
2258 level = level || 0;
2259 maxLevel = maxLevel || MAX_MIX_LEVEL;
2260 for (var key in src) {
2261 if (src.hasOwnProperty(key)) {
2262 var value = src[key];
2263 if (value !== null && isPlainObject(value)) {
2264 if (!isPlainObject(dist[key])) {
2265 dist[key] = {};
2266 }
2267 if (level < maxLevel) {
2268 _deepMix(dist[key], value, level + 1, maxLevel);
2269 } else {
2270 dist[key] = src[key];
2271 }
2272 } else if (isArray(value)) {
2273 dist[key] = [];
2274 dist[key] = dist[key].concat(value);
2275 } else if (value !== undefined) {
2276 dist[key] = value;
2277 }
2278 }
2279 }
2280 }
2281
2282 var deepMix = function deepMix() {
2283 var args = new Array(arguments.length);
2284 var length = args.length;
2285 for (var i = 0; i < length; i++) {
2286 args[i] = arguments[i];
2287 }
2288 var rst = args[0];
2289 for (var _i = 1; _i < length; _i++) {
2290 _deepMix(rst, args[_i]);
2291 }
2292 return rst;
2293 };
2294
2295 module.exports = deepMix;
2296
2297 /***/
2298 },
2299 /* 61 */
2300 /***/function (module, exports, __webpack_require__) {
2301
2302 var isFunction = __webpack_require__(5);
2303 var mix = __webpack_require__(10);
2304
2305 var extend = function extend(subclass, superclass, overrides, staticOverrides) {
2306 // 如果只提供父类构造函数,则自动生成子类构造函数
2307 if (!isFunction(superclass)) {
2308 overrides = superclass;
2309 superclass = subclass;
2310 subclass = function subclass() {};
2311 }
2312
2313 var create = Object.create ? function (proto, c) {
2314 return Object.create(proto, {
2315 constructor: {
2316 value: c
2317 }
2318 });
2319 } : function (proto, c) {
2320 function Tmp() {}
2321 Tmp.prototype = proto;
2322 var o = new Tmp();
2323 o.constructor = c;
2324 return o;
2325 };
2326
2327 var superObj = create(superclass.prototype, subclass); // new superclass(),//实例化父类作为子类的prototype
2328 subclass.prototype = mix(superObj, subclass.prototype); // 指定子类的prototype
2329 subclass.superclass = create(superclass.prototype, superclass);
2330 mix(superObj, overrides);
2331 mix(subclass, staticOverrides);
2332 return subclass;
2333 };
2334
2335 module.exports = extend;
2336
2337 /***/
2338 },
2339 /* 62 */
2340 /***/function (module, exports, __webpack_require__) {
2341
2342 var groupToMap = __webpack_require__(19);
2343
2344 var group = function group(data, condition) {
2345 if (!condition) {
2346 return [data];
2347 }
2348 var groups = groupToMap(data, condition);
2349 var array = [];
2350 for (var i in groups) {
2351 array.push(groups[i]);
2352 }
2353 return array;
2354 };
2355
2356 module.exports = group;
2357
2358 /***/
2359 },
2360 /* 63 */
2361 /***/function (module, exports, __webpack_require__) {
2362
2363 var isArrayLike = __webpack_require__(2);
2364
2365 var indexOf = function indexOf(arr, obj) {
2366 if (!isArrayLike(arr)) {
2367 return -1;
2368 }
2369 var m = Array.prototype.indexOf;
2370 if (m) {
2371 return m.call(arr, obj);
2372 }
2373 var index = -1;
2374
2375 for (var i = 0; i < arr.length; i++) {
2376 if (arr[i] === obj) {
2377 index = i;
2378 break;
2379 }
2380 }
2381 return index;
2382 };
2383
2384 module.exports = indexOf;
2385
2386 /***/
2387 },
2388 /* 64 */
2389 /***/function (module, exports, __webpack_require__) {
2390
2391 var isNil = __webpack_require__(6);
2392 var isArrayLike = __webpack_require__(2);
2393 var getType = __webpack_require__(16);
2394 var isPrototype = __webpack_require__(17);
2395 var hasOwnProperty = Object.prototype.hasOwnProperty;
2396
2397 function isEmpty(value) {
2398 /**
2399 * isEmpty(null) => true
2400 * isEmpty() => true
2401 * isEmpty(true) => true
2402 * isEmpty(1) => true
2403 * isEmpty([1, 2, 3]) => false
2404 * isEmpty('abc') => false
2405 * isEmpty({ a: 1 }) => false
2406 */
2407 if (isNil(value)) {
2408 return true;
2409 }
2410 if (isArrayLike(value)) {
2411 return !value.length;
2412 }
2413 var type = getType(value);
2414 if (type === 'Map' || type === 'Set') {
2415 return !value.size;
2416 }
2417 if (isPrototype(value)) {
2418 return !Object.keys(value).length;
2419 }
2420 for (var key in value) {
2421 if (hasOwnProperty.call(value, key)) {
2422 return false;
2423 }
2424 }
2425 return true;
2426 }
2427
2428 module.exports = isEmpty;
2429
2430 /***/
2431 },
2432 /* 65 */
2433 /***/function (module, exports, __webpack_require__) {
2434
2435 var isFunction = __webpack_require__(5);
2436 var isEqual = __webpack_require__(21);
2437 /**
2438 * @param {*} value The value to compare.
2439 * @param {*} other The other value to compare.
2440 * @param {Function} [fn] The function to customize comparisons.
2441 * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
2442 * @example
2443 *
2444 * function isGreeting(value) {
2445 * return /^h(?:i|ello)$/.test(value);
2446 * }
2447 *
2448 * function customizer(objValue, othValue) {
2449 * if (isGreeting(objValue) && isGreeting(othValue)) {
2450 * return true;
2451 * }
2452 * }
2453 *
2454 * var array = ['hello', 'goodbye'];
2455 * var other = ['hi', 'goodbye'];
2456 *
2457 * _.isEqualWith(array, other, customizer); // => true
2458 */
2459
2460 var isEqualWith = function isEqualWith(value, other, fn) {
2461 if (!isFunction(fn)) {
2462 return isEqual(value, other);
2463 }
2464 return !!fn(value, other);
2465 };
2466
2467 module.exports = isEqualWith;
2468
2469 /***/
2470 },
2471 /* 66 */
2472 /***/function (module, exports, __webpack_require__) {
2473
2474 var each = __webpack_require__(1);
2475 var isArrayLike = __webpack_require__(2);
2476
2477 var map = function map(arr, func) {
2478 if (!isArrayLike(arr)) {
2479 return arr;
2480 }
2481 var result = [];
2482 each(arr, function (value, index) {
2483 result.push(func(value, index));
2484 });
2485 return result;
2486 };
2487
2488 module.exports = map;
2489
2490 /***/
2491 },
2492 /* 67 */
2493 /***/function (module, exports, __webpack_require__) {
2494
2495 var each = __webpack_require__(1);
2496 var isPlaineObject = __webpack_require__(7);
2497
2498 var hasOwnProperty = Object.prototype.hasOwnProperty;
2499 /**
2500 * Creates an object composed of the picked `object` properties.
2501 *
2502 * @param {Object} object The source object.
2503 * @param {...(string|string[])} [paths] The property paths to pick.
2504 * @returns {Object} Returns the new object.
2505 * @example
2506 *
2507 * var object = { 'a': 1, 'b': '2', 'c': 3 };
2508 * pick(object, ['a', 'c']); // => { 'a': 1, 'c': 3 }
2509 */
2510
2511 var pick = function pick(object, keys) {
2512 if (object === null || !isPlaineObject(object)) {
2513 return {};
2514 }
2515 var result = {};
2516 each(keys, function (key) {
2517 if (hasOwnProperty.call(object, key)) {
2518 result[key] = object[key];
2519 }
2520 });
2521 return result;
2522 };
2523
2524 module.exports = pick;
2525
2526 /***/
2527 },
2528 /* 68 */
2529 /***/function (module, exports) {
2530
2531 var uniqueId = function () {
2532 var map = {};
2533 return function (prefix) {
2534 prefix = prefix || 'g';
2535 if (!map[prefix]) {
2536 map[prefix] = 1;
2537 } else {
2538 map[prefix] += 1;
2539 }
2540 return prefix + map[prefix];
2541 };
2542 }();
2543
2544 module.exports = uniqueId;
2545
2546 /***/
2547 }]
2548 /******/)
2549 );
2550});
2551/* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(71)(module)))
2552
2553/***/ }),
2554/* 11 */
2555/***/ (function(module, __webpack_exports__, __webpack_require__) {
2556
2557"use strict";
2558/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
2559 return a = +a, b -= a, function (t) {
2560 return a + b * t;
2561 };
2562});
2563
2564/***/ }),
2565/* 12 */
2566/***/ (function(module, exports, __webpack_require__) {
2567
2568var Util = __webpack_require__(0);
2569var vec2 = __webpack_require__(2).vec2;
2570
2571function cubicAt(p0, p1, p2, p3, t) {
2572 var onet = 1 - t;
2573 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
2574}
2575
2576function cubicDerivativeAt(p0, p1, p2, p3, t) {
2577 var onet = 1 - t;
2578 return 3 * (((p1 - p0) * onet + 2 * (p2 - p1) * t) * onet + (p3 - p2) * t * t);
2579}
2580
2581function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) {
2582 var t = void 0;
2583 var interval = 0.005;
2584 var d = Infinity;
2585 var _t = void 0;
2586 var v1 = void 0;
2587 var d1 = void 0;
2588 var d2 = void 0;
2589 var v2 = void 0;
2590 var prev = void 0;
2591 var next = void 0;
2592 var EPSILON = 0.0001;
2593 var v0 = [x, y];
2594
2595 for (_t = 0; _t < 1; _t += 0.05) {
2596 v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)];
2597
2598 d1 = vec2.squaredDistance(v0, v1);
2599 if (d1 < d) {
2600 t = _t;
2601 d = d1;
2602 }
2603 }
2604 d = Infinity;
2605
2606 for (var i = 0; i < 32; i++) {
2607 if (interval < EPSILON) {
2608 break;
2609 }
2610
2611 prev = t - interval;
2612 next = t + interval;
2613
2614 v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)];
2615
2616 d1 = vec2.squaredDistance(v0, v1);
2617
2618 if (prev >= 0 && d1 < d) {
2619 t = prev;
2620 d = d1;
2621 } else {
2622 v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)];
2623
2624 d2 = vec2.squaredDistance(v0, v2);
2625
2626 if (next <= 1 && d2 < d) {
2627 t = next;
2628 d = d2;
2629 } else {
2630 interval *= 0.5;
2631 }
2632 }
2633 }
2634
2635 if (out) {
2636 out.x = cubicAt(x1, x2, x3, x4, t);
2637 out.y = cubicAt(y1, y2, y3, y4, t);
2638 }
2639
2640 return Math.sqrt(d);
2641}
2642
2643function cubicExtrema(p0, p1, p2, p3) {
2644 var a = 3 * p0 - 9 * p1 + 9 * p2 - 3 * p3;
2645 var b = 6 * p1 - 12 * p2 + 6 * p3;
2646 var c = 3 * p2 - 3 * p3;
2647 var extrema = [];
2648 var t1 = void 0;
2649 var t2 = void 0;
2650 var discSqrt = void 0;
2651
2652 if (Util.isNumberEqual(a, 0)) {
2653 if (!Util.isNumberEqual(b, 0)) {
2654 t1 = -c / b;
2655 if (t1 >= 0 && t1 <= 1) {
2656 extrema.push(t1);
2657 }
2658 }
2659 } else {
2660 var disc = b * b - 4 * a * c;
2661 if (Util.isNumberEqual(disc, 0)) {
2662 extrema.push(-b / (2 * a));
2663 } else if (disc > 0) {
2664 discSqrt = Math.sqrt(disc);
2665 t1 = (-b + discSqrt) / (2 * a);
2666 t2 = (-b - discSqrt) / (2 * a);
2667 if (t1 >= 0 && t1 <= 1) {
2668 extrema.push(t1);
2669 }
2670 if (t2 >= 0 && t2 <= 1) {
2671 extrema.push(t2);
2672 }
2673 }
2674 }
2675 return extrema;
2676}
2677
2678function base3(t, p1, p2, p3, p4) {
2679 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
2680 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
2681 return t * t2 - 3 * p1 + 3 * p2;
2682}
2683
2684function cubiclLen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
2685 if (Util.isNil(z)) {
2686 z = 1;
2687 }
2688 z = z > 1 ? 1 : z < 0 ? 0 : z;
2689 var z2 = z / 2;
2690 var n = 12;
2691 var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
2692 var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
2693 var sum = 0;
2694 for (var i = 0; i < n; i++) {
2695 var ct = z2 * Tvalues[i] + z2;
2696 var xbase = base3(ct, x1, x2, x3, x4);
2697 var ybase = base3(ct, y1, y2, y3, y4);
2698 var comb = xbase * xbase + ybase * ybase;
2699 sum += Cvalues[i] * Math.sqrt(comb);
2700 }
2701 return z2 * sum;
2702}
2703
2704module.exports = {
2705 at: cubicAt,
2706 derivativeAt: cubicDerivativeAt,
2707 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y) {
2708 var rst = {};
2709 cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, rst);
2710 return rst;
2711 },
2712
2713 pointDistance: cubicProjectPoint,
2714 extrema: cubicExtrema,
2715 len: cubiclLen
2716};
2717
2718/***/ }),
2719/* 13 */
2720/***/ (function(module, exports, __webpack_require__) {
2721
2722var Util = __webpack_require__(0);
2723var Attribute = __webpack_require__(72);
2724var Transform = __webpack_require__(73);
2725var Animate = __webpack_require__(32);
2726var EventEmitter = __webpack_require__(41);
2727
2728var Element = function Element(cfg) {
2729 this.__cfg = {
2730 zIndex: 0,
2731 capture: true,
2732 visible: true,
2733 destroyed: false
2734 }; // 配置存放地
2735
2736 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
2737 // 在子元素的init中创建新svg元素,然后设置属性和变换。在这边设置id而不是attr里,是考虑id一旦设置后应不能修改
2738 this.init(cfg ? cfg.id : null); // 类型初始化
2739 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
2740 this.initTransform(); // 初始化变换
2741};
2742
2743Element.CFG = {
2744 /**
2745 * 唯一标示
2746 * @type {Number}
2747 */
2748 id: null,
2749 /**
2750 * Z轴的层叠关系,Z值越大离用户越近
2751 * @type {Number}
2752 */
2753 zIndex: 0,
2754 /**
2755 * Canvas对象
2756 * @type: {Object}
2757 */
2758 canvas: null,
2759 /**
2760 * 父元素指针
2761 * @type {Object}
2762 */
2763 parent: null,
2764 /**
2765 * 用来设置当前对象是否能被捕捉
2766 * true 能
2767 * false 不能
2768 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
2769 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
2770 * @type {Boolean}
2771 **/
2772 capture: true,
2773 /**
2774 * 画布的上下文
2775 * @type {Object}
2776 */
2777 context: null,
2778 /**
2779 * 是否显示
2780 * @type {Boolean}
2781 */
2782 visible: true,
2783 /**
2784 * 是否被销毁
2785 * @type: {Boolean}
2786 */
2787 destroyed: false
2788};
2789
2790Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
2791 init: function init() {
2792 this.setSilent('animable', true);
2793 this.setSilent('animating', false); // 初始时不处于动画状态
2794 },
2795 getParent: function getParent() {
2796 return this.get('parent');
2797 },
2798
2799 /**
2800 * 获取默认的配置信息
2801 * @protected
2802 * @return {Object} 默认的属性
2803 */
2804 getDefaultCfg: function getDefaultCfg() {
2805 return {};
2806 },
2807 set: function set(name, value) {
2808 if (name === 'zIndex') {
2809 this._beforeSetZIndex(value);
2810 }
2811 this.__cfg[name] = value;
2812 return this;
2813 },
2814 setSilent: function setSilent(name, value) {
2815 this.__cfg[name] = value;
2816 },
2817 get: function get(name) {
2818 return this.__cfg[name];
2819 },
2820 draw: function draw() {},
2821 drawInner: function drawInner() {},
2822 show: function show() {
2823 this.set('visible', true);
2824 var el = this.get('el');
2825 if (el) {
2826 el.setAttribute('visibility', 'visible');
2827 }
2828 return this;
2829 },
2830 hide: function hide() {
2831 this.set('visible', false);
2832 var el = this.get('el');
2833 if (el) {
2834 el.setAttribute('visibility', 'hidden');
2835 }
2836 return this;
2837 },
2838 remove: function remove(destroy) {
2839 var el = this.get('el');
2840 if (destroy === undefined) {
2841 destroy = true;
2842 }
2843
2844 if (this.get('parent')) {
2845 var parent = this.get('parent');
2846 var children = parent.get('children');
2847 Util.remove(children, this);
2848 el.parentNode.removeChild(el);
2849 }
2850
2851 if (destroy) {
2852 this.destroy();
2853 }
2854
2855 return this;
2856 },
2857 destroy: function destroy() {
2858 var destroyed = this.get('destroyed');
2859 if (destroyed) {
2860 return;
2861 }
2862 // 如果正在执行动画,清理动画
2863 if (this.get('animating')) {
2864 var timer = this.get('animateTimer');
2865 timer && timer.stop();
2866 }
2867 this.__cfg = {};
2868 this.__attrs = null;
2869 this.removeEvent(); // 移除所有的事件
2870 this.set('destroyed', true);
2871 },
2872 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
2873 this.__cfg.zIndex = zIndex;
2874
2875 if (!Util.isNil(this.get('parent'))) {
2876 this.get('parent').sort();
2877 }
2878 return zIndex;
2879 },
2880 _setAttrs: function _setAttrs(attrs) {
2881 this.attr(attrs);
2882 return attrs;
2883 },
2884 setZIndex: function setZIndex(zIndex) {
2885 this.__cfg.zIndex = zIndex;
2886 return zIndex;
2887 },
2888 clone: function clone() {
2889 return Util.clone(this);
2890 },
2891 getBBox: function getBBox() {
2892 var el = this.get('el');
2893 if (!el) {
2894 return {
2895 minX: 0,
2896 minY: 0,
2897 maxX: 0,
2898 maxY: 0,
2899 width: 0,
2900 height: 0,
2901 x: 0,
2902 y: 0
2903 };
2904 }
2905 var bbox = el.getBBox();
2906 if (!el.parentNode || bbox.width === 0 && bbox.height === 0) {
2907 var node = el.cloneNode();
2908 node.innerHTML = el.innerHTML;
2909 node.setAttribute('visible', 'hidden');
2910 var svg = document.getElementsByTagName('svg')[0];
2911 svg.appendChild(node);
2912 bbox = node.getBBox();
2913 svg.removeChild(node);
2914 }
2915 bbox.minX = bbox.x;
2916 bbox.minY = bbox.y;
2917 bbox.maxX = bbox.x + bbox.width;
2918 bbox.maxY = bbox.y + bbox.height;
2919 return {
2920 minX: bbox.x,
2921 minY: bbox.y,
2922 maxX: bbox.x + bbox.width,
2923 maxY: bbox.y + bbox.height,
2924 width: bbox.width,
2925 height: bbox.height,
2926 x: bbox.x,
2927 y: bbox.y
2928 };
2929 }
2930});
2931
2932module.exports = Element;
2933
2934/***/ }),
2935/* 14 */
2936/***/ (function(module, __webpack_exports__, __webpack_require__) {
2937
2938"use strict";
2939/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return EPSILON; });
2940/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return ARRAY_TYPE; });
2941/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return RANDOM; });
2942/* unused harmony export setMatrixArrayType */
2943/* unused harmony export toRadian */
2944/* unused harmony export equals */
2945/**
2946 * Common utilities
2947 * @module glMatrix
2948 */
2949
2950// Configuration Constants
2951var EPSILON = 0.000001;
2952var ARRAY_TYPE = typeof Float32Array !== 'undefined' ? Float32Array : Array;
2953var RANDOM = Math.random;
2954
2955/**
2956 * Sets the type of array used when creating new vectors and matrices
2957 *
2958 * @param {Type} type Array type, such as Float32Array or Array
2959 */
2960function setMatrixArrayType(type) {
2961 ARRAY_TYPE = type;
2962}
2963
2964var degree = Math.PI / 180;
2965
2966/**
2967 * Convert Degree To Radian
2968 *
2969 * @param {Number} a Angle in Degrees
2970 */
2971function toRadian(a) {
2972 return a * degree;
2973}
2974
2975/**
2976 * Tests whether or not the arguments have approximately the same value, within an absolute
2977 * or relative tolerance of glMatrix.EPSILON (an absolute tolerance is used for values less
2978 * than or equal to 1.0, and a relative tolerance is used for larger values)
2979 *
2980 * @param {Number} a The first number to test.
2981 * @param {Number} b The second number to test.
2982 * @returns {Boolean} True if the numbers are approximately equal, false otherwise.
2983 */
2984function equals(a, b) {
2985 return Math.abs(a - b) <= EPSILON * Math.max(1.0, Math.abs(a), Math.abs(b));
2986}
2987
2988/***/ }),
2989/* 15 */
2990/***/ (function(module, exports, __webpack_require__) {
2991
2992var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2993
2994var Util = __webpack_require__(7);
2995var SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029';
2996var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
2997var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
2998
2999// Parses given path string into an array of arrays of path segments
3000var parsePathString = function parsePathString(pathString) {
3001 if (!pathString) {
3002 return null;
3003 }
3004
3005 if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
3006 return pathString;
3007 }
3008 var paramCounts = {
3009 a: 7,
3010 c: 6,
3011 o: 2,
3012 h: 1,
3013 l: 2,
3014 m: 2,
3015 r: 4,
3016 q: 4,
3017 s: 4,
3018 t: 2,
3019 v: 1,
3020 u: 3,
3021 z: 0
3022 };
3023 var data = [];
3024
3025 String(pathString).replace(PATH_COMMAND, function (a, b, c) {
3026 var params = [];
3027 var name = b.toLowerCase();
3028 c.replace(PATH_VALUES, function (a, b) {
3029 b && params.push(+b);
3030 });
3031 if (name === 'm' && params.length > 2) {
3032 data.push([b].concat(params.splice(0, 2)));
3033 name = 'l';
3034 b = b === 'm' ? 'l' : 'L';
3035 }
3036 if (name === 'o' && params.length === 1) {
3037 data.push([b, params[0]]);
3038 }
3039 if (name === 'r') {
3040 data.push([b].concat(params));
3041 } else {
3042 while (params.length >= paramCounts[name]) {
3043 data.push([b].concat(params.splice(0, paramCounts[name])));
3044 if (!paramCounts[name]) {
3045 break;
3046 }
3047 }
3048 }
3049 });
3050
3051 return data;
3052};
3053
3054// http://schepers.cc/getting-to-the-point
3055var catmullRom2bezier = function catmullRom2bezier(crp, z) {
3056 var d = [];
3057 for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {
3058 var p = [{
3059 x: +crp[i - 2],
3060 y: +crp[i - 1]
3061 }, {
3062 x: +crp[i],
3063 y: +crp[i + 1]
3064 }, {
3065 x: +crp[i + 2],
3066 y: +crp[i + 3]
3067 }, {
3068 x: +crp[i + 4],
3069 y: +crp[i + 5]
3070 }];
3071 if (z) {
3072 if (!i) {
3073 p[0] = {
3074 x: +crp[iLen - 2],
3075 y: +crp[iLen - 1]
3076 };
3077 } else if (iLen - 4 === i) {
3078 p[3] = {
3079 x: +crp[0],
3080 y: +crp[1]
3081 };
3082 } else if (iLen - 2 === i) {
3083 p[2] = {
3084 x: +crp[0],
3085 y: +crp[1]
3086 };
3087 p[3] = {
3088 x: +crp[2],
3089 y: +crp[3]
3090 };
3091 }
3092 } else {
3093 if (iLen - 4 === i) {
3094 p[3] = p[2];
3095 } else if (!i) {
3096 p[0] = {
3097 x: +crp[i],
3098 y: +crp[i + 1]
3099 };
3100 }
3101 }
3102 d.push(['C', (-p[0].x + 6 * p[1].x + p[2].x) / 6, (-p[0].y + 6 * p[1].y + p[2].y) / 6, (p[1].x + 6 * p[2].x - p[3].x) / 6, (p[1].y + 6 * p[2].y - p[3].y) / 6, p[2].x, p[2].y]);
3103 }
3104
3105 return d;
3106};
3107
3108var ellipsePath = function ellipsePath(x, y, rx, ry, a) {
3109 var res = [];
3110 if (a === null && ry === null) {
3111 ry = rx;
3112 }
3113 x = +x;
3114 y = +y;
3115 rx = +rx;
3116 ry = +ry;
3117 if (a !== null) {
3118 var rad = Math.PI / 180;
3119 var x1 = x + rx * Math.cos(-ry * rad);
3120 var x2 = x + rx * Math.cos(-a * rad);
3121 var y1 = y + rx * Math.sin(-ry * rad);
3122 var y2 = y + rx * Math.sin(-a * rad);
3123 res = [['M', x1, y1], ['A', rx, rx, 0, +(a - ry > 180), 0, x2, y2]];
3124 } else {
3125 res = [['M', x, y], ['m', 0, -ry], ['a', rx, ry, 0, 1, 1, 0, 2 * ry], ['a', rx, ry, 0, 1, 1, 0, -2 * ry], ['z']];
3126 }
3127 return res;
3128};
3129
3130var pathToAbsolute = function pathToAbsolute(pathArray) {
3131 pathArray = parsePathString(pathArray);
3132
3133 if (!pathArray || !pathArray.length) {
3134 return [['M', 0, 0]];
3135 }
3136 var res = [];
3137 var x = 0;
3138 var y = 0;
3139 var mx = 0;
3140 var my = 0;
3141 var start = 0;
3142 var pa0 = void 0;
3143 var dots = void 0;
3144 if (pathArray[0][0] === 'M') {
3145 x = +pathArray[0][1];
3146 y = +pathArray[0][2];
3147 mx = x;
3148 my = y;
3149 start++;
3150 res[0] = ['M', x, y];
3151 }
3152 var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
3153 for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {
3154 res.push(r = []);
3155 pa = pathArray[i];
3156 pa0 = pa[0];
3157 if (pa0 !== pa0.toUpperCase()) {
3158 r[0] = pa0.toUpperCase();
3159 switch (r[0]) {
3160 case 'A':
3161 r[1] = pa[1];
3162 r[2] = pa[2];
3163 r[3] = pa[3];
3164 r[4] = pa[4];
3165 r[5] = pa[5];
3166 r[6] = +pa[6] + x;
3167 r[7] = +pa[7] + y;
3168 break;
3169 case 'V':
3170 r[1] = +pa[1] + y;
3171 break;
3172 case 'H':
3173 r[1] = +pa[1] + x;
3174 break;
3175 case 'R':
3176 dots = [x, y].concat(pa.slice(1));
3177 for (var j = 2, jj = dots.length; j < jj; j++) {
3178 dots[j] = +dots[j] + x;
3179 dots[++j] = +dots[j] + y;
3180 }
3181 res.pop();
3182 res = res.concat(catmullRom2bezier(dots, crz));
3183 break;
3184 case 'O':
3185 res.pop();
3186 dots = ellipsePath(x, y, pa[1], pa[2]);
3187 dots.push(dots[0]);
3188 res = res.concat(dots);
3189 break;
3190 case 'U':
3191 res.pop();
3192 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
3193 r = ['U'].concat(res[res.length - 1].slice(-2));
3194 break;
3195 case 'M':
3196 mx = +pa[1] + x;
3197 my = +pa[2] + y;
3198 break; // for lint
3199 default:
3200 for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {
3201 r[_j] = +pa[_j] + (_j % 2 ? x : y);
3202 }
3203 }
3204 } else if (pa0 === 'R') {
3205 dots = [x, y].concat(pa.slice(1));
3206 res.pop();
3207 res = res.concat(catmullRom2bezier(dots, crz));
3208 r = ['R'].concat(pa.slice(-2));
3209 } else if (pa0 === 'O') {
3210 res.pop();
3211 dots = ellipsePath(x, y, pa[1], pa[2]);
3212 dots.push(dots[0]);
3213 res = res.concat(dots);
3214 } else if (pa0 === 'U') {
3215 res.pop();
3216 res = res.concat(ellipsePath(x, y, pa[1], pa[2], pa[3]));
3217 r = ['U'].concat(res[res.length - 1].slice(-2));
3218 } else {
3219 for (var k = 0, kk = pa.length; k < kk; k++) {
3220 r[k] = pa[k];
3221 }
3222 }
3223 pa0 = pa0.toUpperCase();
3224 if (pa0 !== 'O') {
3225 switch (r[0]) {
3226 case 'Z':
3227 x = +mx;
3228 y = +my;
3229 break;
3230 case 'H':
3231 x = r[1];
3232 break;
3233 case 'V':
3234 y = r[1];
3235 break;
3236 case 'M':
3237 mx = r[r.length - 2];
3238 my = r[r.length - 1];
3239 break; // for lint
3240 default:
3241 x = r[r.length - 2];
3242 y = r[r.length - 1];
3243 }
3244 }
3245 }
3246
3247 return res;
3248};
3249
3250var l2c = function l2c(x1, y1, x2, y2) {
3251 return [x1, y1, x2, y2, x2, y2];
3252};
3253
3254var q2c = function q2c(x1, y1, ax, ay, x2, y2) {
3255 var _13 = 1 / 3;
3256 var _23 = 2 / 3;
3257 return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];
3258};
3259
3260var a2c = function a2c(x1, y1, rx, ry, angle, large_arc_flag, sweep_flag, x2, y2, recursive) {
3261 // for more information of where this math came from visit:
3262 // http://www.w3.org/TR/SVG11/implnote.html#ArcImplementationNotes
3263 if (rx === ry) {
3264 rx += 1;
3265 }
3266
3267 var _120 = Math.PI * 120 / 180;
3268 var rad = Math.PI / 180 * (+angle || 0);
3269 var res = [];
3270 var xy = void 0;
3271 var f1 = void 0;
3272 var f2 = void 0;
3273 var cx = void 0;
3274 var cy = void 0;
3275 var rotate = function rotate(x, y, rad) {
3276 var X = x * Math.cos(rad) - y * Math.sin(rad);
3277 var Y = x * Math.sin(rad) + y * Math.cos(rad);
3278 return {
3279 x: X,
3280 y: Y
3281 };
3282 };
3283 if (!recursive) {
3284 xy = rotate(x1, y1, -rad);
3285 x1 = xy.x;
3286 y1 = xy.y;
3287 xy = rotate(x2, y2, -rad);
3288 x2 = xy.x;
3289 y2 = xy.y;
3290 if (x1 === x2 && y1 === y2) {
3291 // 若弧的起始点和终点重叠则错开一点
3292 x2 += 1;
3293 y2 += 1;
3294 }
3295 // const cos = Math.cos(Math.PI / 180 * angle);
3296 // const sin = Math.sin(Math.PI / 180 * angle);
3297 var x = (x1 - x2) / 2;
3298 var y = (y1 - y2) / 2;
3299 var h = x * x / (rx * rx) + y * y / (ry * ry);
3300 if (h > 1) {
3301 h = Math.sqrt(h);
3302 rx = h * rx;
3303 ry = h * ry;
3304 }
3305 var rx2 = rx * rx;
3306 var ry2 = ry * ry;
3307 var k = (large_arc_flag === sweep_flag ? -1 : 1) * Math.sqrt(Math.abs((rx2 * ry2 - rx2 * y * y - ry2 * x * x) / (rx2 * y * y + ry2 * x * x)));
3308 cx = k * rx * y / ry + (x1 + x2) / 2;
3309 cy = k * -ry * x / rx + (y1 + y2) / 2;
3310 f1 = Math.asin(((y1 - cy) / ry).toFixed(9));
3311 f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
3312
3313 f1 = x1 < cx ? Math.PI - f1 : f1;
3314 f2 = x2 < cx ? Math.PI - f2 : f2;
3315 f1 < 0 && (f1 = Math.PI * 2 + f1);
3316 f2 < 0 && (f2 = Math.PI * 2 + f2);
3317 if (sweep_flag && f1 > f2) {
3318 f1 = f1 - Math.PI * 2;
3319 }
3320 if (!sweep_flag && f2 > f1) {
3321 f2 = f2 - Math.PI * 2;
3322 }
3323 } else {
3324 f1 = recursive[0];
3325 f2 = recursive[1];
3326 cx = recursive[2];
3327 cy = recursive[3];
3328 }
3329 var df = f2 - f1;
3330 if (Math.abs(df) > _120) {
3331 var f2old = f2;
3332 var x2old = x2;
3333 var y2old = y2;
3334 f2 = f1 + _120 * (sweep_flag && f2 > f1 ? 1 : -1);
3335 x2 = cx + rx * Math.cos(f2);
3336 y2 = cy + ry * Math.sin(f2);
3337 res = a2c(x2, y2, rx, ry, angle, 0, sweep_flag, x2old, y2old, [f2, f2old, cx, cy]);
3338 }
3339 df = f2 - f1;
3340 var c1 = Math.cos(f1);
3341 var s1 = Math.sin(f1);
3342 var c2 = Math.cos(f2);
3343 var s2 = Math.sin(f2);
3344 var t = Math.tan(df / 4);
3345 var hx = 4 / 3 * rx * t;
3346 var hy = 4 / 3 * ry * t;
3347 var m1 = [x1, y1];
3348 var m2 = [x1 + hx * s1, y1 - hy * c1];
3349 var m3 = [x2 + hx * s2, y2 - hy * c2];
3350 var m4 = [x2, y2];
3351 m2[0] = 2 * m1[0] - m2[0];
3352 m2[1] = 2 * m1[1] - m2[1];
3353 if (recursive) {
3354 return [m2, m3, m4].concat(res);
3355 }
3356 res = [m2, m3, m4].concat(res).join().split(',');
3357 var newres = [];
3358 for (var i = 0, ii = res.length; i < ii; i++) {
3359 newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
3360 }
3361 return newres;
3362};
3363
3364var pathTocurve = function pathTocurve(path, path2) {
3365 var p = pathToAbsolute(path);
3366 var p2 = path2 && pathToAbsolute(path2);
3367 var attrs = {
3368 x: 0,
3369 y: 0,
3370 bx: 0,
3371 by: 0,
3372 X: 0,
3373 Y: 0,
3374 qx: null,
3375 qy: null
3376 };
3377 var attrs2 = {
3378 x: 0,
3379 y: 0,
3380 bx: 0,
3381 by: 0,
3382 X: 0,
3383 Y: 0,
3384 qx: null,
3385 qy: null
3386 };
3387 var pcoms1 = []; // path commands of original path p
3388 var pcoms2 = []; // path commands of original path p2
3389 var pfirst = ''; // temporary holder for original path command
3390 var pcom = ''; // holder for previous path command of original path
3391 var ii = void 0;
3392 var processPath = function processPath(path, d, pcom) {
3393 var nx = void 0,
3394 ny = void 0;
3395 if (!path) {
3396 return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
3397 }!(path[0] in {
3398 T: 1,
3399 Q: 1
3400 }) && (d.qx = d.qy = null);
3401 switch (path[0]) {
3402 case 'M':
3403 d.X = path[1];
3404 d.Y = path[2];
3405 break;
3406 case 'A':
3407 path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
3408 break;
3409 case 'S':
3410 if (pcom === 'C' || pcom === 'S') {
3411 // In "S" case we have to take into account, if the previous command is C/S.
3412 nx = d.x * 2 - d.bx; // And reflect the previous
3413 ny = d.y * 2 - d.by; // command's control point relative to the current point.
3414 } else {
3415 // or some else or nothing
3416 nx = d.x;
3417 ny = d.y;
3418 }
3419 path = ['C', nx, ny].concat(path.slice(1));
3420 break;
3421 case 'T':
3422 if (pcom === 'Q' || pcom === 'T') {
3423 // In "T" case we have to take into account, if the previous command is Q/T.
3424 d.qx = d.x * 2 - d.qx; // And make a reflection similar
3425 d.qy = d.y * 2 - d.qy; // to case "S".
3426 } else {
3427 // or something else or nothing
3428 d.qx = d.x;
3429 d.qy = d.y;
3430 }
3431 path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
3432 break;
3433 case 'Q':
3434 d.qx = path[1];
3435 d.qy = path[2];
3436 path = ['C'].concat(q2c(d.x, d.y, path[1], path[2], path[3], path[4]));
3437 break;
3438 case 'L':
3439 path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
3440 break;
3441 case 'H':
3442 path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
3443 break;
3444 case 'V':
3445 path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
3446 break;
3447 case 'Z':
3448 path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
3449 break;
3450 default:
3451 break;
3452 }
3453 return path;
3454 };
3455 var fixArc = function fixArc(pp, i) {
3456 if (pp[i].length > 7) {
3457 pp[i].shift();
3458 var pi = pp[i];
3459 while (pi.length) {
3460 pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
3461 p2 && (pcoms2[i] = 'A'); // the same as above
3462 pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
3463 }
3464 pp.splice(i, 1);
3465 ii = Math.max(p.length, p2 && p2.length || 0);
3466 }
3467 };
3468 var fixM = function fixM(path1, path2, a1, a2, i) {
3469 if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {
3470 path2.splice(i, 0, ['M', a2.x, a2.y]);
3471 a1.bx = 0;
3472 a1.by = 0;
3473 a1.x = path1[i][1];
3474 a1.y = path1[i][2];
3475 ii = Math.max(p.length, p2 && p2.length || 0);
3476 }
3477 };
3478 ii = Math.max(p.length, p2 && p2.length || 0);
3479 for (var i = 0; i < ii; i++) {
3480
3481 p[i] && (pfirst = p[i][0]); // save current path command
3482
3483 if (pfirst !== 'C') {
3484 // C is not saved yet, because it may be result of conversion
3485 pcoms1[i] = pfirst; // Save current path command
3486 i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
3487 }
3488 p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath
3489
3490 if (pcoms1[i] !== 'A' && pfirst === 'C') pcoms1[i] = 'C'; // A is the only command
3491 // which may produce multiple C:s
3492 // so we have to make sure that C is also C in original path
3493
3494 fixArc(p, i); // fixArc adds also the right amount of A:s to pcoms1
3495
3496 if (p2) {
3497 // the same procedures is done to p2
3498 p2[i] && (pfirst = p2[i][0]);
3499 if (pfirst !== 'C') {
3500 pcoms2[i] = pfirst;
3501 i && (pcom = pcoms2[i - 1]);
3502 }
3503 p2[i] = processPath(p2[i], attrs2, pcom);
3504
3505 if (pcoms2[i] !== 'A' && pfirst === 'C') {
3506 pcoms2[i] = 'C';
3507 }
3508
3509 fixArc(p2, i);
3510 }
3511 fixM(p, p2, attrs, attrs2, i);
3512 fixM(p2, p, attrs2, attrs, i);
3513 var seg = p[i];
3514 var seg2 = p2 && p2[i];
3515 var seglen = seg.length;
3516 var seg2len = p2 && seg2.length;
3517 attrs.x = seg[seglen - 2];
3518 attrs.y = seg[seglen - 1];
3519 attrs.bx = parseFloat(seg[seglen - 4]) || attrs.x;
3520 attrs.by = parseFloat(seg[seglen - 3]) || attrs.y;
3521 attrs2.bx = p2 && (parseFloat(seg2[seg2len - 4]) || attrs2.x);
3522 attrs2.by = p2 && (parseFloat(seg2[seg2len - 3]) || attrs2.y);
3523 attrs2.x = p2 && seg2[seg2len - 2];
3524 attrs2.y = p2 && seg2[seg2len - 1];
3525 }
3526
3527 return p2 ? [p, p2] : p;
3528};
3529
3530var p2s = /,?([a-z]),?/gi;
3531var parsePathArray = function parsePathArray(path) {
3532 return path.join(',').replace(p2s, '$1');
3533};
3534
3535var base3 = function base3(t, p1, p2, p3, p4) {
3536 var t1 = -3 * p1 + 9 * p2 - 9 * p3 + 3 * p4;
3537 var t2 = t * t1 + 6 * p1 - 12 * p2 + 6 * p3;
3538 return t * t2 - 3 * p1 + 3 * p2;
3539};
3540
3541var bezlen = function bezlen(x1, y1, x2, y2, x3, y3, x4, y4, z) {
3542 if (z === null) {
3543 z = 1;
3544 }
3545 z = z > 1 ? 1 : z < 0 ? 0 : z;
3546 var z2 = z / 2;
3547 var n = 12;
3548 var Tvalues = [-0.1252, 0.1252, -0.3678, 0.3678, -0.5873, 0.5873, -0.7699, 0.7699, -0.9041, 0.9041, -0.9816, 0.9816];
3549 var Cvalues = [0.2491, 0.2491, 0.2335, 0.2335, 0.2032, 0.2032, 0.1601, 0.1601, 0.1069, 0.1069, 0.0472, 0.0472];
3550 var sum = 0;
3551 for (var i = 0; i < n; i++) {
3552 var ct = z2 * Tvalues[i] + z2;
3553 var xbase = base3(ct, x1, x2, x3, x4);
3554 var ybase = base3(ct, y1, y2, y3, y4);
3555 var comb = xbase * xbase + ybase * ybase;
3556 sum += Cvalues[i] * Math.sqrt(comb);
3557 }
3558 return z2 * sum;
3559};
3560
3561var curveDim = function curveDim(x0, y0, x1, y1, x2, y2, x3, y3) {
3562 var tvalues = [];
3563 var bounds = [[], []];
3564 var a = void 0;
3565 var b = void 0;
3566 var c = void 0;
3567 var t = void 0;
3568
3569 for (var i = 0; i < 2; ++i) {
3570 if (i === 0) {
3571 b = 6 * x0 - 12 * x1 + 6 * x2;
3572 a = -3 * x0 + 9 * x1 - 9 * x2 + 3 * x3;
3573 c = 3 * x1 - 3 * x0;
3574 } else {
3575 b = 6 * y0 - 12 * y1 + 6 * y2;
3576 a = -3 * y0 + 9 * y1 - 9 * y2 + 3 * y3;
3577 c = 3 * y1 - 3 * y0;
3578 }
3579 if (Math.abs(a) < 1e-12) {
3580 if (Math.abs(b) < 1e-12) {
3581 continue;
3582 }
3583 t = -c / b;
3584 if (t > 0 && t < 1) {
3585 tvalues.push(t);
3586 }
3587 continue;
3588 }
3589 var b2ac = b * b - 4 * c * a;
3590 var sqrtb2ac = Math.sqrt(b2ac);
3591 if (b2ac < 0) {
3592 continue;
3593 }
3594 var t1 = (-b + sqrtb2ac) / (2 * a);
3595 if (t1 > 0 && t1 < 1) {
3596 tvalues.push(t1);
3597 }
3598 var t2 = (-b - sqrtb2ac) / (2 * a);
3599 if (t2 > 0 && t2 < 1) {
3600 tvalues.push(t2);
3601 }
3602 }
3603
3604 var j = tvalues.length;
3605 var jlen = j;
3606 var mt = void 0;
3607 while (j--) {
3608 t = tvalues[j];
3609 mt = 1 - t;
3610 bounds[0][j] = mt * mt * mt * x0 + 3 * mt * mt * t * x1 + 3 * mt * t * t * x2 + t * t * t * x3;
3611 bounds[1][j] = mt * mt * mt * y0 + 3 * mt * mt * t * y1 + 3 * mt * t * t * y2 + t * t * t * y3;
3612 }
3613
3614 bounds[0][jlen] = x0;
3615 bounds[1][jlen] = y0;
3616 bounds[0][jlen + 1] = x3;
3617 bounds[1][jlen + 1] = y3;
3618 bounds[0].length = bounds[1].length = jlen + 2;
3619
3620 return {
3621 min: {
3622 x: Math.min.apply(0, bounds[0]),
3623 y: Math.min.apply(0, bounds[1])
3624 },
3625 max: {
3626 x: Math.max.apply(0, bounds[0]),
3627 y: Math.max.apply(0, bounds[1])
3628 }
3629 };
3630};
3631
3632var intersect = function intersect(x1, y1, x2, y2, x3, y3, x4, y4) {
3633 if (Math.max(x1, x2) < Math.min(x3, x4) || Math.min(x1, x2) > Math.max(x3, x4) || Math.max(y1, y2) < Math.min(y3, y4) || Math.min(y1, y2) > Math.max(y3, y4)) {
3634 return;
3635 }
3636 var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);
3637 var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);
3638 var denominator = (x1 - x2) * (y3 - y4) - (y1 - y2) * (x3 - x4);
3639
3640 if (!denominator) {
3641 return;
3642 }
3643 var px = nx / denominator;
3644 var py = ny / denominator;
3645 var px2 = +px.toFixed(2);
3646 var py2 = +py.toFixed(2);
3647 if (px2 < +Math.min(x1, x2).toFixed(2) || px2 > +Math.max(x1, x2).toFixed(2) || px2 < +Math.min(x3, x4).toFixed(2) || px2 > +Math.max(x3, x4).toFixed(2) || py2 < +Math.min(y1, y2).toFixed(2) || py2 > +Math.max(y1, y2).toFixed(2) || py2 < +Math.min(y3, y4).toFixed(2) || py2 > +Math.max(y3, y4).toFixed(2)) {
3648 return;
3649 }
3650 return {
3651 x: px,
3652 y: py
3653 };
3654};
3655
3656var isPointInsideBBox = function isPointInsideBBox(bbox, x, y) {
3657 return x >= bbox.x && x <= bbox.x + bbox.width && y >= bbox.y && y <= bbox.y + bbox.height;
3658};
3659
3660var rectPath = function rectPath(x, y, w, h, r) {
3661 if (r) {
3662 return [['M', +x + +r, y], ['l', w - r * 2, 0], ['a', r, r, 0, 0, 1, r, r], ['l', 0, h - r * 2], ['a', r, r, 0, 0, 1, -r, r], ['l', r * 2 - w, 0], ['a', r, r, 0, 0, 1, -r, -r], ['l', 0, r * 2 - h], ['a', r, r, 0, 0, 1, r, -r], ['z']];
3663 }
3664 var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];
3665 res.parsePathArray = parsePathArray;
3666 return res;
3667};
3668
3669var box = function box(x, y, width, height) {
3670 if (x === null) {
3671 x = y = width = height = 0;
3672 }
3673 if (y === null) {
3674 y = x.y;
3675 width = x.width;
3676 height = x.height;
3677 x = x.x;
3678 }
3679 return {
3680 x: x,
3681 y: y,
3682 width: width,
3683 w: width,
3684 height: height,
3685 h: height,
3686 x2: x + width,
3687 y2: y + height,
3688 cx: x + width / 2,
3689 cy: y + height / 2,
3690 r1: Math.min(width, height) / 2,
3691 r2: Math.max(width, height) / 2,
3692 r0: Math.sqrt(width * width + height * height) / 2,
3693 path: rectPath(x, y, width, height),
3694 vb: [x, y, width, height].join(' ')
3695 };
3696};
3697
3698var isBBoxIntersect = function isBBoxIntersect(bbox1, bbox2) {
3699 bbox1 = box(bbox1);
3700 bbox2 = box(bbox2);
3701 return isPointInsideBBox(bbox2, bbox1.x, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y) || isPointInsideBBox(bbox2, bbox1.x, bbox1.y2) || isPointInsideBBox(bbox2, bbox1.x2, bbox1.y2) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y) || isPointInsideBBox(bbox1, bbox2.x, bbox2.y2) || isPointInsideBBox(bbox1, bbox2.x2, bbox2.y2) || (bbox1.x < bbox2.x2 && bbox1.x > bbox2.x || bbox2.x < bbox1.x2 && bbox2.x > bbox1.x) && (bbox1.y < bbox2.y2 && bbox1.y > bbox2.y || bbox2.y < bbox1.y2 && bbox2.y > bbox1.y);
3702};
3703
3704var bezierBBox = function bezierBBox(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y) {
3705 if (!Util.isArray(p1x)) {
3706 p1x = [p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y];
3707 }
3708 var bbox = curveDim.apply(null, p1x);
3709 return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);
3710};
3711
3712var findDotsAtSegment = function findDotsAtSegment(p1x, p1y, c1x, c1y, c2x, c2y, p2x, p2y, t) {
3713 var t1 = 1 - t;
3714 var t13 = Math.pow(t1, 3);
3715 var t12 = Math.pow(t1, 2);
3716 var t2 = t * t;
3717 var t3 = t2 * t;
3718 var x = t13 * p1x + t12 * 3 * t * c1x + t1 * 3 * t * t * c2x + t3 * p2x;
3719 var y = t13 * p1y + t12 * 3 * t * c1y + t1 * 3 * t * t * c2y + t3 * p2y;
3720 var mx = p1x + 2 * t * (c1x - p1x) + t2 * (c2x - 2 * c1x + p1x);
3721 var my = p1y + 2 * t * (c1y - p1y) + t2 * (c2y - 2 * c1y + p1y);
3722 var nx = c1x + 2 * t * (c2x - c1x) + t2 * (p2x - 2 * c2x + c1x);
3723 var ny = c1y + 2 * t * (c2y - c1y) + t2 * (p2y - 2 * c2y + c1y);
3724 var ax = t1 * p1x + t * c1x;
3725 var ay = t1 * p1y + t * c1y;
3726 var cx = t1 * c2x + t * p2x;
3727 var cy = t1 * c2y + t * p2y;
3728 var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
3729 // (mx > nx || my < ny) && (alpha += 180);
3730 return {
3731 x: x,
3732 y: y,
3733 m: {
3734 x: mx,
3735 y: my
3736 },
3737 n: {
3738 x: nx,
3739 y: ny
3740 },
3741 start: {
3742 x: ax,
3743 y: ay
3744 },
3745 end: {
3746 x: cx,
3747 y: cy
3748 },
3749 alpha: alpha
3750 };
3751};
3752
3753var interHelper = function interHelper(bez1, bez2, justCount) {
3754 var bbox1 = bezierBBox(bez1);
3755 var bbox2 = bezierBBox(bez2);
3756 if (!isBBoxIntersect(bbox1, bbox2)) {
3757 return justCount ? 0 : [];
3758 }
3759 var l1 = bezlen.apply(0, bez1);
3760 var l2 = bezlen.apply(0, bez2);
3761 var n1 = ~~(l1 / 8);
3762 var n2 = ~~(l2 / 8);
3763 var dots1 = [];
3764 var dots2 = [];
3765 var xy = {};
3766 var res = justCount ? 0 : [];
3767 for (var i = 0; i < n1 + 1; i++) {
3768 var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));
3769 dots1.push({
3770 x: d.x,
3771 y: d.y,
3772 t: i / n1
3773 });
3774 }
3775 for (var _i = 0; _i < n2 + 1; _i++) {
3776 var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
3777 dots2.push({
3778 x: _d.x,
3779 y: _d.y,
3780 t: _i / n2
3781 });
3782 }
3783 for (var _i2 = 0; _i2 < n1; _i2++) {
3784 for (var j = 0; j < n2; j++) {
3785 var di = dots1[_i2];
3786 var di1 = dots1[_i2 + 1];
3787 var dj = dots2[j];
3788 var dj1 = dots2[j + 1];
3789 var ci = Math.abs(di1.x - di.x) < 0.001 ? 'y' : 'x';
3790 var cj = Math.abs(dj1.x - dj.x) < 0.001 ? 'y' : 'x';
3791 var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
3792 if (is) {
3793 if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {
3794 continue;
3795 }
3796 xy[is.x.toFixed(4)] = is.y.toFixed(4);
3797 var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
3798 var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
3799 if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {
3800 if (justCount) {
3801 res++;
3802 } else {
3803 res.push({
3804 x: is.x,
3805 y: is.y,
3806 t1: t1,
3807 t2: t2
3808 });
3809 }
3810 }
3811 }
3812 }
3813 }
3814 return res;
3815};
3816
3817var interPathHelper = function interPathHelper(path1, path2, justCount) {
3818 path1 = pathTocurve(path1);
3819 path2 = pathTocurve(path2);
3820 var x1 = void 0;
3821 var y1 = void 0;
3822 var x2 = void 0;
3823 var y2 = void 0;
3824 var x1m = void 0;
3825 var y1m = void 0;
3826 var x2m = void 0;
3827 var y2m = void 0;
3828 var bez1 = void 0;
3829 var bez2 = void 0;
3830 var res = justCount ? 0 : [];
3831 for (var i = 0, ii = path1.length; i < ii; i++) {
3832 var pi = path1[i];
3833 if (pi[0] === 'M') {
3834 x1 = x1m = pi[1];
3835 y1 = y1m = pi[2];
3836 } else {
3837 if (pi[0] === 'C') {
3838 bez1 = [x1, y1].concat(pi.slice(1));
3839 x1 = bez1[6];
3840 y1 = bez1[7];
3841 } else {
3842 bez1 = [x1, y1, x1, y1, x1m, y1m, x1m, y1m];
3843 x1 = x1m;
3844 y1 = y1m;
3845 }
3846 for (var j = 0, jj = path2.length; j < jj; j++) {
3847 var pj = path2[j];
3848 if (pj[0] === 'M') {
3849 x2 = x2m = pj[1];
3850 y2 = y2m = pj[2];
3851 } else {
3852 if (pj[0] === 'C') {
3853 bez2 = [x2, y2].concat(pj.slice(1));
3854 x2 = bez2[6];
3855 y2 = bez2[7];
3856 } else {
3857 bez2 = [x2, y2, x2, y2, x2m, y2m, x2m, y2m];
3858 x2 = x2m;
3859 y2 = y2m;
3860 }
3861 var intr = interHelper(bez1, bez2, justCount);
3862 if (justCount) {
3863 res += intr;
3864 } else {
3865 for (var k = 0, kk = intr.length; k < kk; k++) {
3866 intr[k].segment1 = i;
3867 intr[k].segment2 = j;
3868 intr[k].bez1 = bez1;
3869 intr[k].bez2 = bez2;
3870 }
3871 res = res.concat(intr);
3872 }
3873 }
3874 }
3875 }
3876 }
3877 return res;
3878};
3879
3880var pathIntersection = function pathIntersection(path1, path2) {
3881 return interPathHelper(path1, path2);
3882};
3883
3884module.exports = {
3885 parsePathString: parsePathString,
3886 parsePathArray: parsePathArray,
3887 pathTocurve: pathTocurve,
3888 pathToAbsolute: pathToAbsolute,
3889 catmullRomToBezier: catmullRom2bezier,
3890 rectPath: rectPath,
3891 intersection: pathIntersection
3892};
3893
3894/***/ }),
3895/* 16 */
3896/***/ (function(module, __webpack_exports__, __webpack_require__) {
3897
3898"use strict";
3899/* harmony export (immutable) */ __webpack_exports__["b"] = now;
3900/* harmony export (immutable) */ __webpack_exports__["a"] = Timer;
3901/* harmony export (immutable) */ __webpack_exports__["c"] = timer;
3902/* harmony export (immutable) */ __webpack_exports__["d"] = timerFlush;
3903var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
3904
3905var frame = 0,
3906 // is an animation frame pending?
3907timeout = 0,
3908 // is a timeout pending?
3909interval = 0,
3910 // are any timers active?
3911pokeDelay = 1000,
3912 // how frequently we check for clock skew
3913taskHead,
3914 taskTail,
3915 clockLast = 0,
3916 clockNow = 0,
3917 clockSkew = 0,
3918 clock = (typeof performance === "undefined" ? "undefined" : _typeof(performance)) === "object" && performance.now ? performance : Date,
3919 setFrame = (typeof window === "undefined" ? "undefined" : _typeof(window)) === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function (f) {
3920 setTimeout(f, 17);
3921};
3922
3923function now() {
3924 return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
3925}
3926
3927function clearNow() {
3928 clockNow = 0;
3929}
3930
3931function Timer() {
3932 this._call = this._time = this._next = null;
3933}
3934
3935Timer.prototype = timer.prototype = {
3936 constructor: Timer,
3937 restart: function restart(callback, delay, time) {
3938 if (typeof callback !== "function") throw new TypeError("callback is not a function");
3939 time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
3940 if (!this._next && taskTail !== this) {
3941 if (taskTail) taskTail._next = this;else taskHead = this;
3942 taskTail = this;
3943 }
3944 this._call = callback;
3945 this._time = time;
3946 sleep();
3947 },
3948 stop: function stop() {
3949 if (this._call) {
3950 this._call = null;
3951 this._time = Infinity;
3952 sleep();
3953 }
3954 }
3955};
3956
3957function timer(callback, delay, time) {
3958 var t = new Timer();
3959 t.restart(callback, delay, time);
3960 return t;
3961}
3962
3963function timerFlush() {
3964 now(); // Get the current time, if not already set.
3965 ++frame; // Pretend we’ve set an alarm, if we haven’t already.
3966 var t = taskHead,
3967 e;
3968 while (t) {
3969 if ((e = clockNow - t._time) >= 0) t._call.call(null, e);
3970 t = t._next;
3971 }
3972 --frame;
3973}
3974
3975function wake() {
3976 clockNow = (clockLast = clock.now()) + clockSkew;
3977 frame = timeout = 0;
3978 try {
3979 timerFlush();
3980 } finally {
3981 frame = 0;
3982 nap();
3983 clockNow = 0;
3984 }
3985}
3986
3987function poke() {
3988 var now = clock.now(),
3989 delay = now - clockLast;
3990 if (delay > pokeDelay) clockSkew -= delay, clockLast = now;
3991}
3992
3993function nap() {
3994 var t0,
3995 t1 = taskHead,
3996 t2,
3997 time = Infinity;
3998 while (t1) {
3999 if (t1._call) {
4000 if (time > t1._time) time = t1._time;
4001 t0 = t1, t1 = t1._next;
4002 } else {
4003 t2 = t1._next, t1._next = null;
4004 t1 = t0 ? t0._next = t2 : taskHead = t2;
4005 }
4006 }
4007 taskTail = t0;
4008 sleep(time);
4009}
4010
4011function sleep(time) {
4012 if (frame) return; // Soonest alarm already set, or will be.
4013 if (timeout) timeout = clearTimeout(timeout);
4014 var delay = time - clockNow; // Strictly less than if we recomputed clockNow.
4015 if (delay > 24) {
4016 if (time < Infinity) timeout = setTimeout(wake, time - clock.now() - clockSkew);
4017 if (interval) interval = clearInterval(interval);
4018 } else {
4019 if (!interval) clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
4020 frame = 1, setFrame(wake);
4021 }
4022}
4023
4024/***/ }),
4025/* 17 */
4026/***/ (function(module, __webpack_exports__, __webpack_require__) {
4027
4028"use strict";
4029/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
4030/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__rgb__ = __webpack_require__(34);
4031/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__array__ = __webpack_require__(37);
4032/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__date__ = __webpack_require__(38);
4033/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__number__ = __webpack_require__(11);
4034/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__object__ = __webpack_require__(39);
4035/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__string__ = __webpack_require__(40);
4036/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__constant__ = __webpack_require__(36);
4037var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
4049 var t = typeof b === "undefined" ? "undefined" : _typeof(b),
4050 c;
4051 return b == null || t === "boolean" ? Object(__WEBPACK_IMPORTED_MODULE_7__constant__["a" /* default */])(b) : (t === "number" ? __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */] : t === "string" ? (c = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */])(b)) ? (b = c, __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */]) : __WEBPACK_IMPORTED_MODULE_6__string__["a" /* default */] : b instanceof __WEBPACK_IMPORTED_MODULE_0_d3_color__["a" /* color */] ? __WEBPACK_IMPORTED_MODULE_1__rgb__["a" /* default */] : b instanceof Date ? __WEBPACK_IMPORTED_MODULE_3__date__["a" /* default */] : Array.isArray(b) ? __WEBPACK_IMPORTED_MODULE_2__array__["a" /* default */] : typeof b.valueOf !== "function" && typeof b.toString !== "function" || isNaN(b) ? __WEBPACK_IMPORTED_MODULE_5__object__["a" /* default */] : __WEBPACK_IMPORTED_MODULE_4__number__["a" /* default */])(a, b);
4052});
4053
4054/***/ }),
4055/* 18 */
4056/***/ (function(module, __webpack_exports__, __webpack_require__) {
4057
4058"use strict";
4059/* harmony export (immutable) */ __webpack_exports__["a"] = Color;
4060/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return _darker; });
4061/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return _brighter; });
4062/* harmony export (immutable) */ __webpack_exports__["e"] = color;
4063/* harmony export (immutable) */ __webpack_exports__["h"] = rgbConvert;
4064/* harmony export (immutable) */ __webpack_exports__["g"] = rgb;
4065/* harmony export (immutable) */ __webpack_exports__["b"] = Rgb;
4066/* unused harmony export hslConvert */
4067/* harmony export (immutable) */ __webpack_exports__["f"] = hsl;
4068/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(19);
4069
4070
4071function Color() {}
4072
4073var _darker = 0.7;
4074
4075var _brighter = 1 / _darker;
4076
4077
4078var reI = "\\s*([+-]?\\d+)\\s*",
4079 reN = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)\\s*",
4080 reP = "\\s*([+-]?\\d*\\.?\\d+(?:[eE][+-]?\\d+)?)%\\s*",
4081 reHex3 = /^#([0-9a-f]{3})$/,
4082 reHex6 = /^#([0-9a-f]{6})$/,
4083 reRgbInteger = new RegExp("^rgb\\(" + [reI, reI, reI] + "\\)$"),
4084 reRgbPercent = new RegExp("^rgb\\(" + [reP, reP, reP] + "\\)$"),
4085 reRgbaInteger = new RegExp("^rgba\\(" + [reI, reI, reI, reN] + "\\)$"),
4086 reRgbaPercent = new RegExp("^rgba\\(" + [reP, reP, reP, reN] + "\\)$"),
4087 reHslPercent = new RegExp("^hsl\\(" + [reN, reP, reP] + "\\)$"),
4088 reHslaPercent = new RegExp("^hsla\\(" + [reN, reP, reP, reN] + "\\)$");
4089
4090var named = {
4091 aliceblue: 0xf0f8ff,
4092 antiquewhite: 0xfaebd7,
4093 aqua: 0x00ffff,
4094 aquamarine: 0x7fffd4,
4095 azure: 0xf0ffff,
4096 beige: 0xf5f5dc,
4097 bisque: 0xffe4c4,
4098 black: 0x000000,
4099 blanchedalmond: 0xffebcd,
4100 blue: 0x0000ff,
4101 blueviolet: 0x8a2be2,
4102 brown: 0xa52a2a,
4103 burlywood: 0xdeb887,
4104 cadetblue: 0x5f9ea0,
4105 chartreuse: 0x7fff00,
4106 chocolate: 0xd2691e,
4107 coral: 0xff7f50,
4108 cornflowerblue: 0x6495ed,
4109 cornsilk: 0xfff8dc,
4110 crimson: 0xdc143c,
4111 cyan: 0x00ffff,
4112 darkblue: 0x00008b,
4113 darkcyan: 0x008b8b,
4114 darkgoldenrod: 0xb8860b,
4115 darkgray: 0xa9a9a9,
4116 darkgreen: 0x006400,
4117 darkgrey: 0xa9a9a9,
4118 darkkhaki: 0xbdb76b,
4119 darkmagenta: 0x8b008b,
4120 darkolivegreen: 0x556b2f,
4121 darkorange: 0xff8c00,
4122 darkorchid: 0x9932cc,
4123 darkred: 0x8b0000,
4124 darksalmon: 0xe9967a,
4125 darkseagreen: 0x8fbc8f,
4126 darkslateblue: 0x483d8b,
4127 darkslategray: 0x2f4f4f,
4128 darkslategrey: 0x2f4f4f,
4129 darkturquoise: 0x00ced1,
4130 darkviolet: 0x9400d3,
4131 deeppink: 0xff1493,
4132 deepskyblue: 0x00bfff,
4133 dimgray: 0x696969,
4134 dimgrey: 0x696969,
4135 dodgerblue: 0x1e90ff,
4136 firebrick: 0xb22222,
4137 floralwhite: 0xfffaf0,
4138 forestgreen: 0x228b22,
4139 fuchsia: 0xff00ff,
4140 gainsboro: 0xdcdcdc,
4141 ghostwhite: 0xf8f8ff,
4142 gold: 0xffd700,
4143 goldenrod: 0xdaa520,
4144 gray: 0x808080,
4145 green: 0x008000,
4146 greenyellow: 0xadff2f,
4147 grey: 0x808080,
4148 honeydew: 0xf0fff0,
4149 hotpink: 0xff69b4,
4150 indianred: 0xcd5c5c,
4151 indigo: 0x4b0082,
4152 ivory: 0xfffff0,
4153 khaki: 0xf0e68c,
4154 lavender: 0xe6e6fa,
4155 lavenderblush: 0xfff0f5,
4156 lawngreen: 0x7cfc00,
4157 lemonchiffon: 0xfffacd,
4158 lightblue: 0xadd8e6,
4159 lightcoral: 0xf08080,
4160 lightcyan: 0xe0ffff,
4161 lightgoldenrodyellow: 0xfafad2,
4162 lightgray: 0xd3d3d3,
4163 lightgreen: 0x90ee90,
4164 lightgrey: 0xd3d3d3,
4165 lightpink: 0xffb6c1,
4166 lightsalmon: 0xffa07a,
4167 lightseagreen: 0x20b2aa,
4168 lightskyblue: 0x87cefa,
4169 lightslategray: 0x778899,
4170 lightslategrey: 0x778899,
4171 lightsteelblue: 0xb0c4de,
4172 lightyellow: 0xffffe0,
4173 lime: 0x00ff00,
4174 limegreen: 0x32cd32,
4175 linen: 0xfaf0e6,
4176 magenta: 0xff00ff,
4177 maroon: 0x800000,
4178 mediumaquamarine: 0x66cdaa,
4179 mediumblue: 0x0000cd,
4180 mediumorchid: 0xba55d3,
4181 mediumpurple: 0x9370db,
4182 mediumseagreen: 0x3cb371,
4183 mediumslateblue: 0x7b68ee,
4184 mediumspringgreen: 0x00fa9a,
4185 mediumturquoise: 0x48d1cc,
4186 mediumvioletred: 0xc71585,
4187 midnightblue: 0x191970,
4188 mintcream: 0xf5fffa,
4189 mistyrose: 0xffe4e1,
4190 moccasin: 0xffe4b5,
4191 navajowhite: 0xffdead,
4192 navy: 0x000080,
4193 oldlace: 0xfdf5e6,
4194 olive: 0x808000,
4195 olivedrab: 0x6b8e23,
4196 orange: 0xffa500,
4197 orangered: 0xff4500,
4198 orchid: 0xda70d6,
4199 palegoldenrod: 0xeee8aa,
4200 palegreen: 0x98fb98,
4201 paleturquoise: 0xafeeee,
4202 palevioletred: 0xdb7093,
4203 papayawhip: 0xffefd5,
4204 peachpuff: 0xffdab9,
4205 peru: 0xcd853f,
4206 pink: 0xffc0cb,
4207 plum: 0xdda0dd,
4208 powderblue: 0xb0e0e6,
4209 purple: 0x800080,
4210 rebeccapurple: 0x663399,
4211 red: 0xff0000,
4212 rosybrown: 0xbc8f8f,
4213 royalblue: 0x4169e1,
4214 saddlebrown: 0x8b4513,
4215 salmon: 0xfa8072,
4216 sandybrown: 0xf4a460,
4217 seagreen: 0x2e8b57,
4218 seashell: 0xfff5ee,
4219 sienna: 0xa0522d,
4220 silver: 0xc0c0c0,
4221 skyblue: 0x87ceeb,
4222 slateblue: 0x6a5acd,
4223 slategray: 0x708090,
4224 slategrey: 0x708090,
4225 snow: 0xfffafa,
4226 springgreen: 0x00ff7f,
4227 steelblue: 0x4682b4,
4228 tan: 0xd2b48c,
4229 teal: 0x008080,
4230 thistle: 0xd8bfd8,
4231 tomato: 0xff6347,
4232 turquoise: 0x40e0d0,
4233 violet: 0xee82ee,
4234 wheat: 0xf5deb3,
4235 white: 0xffffff,
4236 whitesmoke: 0xf5f5f5,
4237 yellow: 0xffff00,
4238 yellowgreen: 0x9acd32
4239};
4240
4241Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Color, color, {
4242 displayable: function displayable() {
4243 return this.rgb().displayable();
4244 },
4245 hex: function hex() {
4246 return this.rgb().hex();
4247 },
4248 toString: function toString() {
4249 return this.rgb() + "";
4250 }
4251});
4252
4253function color(format) {
4254 var m;
4255 format = (format + "").trim().toLowerCase();
4256 return (m = reHex3.exec(format)) ? (m = parseInt(m[1], 16), new Rgb(m >> 8 & 0xf | m >> 4 & 0x0f0, m >> 4 & 0xf | m & 0xf0, (m & 0xf) << 4 | m & 0xf, 1) // #f00
4257 ) : (m = reHex6.exec(format)) ? rgbn(parseInt(m[1], 16)) // #ff0000
4258 : (m = reRgbInteger.exec(format)) ? new Rgb(m[1], m[2], m[3], 1) // rgb(255, 0, 0)
4259 : (m = reRgbPercent.exec(format)) ? new Rgb(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, 1) // rgb(100%, 0%, 0%)
4260 : (m = reRgbaInteger.exec(format)) ? rgba(m[1], m[2], m[3], m[4]) // rgba(255, 0, 0, 1)
4261 : (m = reRgbaPercent.exec(format)) ? rgba(m[1] * 255 / 100, m[2] * 255 / 100, m[3] * 255 / 100, m[4]) // rgb(100%, 0%, 0%, 1)
4262 : (m = reHslPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, 1) // hsl(120, 50%, 50%)
4263 : (m = reHslaPercent.exec(format)) ? hsla(m[1], m[2] / 100, m[3] / 100, m[4]) // hsla(120, 50%, 50%, 1)
4264 : named.hasOwnProperty(format) ? rgbn(named[format]) : format === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
4265}
4266
4267function rgbn(n) {
4268 return new Rgb(n >> 16 & 0xff, n >> 8 & 0xff, n & 0xff, 1);
4269}
4270
4271function rgba(r, g, b, a) {
4272 if (a <= 0) r = g = b = NaN;
4273 return new Rgb(r, g, b, a);
4274}
4275
4276function rgbConvert(o) {
4277 if (!(o instanceof Color)) o = color(o);
4278 if (!o) return new Rgb();
4279 o = o.rgb();
4280 return new Rgb(o.r, o.g, o.b, o.opacity);
4281}
4282
4283function rgb(r, g, b, opacity) {
4284 return arguments.length === 1 ? rgbConvert(r) : new Rgb(r, g, b, opacity == null ? 1 : opacity);
4285}
4286
4287function Rgb(r, g, b, opacity) {
4288 this.r = +r;
4289 this.g = +g;
4290 this.b = +b;
4291 this.opacity = +opacity;
4292}
4293
4294Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Rgb, rgb, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
4295 brighter: function brighter(k) {
4296 k = k == null ? _brighter : Math.pow(_brighter, k);
4297 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
4298 },
4299 darker: function darker(k) {
4300 k = k == null ? _darker : Math.pow(_darker, k);
4301 return new Rgb(this.r * k, this.g * k, this.b * k, this.opacity);
4302 },
4303 rgb: function rgb() {
4304 return this;
4305 },
4306 displayable: function displayable() {
4307 return 0 <= this.r && this.r <= 255 && 0 <= this.g && this.g <= 255 && 0 <= this.b && this.b <= 255 && 0 <= this.opacity && this.opacity <= 1;
4308 },
4309 hex: function hex() {
4310 return "#" + _hex(this.r) + _hex(this.g) + _hex(this.b);
4311 },
4312 toString: function toString() {
4313 var a = this.opacity;a = isNaN(a) ? 1 : Math.max(0, Math.min(1, a));
4314 return (a === 1 ? "rgb(" : "rgba(") + Math.max(0, Math.min(255, Math.round(this.r) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.g) || 0)) + ", " + Math.max(0, Math.min(255, Math.round(this.b) || 0)) + (a === 1 ? ")" : ", " + a + ")");
4315 }
4316}));
4317
4318function _hex(value) {
4319 value = Math.max(0, Math.min(255, Math.round(value) || 0));
4320 return (value < 16 ? "0" : "") + value.toString(16);
4321}
4322
4323function hsla(h, s, l, a) {
4324 if (a <= 0) h = s = l = NaN;else if (l <= 0 || l >= 1) h = s = NaN;else if (s <= 0) h = NaN;
4325 return new Hsl(h, s, l, a);
4326}
4327
4328function hslConvert(o) {
4329 if (o instanceof Hsl) return new Hsl(o.h, o.s, o.l, o.opacity);
4330 if (!(o instanceof Color)) o = color(o);
4331 if (!o) return new Hsl();
4332 if (o instanceof Hsl) return o;
4333 o = o.rgb();
4334 var r = o.r / 255,
4335 g = o.g / 255,
4336 b = o.b / 255,
4337 min = Math.min(r, g, b),
4338 max = Math.max(r, g, b),
4339 h = NaN,
4340 s = max - min,
4341 l = (max + min) / 2;
4342 if (s) {
4343 if (r === max) h = (g - b) / s + (g < b) * 6;else if (g === max) h = (b - r) / s + 2;else h = (r - g) / s + 4;
4344 s /= l < 0.5 ? max + min : 2 - max - min;
4345 h *= 60;
4346 } else {
4347 s = l > 0 && l < 1 ? 0 : h;
4348 }
4349 return new Hsl(h, s, l, o.opacity);
4350}
4351
4352function hsl(h, s, l, opacity) {
4353 return arguments.length === 1 ? hslConvert(h) : new Hsl(h, s, l, opacity == null ? 1 : opacity);
4354}
4355
4356function Hsl(h, s, l, opacity) {
4357 this.h = +h;
4358 this.s = +s;
4359 this.l = +l;
4360 this.opacity = +opacity;
4361}
4362
4363Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hsl, hsl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(Color, {
4364 brighter: function brighter(k) {
4365 k = k == null ? _brighter : Math.pow(_brighter, k);
4366 return new Hsl(this.h, this.s, this.l * k, this.opacity);
4367 },
4368 darker: function darker(k) {
4369 k = k == null ? _darker : Math.pow(_darker, k);
4370 return new Hsl(this.h, this.s, this.l * k, this.opacity);
4371 },
4372 rgb: function rgb() {
4373 var h = this.h % 360 + (this.h < 0) * 360,
4374 s = isNaN(h) || isNaN(this.s) ? 0 : this.s,
4375 l = this.l,
4376 m2 = l + (l < 0.5 ? l : 1 - l) * s,
4377 m1 = 2 * l - m2;
4378 return new Rgb(hsl2rgb(h >= 240 ? h - 240 : h + 120, m1, m2), hsl2rgb(h, m1, m2), hsl2rgb(h < 120 ? h + 240 : h - 120, m1, m2), this.opacity);
4379 },
4380 displayable: function displayable() {
4381 return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
4382 }
4383}));
4384
4385/* From FvD 13.37, CSS Color Module Level 3 */
4386function hsl2rgb(h, m1, m2) {
4387 return (h < 60 ? m1 + (m2 - m1) * h / 60 : h < 180 ? m2 : h < 240 ? m1 + (m2 - m1) * (240 - h) / 60 : m1) * 255;
4388}
4389
4390/***/ }),
4391/* 19 */
4392/***/ (function(module, __webpack_exports__, __webpack_require__) {
4393
4394"use strict";
4395/* harmony export (immutable) */ __webpack_exports__["b"] = extend;
4396/* harmony default export */ __webpack_exports__["a"] = (function (constructor, factory, prototype) {
4397 constructor.prototype = factory.prototype = prototype;
4398 prototype.constructor = constructor;
4399});
4400
4401function extend(parent, definition) {
4402 var prototype = Object.create(parent.prototype);
4403 for (var key in definition) {
4404 prototype[key] = definition[key];
4405 }return prototype;
4406}
4407
4408/***/ }),
4409/* 20 */
4410/***/ (function(module, __webpack_exports__, __webpack_require__) {
4411
4412"use strict";
4413/* harmony export (immutable) */ __webpack_exports__["a"] = basis;
4414function basis(t1, v0, v1, v2, v3) {
4415 var t2 = t1 * t1,
4416 t3 = t2 * t1;
4417 return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
4418}
4419
4420/* harmony default export */ __webpack_exports__["b"] = (function (values) {
4421 var n = values.length - 1;
4422 return function (t) {
4423 var i = t <= 0 ? t = 0 : t >= 1 ? (t = 1, n - 1) : Math.floor(t * n),
4424 v1 = values[i],
4425 v2 = values[i + 1],
4426 v0 = i > 0 ? values[i - 1] : 2 * v1 - v2,
4427 v3 = i < n - 1 ? values[i + 2] : 2 * v2 - v1;
4428 return basis((t - i / n) * n, v0, v1, v2, v3);
4429 };
4430});
4431
4432/***/ }),
4433/* 21 */
4434/***/ (function(module, exports, __webpack_require__) {
4435
4436var Util = __webpack_require__(0);
4437
4438var regexTags = /[MLHVQTCSAZ]([^MLHVQTCSAZ]*)/ig;
4439var regexDot = /[^\s\,]+/ig;
4440var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
4441var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
4442var regexPR = /^p\s*\(\s*([axyn])\s*\)\s*(.*)/i;
4443var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
4444var numColorCache = {};
4445
4446function addStop(steps, gradient) {
4447 var arr = steps.match(regexColorStop);
4448 Util.each(arr, function (item) {
4449 item = item.split(':');
4450 gradient.addColorStop(item[0], item[1]);
4451 });
4452}
4453
4454function parseLineGradient(color, self) {
4455 var arr = regexLG.exec(color);
4456 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
4457 var steps = arr[2];
4458 var box = self.getBBox();
4459 var start = void 0;
4460 var end = void 0;
4461
4462 if (angle >= 0 && angle < 0.5 * Math.PI) {
4463 start = {
4464 x: box.minX,
4465 y: box.minY
4466 };
4467 end = {
4468 x: box.maxX,
4469 y: box.maxY
4470 };
4471 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
4472 start = {
4473 x: box.maxX,
4474 y: box.minY
4475 };
4476 end = {
4477 x: box.minX,
4478 y: box.maxY
4479 };
4480 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
4481 start = {
4482 x: box.maxX,
4483 y: box.maxY
4484 };
4485 end = {
4486 x: box.minX,
4487 y: box.minY
4488 };
4489 } else {
4490 start = {
4491 x: box.minX,
4492 y: box.maxY
4493 };
4494 end = {
4495 x: box.maxX,
4496 y: box.minY
4497 };
4498 }
4499
4500 var tanTheta = Math.tan(angle);
4501 var tanTheta2 = tanTheta * tanTheta;
4502
4503 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
4504 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
4505 var context = self.get('context');
4506 var gradient = context.createLinearGradient(start.x, start.y, x, y);
4507 addStop(steps, gradient);
4508 return gradient;
4509}
4510
4511function parseRadialGradient(color, self) {
4512 var arr = regexRG.exec(color);
4513 var fx = parseFloat(arr[1]);
4514 var fy = parseFloat(arr[2]);
4515 var fr = parseFloat(arr[3]);
4516 var steps = arr[4];
4517 // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
4518 if (fr === 0) {
4519 var colors = steps.match(regexColorStop);
4520 return colors[colors.length - 1].split(':')[1];
4521 }
4522 var box = self.getBBox();
4523 var context = self.get('context');
4524 var width = box.maxX - box.minX;
4525 var height = box.maxY - box.minY;
4526 var r = Math.sqrt(width * width + height * height) / 2;
4527 var gradient = context.createRadialGradient(box.minX + width * fx, box.minY + height * fy, fr * r, box.minX + width / 2, box.minY + height / 2, r);
4528 addStop(steps, gradient);
4529 return gradient;
4530}
4531
4532function parsePattern(color, self) {
4533 if (self.get('patternSource') && self.get('patternSource') === color) {
4534 return self.get('pattern');
4535 }
4536 var pattern = void 0;
4537 var img = void 0;
4538 var arr = regexPR.exec(color);
4539 var repeat = arr[1];
4540 var source = arr[2];
4541
4542 // Function to be called when pattern loads
4543 function onload() {
4544 // Create pattern
4545 var context = self.get('context');
4546 pattern = context.createPattern(img, repeat);
4547 self.setSilent('pattern', pattern); // be a cache
4548 self.setSilent('patternSource', color);
4549 }
4550
4551 switch (repeat) {
4552 case 'a':
4553 repeat = 'repeat';
4554 break;
4555 case 'x':
4556 repeat = 'repeat-x';
4557 break;
4558 case 'y':
4559 repeat = 'repeat-y';
4560 break;
4561 case 'n':
4562 repeat = 'no-repeat';
4563 break;
4564 default:
4565 repeat = 'no-repeat';
4566 }
4567
4568 img = new Image();
4569 // If source URL is not a data URL
4570 if (!source.match(/^data:/i)) {
4571 // Set crossOrigin for this image
4572 img.crossOrigin = 'Anonymous';
4573 }
4574 img.src = source;
4575
4576 if (img.complete) {
4577 onload();
4578 } else {
4579 img.onload = onload;
4580 // Fix onload() bug in IE9
4581 img.src = img.src;
4582 }
4583
4584 return pattern;
4585}
4586
4587module.exports = {
4588 parsePath: function parsePath(path) {
4589 path = path || [];
4590 if (Util.isArray(path)) {
4591 return path;
4592 }
4593
4594 if (Util.isString(path)) {
4595 path = path.match(regexTags);
4596 Util.each(path, function (item, index) {
4597 item = item.match(regexDot);
4598 if (item[0].length > 1) {
4599 var tag = item[0].charAt(0);
4600 item.splice(1, 0, item[0].substr(1));
4601 item[0] = tag;
4602 }
4603 Util.each(item, function (sub, i) {
4604 if (!isNaN(sub)) {
4605 item[i] = +sub;
4606 }
4607 });
4608 path[index] = item;
4609 });
4610 return path;
4611 }
4612 },
4613 parseStyle: function parseStyle(color, self) {
4614 if (Util.isString(color)) {
4615 if (color[1] === '(' || color[2] === '(') {
4616 if (color[0] === 'l') {
4617 // regexLG.test(color)
4618 return parseLineGradient(color, self);
4619 } else if (color[0] === 'r') {
4620 // regexRG.test(color)
4621 return parseRadialGradient(color, self);
4622 } else if (color[0] === 'p') {
4623 // regexPR.test(color)
4624 return parsePattern(color, self);
4625 }
4626 }
4627 return color;
4628 }
4629 },
4630 numberToColor: function numberToColor(num) {
4631 // 增加缓存
4632 var color = numColorCache[num];
4633 if (!color) {
4634 var str = num.toString(16);
4635 for (var i = str.length; i < 6; i++) {
4636 str = '0' + str;
4637 }
4638 color = '#' + str;
4639 numColorCache[num] = color;
4640 }
4641 return color;
4642 }
4643};
4644
4645/***/ }),
4646/* 22 */
4647/***/ (function(module, exports, __webpack_require__) {
4648
4649var vec2 = __webpack_require__(2).vec2;
4650
4651module.exports = {
4652 at: function at(p1, p2, t) {
4653 return (p2 - p1) * t + p1;
4654 },
4655 pointDistance: function pointDistance(x1, y1, x2, y2, x, y) {
4656 var d = [x2 - x1, y2 - y1];
4657 if (vec2.exactEquals(d, [0, 0])) {
4658 return NaN;
4659 }
4660
4661 var u = [-d[1], d[0]];
4662 vec2.normalize(u, u);
4663 var a = [x - x1, y - y1];
4664 return Math.abs(vec2.dot(a, u));
4665 },
4666 box: function box(x1, y1, x2, y2, lineWidth) {
4667 var halfWidth = lineWidth / 2;
4668 var minX = Math.min(x1, x2);
4669 var maxX = Math.max(x1, x2);
4670 var minY = Math.min(y1, y2);
4671 var maxY = Math.max(y1, y2);
4672
4673 return {
4674 minX: minX - halfWidth,
4675 minY: minY - halfWidth,
4676 maxX: maxX + halfWidth,
4677 maxY: maxY + halfWidth
4678 };
4679 },
4680 len: function len(x1, y1, x2, y2) {
4681 return Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
4682 }
4683};
4684
4685/***/ }),
4686/* 23 */
4687/***/ (function(module, exports, __webpack_require__) {
4688
4689var Util = __webpack_require__(0);
4690var vec2 = __webpack_require__(2).vec2;
4691
4692function quadraticAt(p0, p1, p2, t) {
4693 var onet = 1 - t;
4694 return onet * (onet * p0 + 2 * t * p1) + t * t * p2;
4695}
4696
4697function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) {
4698 var t = void 0;
4699 var interval = 0.005;
4700 var d = Infinity;
4701 var d1 = void 0;
4702 var v1 = void 0;
4703 var v2 = void 0;
4704 var _t = void 0;
4705 var d2 = void 0;
4706 var i = void 0;
4707 var EPSILON = 0.0001;
4708 var v0 = [x, y];
4709
4710 for (_t = 0; _t < 1; _t += 0.05) {
4711 v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)];
4712
4713 d1 = vec2.squaredDistance(v0, v1);
4714 if (d1 < d) {
4715 t = _t;
4716 d = d1;
4717 }
4718 }
4719 d = Infinity;
4720
4721 for (i = 0; i < 32; i++) {
4722 if (interval < EPSILON) {
4723 break;
4724 }
4725
4726 var prev = t - interval;
4727 var next = t + interval;
4728
4729 v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)];
4730
4731 d1 = vec2.squaredDistance(v0, v1);
4732
4733 if (prev >= 0 && d1 < d) {
4734 t = prev;
4735 d = d1;
4736 } else {
4737 v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)];
4738
4739 d2 = vec2.squaredDistance(v0, v2);
4740
4741 if (next <= 1 && d2 < d) {
4742 t = next;
4743 d = d2;
4744 } else {
4745 interval *= 0.5;
4746 }
4747 }
4748 }
4749
4750 if (out) {
4751 out.x = quadraticAt(x1, x2, x3, t);
4752 out.y = quadraticAt(y1, y2, y3, t);
4753 }
4754
4755 return Math.sqrt(d);
4756}
4757
4758function quadraticExtrema(p0, p1, p2) {
4759 var a = p0 + p2 - 2 * p1;
4760 if (Util.isNumberEqual(a, 0)) {
4761 return [0.5];
4762 }
4763 var rst = (p0 - p1) / a;
4764 if (rst <= 1 && rst >= 0) {
4765 return [rst];
4766 }
4767 return [];
4768}
4769
4770module.exports = {
4771 at: quadraticAt,
4772 projectPoint: function projectPoint(x1, y1, x2, y2, x3, y3, x, y) {
4773 var rst = {};
4774 quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, rst);
4775 return rst;
4776 },
4777
4778 pointDistance: quadraticProjectPoint,
4779 extrema: quadraticExtrema
4780};
4781
4782/***/ }),
4783/* 24 */
4784/***/ (function(module, exports, __webpack_require__) {
4785
4786var Util = __webpack_require__(0);
4787var vec2 = __webpack_require__(2).vec2;
4788
4789function circlePoint(cx, cy, r, angle) {
4790 return {
4791 x: Math.cos(angle) * r + cx,
4792 y: Math.sin(angle) * r + cy
4793 };
4794}
4795
4796function angleNearTo(angle, min, max, out) {
4797 var v1 = void 0;
4798 var v2 = void 0;
4799 if (out) {
4800 if (angle < min) {
4801 v1 = min - angle;
4802 v2 = Math.PI * 2 - max + angle;
4803 } else if (angle > max) {
4804 v1 = Math.PI * 2 - angle + min;
4805 v2 = angle - max;
4806 }
4807 } else {
4808 v1 = angle - min;
4809 v2 = max - angle;
4810 }
4811
4812 return v1 > v2 ? max : min;
4813}
4814
4815function nearAngle(angle, startAngle, endAngle, clockwise) {
4816 var plus = 0;
4817 if (endAngle - startAngle >= Math.PI * 2) {
4818 plus = Math.PI * 2;
4819 }
4820 startAngle = Util.mod(startAngle, Math.PI * 2);
4821 endAngle = Util.mod(endAngle, Math.PI * 2) + plus;
4822 angle = Util.mod(angle, Math.PI * 2);
4823 if (clockwise) {
4824 if (startAngle >= endAngle) {
4825 if (angle > endAngle && angle < startAngle) {
4826 return angle;
4827 }
4828 return angleNearTo(angle, endAngle, startAngle, true);
4829 }
4830 if (angle < startAngle || angle > endAngle) {
4831 return angle;
4832 }
4833 return angleNearTo(angle, startAngle, endAngle);
4834 }
4835 if (startAngle <= endAngle) {
4836 if (startAngle < angle && angle < endAngle) {
4837 return angle;
4838 }
4839 return angleNearTo(angle, startAngle, endAngle, true);
4840 }
4841 if (angle > startAngle || angle < endAngle) {
4842 return angle;
4843 }
4844 return angleNearTo(angle, endAngle, startAngle);
4845}
4846
4847function arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, out) {
4848 var v = [x, y];
4849 var v0 = [cx, cy];
4850 var v1 = [1, 0];
4851 var subv = vec2.subtract([], v, v0);
4852 var angle = vec2.angleTo(v1, subv);
4853
4854 angle = nearAngle(angle, startAngle, endAngle, clockwise);
4855 var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy];
4856 if (out) {
4857 out.x = vpoint[0];
4858 out.y = vpoint[1];
4859 }
4860 var d = vec2.distance(vpoint, v);
4861 return d;
4862}
4863
4864function arcBox(cx, cy, r, startAngle, endAngle, clockwise) {
4865 var angleRight = 0;
4866 var angleBottom = Math.PI / 2;
4867 var angleLeft = Math.PI;
4868 var angleTop = Math.PI * 3 / 2;
4869 var points = [];
4870 var angle = nearAngle(angleRight, startAngle, endAngle, clockwise);
4871 if (angle === angleRight) {
4872 points.push(circlePoint(cx, cy, r, angleRight));
4873 }
4874
4875 angle = nearAngle(angleBottom, startAngle, endAngle, clockwise);
4876 if (angle === angleBottom) {
4877 points.push(circlePoint(cx, cy, r, angleBottom));
4878 }
4879
4880 angle = nearAngle(angleLeft, startAngle, endAngle, clockwise);
4881 if (angle === angleLeft) {
4882 points.push(circlePoint(cx, cy, r, angleLeft));
4883 }
4884
4885 angle = nearAngle(angleTop, startAngle, endAngle, clockwise);
4886 if (angle === angleTop) {
4887 points.push(circlePoint(cx, cy, r, angleTop));
4888 }
4889
4890 points.push(circlePoint(cx, cy, r, startAngle));
4891 points.push(circlePoint(cx, cy, r, endAngle));
4892 var minX = Infinity;
4893 var maxX = -Infinity;
4894 var minY = Infinity;
4895 var maxY = -Infinity;
4896 Util.each(points, function (point) {
4897 if (minX > point.x) {
4898 minX = point.x;
4899 }
4900 if (maxX < point.x) {
4901 maxX = point.x;
4902 }
4903 if (minY > point.y) {
4904 minY = point.y;
4905 }
4906 if (maxY < point.y) {
4907 maxY = point.y;
4908 }
4909 });
4910
4911 return {
4912 minX: minX,
4913 minY: minY,
4914 maxX: maxX,
4915 maxY: maxY
4916 };
4917}
4918
4919module.exports = {
4920 nearAngle: nearAngle,
4921 projectPoint: function projectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y) {
4922 var rst = {};
4923 arcProjectPoint(cx, cy, r, startAngle, endAngle, clockwise, x, y, rst);
4924 return rst;
4925 },
4926
4927 pointDistance: arcProjectPoint,
4928 box: arcBox
4929};
4930
4931/***/ }),
4932/* 25 */
4933/***/ (function(module, exports, __webpack_require__) {
4934
4935var Util = __webpack_require__(0);
4936var Shape = __webpack_require__(1);
4937var Inside = __webpack_require__(3);
4938
4939var Rect = function Rect(cfg) {
4940 Rect.superclass.constructor.call(this, cfg);
4941};
4942
4943Rect.ATTRS = {
4944 x: 0,
4945 y: 0,
4946 width: 0,
4947 height: 0,
4948 radius: 0,
4949 lineWidth: 1
4950};
4951
4952Util.extend(Rect, Shape);
4953
4954Util.augment(Rect, {
4955 canFill: true,
4956 canStroke: true,
4957 type: 'rect',
4958 getDefaultAttrs: function getDefaultAttrs() {
4959 return {
4960 lineWidth: 1,
4961 radius: 0
4962 };
4963 },
4964 calculateBox: function calculateBox() {
4965 var self = this;
4966 var attrs = self.__attrs;
4967 var x = attrs.x;
4968 var y = attrs.y;
4969 var width = attrs.width;
4970 var height = attrs.height;
4971 var lineWidth = this.getHitLineWidth();
4972
4973 var halfWidth = lineWidth / 2;
4974 return {
4975 minX: x - halfWidth,
4976 minY: y - halfWidth,
4977 maxX: x + width + halfWidth,
4978 maxY: y + height + halfWidth
4979 };
4980 },
4981 isPointInPath: function isPointInPath(x, y) {
4982 var self = this;
4983 var fill = self.hasFill();
4984 var stroke = self.hasStroke();
4985
4986 if (fill && stroke) {
4987 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
4988 }
4989
4990 if (fill) {
4991 return self._isPointInFill(x, y);
4992 }
4993
4994 if (stroke) {
4995 return self._isPointInStroke(x, y);
4996 }
4997
4998 return false;
4999 },
5000 _isPointInFill: function _isPointInFill(x, y) {
5001 var context = this.get('context');
5002
5003 if (!context) return false;
5004 this.createPath();
5005 return context.isPointInPath(x, y);
5006 },
5007 _isPointInStroke: function _isPointInStroke(x, y) {
5008 var self = this;
5009 var attrs = self.__attrs;
5010 var rx = attrs.x;
5011 var ry = attrs.y;
5012 var width = attrs.width;
5013 var height = attrs.height;
5014 var radius = attrs.radius;
5015 var lineWidth = this.getHitLineWidth();
5016
5017 if (radius === 0) {
5018 var halfWidth = lineWidth / 2;
5019 return Inside.line(rx - halfWidth, ry, rx + width + halfWidth, ry, lineWidth, x, y) || Inside.line(rx + width, ry - halfWidth, rx + width, ry + height + halfWidth, lineWidth, x, y) || Inside.line(rx + width + halfWidth, ry + height, rx - halfWidth, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height + halfWidth, rx, ry - halfWidth, lineWidth, x, y);
5020 }
5021
5022 return Inside.line(rx + radius, ry, rx + width - radius, ry, lineWidth, x, y) || Inside.line(rx + width, ry + radius, rx + width, ry + height - radius, lineWidth, x, y) || Inside.line(rx + width - radius, ry + height, rx + radius, ry + height, lineWidth, x, y) || Inside.line(rx, ry + height - radius, rx, ry + radius, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + radius, radius, 1.5 * Math.PI, 2 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + width - radius, ry + height - radius, radius, 0, 0.5 * Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + height - radius, radius, 0.5 * Math.PI, Math.PI, false, lineWidth, x, y) || Inside.arcline(rx + radius, ry + radius, radius, Math.PI, 1.5 * Math.PI, false, lineWidth, x, y);
5023 },
5024 createPath: function createPath(context) {
5025 var self = this;
5026 var attrs = self.__attrs;
5027 var x = attrs.x;
5028 var y = attrs.y;
5029 var width = attrs.width;
5030 var height = attrs.height;
5031 var radius = attrs.radius;
5032 context = context || self.get('context');
5033
5034 context.beginPath();
5035 if (radius === 0) {
5036 // 改成原生的rect方法
5037 context.rect(x, y, width, height);
5038 } else {
5039 context.moveTo(x + radius, y);
5040 context.lineTo(x + width - radius, y);
5041 context.arc(x + width - radius, y + radius, radius, -Math.PI / 2, 0, false);
5042 context.lineTo(x + width, y + height - radius);
5043 context.arc(x + width - radius, y + height - radius, radius, 0, Math.PI / 2, false);
5044 context.lineTo(x + radius, y + height);
5045 context.arc(x + radius, y + height - radius, radius, Math.PI / 2, Math.PI, false);
5046 context.lineTo(x, y + radius);
5047 context.arc(x + radius, y + radius, radius, Math.PI, Math.PI * 3 / 2, false);
5048 context.closePath();
5049 }
5050 }
5051});
5052
5053module.exports = Rect;
5054
5055/***/ }),
5056/* 26 */
5057/***/ (function(module, exports, __webpack_require__) {
5058
5059var Util = __webpack_require__(0);
5060var Inside = __webpack_require__(3);
5061var Cubic = __webpack_require__(12);
5062var Quadratic = __webpack_require__(23);
5063var Ellipse = __webpack_require__(115);
5064var vec3 = __webpack_require__(2).vec3;
5065var mat3 = __webpack_require__(2).mat3;
5066
5067var ARR_CMD = ['m', 'l', 'c', 'a', 'q', 'h', 'v', 't', 's', 'z'];
5068
5069function toAbsolute(x, y, curPoint) {
5070 // 获取绝对坐标
5071 return {
5072 x: curPoint.x + x,
5073 y: curPoint.y + y
5074 };
5075}
5076
5077function toSymmetry(point, center) {
5078 // 点对称
5079 return {
5080 x: center.x + (center.x - point.x),
5081 y: center.y + (center.y - point.y)
5082 };
5083}
5084
5085function vMag(v) {
5086 return Math.sqrt(v[0] * v[0] + v[1] * v[1]);
5087}
5088
5089function vRatio(u, v) {
5090 return (u[0] * v[0] + u[1] * v[1]) / (vMag(u) * vMag(v));
5091}
5092
5093function vAngle(u, v) {
5094 return (u[0] * v[1] < u[1] * v[0] ? -1 : 1) * Math.acos(vRatio(u, v));
5095}
5096
5097function getArcParams(point1, point2, fa, fs, rx, ry, psiDeg) {
5098 var psi = Util.mod(Util.toRadian(psiDeg), Math.PI * 2);
5099 var x1 = point1.x;
5100 var y1 = point1.y;
5101 var x2 = point2.x;
5102 var y2 = point2.y;
5103 var xp = Math.cos(psi) * (x1 - x2) / 2.0 + Math.sin(psi) * (y1 - y2) / 2.0;
5104 var yp = -1 * Math.sin(psi) * (x1 - x2) / 2.0 + Math.cos(psi) * (y1 - y2) / 2.0;
5105 var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
5106 if (lambda > 1) {
5107 rx *= Math.sqrt(lambda);
5108 ry *= Math.sqrt(lambda);
5109 }
5110 var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);
5111 var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff);
5112
5113 if (fa === fs) {
5114 f *= -1;
5115 }
5116 if (isNaN(f)) {
5117 f = 0;
5118 }
5119
5120 var cxp = f * rx * yp / ry;
5121 var cyp = f * -ry * xp / rx;
5122
5123 var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
5124 var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
5125
5126 var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);
5127 var u = [(xp - cxp) / rx, (yp - cyp) / ry];
5128 var v = [(-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry];
5129 var dTheta = vAngle(u, v);
5130 if (fs === 0 && dTheta > 0) {
5131 dTheta = dTheta - 2 * Math.PI;
5132 }
5133 if (fs === 1 && dTheta < 0) {
5134 dTheta = dTheta + 2 * Math.PI;
5135 }
5136 return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs];
5137}
5138
5139var PathSegment = function PathSegment(item, preSegment, isLast) {
5140 this.preSegment = preSegment;
5141 this.isLast = isLast;
5142 this.init(item, preSegment);
5143};
5144
5145Util.augment(PathSegment, {
5146 init: function init(item, preSegment) {
5147 var command = item[0];
5148 preSegment = preSegment || {
5149 endPoint: {
5150 x: 0,
5151 y: 0
5152 }
5153 };
5154 var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command);
5155 var cmd = relative ? command.toUpperCase() : command;
5156 var p = item;
5157 var point1 = void 0;
5158 var point2 = void 0;
5159 var point3 = void 0;
5160 var point = void 0;
5161 var preEndPoint = preSegment.endPoint;
5162
5163 var p1 = p[1];
5164 var p2 = p[2];
5165 switch (cmd) {
5166 default:
5167 break;
5168 case 'M':
5169 if (relative) {
5170 point = toAbsolute(p1, p2, preEndPoint);
5171 } else {
5172 point = {
5173 x: p1,
5174 y: p2
5175 };
5176 }
5177 this.command = 'M';
5178 this.params = [preEndPoint, point];
5179 this.subStart = point;
5180 this.endPoint = point;
5181 break;
5182 case 'L':
5183 if (relative) {
5184 point = toAbsolute(p1, p2, preEndPoint);
5185 } else {
5186 point = {
5187 x: p1,
5188 y: p2
5189 };
5190 }
5191 this.command = 'L';
5192 this.params = [preEndPoint, point];
5193 this.subStart = preSegment.subStart;
5194 this.endPoint = point;
5195 this.endTangent = function () {
5196 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
5197 };
5198 this.startTangent = function () {
5199 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
5200 };
5201 break;
5202 case 'H':
5203 if (relative) {
5204 point = toAbsolute(p1, 0, preEndPoint);
5205 } else {
5206 point = {
5207 x: p1,
5208 y: preEndPoint.y
5209 };
5210 }
5211 this.command = 'L';
5212 this.params = [preEndPoint, point];
5213 this.subStart = preSegment.subStart;
5214 this.endPoint = point;
5215 this.endTangent = function () {
5216 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
5217 };
5218 this.startTangent = function () {
5219 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
5220 };
5221 break;
5222 case 'V':
5223 if (relative) {
5224 point = toAbsolute(0, p1, preEndPoint);
5225 } else {
5226 point = {
5227 x: preEndPoint.x,
5228 y: p1
5229 };
5230 }
5231 this.command = 'L';
5232 this.params = [preEndPoint, point];
5233 this.subStart = preSegment.subStart;
5234 this.endPoint = point;
5235 this.endTangent = function () {
5236 return [point.x - preEndPoint.x, point.y - preEndPoint.y];
5237 };
5238 this.startTangent = function () {
5239 return [preEndPoint.x - point.x, preEndPoint.y - point.y];
5240 };
5241 break;
5242 case 'Q':
5243 if (relative) {
5244 point1 = toAbsolute(p1, p2, preEndPoint);
5245 point2 = toAbsolute(p[3], p[4], preEndPoint);
5246 } else {
5247 point1 = {
5248 x: p1,
5249 y: p2
5250 };
5251 point2 = {
5252 x: p[3],
5253 y: p[4]
5254 };
5255 }
5256 this.command = 'Q';
5257 this.params = [preEndPoint, point1, point2];
5258 this.subStart = preSegment.subStart;
5259 this.endPoint = point2;
5260 this.endTangent = function () {
5261 return [point2.x - point1.x, point2.y - point1.y];
5262 };
5263 this.startTangent = function () {
5264 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5265 };
5266 break;
5267 case 'T':
5268 if (relative) {
5269 point2 = toAbsolute(p1, p2, preEndPoint);
5270 } else {
5271 point2 = {
5272 x: p1,
5273 y: p2
5274 };
5275 }
5276 if (preSegment.command === 'Q') {
5277 point1 = toSymmetry(preSegment.params[1], preEndPoint);
5278 this.command = 'Q';
5279 this.params = [preEndPoint, point1, point2];
5280 this.subStart = preSegment.subStart;
5281 this.endPoint = point2;
5282 this.endTangent = function () {
5283 return [point2.x - point1.x, point2.y - point1.y];
5284 };
5285 this.startTangent = function () {
5286 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5287 };
5288 } else {
5289 this.command = 'TL';
5290 this.params = [preEndPoint, point2];
5291 this.subStart = preSegment.subStart;
5292 this.endPoint = point2;
5293 this.endTangent = function () {
5294 return [point2.x - preEndPoint.x, point2.y - preEndPoint.y];
5295 };
5296 this.startTangent = function () {
5297 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
5298 };
5299 }
5300
5301 break;
5302 case 'C':
5303 if (relative) {
5304 point1 = toAbsolute(p1, p2, preEndPoint);
5305 point2 = toAbsolute(p[3], p[4], preEndPoint);
5306 point3 = toAbsolute(p[5], p[6], preEndPoint);
5307 } else {
5308 point1 = {
5309 x: p1,
5310 y: p2
5311 };
5312 point2 = {
5313 x: p[3],
5314 y: p[4]
5315 };
5316 point3 = {
5317 x: p[5],
5318 y: p[6]
5319 };
5320 }
5321 this.command = 'C';
5322 this.params = [preEndPoint, point1, point2, point3];
5323 this.subStart = preSegment.subStart;
5324 this.endPoint = point3;
5325 this.endTangent = function () {
5326 return [point3.x - point2.x, point3.y - point2.y];
5327 };
5328 this.startTangent = function () {
5329 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5330 };
5331 break;
5332 case 'S':
5333 if (relative) {
5334 point2 = toAbsolute(p1, p2, preEndPoint);
5335 point3 = toAbsolute(p[3], p[4], preEndPoint);
5336 } else {
5337 point2 = {
5338 x: p1,
5339 y: p2
5340 };
5341 point3 = {
5342 x: p[3],
5343 y: p[4]
5344 };
5345 }
5346 if (preSegment.command === 'C') {
5347 point1 = toSymmetry(preSegment.params[2], preEndPoint);
5348 this.command = 'C';
5349 this.params = [preEndPoint, point1, point2, point3];
5350 this.subStart = preSegment.subStart;
5351 this.endPoint = point3;
5352 this.endTangent = function () {
5353 return [point3.x - point2.x, point3.y - point2.y];
5354 };
5355 this.startTangent = function () {
5356 return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
5357 };
5358 } else {
5359 this.command = 'SQ';
5360 this.params = [preEndPoint, point2, point3];
5361 this.subStart = preSegment.subStart;
5362 this.endPoint = point3;
5363 this.endTangent = function () {
5364 return [point3.x - point2.x, point3.y - point2.y];
5365 };
5366 this.startTangent = function () {
5367 return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];
5368 };
5369 }
5370 break;
5371 case 'A':
5372 {
5373 var rx = p1;
5374 var ry = p2;
5375 var psi = p[3];
5376 var fa = p[4];
5377 var fs = p[5];
5378 if (relative) {
5379 point = toAbsolute(p[6], p[7], preEndPoint);
5380 } else {
5381 point = {
5382 x: p[6],
5383 y: p[7]
5384 };
5385 }
5386
5387 this.command = 'A';
5388 var params = getArcParams(preEndPoint, point, fa, fs, rx, ry, psi);
5389 this.params = params;
5390 var start = preSegment.subStart;
5391 this.subStart = start;
5392 this.endPoint = point;
5393 var startAngle = params[5] % (Math.PI * 2);
5394 if (Util.isNumberEqual(startAngle, Math.PI * 2)) {
5395 startAngle = 0;
5396 }
5397 var endAngle = params[6] % (Math.PI * 2);
5398 if (Util.isNumberEqual(endAngle, Math.PI * 2)) {
5399 endAngle = 0;
5400 }
5401 var d = 0.001;
5402 this.startTangent = function () {
5403 if (fs === 0) {
5404 d *= -1;
5405 }
5406 var dx = params[3] * Math.cos(startAngle - d) + params[1];
5407 var dy = params[4] * Math.sin(startAngle - d) + params[2];
5408 return [dx - start.x, dy - start.y];
5409 };
5410 this.endTangent = function () {
5411 var endAngle = params[6];
5412 if (endAngle - Math.PI * 2 < 0.0001) {
5413 endAngle = 0;
5414 }
5415 var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1];
5416 var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2];
5417 return [preEndPoint.x - dx, preEndPoint.y - dy];
5418 };
5419 break;
5420 }
5421 case 'Z':
5422 {
5423 this.command = 'Z';
5424 this.params = [preEndPoint, preSegment.subStart];
5425 this.subStart = preSegment.subStart;
5426 this.endPoint = preSegment.subStart;
5427 }
5428 }
5429 },
5430 isInside: function isInside(x, y, lineWidth) {
5431 var self = this;
5432 var command = self.command;
5433 var params = self.params;
5434 var box = self.box;
5435 if (box) {
5436 if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {
5437 return false;
5438 }
5439 }
5440 switch (command) {
5441 default:
5442 break;
5443 case 'M':
5444 return false;
5445 case 'TL':
5446 case 'L':
5447 case 'Z':
5448 return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y);
5449 case 'SQ':
5450 case 'Q':
5451 return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y);
5452 case 'C':
5453 {
5454 return Inside.cubicline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, params[3].x, params[3].y, lineWidth, x, y);
5455 }
5456 case 'A':
5457 {
5458 var p = params;
5459 var cx = p[1];
5460 var cy = p[2];
5461 var rx = p[3];
5462 var ry = p[4];
5463 var theta = p[5];
5464 var dTheta = p[6];
5465 var psi = p[7];
5466 var fs = p[8];
5467
5468 var r = rx > ry ? rx : ry;
5469 var scaleX = rx > ry ? 1 : rx / ry;
5470 var scaleY = rx > ry ? ry / rx : 1;
5471
5472 p = [x, y, 1];
5473 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
5474 mat3.translate(m, m, [-cx, -cy]);
5475 mat3.rotate(m, m, -psi);
5476 mat3.scale(m, m, [1 / scaleX, 1 / scaleY]);
5477 vec3.transformMat3(p, p, m);
5478 return Inside.arcline(0, 0, r, theta, theta + dTheta, 1 - fs, lineWidth, p[0], p[1]);
5479 }
5480 }
5481 return false;
5482 },
5483 draw: function draw(context) {
5484 var command = this.command;
5485 var params = this.params;
5486 var point1 = void 0;
5487 var point2 = void 0;
5488 var point3 = void 0;
5489
5490 switch (command) {
5491 default:
5492 break;
5493 case 'M':
5494 context.moveTo(params[1].x, params[1].y);
5495 break;
5496 case 'TL':
5497 case 'L':
5498 context.lineTo(params[1].x, params[1].y);
5499 break;
5500 case 'SQ':
5501 case 'Q':
5502 point1 = params[1];
5503 point2 = params[2];
5504 context.quadraticCurveTo(point1.x, point1.y, point2.x, point2.y);
5505 break;
5506 case 'C':
5507 point1 = params[1];
5508 point2 = params[2];
5509 point3 = params[3];
5510 context.bezierCurveTo(point1.x, point1.y, point2.x, point2.y, point3.x, point3.y);
5511 break;
5512 case 'A':
5513 {
5514 var p = params;
5515 var p1 = p[1];
5516 var p2 = p[2];
5517 var cx = p1;
5518 var cy = p2;
5519 var rx = p[3];
5520 var ry = p[4];
5521 var theta = p[5];
5522 var dTheta = p[6];
5523 var psi = p[7];
5524 var fs = p[8];
5525
5526 var r = rx > ry ? rx : ry;
5527 var scaleX = rx > ry ? 1 : rx / ry;
5528 var scaleY = rx > ry ? ry / rx : 1;
5529
5530 context.translate(cx, cy);
5531 context.rotate(psi);
5532 context.scale(scaleX, scaleY);
5533 context.arc(0, 0, r, theta, theta + dTheta, 1 - fs);
5534 context.scale(1 / scaleX, 1 / scaleY);
5535 context.rotate(-psi);
5536 context.translate(-cx, -cy);
5537 break;
5538 }
5539 case 'Z':
5540 context.closePath();
5541 break;
5542 }
5543 },
5544 getBBox: function getBBox(lineWidth) {
5545 var halfWidth = lineWidth / 2;
5546 var params = this.params;
5547 var yDims = void 0;
5548 var xDims = void 0;
5549 var i = void 0;
5550 var l = void 0;
5551
5552 switch (this.command) {
5553 default:
5554 case 'M':
5555 case 'Z':
5556 break;
5557 case 'TL':
5558 case 'L':
5559 this.box = {
5560 minX: Math.min(params[0].x, params[1].x) - halfWidth,
5561 maxX: Math.max(params[0].x, params[1].x) + halfWidth,
5562 minY: Math.min(params[0].y, params[1].y) - halfWidth,
5563 maxY: Math.max(params[0].y, params[1].y) + halfWidth
5564 };
5565 break;
5566 case 'SQ':
5567 case 'Q':
5568 xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x);
5569 for (i = 0, l = xDims.length; i < l; i++) {
5570 xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]);
5571 }
5572 xDims.push(params[0].x, params[2].x);
5573 yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y);
5574 for (i = 0, l = yDims.length; i < l; i++) {
5575 yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims);
5576 }
5577 yDims.push(params[0].y, params[2].y);
5578 this.box = {
5579 minX: Math.min.apply(Math, xDims) - halfWidth,
5580 maxX: Math.max.apply(Math, xDims) + halfWidth,
5581 minY: Math.min.apply(Math, yDims) - halfWidth,
5582 maxY: Math.max.apply(Math, yDims) + halfWidth
5583 };
5584 break;
5585 case 'C':
5586 xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x);
5587 for (i = 0, l = xDims.length; i < l; i++) {
5588 xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]);
5589 }
5590 yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y);
5591 for (i = 0, l = yDims.length; i < l; i++) {
5592 yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]);
5593 }
5594 xDims.push(params[0].x, params[3].x);
5595 yDims.push(params[0].y, params[3].y);
5596 this.box = {
5597 minX: Math.min.apply(Math, xDims) - halfWidth,
5598 maxX: Math.max.apply(Math, xDims) + halfWidth,
5599 minY: Math.min.apply(Math, yDims) - halfWidth,
5600 maxY: Math.max.apply(Math, yDims) + halfWidth
5601 };
5602 break;
5603 case 'A':
5604 {
5605 // todo 待优化
5606 var p = params;
5607 var cx = p[1];
5608 var cy = p[2];
5609 var rx = p[3];
5610 var ry = p[4];
5611 var theta = p[5];
5612 var dTheta = p[6];
5613 var psi = p[7];
5614 var fs = p[8];
5615 var start = theta;
5616 var end = theta + dTheta;
5617
5618 var xDim = Ellipse.xExtrema(psi, rx, ry);
5619 var minX = Infinity;
5620 var maxX = -Infinity;
5621 var xs = [start, end];
5622 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
5623 var xAngle = xDim + i;
5624 if (fs === 1) {
5625 if (start < xAngle && xAngle < end) {
5626 xs.push(xAngle);
5627 }
5628 } else {
5629 if (end < xAngle && xAngle < start) {
5630 xs.push(xAngle);
5631 }
5632 }
5633 }
5634
5635 for (i = 0, l = xs.length; i < l; i++) {
5636 var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]);
5637 if (x < minX) {
5638 minX = x;
5639 }
5640 if (x > maxX) {
5641 maxX = x;
5642 }
5643 }
5644
5645 var yDim = Ellipse.yExtrema(psi, rx, ry);
5646 var minY = Infinity;
5647 var maxY = -Infinity;
5648 var ys = [start, end];
5649 for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
5650 var yAngle = yDim + i;
5651 if (fs === 1) {
5652 if (start < yAngle && yAngle < end) {
5653 ys.push(yAngle);
5654 }
5655 } else {
5656 if (end < yAngle && yAngle < start) {
5657 ys.push(yAngle);
5658 }
5659 }
5660 }
5661
5662 for (i = 0, l = ys.length; i < l; i++) {
5663 var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]);
5664 if (y < minY) {
5665 minY = y;
5666 }
5667 if (y > maxY) {
5668 maxY = y;
5669 }
5670 }
5671 this.box = {
5672 minX: minX - halfWidth,
5673 maxX: maxX + halfWidth,
5674 minY: minY - halfWidth,
5675 maxY: maxY + halfWidth
5676 };
5677 break;
5678 }
5679 }
5680 }
5681});
5682
5683module.exports = PathSegment;
5684
5685/***/ }),
5686/* 27 */
5687/***/ (function(module, exports, __webpack_require__) {
5688
5689var Util = __webpack_require__(0);
5690var Shape = __webpack_require__(1);
5691var Inside = __webpack_require__(3);
5692var Format = __webpack_require__(21);
5693var PathSegment = __webpack_require__(26);
5694
5695var Marker = function Marker(cfg) {
5696 Marker.superclass.constructor.call(this, cfg);
5697};
5698
5699Marker.Symbols = {
5700 // 圆
5701 circle: function circle(x, y, r) {
5702 return [['M', x, y], ['m', -r, 0], ['a', r, r, 0, 1, 0, r * 2, 0], ['a', r, r, 0, 1, 0, -r * 2, 0]];
5703 },
5704
5705 // 正方形
5706 square: function square(x, y, r) {
5707 return [['M', x - r, y - r], ['L', x + r, y - r], ['L', x + r, y + r], ['L', x - r, y + r], ['Z']];
5708 },
5709
5710 // 菱形
5711 diamond: function diamond(x, y, r) {
5712 return [['M', x - r, y], ['L', x, y - r], ['L', x + r, y], ['L', x, y + r], ['Z']];
5713 },
5714
5715 // 三角形
5716 triangle: function triangle(x, y, r) {
5717 var diffY = r * Math.sin(1 / 3 * Math.PI);
5718 return [['M', x - r, y + diffY], ['L', x, y - diffY], ['L', x + r, y + diffY], ['z']];
5719 },
5720
5721 // 倒三角形
5722 'triangle-down': function triangleDown(x, y, r) {
5723 var diffY = r * Math.sin(1 / 3 * Math.PI);
5724 return [['M', x - r, y - diffY], ['L', x + r, y - diffY], ['L', x, y + diffY], ['Z']];
5725 }
5726};
5727
5728Marker.ATTRS = {
5729 path: null,
5730 lineWidth: 1
5731};
5732
5733Util.extend(Marker, Shape);
5734
5735Util.augment(Marker, {
5736 type: 'marker',
5737 canFill: true,
5738 canStroke: true,
5739 getDefaultAttrs: function getDefaultAttrs() {
5740 return {
5741 x: 0,
5742 y: 0,
5743 lineWidth: 1
5744 };
5745 },
5746 calculateBox: function calculateBox() {
5747 var attrs = this.__attrs;
5748 var cx = attrs.x;
5749 var cy = attrs.y;
5750 var r = attrs.radius;
5751 var lineWidth = this.getHitLineWidth();
5752 var halfWidth = lineWidth / 2 + r;
5753 return {
5754 minX: cx - halfWidth,
5755 minY: cy - halfWidth,
5756 maxX: cx + halfWidth,
5757 maxY: cy + halfWidth
5758 };
5759 },
5760 isPointInPath: function isPointInPath(x, y) {
5761 var attrs = this.__attrs;
5762 var cx = attrs.x;
5763 var cy = attrs.y;
5764 var r = attrs.radius || attrs.r;
5765 var lineWidth = this.getHitLineWidth();
5766 return Inside.circle(cx, cy, r + lineWidth / 2, x, y);
5767 },
5768 createPath: function createPath(context) {
5769 var attrs = this.__attrs;
5770 var x = attrs.x;
5771 var y = attrs.y;
5772 var r = attrs.radius || attrs.r;
5773 var symbol = attrs.symbol || 'circle';
5774 var method = void 0;
5775 if (Util.isFunction(symbol)) {
5776 method = symbol;
5777 } else {
5778 method = Marker.Symbols[symbol];
5779 }
5780 var path = method(x, y, r);
5781 path = Format.parsePath(path);
5782 context.beginPath();
5783 var preSegment = void 0;
5784 for (var i = 0; i < path.length; i++) {
5785 var item = path[i];
5786 preSegment = new PathSegment(item, preSegment, i === path.length - 1);
5787 preSegment.draw(context);
5788 }
5789 }
5790});
5791
5792module.exports = Marker;
5793
5794/***/ }),
5795/* 28 */
5796/***/ (function(module, exports, __webpack_require__) {
5797
5798module.exports = {
5799 // renderers
5800 svg: __webpack_require__(69),
5801 canvas: __webpack_require__(110),
5802 // utils
5803 CommonUtil: __webpack_require__(7),
5804 DomUtil: __webpack_require__(29),
5805 MatrixUtil: __webpack_require__(2),
5806 PathUtil: __webpack_require__(15),
5807 // version, etc.
5808 version: '3.0.0-beta.4'
5809};
5810
5811/***/ }),
5812/* 29 */
5813/***/ (function(module, exports, __webpack_require__) {
5814
5815var Util = __webpack_require__(7);
5816
5817var TABLE = document.createElement('table');
5818var TABLE_TR = document.createElement('tr');
5819var FRAGMENT_REG = /^\s*<(\w+|!)[^>]*>/;
5820var CONTAINERS = {
5821 tr: document.createElement('tbody'),
5822 tbody: TABLE,
5823 thead: TABLE,
5824 tfoot: TABLE,
5825 td: TABLE_TR,
5826 th: TABLE_TR,
5827 '*': document.createElement('div')
5828};
5829
5830module.exports = {
5831 getBoundingClientRect: function getBoundingClientRect(node, defaultValue) {
5832 if (node && node.getBoundingClientRect) {
5833 var rect = node.getBoundingClientRect();
5834 var top = document.documentElement.clientTop;
5835 var left = document.documentElement.clientLeft;
5836 return {
5837 top: rect.top - top,
5838 bottom: rect.bottom - top,
5839 left: rect.left - left,
5840 right: rect.right - left
5841 };
5842 }
5843 return defaultValue || null;
5844 },
5845
5846 /**
5847 * 获取样式
5848 * @param {Object} dom DOM节点
5849 * @param {String} name 样式名
5850 * @param {Any} defaultValue 默认值
5851 * @return {String} 属性值
5852 */
5853 getStyle: function getStyle(dom, name, defaultValue) {
5854 try {
5855 if (window.getComputedStyle) {
5856 return window.getComputedStyle(dom, null)[name];
5857 }
5858 return dom.currentStyle[name];
5859 } catch (e) {
5860 if (!Util.isNil(defaultValue)) {
5861 return defaultValue;
5862 }
5863 return null;
5864 }
5865 },
5866 modifyCSS: function modifyCSS(dom, css) {
5867 if (dom) {
5868 for (var key in css) {
5869 if (css.hasOwnProperty(key)) {
5870 dom.style[key] = css[key];
5871 }
5872 }
5873 }
5874 return dom;
5875 },
5876
5877 /**
5878 * 创建DOM 节点
5879 * @param {String} str Dom 字符串
5880 * @return {HTMLElement} DOM 节点
5881 */
5882 createDom: function createDom(str) {
5883 var name = FRAGMENT_REG.test(str) && RegExp.$1;
5884 if (!(name in CONTAINERS)) {
5885 name = '*';
5886 }
5887 var container = CONTAINERS[name];
5888 str = str.replace(/(^\s*)|(\s*$)/g, '');
5889 container.innerHTML = '' + str;
5890 var dom = container.childNodes[0];
5891 container.removeChild(dom);
5892 return dom;
5893 },
5894 getRatio: function getRatio() {
5895 return window.devicePixelRatio ? window.devicePixelRatio : 2;
5896 },
5897
5898 /**
5899 * 获取宽度
5900 * @param {HTMLElement} el dom节点
5901 * @param {Number} defaultValue 默认值
5902 * @return {Number} 宽度
5903 */
5904 getWidth: function getWidth(el, defaultValue) {
5905 var width = this.getStyle(el, 'width', defaultValue);
5906 if (width === 'auto') {
5907 width = el.offsetWidth;
5908 }
5909 return parseFloat(width);
5910 },
5911
5912 /**
5913 * 获取高度
5914 * @param {HTMLElement} el dom节点
5915 * @param {Number} defaultValue 默认值
5916 * @return {Number} 高度
5917 */
5918 getHeight: function getHeight(el, defaultValue) {
5919 var height = this.getStyle(el, 'height', defaultValue);
5920 if (height === 'auto') {
5921 height = el.offsetHeight;
5922 }
5923 return parseFloat(height);
5924 },
5925
5926 /**
5927 * 获取外层高度
5928 * @param {HTMLElement} el dom节点
5929 * @param {Number} defaultValue 默认值
5930 * @return {Number} 高度
5931 */
5932 getOuterHeight: function getOuterHeight(el, defaultValue) {
5933 var height = this.getHeight(el, defaultValue);
5934 var bTop = parseFloat(this.getStyle(el, 'borderTopWidth')) || 0;
5935 var pTop = parseFloat(this.getStyle(el, 'paddingTop')) || 0;
5936 var pBottom = parseFloat(this.getStyle(el, 'paddingBottom')) || 0;
5937 var bBottom = parseFloat(this.getStyle(el, 'borderBottomWidth')) || 0;
5938 return height + bTop + bBottom + pTop + pBottom;
5939 },
5940
5941 /**
5942 * 获取外层宽度
5943 * @param {HTMLElement} el dom节点
5944 * @param {Number} defaultValue 默认值
5945 * @return {Number} 宽度
5946 */
5947 getOuterWidth: function getOuterWidth(el, defaultValue) {
5948 var width = this.getWidth(el, defaultValue);
5949 var bLeft = parseFloat(this.getStyle(el, 'borderLeftWidth')) || 0;
5950 var pLeft = parseFloat(this.getStyle(el, 'paddingLeft')) || 0;
5951 var pRight = parseFloat(this.getStyle(el, 'paddingRight')) || 0;
5952 var bRight = parseFloat(this.getStyle(el, 'borderRightWidth')) || 0;
5953 return width + bLeft + bRight + pLeft + pRight;
5954 },
5955
5956 /**
5957 * 添加事件监听器
5958 * @param {Object} target DOM对象
5959 * @param {String} eventType 事件名
5960 * @param {Funtion} callback 回调函数
5961 * @return {Object} 返回对象
5962 */
5963 addEventListener: function addEventListener(target, eventType, callback) {
5964 if (target) {
5965 if (target.addEventListener) {
5966 target.addEventListener(eventType, callback, false);
5967 return {
5968 remove: function remove() {
5969 target.removeEventListener(eventType, callback, false);
5970 }
5971 };
5972 } else if (target.attachEvent) {
5973 target.attachEvent('on' + eventType, callback);
5974 return {
5975 remove: function remove() {
5976 target.detachEvent('on' + eventType, callback);
5977 }
5978 };
5979 }
5980 }
5981 },
5982 requestAnimationFrame: function requestAnimationFrame(fn) {
5983 var method = window.requestAnimationFrame || window.webkitRequestAnimationFrame || function (fn) {
5984 return setTimeout(fn, 16);
5985 };
5986
5987 return method(fn);
5988 }
5989};
5990
5991/***/ }),
5992/* 30 */
5993/***/ (function(module, exports, __webpack_require__) {
5994
5995var Util = __webpack_require__(0);
5996
5997var Event = function Event(type, event, bubbles, cancelable) {
5998 this.type = type; // 事件类型
5999 this.target = null; // 目标
6000 this.currentTarget = null; // 当前目标
6001 this.bubbles = bubbles; // 冒泡
6002 this.cancelable = cancelable; // 是否能够阻止
6003 this.timeStamp = new Date().getTime(); // 时间戳
6004 this.defaultPrevented = false; // 阻止默认
6005 this.propagationStopped = false; // 阻止冒泡
6006 this.removed = false; // 是否被移除
6007 this.event = event; // 触发的原生事件
6008};
6009
6010Util.augment(Event, {
6011 preventDefault: function preventDefault() {
6012 this.defaultPrevented = this.cancelable && true;
6013 },
6014 stopPropagation: function stopPropagation() {
6015 this.propagationStopped = true;
6016 },
6017 remove: function remove() {
6018 this.remove = true;
6019 },
6020 clone: function clone() {
6021 return Util.clone(this);
6022 },
6023 toString: function toString() {
6024 return '[Event (type=' + this.type + ')]';
6025 }
6026});
6027
6028module.exports = Event;
6029
6030/***/ }),
6031/* 31 */
6032/***/ (function(module, exports, __webpack_require__) {
6033
6034var Util = __webpack_require__(0);
6035var Element = __webpack_require__(13);
6036var Shape = __webpack_require__(104);
6037
6038var SHAPE_MAP = {}; // 缓存图形类型
6039var INDEX = '_INDEX';
6040
6041function getComparer(compare) {
6042 return function (left, right) {
6043 var result = compare(left, right);
6044 return result === 0 ? left[INDEX] - right[INDEX] : result;
6045 };
6046}
6047
6048var Group = function Group(cfg) {
6049 Group.superclass.constructor.call(this, cfg);
6050 this.set('children', []);
6051
6052 this._beforeRenderUI();
6053 this._renderUI();
6054 this._bindUI();
6055};
6056
6057function initClassCfgs(c) {
6058 if (c.__cfg || c === Group) {
6059 return;
6060 }
6061 var superCon = c.superclass.constructor;
6062 if (superCon && !superCon.__cfg) {
6063 initClassCfgs(superCon);
6064 }
6065 c.__cfg = {};
6066
6067 Util.merge(c.__cfg, superCon.__cfg);
6068 Util.merge(c.__cfg, c.CFG);
6069}
6070
6071Util.extend(Group, Element);
6072
6073Util.augment(Group, {
6074 isGroup: true,
6075 canFill: true,
6076 canStroke: true,
6077 init: function init(id) {
6078 Group.superclass.init.call(this);
6079 var shape = document.createElementNS('http://www.w3.org/2000/svg', 'g');
6080 id = id || Util.uniqueId('g_');
6081 shape.setAttribute('id', id);
6082 this.setSilent('el', shape);
6083 this.setSilent('id', id);
6084 },
6085 getDefaultCfg: function getDefaultCfg() {
6086 initClassCfgs(this.constructor);
6087 return Util.merge({}, this.constructor.__cfg);
6088 },
6089 _beforeRenderUI: function _beforeRenderUI() {},
6090 _renderUI: function _renderUI() {},
6091 _bindUI: function _bindUI() {},
6092 addShape: function addShape(type, cfg) {
6093 var canvas = this.get('canvas');
6094 cfg = cfg || {};
6095 var shapeType = SHAPE_MAP[type];
6096 if (!shapeType) {
6097 shapeType = Util.upperFirst(type);
6098 SHAPE_MAP[type] = shapeType;
6099 }
6100 if (cfg.attrs) {
6101 var attrs = cfg.attrs;
6102 if (type === 'text') {
6103 // 临时解决
6104 var topFontFamily = canvas.get('fontFamily');
6105 if (topFontFamily) {
6106 attrs.fontFamily = attrs.fontFamily || topFontFamily;
6107 }
6108 }
6109 }
6110 cfg.canvas = canvas;
6111 cfg.defs = this.get('defs');
6112 cfg.type = type;
6113 var shape = Shape[shapeType];
6114 if (!shape) {
6115 throw new TypeError('the shape ' + shapeType + ' is not supported by svg version, use canvas instead');
6116 }
6117 var rst = new shape(cfg);
6118 this.add(rst);
6119 return rst;
6120 },
6121
6122 /** 添加图组
6123 * @param {Function|Object|undefined} param 图组类
6124 * @param {Object} cfg 配置项
6125 * @return {Object} rst 图组
6126 */
6127 addGroup: function addGroup(param, cfg) {
6128 var canvas = this.get('canvas');
6129 var rst = void 0;
6130 cfg = Util.merge({}, cfg);
6131 if (Util.isFunction(param)) {
6132 if (cfg) {
6133 cfg.canvas = canvas;
6134 cfg.parent = this;
6135 rst = new param(cfg);
6136 } else {
6137 rst = new param({
6138 canvas: canvas,
6139 parent: this
6140 });
6141 }
6142 this.add(rst);
6143 } else if (Util.isObject(param)) {
6144 param.canvas = canvas;
6145 rst = new Group(param);
6146 this.add(rst);
6147 } else if (param === undefined) {
6148 rst = new Group();
6149 this.add(rst);
6150 } else {
6151 return false;
6152 }
6153 return rst;
6154 },
6155
6156 /** 绘制背景
6157 * @param {Array} padding 内边距
6158 * @param {Attrs} attrs 图形属性
6159 * @param {Shape} backShape 背景图形
6160 * @return {Object} 背景层对象
6161 */
6162 renderBack: function renderBack(padding, attrs) {
6163 var backShape = this.get('backShape');
6164 var innerBox = this.getBBox();
6165 // const parent = this.get('parent'); // getParent
6166 Util.merge(attrs, {
6167 x: innerBox.minX - padding[3],
6168 y: innerBox.minY - padding[0],
6169 width: innerBox.width + padding[1] + padding[3],
6170 height: innerBox.height + padding[0] + padding[2]
6171 });
6172 if (backShape) {
6173 backShape.attr(attrs);
6174 } else {
6175 backShape = this.addShape('rect', {
6176 zIndex: -1,
6177 attrs: attrs
6178 });
6179 }
6180 this.set('backShape', backShape);
6181 this.sort();
6182 return backShape;
6183 },
6184 removeChild: function removeChild(item, destroy) {
6185 if (arguments.length >= 2) {
6186 if (this.contain(item)) {
6187 item.remove(destroy);
6188 }
6189 } else {
6190 if (arguments.length === 1) {
6191 if (Util.isBoolean(item)) {
6192 destroy = item;
6193 } else {
6194 if (this.contain(item)) {
6195 item.remove(true);
6196 }
6197 return this;
6198 }
6199 }
6200 if (arguments.length === 0) {
6201 destroy = true;
6202 }
6203
6204 Group.superclass.remove.call(this, destroy);
6205 }
6206 return this;
6207 },
6208
6209 /**
6210 * 向组中添加shape或者group
6211 * @param {Object} items 图形或者分组
6212 * @return {Object} group 本尊
6213 */
6214 add: function add(items) {
6215 var self = this;
6216 var children = self.get('children');
6217 var el = self.get('el');
6218 if (Util.isArray(items)) {
6219 Util.each(items, function (item) {
6220 var parent = item.get('parent');
6221 if (parent) {
6222 parent.removeChild(item, false);
6223 }
6224 if (item.get('dependencies')) {
6225 self._addDependency(item);
6226 }
6227 self._setEvn(item);
6228 el.appendChild(item.get('el'));
6229 });
6230 children.push.apply(children, items);
6231 } else {
6232 var item = items;
6233 var parent = item.get('parent');
6234 if (parent) {
6235 parent.removeChild(item, false);
6236 }
6237 self._setEvn(item);
6238 if (item.get('dependencies')) {
6239 self._addDependency(item);
6240 }
6241 el.appendChild(item.get('el'));
6242 children.push(item);
6243 }
6244 return self;
6245 },
6246 contain: function contain(item) {
6247 var children = this.get('children');
6248 return children.indexOf(item) > -1;
6249 },
6250 getChildByIndex: function getChildByIndex(index) {
6251 var children = this.get('children');
6252 return children[index];
6253 },
6254 getFirst: function getFirst() {
6255 return this.getChildByIndex(0);
6256 },
6257 getLast: function getLast() {
6258 var lastIndex = this.get('children').length - 1;
6259 return this.getChildByIndex(lastIndex);
6260 },
6261 _addDependency: function _addDependency(item) {
6262 var dependencies = item.get('dependencies');
6263 item.attr(dependencies);
6264 item.__cfg.dependencies = {};
6265 },
6266 _setEvn: function _setEvn(item) {
6267 var self = this;
6268 item.__cfg.parent = self;
6269 item.__cfg.parent = self;
6270 item.__cfg.canvas = self.__cfg.canvas;
6271 item.__cfg.defs = self.__cfg.defs;
6272 var clip = item.__attrs.clip;
6273 if (clip) {
6274 clip.setSilent('parent', self);
6275 clip.setSilent('context', self.get('context'));
6276 }
6277 var children = item.__cfg.children;
6278 if (children) {
6279 Util.each(children, function (child) {
6280 item._setEvn(child);
6281 });
6282 }
6283 },
6284 getCount: function getCount() {
6285 return this.get('children').length;
6286 },
6287 sort: function sort() {
6288 var children = this.get('children');
6289 // 稳定排序
6290 Util.each(children, function (child, index) {
6291 child[INDEX] = index;
6292 return child;
6293 });
6294
6295 children.sort(getComparer(function (obj1, obj2) {
6296 return obj1.get('zIndex') - obj2.get('zIndex');
6297 }));
6298
6299 return this;
6300 },
6301 findById: function findById(id) {
6302 return this.find(function (item) {
6303 return item.get('id') === id;
6304 });
6305 },
6306
6307 /**
6308 * 根据查找函数查找分组或者图形
6309 * @param {Function} fn 匹配函数
6310 * @return {Canvas.Base} 分组或者图形
6311 */
6312 find: function find(fn) {
6313 if (Util.isString(fn)) {
6314 return this.findById(fn);
6315 }
6316 var children = this.get('children');
6317 var rst = null;
6318
6319 Util.each(children, function (item) {
6320 if (fn(item)) {
6321 rst = item;
6322 } else if (item.find) {
6323 rst = item.find(fn);
6324 }
6325 if (rst) {
6326 return false;
6327 }
6328 });
6329 return rst;
6330 },
6331
6332 /**
6333 * @param {Function} fn filter mathod
6334 * @return {Array} all the matching shapes and groups
6335 */
6336 findAll: function findAll(fn) {
6337 var children = this.get('children');
6338 var rst = [];
6339 var childRst = [];
6340 Util.each(children, function (item) {
6341 if (fn(item)) {
6342 rst.push(item);
6343 }
6344 if (item.findAllBy) {
6345 childRst = item.findAllBy(fn);
6346 rst = rst.concat(childRst);
6347 }
6348 });
6349 return rst;
6350 },
6351
6352 /**
6353 * @Deprecated
6354 * @param {Function} fn filter method
6355 * @return {Object} found shape or group
6356 */
6357 findBy: function findBy(fn) {
6358 var children = this.get('children');
6359 var rst = null;
6360
6361 Util.each(children, function (item) {
6362 if (fn(item)) {
6363 rst = item;
6364 } else if (item.findBy) {
6365 rst = item.findBy(fn);
6366 }
6367 if (rst) {
6368 return false;
6369 }
6370 });
6371 return rst;
6372 },
6373
6374 /**
6375 * @Deprecated
6376 * @param {Function} fn filter mathod
6377 * @return {Array} all the matching shapes and groups
6378 */
6379 findAllBy: function findAllBy(fn) {
6380 var children = this.get('children');
6381 var rst = [];
6382 var childRst = [];
6383 Util.each(children, function (item) {
6384 if (fn(item)) {
6385 rst.push(item);
6386 }
6387 if (item.findAllBy) {
6388 childRst = item.findAllBy(fn);
6389 rst = rst.concat(childRst);
6390 }
6391 });
6392 return rst;
6393 },
6394
6395 // svg不进行拾取,仅保留接口
6396 getShape: function getShape() {
6397 return null;
6398 },
6399
6400 /**
6401 * 根据点击事件的element获取对应的图形对象
6402 * @param {Object} el 点击的dom元素
6403 * @return {Object} 对应图形对象
6404 */
6405 findShape: function findShape(el) {
6406 if (this.__cfg.visible && this.__cfg.capture && this.get('el') === el) {
6407 return this;
6408 }
6409 var children = this.__cfg.children;
6410 var shape = null;
6411 for (var i = children.length - 1; i >= 0; i--) {
6412 var child = children[i];
6413 if (child.isGroup) {
6414 shape = child.findShape(el);
6415 shape = child.findShape(el);
6416 } else if (child.get('visible') && child.get('el') === el) {
6417 shape = child;
6418 }
6419 if (shape) {
6420 break;
6421 }
6422 }
6423 return shape;
6424 },
6425 clearTotalMatrix: function clearTotalMatrix() {
6426 var m = this.get('totalMatrix');
6427 if (m) {
6428 this.setSilent('totalMatrix', null);
6429 var children = this.__cfg.children;
6430 for (var i = 0; i < children.length; i++) {
6431 var child = children[i];
6432 child.clearTotalMatrix();
6433 }
6434 }
6435 },
6436 clear: function clear() {
6437 var children = this.get('children');
6438
6439 while (children.length !== 0) {
6440 children[children.length - 1].remove();
6441 }
6442 return this;
6443 },
6444 destroy: function destroy() {
6445 if (this.get('destroyed')) {
6446 return;
6447 }
6448 this.clear();
6449 Group.superclass.destroy.call(this);
6450 }
6451});
6452
6453module.exports = Group;
6454
6455/***/ }),
6456/* 32 */
6457/***/ (function(module, exports, __webpack_require__) {
6458
6459var MatrixUtil = __webpack_require__(2);
6460var PathUtil = __webpack_require__(15);
6461var Util = __webpack_require__(0);
6462var d3Ease = __webpack_require__(77);
6463var d3Timer = __webpack_require__(88);
6464
6465var _require = __webpack_require__(91),
6466 interpolate = _require.interpolate,
6467 interpolateArray = _require.interpolateArray; // 目前整体动画只需要数值和数组的差值计算
6468
6469
6470var ReservedProps = {
6471 delay: 'delay'
6472};
6473module.exports = {
6474 stopAnimate: function stopAnimate() {
6475 var self = this;
6476 var canvas = self.get('canvas');
6477 if (self.get('destroyed')) {
6478 return;
6479 }
6480 if (self.get('animating')) {
6481 var clip = self.attr('clip');
6482 // 如果 clip 在执行动画
6483 if (clip && clip.get('animating')) {
6484 clip.stopAnimate();
6485 }
6486 var timer = self.get('animateTimer');
6487 if (timer) {
6488 timer.stop();
6489 self.setSilent('animateTimer', null);
6490 }
6491 var animateCfg = self.get('animateCfg');
6492 if (animateCfg) {
6493 self.attr(animateCfg.toAttrs);
6494 if (animateCfg.toM) {
6495 self.setMatrix(animateCfg.toM);
6496 }
6497 if (animateCfg.callback) {
6498 animateCfg.callback();
6499 }
6500 self.setSilent('animateCfg', null);
6501 }
6502 self.setSilent('animating', false); // 动画停止
6503 canvas.draw();
6504 }
6505 },
6506
6507 /**
6508 * 执行动画
6509 * @param {Object} toProps 动画最终状态
6510 * @param {Number} duration 动画执行时间
6511 * @param {String} easing 动画缓动效果
6512 * @param {Function} callback 动画执行后的回调
6513 * @param {Number} delay 动画延迟时间
6514 */
6515 animate: function animate(toProps, duration, easing, callback) {
6516 var delay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
6517
6518 var self = this;
6519 var canvas = self.get('canvas');
6520 var formatProps = getFormatProps(toProps);
6521 var toAttrs = formatProps.attrs;
6522 var toM = formatProps.M;
6523 var fromAttrs = getfromAttrs(toAttrs);
6524 var fromM = Util.clone(self.getMatrix());
6525 var repeat = toProps.repeat;
6526 var timer = self.get('animateTimer');
6527 timer && timer.stop();
6528 // 可能不设置 easing
6529 if (Util.isNumber(callback)) {
6530 delay = callback;
6531 callback = null;
6532 }
6533 if (Util.isFunction(easing)) {
6534 callback = easing;
6535 easing = 'easeLinear';
6536 } else {
6537 easing = easing ? easing : 'easeLinear';
6538 }
6539
6540 self.setSilent('animating', true); // 处于动画状态
6541 self.setSilent('animateCfg', {
6542 toAttrs: toAttrs,
6543 toM: toM,
6544 callback: callback
6545 });
6546
6547 // 执行动画
6548 timer = d3Timer.timer(function (elapsed) {
6549 if (repeat) {
6550 excuteRepeat(elapsed);
6551 } else {
6552 excuteOnce(elapsed);
6553 }
6554 }, delay);
6555
6556 self.setSilent('animateTimer', timer);
6557
6558 function excuteRepeat(elapsed) {
6559 var ratio = elapsed % duration / duration;
6560 ratio = d3Ease[easing](ratio);
6561 update(ratio);
6562 }
6563
6564 function excuteOnce(elapsed) {
6565 var ratio = elapsed / duration;
6566 if (ratio < 1) {
6567 ratio = d3Ease[easing](ratio);
6568 update(ratio);
6569 } else {
6570 update(1); // 保证最后一帧的绘制
6571 callback && callback();
6572 self.setSilent('animating', false); // 动画停止
6573 self.setSilent('animateCfg', null);
6574 self.setSilent('animateTimer', null);
6575 timer.stop();
6576 }
6577 }
6578
6579 function update(ratio) {
6580 var cProps = {}; // 此刻属性
6581 if (self.get('destroyed')) {
6582 return;
6583 }
6584 var interf = void 0; // 差值函数
6585
6586 for (var k in toAttrs) {
6587 if (!Util.isEqual(fromAttrs[k], toAttrs[k])) {
6588 if (k === 'path') {
6589 var toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态
6590 var fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态
6591 cProps[k] = [];
6592 for (var i = 0; i < toPath.length; i++) {
6593 var toPathPoint = toPath[i];
6594 var fromPathPoint = fromPath[i];
6595 var cPathPoint = [];
6596 for (var j = 0; j < toPathPoint.length; j++) {
6597 if (Util.isNumber(toPathPoint[j]) && fromPathPoint) {
6598 interf = interpolate(fromPathPoint[j], toPathPoint[j]);
6599 cPathPoint.push(interf(ratio));
6600 } else {
6601 cPathPoint.push(toPathPoint[j]);
6602 }
6603 }
6604 cProps[k].push(cPathPoint);
6605 }
6606 } else {
6607 interf = interpolate(fromAttrs[k], toAttrs[k]);
6608 cProps[k] = interf(ratio);
6609 }
6610 }
6611 }
6612 if (toM) {
6613 var mf = interpolateArray(fromM, toM);
6614 var cM = mf(ratio);
6615 self.setMatrix(cM);
6616 }
6617 self.attr(cProps);
6618 canvas.draw();
6619 }
6620
6621 function getFormatProps(props) {
6622 var rst = {
6623 M: null,
6624 attrs: {}
6625 };
6626 for (var k in props) {
6627 if (k === 'transform') {
6628 rst.M = MatrixUtil.transform(self.getMatrix(), props[k]);
6629 } else if (k === 'matrix') {
6630 rst.M = props[k];
6631 } else if (!ReservedProps[k]) {
6632 rst.attrs[k] = props[k];
6633 }
6634 }
6635 return rst;
6636 }
6637
6638 function getfromAttrs(toAttrs) {
6639 var rst = {};
6640 for (var k in toAttrs) {
6641 rst[k] = self.attr(k);
6642 }
6643 return rst;
6644 }
6645 }
6646};
6647
6648/***/ }),
6649/* 33 */
6650/***/ (function(module, __webpack_exports__, __webpack_require__) {
6651
6652"use strict";
6653/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return deg2rad; });
6654/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rad2deg; });
6655var deg2rad = Math.PI / 180;
6656var rad2deg = 180 / Math.PI;
6657
6658/***/ }),
6659/* 34 */
6660/***/ (function(module, __webpack_exports__, __webpack_require__) {
6661
6662"use strict";
6663/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return rgbBasis; });
6664/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return rgbBasisClosed; });
6665/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
6666/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__basis__ = __webpack_require__(20);
6667/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__basisClosed__ = __webpack_require__(35);
6668/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__color__ = __webpack_require__(8);
6669
6670
6671
6672
6673
6674/* harmony default export */ __webpack_exports__["a"] = ((function rgbGamma(y) {
6675 var color = Object(__WEBPACK_IMPORTED_MODULE_3__color__["b" /* gamma */])(y);
6676
6677 function rgb(start, end) {
6678 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),
6679 g = color(start.g, end.g),
6680 b = color(start.b, end.b),
6681 opacity = Object(__WEBPACK_IMPORTED_MODULE_3__color__["a" /* default */])(start.opacity, end.opacity);
6682 return function (t) {
6683 start.r = r(t);
6684 start.g = g(t);
6685 start.b = b(t);
6686 start.opacity = opacity(t);
6687 return start + "";
6688 };
6689 }
6690
6691 rgb.gamma = rgbGamma;
6692
6693 return rgb;
6694})(1));
6695
6696function rgbSpline(spline) {
6697 return function (colors) {
6698 var n = colors.length,
6699 r = new Array(n),
6700 g = new Array(n),
6701 b = new Array(n),
6702 i,
6703 color;
6704 for (i = 0; i < n; ++i) {
6705 color = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["f" /* rgb */])(colors[i]);
6706 r[i] = color.r || 0;
6707 g[i] = color.g || 0;
6708 b[i] = color.b || 0;
6709 }
6710 r = spline(r);
6711 g = spline(g);
6712 b = spline(b);
6713 color.opacity = 1;
6714 return function (t) {
6715 color.r = r(t);
6716 color.g = g(t);
6717 color.b = b(t);
6718 return color + "";
6719 };
6720 };
6721}
6722
6723var rgbBasis = rgbSpline(__WEBPACK_IMPORTED_MODULE_1__basis__["b" /* default */]);
6724var rgbBasisClosed = rgbSpline(__WEBPACK_IMPORTED_MODULE_2__basisClosed__["a" /* default */]);
6725
6726/***/ }),
6727/* 35 */
6728/***/ (function(module, __webpack_exports__, __webpack_require__) {
6729
6730"use strict";
6731/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__basis__ = __webpack_require__(20);
6732
6733
6734/* harmony default export */ __webpack_exports__["a"] = (function (values) {
6735 var n = values.length;
6736 return function (t) {
6737 var i = Math.floor(((t %= 1) < 0 ? ++t : t) * n),
6738 v0 = values[(i + n - 1) % n],
6739 v1 = values[i % n],
6740 v2 = values[(i + 1) % n],
6741 v3 = values[(i + 2) % n];
6742 return Object(__WEBPACK_IMPORTED_MODULE_0__basis__["a" /* basis */])((t - i / n) * n, v0, v1, v2, v3);
6743 };
6744});
6745
6746/***/ }),
6747/* 36 */
6748/***/ (function(module, __webpack_exports__, __webpack_require__) {
6749
6750"use strict";
6751/* harmony default export */ __webpack_exports__["a"] = (function (x) {
6752 return function () {
6753 return x;
6754 };
6755});
6756
6757/***/ }),
6758/* 37 */
6759/***/ (function(module, __webpack_exports__, __webpack_require__) {
6760
6761"use strict";
6762/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(17);
6763
6764
6765/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6766 var nb = b ? b.length : 0,
6767 na = a ? Math.min(nb, a.length) : 0,
6768 x = new Array(na),
6769 c = new Array(nb),
6770 i;
6771
6772 for (i = 0; i < na; ++i) {
6773 x[i] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[i], b[i]);
6774 }for (; i < nb; ++i) {
6775 c[i] = b[i];
6776 }return function (t) {
6777 for (i = 0; i < na; ++i) {
6778 c[i] = x[i](t);
6779 }return c;
6780 };
6781});
6782
6783/***/ }),
6784/* 38 */
6785/***/ (function(module, __webpack_exports__, __webpack_require__) {
6786
6787"use strict";
6788/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6789 var d = new Date();
6790 return a = +a, b -= a, function (t) {
6791 return d.setTime(a + b * t), d;
6792 };
6793});
6794
6795/***/ }),
6796/* 39 */
6797/***/ (function(module, __webpack_exports__, __webpack_require__) {
6798
6799"use strict";
6800/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__value__ = __webpack_require__(17);
6801var _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; };
6802
6803
6804
6805/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6806 var i = {},
6807 c = {},
6808 k;
6809
6810 if (a === null || (typeof a === "undefined" ? "undefined" : _typeof(a)) !== "object") a = {};
6811 if (b === null || (typeof b === "undefined" ? "undefined" : _typeof(b)) !== "object") b = {};
6812
6813 for (k in b) {
6814 if (k in a) {
6815 i[k] = Object(__WEBPACK_IMPORTED_MODULE_0__value__["a" /* default */])(a[k], b[k]);
6816 } else {
6817 c[k] = b[k];
6818 }
6819 }
6820
6821 return function (t) {
6822 for (k in i) {
6823 c[k] = i[k](t);
6824 }return c;
6825 };
6826});
6827
6828/***/ }),
6829/* 40 */
6830/***/ (function(module, __webpack_exports__, __webpack_require__) {
6831
6832"use strict";
6833/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(11);
6834
6835
6836var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,
6837 reB = new RegExp(reA.source, "g");
6838
6839function zero(b) {
6840 return function () {
6841 return b;
6842 };
6843}
6844
6845function one(b) {
6846 return function (t) {
6847 return b(t) + "";
6848 };
6849}
6850
6851/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
6852 var bi = reA.lastIndex = reB.lastIndex = 0,
6853 // scan index for next number in b
6854 am,
6855 // current match in a
6856 bm,
6857 // current match in b
6858 bs,
6859 // string preceding current number in b, if any
6860 i = -1,
6861 // index in s
6862 s = [],
6863 // string constants and placeholders
6864 q = []; // number interpolators
6865
6866 // Coerce inputs to strings.
6867 a = a + "", b = b + "";
6868
6869 // Interpolate pairs of numbers in a & b.
6870 while ((am = reA.exec(a)) && (bm = reB.exec(b))) {
6871 if ((bs = bm.index) > bi) {
6872 // a string precedes the next number in b
6873 bs = b.slice(bi, bs);
6874 if (s[i]) s[i] += bs; // coalesce with previous string
6875 else s[++i] = bs;
6876 }
6877 if ((am = am[0]) === (bm = bm[0])) {
6878 // numbers in a & b match
6879 if (s[i]) s[i] += bm; // coalesce with previous string
6880 else s[++i] = bm;
6881 } else {
6882 // interpolate non-matching numbers
6883 s[++i] = null;
6884 q.push({ i: i, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(am, bm) });
6885 }
6886 bi = reB.lastIndex;
6887 }
6888
6889 // Add remains of b.
6890 if (bi < b.length) {
6891 bs = b.slice(bi);
6892 if (s[i]) s[i] += bs; // coalesce with previous string
6893 else s[++i] = bs;
6894 }
6895
6896 // Special optimization for only a single match.
6897 // Otherwise, interpolate each of the numbers and rejoin the string.
6898 return s.length < 2 ? q[0] ? one(q[0].x) : zero(b) : (b = q.length, function (t) {
6899 for (var i = 0, o; i < b; ++i) {
6900 s[(o = q[i]).i] = o.x(t);
6901 }return s.join("");
6902 });
6903});
6904
6905/***/ }),
6906/* 41 */
6907/***/ (function(module, exports, __webpack_require__) {
6908
6909var __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; };
6910
6911/*!
6912 * EventEmitter v5.1.0 - git.io/ee
6913 * Unlicense - http://unlicense.org/
6914 * Oliver Caldwell - http://oli.me.uk/
6915 * @preserve
6916 */
6917
6918;(function (exports) {
6919 'use strict';
6920
6921 /**
6922 * Class for managing events.
6923 * Can be extended to provide event functionality in other classes.
6924 *
6925 * @class EventEmitter Manages event registering and emitting.
6926 */
6927
6928 function EventEmitter() {}
6929
6930 // Shortcuts to improve speed and size
6931 var proto = EventEmitter.prototype;
6932 var originalGlobalValue = exports.EventEmitter;
6933
6934 /**
6935 * Finds the index of the listener for the event in its storage array.
6936 *
6937 * @param {Function[]} listeners Array of listeners to search through.
6938 * @param {Function} listener Method to look for.
6939 * @return {Number} Index of the specified listener, -1 if not found
6940 * @api private
6941 */
6942 function indexOfListener(listeners, listener) {
6943 var i = listeners.length;
6944 while (i--) {
6945 if (listeners[i].listener === listener) {
6946 return i;
6947 }
6948 }
6949
6950 return -1;
6951 }
6952
6953 /**
6954 * Alias a method while keeping the context correct, to allow for overwriting of target method.
6955 *
6956 * @param {String} name The name of the target method.
6957 * @return {Function} The aliased method
6958 * @api private
6959 */
6960 function alias(name) {
6961 return function aliasClosure() {
6962 return this[name].apply(this, arguments);
6963 };
6964 }
6965
6966 /**
6967 * Returns the listener array for the specified event.
6968 * Will initialise the event object and listener arrays if required.
6969 * 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.
6970 * Each property in the object response is an array of listener functions.
6971 *
6972 * @param {String|RegExp} evt Name of the event to return the listeners from.
6973 * @return {Function[]|Object} All listener functions for the event.
6974 */
6975 proto.getListeners = function getListeners(evt) {
6976 var events = this._getEvents();
6977 var response;
6978 var key;
6979
6980 // Return a concatenated array of all matching events if
6981 // the selector is a regular expression.
6982 if (evt instanceof RegExp) {
6983 response = {};
6984 for (key in events) {
6985 if (events.hasOwnProperty(key) && evt.test(key)) {
6986 response[key] = events[key];
6987 }
6988 }
6989 } else {
6990 response = events[evt] || (events[evt] = []);
6991 }
6992
6993 return response;
6994 };
6995
6996 /**
6997 * Takes a list of listener objects and flattens it into a list of listener functions.
6998 *
6999 * @param {Object[]} listeners Raw listener objects.
7000 * @return {Function[]} Just the listener functions.
7001 */
7002 proto.flattenListeners = function flattenListeners(listeners) {
7003 var flatListeners = [];
7004 var i;
7005
7006 for (i = 0; i < listeners.length; i += 1) {
7007 flatListeners.push(listeners[i].listener);
7008 }
7009
7010 return flatListeners;
7011 };
7012
7013 /**
7014 * 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.
7015 *
7016 * @param {String|RegExp} evt Name of the event to return the listeners from.
7017 * @return {Object} All listener functions for an event in an object.
7018 */
7019 proto.getListenersAsObject = function getListenersAsObject(evt) {
7020 var listeners = this.getListeners(evt);
7021 var response;
7022
7023 if (listeners instanceof Array) {
7024 response = {};
7025 response[evt] = listeners;
7026 }
7027
7028 return response || listeners;
7029 };
7030
7031 function isValidListener(listener) {
7032 if (typeof listener === 'function' || listener instanceof RegExp) {
7033 return true;
7034 } else if (listener && (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object') {
7035 return isValidListener(listener.listener);
7036 } else {
7037 return false;
7038 }
7039 }
7040
7041 /**
7042 * Adds a listener function to the specified event.
7043 * The listener will not be added if it is a duplicate.
7044 * If the listener returns true then it will be removed after it is called.
7045 * If you pass a regular expression as the event name then the listener will be added to all events that match it.
7046 *
7047 * @param {String|RegExp} evt Name of the event to attach the listener to.
7048 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
7049 * @return {Object} Current instance of EventEmitter for chaining.
7050 */
7051 proto.addListener = function addListener(evt, listener) {
7052 if (!isValidListener(listener)) {
7053 throw new TypeError('listener must be a function');
7054 }
7055
7056 var listeners = this.getListenersAsObject(evt);
7057 var listenerIsWrapped = (typeof listener === 'undefined' ? 'undefined' : _typeof(listener)) === 'object';
7058 var key;
7059
7060 for (key in listeners) {
7061 if (listeners.hasOwnProperty(key) && indexOfListener(listeners[key], listener) === -1) {
7062 listeners[key].push(listenerIsWrapped ? listener : {
7063 listener: listener,
7064 once: false
7065 });
7066 }
7067 }
7068
7069 return this;
7070 };
7071
7072 /**
7073 * Alias of addListener
7074 */
7075 proto.on = alias('addListener');
7076
7077 /**
7078 * Semi-alias of addListener. It will add a listener that will be
7079 * automatically removed after its first execution.
7080 *
7081 * @param {String|RegExp} evt Name of the event to attach the listener to.
7082 * @param {Function} listener Method to be called when the event is emitted. If the function returns true then it will be removed after calling.
7083 * @return {Object} Current instance of EventEmitter for chaining.
7084 */
7085 proto.addOnceListener = function addOnceListener(evt, listener) {
7086 return this.addListener(evt, {
7087 listener: listener,
7088 once: true
7089 });
7090 };
7091
7092 /**
7093 * Alias of addOnceListener.
7094 */
7095 proto.once = alias('addOnceListener');
7096
7097 /**
7098 * 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.
7099 * You need to tell it what event names should be matched by a regex.
7100 *
7101 * @param {String} evt Name of the event to create.
7102 * @return {Object} Current instance of EventEmitter for chaining.
7103 */
7104 proto.defineEvent = function defineEvent(evt) {
7105 this.getListeners(evt);
7106 return this;
7107 };
7108
7109 /**
7110 * Uses defineEvent to define multiple events.
7111 *
7112 * @param {String[]} evts An array of event names to define.
7113 * @return {Object} Current instance of EventEmitter for chaining.
7114 */
7115 proto.defineEvents = function defineEvents(evts) {
7116 for (var i = 0; i < evts.length; i += 1) {
7117 this.defineEvent(evts[i]);
7118 }
7119 return this;
7120 };
7121
7122 /**
7123 * Removes a listener function from the specified event.
7124 * When passed a regular expression as the event name, it will remove the listener from all events that match it.
7125 *
7126 * @param {String|RegExp} evt Name of the event to remove the listener from.
7127 * @param {Function} listener Method to remove from the event.
7128 * @return {Object} Current instance of EventEmitter for chaining.
7129 */
7130 proto.removeListener = function removeListener(evt, listener) {
7131 var listeners = this.getListenersAsObject(evt);
7132 var index;
7133 var key;
7134
7135 for (key in listeners) {
7136 if (listeners.hasOwnProperty(key)) {
7137 index = indexOfListener(listeners[key], listener);
7138
7139 if (index !== -1) {
7140 listeners[key].splice(index, 1);
7141 }
7142 }
7143 }
7144
7145 return this;
7146 };
7147
7148 /**
7149 * Alias of removeListener
7150 */
7151 proto.off = alias('removeListener');
7152
7153 /**
7154 * Adds listeners in bulk using the manipulateListeners method.
7155 * 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.
7156 * You can also pass it a regular expression to add the array of listeners to all events that match it.
7157 * Yeah, this function does quite a bit. That's probably a bad thing.
7158 *
7159 * @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.
7160 * @param {Function[]} [listeners] An optional array of listener functions to add.
7161 * @return {Object} Current instance of EventEmitter for chaining.
7162 */
7163 proto.addListeners = function addListeners(evt, listeners) {
7164 // Pass through to manipulateListeners
7165 return this.manipulateListeners(false, evt, listeners);
7166 };
7167
7168 /**
7169 * Removes listeners in bulk using the manipulateListeners method.
7170 * 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.
7171 * You can also pass it an event name and an array of listeners to be removed.
7172 * You can also pass it a regular expression to remove the listeners from all events that match it.
7173 *
7174 * @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.
7175 * @param {Function[]} [listeners] An optional array of listener functions to remove.
7176 * @return {Object} Current instance of EventEmitter for chaining.
7177 */
7178 proto.removeListeners = function removeListeners(evt, listeners) {
7179 // Pass through to manipulateListeners
7180 return this.manipulateListeners(true, evt, listeners);
7181 };
7182
7183 /**
7184 * 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.
7185 * The first argument will determine if the listeners are removed (true) or added (false).
7186 * 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.
7187 * You can also pass it an event name and an array of listeners to be added/removed.
7188 * You can also pass it a regular expression to manipulate the listeners of all events that match it.
7189 *
7190 * @param {Boolean} remove True if you want to remove listeners, false if you want to add.
7191 * @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.
7192 * @param {Function[]} [listeners] An optional array of listener functions to add/remove.
7193 * @return {Object} Current instance of EventEmitter for chaining.
7194 */
7195 proto.manipulateListeners = function manipulateListeners(remove, evt, listeners) {
7196 var i;
7197 var value;
7198 var single = remove ? this.removeListener : this.addListener;
7199 var multiple = remove ? this.removeListeners : this.addListeners;
7200
7201 // If evt is an object then pass each of its properties to this method
7202 if ((typeof evt === 'undefined' ? 'undefined' : _typeof(evt)) === 'object' && !(evt instanceof RegExp)) {
7203 for (i in evt) {
7204 if (evt.hasOwnProperty(i) && (value = evt[i])) {
7205 // Pass the single listener straight through to the singular method
7206 if (typeof value === 'function') {
7207 single.call(this, i, value);
7208 } else {
7209 // Otherwise pass back to the multiple function
7210 multiple.call(this, i, value);
7211 }
7212 }
7213 }
7214 } else {
7215 // So evt must be a string
7216 // And listeners must be an array of listeners
7217 // Loop over it and pass each one to the multiple method
7218 i = listeners.length;
7219 while (i--) {
7220 single.call(this, evt, listeners[i]);
7221 }
7222 }
7223
7224 return this;
7225 };
7226
7227 /**
7228 * Removes all listeners from a specified event.
7229 * If you do not specify an event then all listeners will be removed.
7230 * That means every event will be emptied.
7231 * You can also pass a regex to remove all events that match it.
7232 *
7233 * @param {String|RegExp} [evt] Optional name of the event to remove all listeners for. Will remove from every event if not passed.
7234 * @return {Object} Current instance of EventEmitter for chaining.
7235 */
7236 proto.removeEvent = function removeEvent(evt) {
7237 var type = typeof evt === 'undefined' ? 'undefined' : _typeof(evt);
7238 var events = this._getEvents();
7239 var key;
7240
7241 // Remove different things depending on the state of evt
7242 if (type === 'string') {
7243 // Remove all listeners for the specified event
7244 delete events[evt];
7245 } else if (evt instanceof RegExp) {
7246 // Remove all events matching the regex.
7247 for (key in events) {
7248 if (events.hasOwnProperty(key) && evt.test(key)) {
7249 delete events[key];
7250 }
7251 }
7252 } else {
7253 // Remove all listeners in all events
7254 delete this._events;
7255 }
7256
7257 return this;
7258 };
7259
7260 /**
7261 * Alias of removeEvent.
7262 *
7263 * Added to mirror the node API.
7264 */
7265 proto.removeAllListeners = alias('removeEvent');
7266
7267 /**
7268 * Emits an event of your choice.
7269 * When emitted, every listener attached to that event will be executed.
7270 * If you pass the optional argument array then those arguments will be passed to every listener upon execution.
7271 * Because it uses `apply`, your array of arguments will be passed as if you wrote them out separately.
7272 * So they will not arrive within the array on the other side, they will be separate.
7273 * You can also pass a regular expression to emit to all events that match it.
7274 *
7275 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
7276 * @param {Array} [args] Optional array of arguments to be passed to each listener.
7277 * @return {Object} Current instance of EventEmitter for chaining.
7278 */
7279 proto.emitEvent = function emitEvent(evt, args) {
7280 var listenersMap = this.getListenersAsObject(evt);
7281 var listeners;
7282 var listener;
7283 var i;
7284 var key;
7285 var response;
7286
7287 for (key in listenersMap) {
7288 if (listenersMap.hasOwnProperty(key)) {
7289 listeners = listenersMap[key].slice(0);
7290
7291 for (i = 0; i < listeners.length; i++) {
7292 // If the listener returns true then it shall be removed from the event
7293 // The function is executed either with a basic call or an apply if there is an args array
7294 listener = listeners[i];
7295
7296 if (listener.once === true) {
7297 this.removeListener(evt, listener.listener);
7298 }
7299
7300 response = listener.listener.apply(this, args || []);
7301
7302 if (response === this._getOnceReturnValue()) {
7303 this.removeListener(evt, listener.listener);
7304 }
7305 }
7306 }
7307 }
7308
7309 return this;
7310 };
7311
7312 /**
7313 * Alias of emitEvent
7314 */
7315 proto.trigger = alias('emitEvent');
7316
7317 /**
7318 * 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.
7319 * As with emitEvent, you can pass a regex in place of the event name to emit to all events that match it.
7320 *
7321 * @param {String|RegExp} evt Name of the event to emit and execute listeners for.
7322 * @param {...*} Optional additional arguments to be passed to each listener.
7323 * @return {Object} Current instance of EventEmitter for chaining.
7324 */
7325 proto.emit = function emit(evt) {
7326 var args = Array.prototype.slice.call(arguments, 1);
7327 return this.emitEvent(evt, args);
7328 };
7329
7330 /**
7331 * Sets the current value to check against when executing listeners. If a
7332 * listeners return value matches the one set here then it will be removed
7333 * after execution. This value defaults to true.
7334 *
7335 * @param {*} value The new value to check for when executing listeners.
7336 * @return {Object} Current instance of EventEmitter for chaining.
7337 */
7338 proto.setOnceReturnValue = function setOnceReturnValue(value) {
7339 this._onceReturnValue = value;
7340 return this;
7341 };
7342
7343 /**
7344 * Fetches the current value to check against when executing listeners. If
7345 * the listeners return value matches this one then it should be removed
7346 * automatically. It will return true by default.
7347 *
7348 * @return {*|Boolean} The current value to check for or the default, true.
7349 * @api private
7350 */
7351 proto._getOnceReturnValue = function _getOnceReturnValue() {
7352 if (this.hasOwnProperty('_onceReturnValue')) {
7353 return this._onceReturnValue;
7354 } else {
7355 return true;
7356 }
7357 };
7358
7359 /**
7360 * Fetches the events object and creates one if required.
7361 *
7362 * @return {Object} The events storage object.
7363 * @api private
7364 */
7365 proto._getEvents = function _getEvents() {
7366 return this._events || (this._events = {});
7367 };
7368
7369 /**
7370 * Reverts the global {@link EventEmitter} to its previous value and returns a reference to this version.
7371 *
7372 * @return {Function} Non conflicting EventEmitter class.
7373 */
7374 EventEmitter.noConflict = function noConflict() {
7375 exports.EventEmitter = originalGlobalValue;
7376 return EventEmitter;
7377 };
7378
7379 // Expose the class either via AMD, CommonJS or the global object
7380 if (true) {
7381 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
7382 return EventEmitter;
7383 }).call(exports, __webpack_require__, exports, module),
7384 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
7385 } else if ((typeof module === 'undefined' ? 'undefined' : _typeof(module)) === 'object' && module.exports) {
7386 module.exports = EventEmitter;
7387 } else {
7388 exports.EventEmitter = EventEmitter;
7389 }
7390})(this || {});
7391
7392/***/ }),
7393/* 42 */
7394/***/ (function(module, exports, __webpack_require__) {
7395
7396var Util = __webpack_require__(0);
7397var Shape = __webpack_require__(4);
7398
7399var Rect = function Rect(cfg) {
7400 Rect.superclass.constructor.call(this, cfg);
7401};
7402
7403Rect.ATTRS = {
7404 x: 0,
7405 y: 0,
7406 width: 0,
7407 height: 0,
7408 radius: 0,
7409 lineWidth: 1,
7410 fill: 'none'
7411};
7412
7413Util.extend(Rect, Shape);
7414
7415Util.augment(Rect, {
7416 canFill: true,
7417 canStroke: true,
7418 type: 'rect',
7419 getDefaultAttrs: function getDefaultAttrs() {
7420 return {
7421 lineWidth: 1,
7422 fill: 'none'
7423 };
7424 },
7425 _afterSetRadius: function _afterSetRadius() {
7426 var el = this.get('el');
7427 el.setAttribute('rx', this.__attrs.radius);
7428 el.setAttribute('ry', this.__attrs.radius);
7429 },
7430 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7431 if ('radius' in objs) {
7432 this._afterSetRadius();
7433 }
7434 }
7435});
7436
7437module.exports = Rect;
7438
7439/***/ }),
7440/* 43 */
7441/***/ (function(module, exports, __webpack_require__) {
7442
7443var Util = __webpack_require__(0);
7444var Shape = __webpack_require__(4);
7445
7446var Circle = function Circle(cfg) {
7447 Circle.superclass.constructor.call(this, cfg);
7448};
7449
7450Circle.ATTRS = {
7451 x: 0,
7452 y: 0,
7453 r: 0,
7454 lineWidth: 1
7455};
7456
7457Util.extend(Circle, Shape);
7458
7459Util.augment(Circle, {
7460 canFill: true,
7461 canStroke: true,
7462 type: 'circle',
7463 getDefaultAttrs: function getDefaultAttrs() {
7464 return {
7465 lineWidth: 1,
7466 fill: 'none'
7467 };
7468 }
7469});
7470
7471module.exports = Circle;
7472
7473/***/ }),
7474/* 44 */
7475/***/ (function(module, exports, __webpack_require__) {
7476
7477var Util = __webpack_require__(0);
7478var Shape = __webpack_require__(4);
7479
7480var Ellipse = function Ellipse(cfg) {
7481 Ellipse.superclass.constructor.call(this, cfg);
7482};
7483
7484Ellipse.ATTRS = {
7485 x: 0,
7486 y: 0,
7487 rx: 1,
7488 ry: 1,
7489 lineWidth: 1
7490};
7491
7492Util.extend(Ellipse, Shape);
7493
7494Util.augment(Ellipse, {
7495 canFill: true,
7496 canStroke: true,
7497 type: 'ellipse',
7498 getDefaultAttrs: function getDefaultAttrs() {
7499 return {
7500 lineWidth: 1
7501 };
7502 }
7503});
7504
7505module.exports = Ellipse;
7506
7507/***/ }),
7508/* 45 */
7509/***/ (function(module, exports, __webpack_require__) {
7510
7511var Util = __webpack_require__(0);
7512var Shape = __webpack_require__(4);
7513
7514var Path = function Path(cfg) {
7515 Path.superclass.constructor.call(this, cfg);
7516};
7517
7518function at(p0, p1, p2, p3, t) {
7519 var onet = 1 - t;
7520 return onet * onet * (onet * p3 + 3 * t * p2) + t * t * (t * p0 + 3 * onet * p1);
7521}
7522
7523Path.ATTRS = {
7524 path: null,
7525 lineWidth: 1,
7526 curve: null, // 曲线path
7527 tCache: null,
7528 startArrow: false,
7529 endArrow: false
7530};
7531
7532Util.extend(Path, Shape);
7533
7534Util.augment(Path, {
7535 canFill: true,
7536 canStroke: true,
7537 type: 'path',
7538 getDefaultAttrs: function getDefaultAttrs() {
7539 return {
7540 lineWidth: 1,
7541 fill: 'none',
7542 startArrow: false,
7543 endArrow: false
7544 };
7545 },
7546 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
7547 var start = this.get('marker-start');
7548 var end = this.get('marker-end');
7549 if (start) {
7550 this.get('defs').findById(start).update(null, value);
7551 }
7552 if (end) {
7553 this.get('defs').findById(end).update(null, value);
7554 }
7555 },
7556 _afterSetAttrPath: function _afterSetAttrPath(value) {
7557 var el = this.get('el');
7558 var d = value;
7559 if (Util.isArray(d)) {
7560 d = d.map(function (path) {
7561 return path.join(' ');
7562 }).join('');
7563 }
7564 if (~d.indexOf('NaN')) {
7565 el.setAttribute('d', '');
7566 } else {
7567 el.setAttribute('d', d);
7568 }
7569 },
7570 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7571 if (objs.path) {
7572 this._afterSetAttrPath(objs.path);
7573 }
7574 if (objs.stroke) {
7575 this._afterSetAttrStroke(objs.stroke);
7576 }
7577 },
7578 getPoint: function getPoint(t) {
7579 var tCache = this.tCache;
7580 var subt = void 0;
7581 var index = void 0;
7582
7583 if (!tCache) {
7584 this._calculateCurve();
7585 this._setTcache();
7586 tCache = this.tCache;
7587 }
7588
7589 var curve = this.curve;
7590
7591 if (!tCache) {
7592 if (curve) {
7593 return {
7594 x: curve[0][1],
7595 y: curve[0][2]
7596 };
7597 }
7598 return null;
7599 }
7600 Util.each(tCache, function (v, i) {
7601 if (t >= v[0] && t <= v[1]) {
7602 subt = (t - v[0]) / (v[1] - v[0]);
7603 index = i;
7604 }
7605 });
7606 var seg = curve[index];
7607 if (Util.isNil(seg) || Util.isNil(index)) {
7608 return null;
7609 }
7610 var l = seg.length;
7611 var nextSeg = curve[index + 1];
7612
7613 return {
7614 x: at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
7615 y: at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
7616 };
7617 },
7618 createPath: function createPath() {}
7619});
7620
7621module.exports = Path;
7622
7623/***/ }),
7624/* 46 */
7625/***/ (function(module, exports, __webpack_require__) {
7626
7627var Util = __webpack_require__(0);
7628var Shape = __webpack_require__(4);
7629
7630var CText = function CText(cfg) {
7631 CText.superclass.constructor.call(this, cfg);
7632};
7633
7634var BASELINE_MAP = {
7635 top: 'before-edge',
7636 middle: 'central',
7637 bottom: 'after-edge',
7638 alphabetic: 'baseline',
7639 hanging: 'hanging'
7640};
7641
7642var ANCHOR_MAP = {
7643 left: 'left',
7644 start: 'left',
7645 center: 'middle',
7646 right: 'end',
7647 end: 'end'
7648};
7649
7650CText.ATTRS = {
7651 x: 0,
7652 y: 0,
7653 text: null,
7654 fontSize: 12,
7655 fontFamily: 'sans-serif',
7656 fontStyle: 'normal',
7657 fontWeight: 'normal',
7658 fontVariant: 'normal',
7659 textAlign: 'start',
7660 textBaseline: 'bottom',
7661 lineHeight: null,
7662 textArr: null
7663};
7664
7665Util.extend(CText, Shape);
7666
7667Util.augment(CText, {
7668 canFill: true,
7669 canStroke: true,
7670 type: 'text',
7671 getDefaultAttrs: function getDefaultAttrs() {
7672 return {
7673 lineWidth: 1,
7674 lineCount: 1,
7675 fontSize: 12,
7676 fill: '#000',
7677 fontFamily: 'sans-serif',
7678 fontStyle: 'normal',
7679 fontWeight: 'normal',
7680 fontVariant: 'normal',
7681 textAlign: 'start',
7682 textBaseline: 'bottom'
7683 };
7684 },
7685 initTransform: function initTransform() {
7686 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
7687 var fontSize = this.__attrs.fontSize;
7688 if (fontSize && +fontSize < 12) {
7689 // 小于 12 像素的文本进行 scale 处理
7690 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
7691 }
7692 },
7693 _assembleFont: function _assembleFont() {
7694 var el = this.get('el');
7695 var attrs = this.__attrs;
7696 var fontSize = attrs.fontSize;
7697 var fontFamily = attrs.fontFamily;
7698 var fontWeight = attrs.fontWeight;
7699 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
7700 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
7701 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
7702 var font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
7703 attrs.font = font;
7704 el.setAttribute('font', attrs.font);
7705 },
7706 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
7707 /* this.attr({
7708 height: this._getTextHeight()
7709 }); */
7710 this._assembleFont();
7711 },
7712 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
7713 this._assembleFont();
7714 },
7715 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
7716 this._assembleFont();
7717 },
7718 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
7719 this._assembleFont();
7720 },
7721 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
7722 this._assembleFont();
7723 },
7724 _afterSetAttrTextAlign: function _afterSetAttrTextAlign() {
7725 // 由于本身不支持设置direction,所以left = start, right = end。之后看是否需要根据direction判断
7726 var attr = this.__attrs.textAlign;
7727 var el = this.get('el');
7728 el.setAttribute('text-anchor', ANCHOR_MAP[attr]);
7729 },
7730 _afterSetAttrTextBaseLine: function _afterSetAttrTextBaseLine() {
7731 var attr = this.__attrs.textBaseline;
7732 this.get('el').setAttribute('alignment-baseline', BASELINE_MAP[attr] || 'baseline');
7733 },
7734 _afterSetAttrText: function _afterSetAttrText(text) {
7735 var attrs = this.__attrs;
7736 var textArr = void 0;
7737 if (Util.isString(text) && text.indexOf('\n') !== -1) {
7738 textArr = text.split('\n');
7739 var lineCount = textArr.length;
7740 attrs.lineCount = lineCount;
7741 attrs.textArr = textArr;
7742 }
7743 var el = this.get('el');
7744 if (~['undefined', 'null', 'NaN'].indexOf(String(text)) && el) {
7745 el.innerHTML = '';
7746 } else if (~text.indexOf('\n')) {
7747 textArr = text.split('\n');
7748 attrs.lineCount = textArr.length;
7749 attrs.textArr = textArr;
7750 var arr = '';
7751 Util.each(textArr, function (segment, i) {
7752 arr += '<tspan x="0" y="' + (i + 1) + 'em">' + segment + '</tspan>';
7753 });
7754 el.innerHTML = arr;
7755 } else {
7756 el.innerHTML = text;
7757 }
7758 },
7759 _afterSetAttrOutline: function _afterSetAttrOutline(val) {
7760 var el = this.get('el');
7761 if (!val) {
7762 el.setAttribute('paint-order', 'normal');
7763 }
7764 var stroke = val.stroke || '#000';
7765 var fill = val.fill || this.__attrs.stroke;
7766 var lineWidth = val.lineWidth || this.__attrs.lineWidth * 2;
7767 el.setAttribute('paint-order', 'stroke');
7768 el.setAttribute('style', 'stroke-linecap:butt; stroke-linejoin:miter;');
7769 el.setAttribute('stroke', stroke);
7770 el.setAttribute('fill', fill);
7771 el.setAttribute('stroke-width', lineWidth);
7772 },
7773
7774 // 计算浪费,效率低,待优化
7775 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7776 var self = this;
7777 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
7778 self._assembleFont();
7779 }
7780 if ('textAlign' in objs) {
7781 this._afterSetAttrTextAlign();
7782 }
7783 if ('textBaseline' in objs) {
7784 this._afterSetAttrTextBaseLine();
7785 }
7786 if ('text' in objs) {
7787 self._afterSetAttrText(objs.text);
7788 }
7789 if ('outline' in objs) {
7790 self._afterSetAttrOutline(objs.outline);
7791 }
7792 }
7793});
7794
7795module.exports = CText;
7796
7797/***/ }),
7798/* 47 */
7799/***/ (function(module, exports, __webpack_require__) {
7800
7801var Util = __webpack_require__(0);
7802var Shape = __webpack_require__(4);
7803
7804var Line = function Line(cfg) {
7805 Line.superclass.constructor.call(this, cfg);
7806};
7807
7808Line.ATTRS = {
7809 x1: 0,
7810 y1: 0,
7811 x2: 0,
7812 y2: 0,
7813 lineWidth: 1,
7814 startArrow: false,
7815 endArrow: false
7816};
7817
7818Util.extend(Line, Shape);
7819
7820Util.augment(Line, {
7821 canStroke: true,
7822 type: 'line',
7823 getDefaultAttrs: function getDefaultAttrs() {
7824 return {
7825 lineWidth: 1,
7826 stroke: '#000',
7827 startArrow: false,
7828 endArrow: false
7829 };
7830 },
7831 _afterSetAttrStroke: function _afterSetAttrStroke(value) {
7832 var start = this.get('marker-start');
7833 var end = this.get('marker-end');
7834 if (start) {
7835 this.get('defs').findById(start).update(value);
7836 }
7837 if (end) {
7838 this.get('defs').findById(end).update(value);
7839 }
7840 },
7841 _afterSetAttrAll: function _afterSetAttrAll(objs) {
7842 if (objs.stroke) {
7843 this._afterSetAttrStroke(objs.stroke);
7844 }
7845 },
7846 createPath: function createPath() {},
7847 getPoint: function getPoint(t) {
7848 var attrs = this.__attrs;
7849 return {
7850 x: (attrs.x2 - attrs.x1) * t + attrs.x1,
7851 y: (attrs.y2 - attrs.y1) * t + attrs.y1
7852 };
7853 }
7854});
7855
7856module.exports = Line;
7857
7858/***/ }),
7859/* 48 */
7860/***/ (function(module, exports, __webpack_require__) {
7861
7862var Util = __webpack_require__(0);
7863var Shape = __webpack_require__(4);
7864
7865var CImage = function CImage(cfg) {
7866 CImage.superclass.constructor.call(this, cfg);
7867};
7868
7869CImage.ATTRS = {
7870 x: 0,
7871 y: 0,
7872 img: undefined,
7873 width: 0,
7874 height: 0,
7875 sx: null,
7876 sy: null,
7877 swidth: null,
7878 sheight: null
7879};
7880
7881Util.extend(CImage, Shape);
7882
7883Util.augment(CImage, {
7884 type: 'image',
7885 _afterSetAttrImg: function _afterSetAttrImg(img) {
7886 this._setAttrImg(img);
7887 },
7888 _afterSetAttrAll: function _afterSetAttrAll(params) {
7889 if (params.img) {
7890 this._setAttrImg(params.img);
7891 }
7892 },
7893 _setAttrImg: function _setAttrImg(image) {
7894 var self = this;
7895 var el = this.get('el');
7896 var attrs = self.__attrs;
7897 var img = image;
7898
7899 if (Util.isString(img)) {
7900 // 如果传入的
7901 el.setAttribute('href', img);
7902 } else if (img instanceof Image) {
7903 if (!attrs.width) {
7904 self.attr('width', img.width);
7905 }
7906 if (!attrs.height) {
7907 self.attr('height', img.height);
7908 }
7909 el.setAttribute('href', img.src);
7910 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
7911 el.setAttribute('href', img.toDataURL());
7912 } else if (img instanceof ImageData) {
7913 var canvas = document.createElement('canvas');
7914 canvas.setAttribute('width', img.width);
7915 canvas.setAttribute('height', img.height);
7916 canvas.getContext('2d').putImageData(img, 0, 0);
7917 if (!attrs.width) {
7918 self.attr('width', img.width);
7919 }
7920
7921 if (!attrs.height) {
7922 self.attr('height', img.height);
7923 }
7924 el.setAttribute('href', canvas.toDataURL());
7925 }
7926 },
7927 drawInner: function drawInner() {}
7928});
7929
7930module.exports = CImage;
7931
7932/***/ }),
7933/* 49 */
7934/***/ (function(module, exports, __webpack_require__) {
7935
7936var Util = __webpack_require__(0);
7937var Shape = __webpack_require__(4);
7938
7939var Polygon = function Polygon(cfg) {
7940 Polygon.superclass.constructor.call(this, cfg);
7941};
7942
7943Polygon.ATTRS = {
7944 points: null,
7945 lineWidth: 1
7946};
7947
7948Util.extend(Polygon, Shape);
7949
7950Util.augment(Polygon, {
7951 canFill: true,
7952 canStroke: true,
7953 type: 'polygon',
7954 getDefaultAttrs: function getDefaultAttrs() {
7955 return {
7956 lineWidth: 1,
7957 fill: 'none'
7958 };
7959 },
7960 _afterSetAttrPoints: function _afterSetAttrPoints() {
7961 var value = this.__attrs.points;
7962 var el = this.get('el');
7963 var points = value;
7964 if (!value || value.length === 0) {
7965 points = '';
7966 } else if (Util.isArray(value)) {
7967 points = points.map(function (point) {
7968 return point[0] + ',' + point[1];
7969 });
7970 points = points.join(' ');
7971 }
7972 el.setAttribute('points', points);
7973 },
7974 _afterSetAttrAll: function _afterSetAttrAll(obj) {
7975 if ('points' in obj) {
7976 this._afterSetAttrPoints();
7977 }
7978 },
7979 createPath: function createPath() {}
7980});
7981
7982module.exports = Polygon;
7983
7984/***/ }),
7985/* 50 */
7986/***/ (function(module, exports, __webpack_require__) {
7987
7988var Util = __webpack_require__(0);
7989var Shape = __webpack_require__(4);
7990
7991var Marker = function Marker(cfg) {
7992 Marker.superclass.constructor.call(this, cfg);
7993};
7994
7995Marker.Symbols = {
7996 // 圆
7997 circle: function circle(x, y, r) {
7998 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';
7999 },
8000
8001 // 正方形
8002 square: function square(x, y, r) {
8003 return 'M' + (x - r) + ',' + (y - r) + '\n H' + (x + r) + 'V' + (y + r) + '\n H' + (x - r) + 'Z';
8004 },
8005
8006 // 菱形
8007 diamond: function diamond(x, y, r) {
8008 return 'M' + (x - r) + ',' + y + '\n L' + x + ',' + (y - r) + '\n L' + (x + r) + ',' + y + ',\n L' + x + ',' + (y + r) + 'Z';
8009 },
8010
8011 // 三角形
8012 triangle: function triangle(x, y, r) {
8013 var diff = r * Math.sin(1 / 3 * Math.PI);
8014 return 'M' + (x - r) + ',' + (y + diff) + '\n L' + x + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y + diff) + 'Z';
8015 },
8016
8017 // 倒三角形
8018 'triangle-down': function triangleDown(x, y, r) {
8019 var diff = r * Math.sin(1 / 3 * Math.PI);
8020 return 'M' + (x - r) + ',' + (y - diff) + '\n L' + (x + r) + ',' + (y - diff) + '\n L' + x + ',' + (y + diff) + 'Z';
8021 }
8022};
8023
8024Marker.ATTRS = {
8025 path: null,
8026 lineWidth: 1
8027};
8028
8029Util.extend(Marker, Shape);
8030
8031Util.augment(Marker, {
8032 type: 'marker',
8033 canFill: true,
8034 canStroke: true,
8035 init: function init(id) {
8036 Marker.superclass.init.call(this);
8037 var marker = document.createElementNS('http://www.w3.org/2000/svg', 'path');
8038 id = id || Util.uniqueId(this.type + '_');
8039 marker.setAttribute('id', id);
8040 this.setSilent('el', marker);
8041 },
8042 getDefaultAttrs: function getDefaultAttrs() {
8043 return {
8044 x: 0,
8045 y: 0,
8046 lineWidth: 1,
8047 fill: 'none'
8048 };
8049 },
8050 _afterSetX: function _afterSetX() {
8051 this._assembleShape();
8052 },
8053 _afterSetY: function _afterSetY() {
8054 this._assembleShape();
8055 },
8056 _afterSetRadius: function _afterSetRadius() {
8057 this._assembleShape();
8058 },
8059 _afterSetR: function _afterSetR() {
8060 this._assembleShape();
8061 },
8062 _afterSetAttrAll: function _afterSetAttrAll(objs) {
8063 if ('x' in objs || 'y' in objs || 'radius' in objs) {
8064 this._assembleShape();
8065 }
8066 },
8067 _assembleShape: function _assembleShape() {
8068 var attrs = this.__attrs;
8069 var r = attrs.r;
8070 if (typeof attrs.r === 'undefined') {
8071 r = attrs.radius;
8072 }
8073 if (isNaN(Number(attrs.x)) || isNaN(Number(attrs.y)) || isNaN(Number(r))) {
8074 return;
8075 }
8076 var d = '';
8077 if (typeof attrs.symbol === 'function') {
8078 d = attrs.symbol(attrs.x, attrs.y, r);
8079 } else {
8080 d = Marker.Symbols[attrs.symbol || 'circle'](attrs.x, attrs.y, r);
8081 }
8082 if (Util.isArray(d)) {
8083 d = d.map(function (path) {
8084 return path.join(' ');
8085 }).join('');
8086 }
8087 this.get('el').setAttribute('d', d);
8088 }
8089});
8090
8091module.exports = Marker;
8092
8093/***/ }),
8094/* 51 */
8095/***/ (function(module, exports, __webpack_require__) {
8096
8097var Util = __webpack_require__(0);
8098var Shape = __webpack_require__(4);
8099
8100var Dom = function Dom(cfg) {
8101 Dom.superclass.constructor.call(this, cfg);
8102};
8103
8104Util.extend(Dom, Shape);
8105
8106Util.augment(Dom, {
8107 canFill: true,
8108 canStroke: true,
8109 type: 'dom',
8110 _afterSetAttrHtml: function _afterSetAttrHtml() {
8111 var html = this.__attrs.html;
8112 var el = this.get('el');
8113 if (typeof html === 'string') {
8114 el.innerHTML = html;
8115 } else {
8116 el.innerHTML = '';
8117 el.appendChild(html);
8118 }
8119 },
8120 _afterSetAttrAll: function _afterSetAttrAll(objs) {
8121 if ('html' in objs) {
8122 this._afterSetAttrHtml();
8123 }
8124 }
8125});
8126
8127module.exports = Dom;
8128
8129/***/ }),
8130/* 52 */
8131/***/ (function(module, exports, __webpack_require__) {
8132
8133var Util = __webpack_require__(0);
8134var Shape = __webpack_require__(4);
8135
8136var Fan = function Fan(cfg) {
8137 Fan.superclass.constructor.call(this, cfg);
8138};
8139
8140function getPoint(angle, radius, center) {
8141 return {
8142 x: radius * Math.cos(angle) + center.x,
8143 y: radius * Math.sin(angle) + center.y
8144 };
8145}
8146
8147Fan.ATTRS = {
8148 x: 0,
8149 y: 0,
8150 rs: 0,
8151 re: 0,
8152 startAngle: 0,
8153 endAngle: 0,
8154 clockwise: false,
8155 lineWidth: 1
8156};
8157
8158Util.extend(Fan, Shape);
8159
8160Util.augment(Fan, {
8161 canFill: true,
8162 canStroke: true,
8163 type: 'fan',
8164 getDefaultAttrs: function getDefaultAttrs() {
8165 return {
8166 clockwise: false,
8167 lineWidth: 1,
8168 rs: 0,
8169 re: 0,
8170 fill: 'none'
8171 };
8172 },
8173 _afterSetAttrX: function _afterSetAttrX() {
8174 this._calculatePath();
8175 },
8176 _afterSetAttrY: function _afterSetAttrY() {
8177 this._calculatePath();
8178 },
8179 _afterSetAttrRs: function _afterSetAttrRs() {
8180 this._calculatePath();
8181 },
8182 _afterSetAttrRe: function _afterSetAttrRe() {
8183 this._calculatePath();
8184 },
8185 _afterSetAttrStartAngle: function _afterSetAttrStartAngle() {
8186 this._calculatePath();
8187 },
8188 _afterSetAttrEndAngle: function _afterSetAttrEndAngle() {
8189 this._calculatePath();
8190 },
8191 _afterSetAttrClockwise: function _afterSetAttrClockwise() {
8192 this._calculatePath();
8193 },
8194 _afterSetAttrAll: function _afterSetAttrAll(obj) {
8195 if ('x' in obj || 'y' in obj || 'rs' in obj || 're' in obj || 'startAngle' in obj || 'endAngle' in obj || 'clockwise' in obj) {
8196 this._calculatePath();
8197 }
8198 },
8199 _calculatePath: function _calculatePath() {
8200 var self = this;
8201 var attrs = self.__attrs;
8202 var center = {
8203 x: attrs.x,
8204 y: attrs.y
8205 };
8206 var d = [];
8207 var startAngle = attrs.startAngle;
8208 var endAngle = attrs.endAngle;
8209 if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
8210 endAngle -= 0.00001;
8211 }
8212 var outerStart = getPoint(startAngle, attrs.re, center);
8213 var outerEnd = getPoint(endAngle, attrs.re, center);
8214 var fa = endAngle > startAngle ? 1 : 0;
8215 var fs = Math.abs(endAngle - startAngle) > Math.PI ? 1 : 0;
8216 var rs = attrs.rs;
8217 var re = attrs.re;
8218 var innerStart = getPoint(startAngle, attrs.rs, center);
8219 var innerEnd = getPoint(endAngle, attrs.rs, center);
8220 if (attrs.rs > 0) {
8221 d.push('M ' + outerEnd.x + ',' + outerEnd.y);
8222 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
8223 /* if (endAngle - startAngle >= Math.PI) {
8224 const endPoint = getSymmetricalPoint(innerStart, center);
8225 d.push(`A ${rs},${rs},0,0,${fa},${endPoint.x},${endPoint.y}`);
8226 d.push(`M ${endPoint.x},${endPoint.y}`);
8227 }*/
8228 d.push('A ' + rs + ',' + rs + ',0,' + fs + ',' + (fa === 1 ? 0 : 1) + ',' + innerStart.x + ',' + innerStart.y);
8229 d.push('L ' + outerStart.x + ' ' + outerStart.y);
8230 } else {
8231 d.push('M ' + center.x + ',' + center.y);
8232 d.push('L ' + outerStart.x + ',' + outerStart.y);
8233 }
8234 /* if (endAngle - startAngle >= Math.PI) {
8235 const endPoint = getSymmetricalPoint(outerStart, center);
8236 d.push(`A ${re},${re},0,0,${fa},${endPoint.x},${endPoint.y}`);
8237 }*/
8238 d.push('A ' + re + ',' + re + ',0,' + fs + ',' + fa + ',' + outerEnd.x + ',' + outerEnd.y);
8239 if (attrs.rs > 0) {
8240 d.push('L ' + innerEnd.x + ',' + innerEnd.y);
8241 } else {
8242 d.push('Z');
8243 }
8244 self.get('el').setAttribute('d', d.join(' '));
8245 }
8246});
8247
8248module.exports = Fan;
8249
8250/***/ }),
8251/* 53 */
8252/***/ (function(module, exports, __webpack_require__) {
8253
8254var Util = __webpack_require__(0);
8255
8256var Event = function Event(type, event, bubbles, cancelable) {
8257 this.type = type; // 事件类型
8258 this.target = null; // 目标
8259 this.currentTarget = null; // 当前目标
8260 this.bubbles = bubbles; // 冒泡
8261 this.cancelable = cancelable; // 是否能够阻止
8262 this.timeStamp = new Date().getTime(); // 时间戳
8263 this.defaultPrevented = false; // 阻止默认
8264 this.propagationStopped = false; // 阻止冒泡
8265 this.removed = false; // 是否被移除
8266 this.event = event; // 触发的原生事件
8267};
8268
8269Util.augment(Event, {
8270 preventDefault: function preventDefault() {
8271 this.defaultPrevented = this.cancelable && true;
8272 },
8273 stopPropagation: function stopPropagation() {
8274 this.propagationStopped = true;
8275 },
8276 remove: function remove() {
8277 this.remove = true;
8278 },
8279 clone: function clone() {
8280 return Util.clone(this);
8281 },
8282 toString: function toString() {
8283 return '[Event (type=' + this.type + ')]';
8284 }
8285});
8286
8287module.exports = Event;
8288
8289/***/ }),
8290/* 54 */
8291/***/ (function(module, exports, __webpack_require__) {
8292
8293var Util = __webpack_require__(0);
8294var Element = __webpack_require__(55);
8295var Shape = __webpack_require__(114);
8296var SHAPE_MAP = {}; // 缓存图形类型
8297var INDEX = '_INDEX';
8298
8299function find(children, x, y) {
8300 var rst = void 0;
8301 for (var i = children.length - 1; i >= 0; i--) {
8302 var child = children[i];
8303 if (child.__cfg.visible && child.__cfg.capture) {
8304 if (child.isGroup) {
8305 rst = child.getShape(x, y);
8306 } else if (child.isHit(x, y)) {
8307 rst = child;
8308 }
8309 }
8310 if (rst) {
8311 break;
8312 }
8313 }
8314 return rst;
8315}
8316
8317function getComparer(compare) {
8318 return function (left, right) {
8319 var result = compare(left, right);
8320 return result === 0 ? left[INDEX] - right[INDEX] : result;
8321 };
8322}
8323
8324var Group = function Group(cfg) {
8325 Group.superclass.constructor.call(this, cfg);
8326 this.set('children', []);
8327
8328 this._beforeRenderUI();
8329 this._renderUI();
8330 this._bindUI();
8331};
8332
8333function initClassCfgs(c) {
8334 if (c.__cfg || c === Group) {
8335 return;
8336 }
8337 var superCon = c.superclass.constructor;
8338 if (superCon && !superCon.__cfg) {
8339 initClassCfgs(superCon);
8340 }
8341 c.__cfg = {};
8342
8343 Util.merge(c.__cfg, superCon.__cfg);
8344 Util.merge(c.__cfg, c.CFG);
8345}
8346
8347Util.extend(Group, Element);
8348
8349Util.augment(Group, {
8350 isGroup: true,
8351 canFill: true,
8352 canStroke: true,
8353 getDefaultCfg: function getDefaultCfg() {
8354 initClassCfgs(this.constructor);
8355 return Util.merge({}, this.constructor.__cfg);
8356 },
8357 _beforeRenderUI: function _beforeRenderUI() {},
8358 _renderUI: function _renderUI() {},
8359 _bindUI: function _bindUI() {},
8360 addShape: function addShape(type, cfg) {
8361 var canvas = this.get('canvas');
8362 cfg = cfg || {};
8363 var shapeType = SHAPE_MAP[type];
8364 if (!shapeType) {
8365 shapeType = Util.upperFirst(type);
8366 SHAPE_MAP[type] = shapeType;
8367 }
8368 if (cfg.attrs) {
8369 var attrs = cfg.attrs;
8370 if (type === 'text') {
8371 // 临时解决
8372 var topFontFamily = canvas.get('fontFamily');
8373 if (topFontFamily) {
8374 attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily;
8375 }
8376 }
8377 }
8378 cfg.canvas = canvas;
8379 cfg.type = type;
8380 var rst = new Shape[shapeType](cfg);
8381 this.add(rst);
8382 return rst;
8383 },
8384
8385 /** 添加图组
8386 * @param {Function|Object|undefined} param 图组类
8387 * @param {Object} cfg 配置项
8388 * @return {Object} rst 图组
8389 */
8390 addGroup: function addGroup(param, cfg) {
8391 var canvas = this.get('canvas');
8392 var rst = void 0;
8393 cfg = Util.merge({}, cfg);
8394 if (Util.isFunction(param)) {
8395 if (cfg) {
8396 cfg.canvas = canvas;
8397 cfg.parent = this;
8398 rst = new param(cfg);
8399 } else {
8400 rst = new param({
8401 canvas: canvas,
8402 parent: this
8403 });
8404 }
8405 this.add(rst);
8406 } else if (Util.isObject(param)) {
8407 param.canvas = canvas;
8408 rst = new Group(param);
8409 this.add(rst);
8410 } else if (param === undefined) {
8411 rst = new Group();
8412 this.add(rst);
8413 } else {
8414 return false;
8415 }
8416 return rst;
8417 },
8418
8419 /** 绘制背景
8420 * @param {Array} padding 内边距
8421 * @param {Attrs} attrs 图形属性
8422 * @param {Shape} backShape 背景图形
8423 * @return {Object} 背景层对象
8424 */
8425 renderBack: function renderBack(padding, attrs) {
8426 var backShape = this.get('backShape');
8427 var innerBox = this.getBBox();
8428 // const parent = this.get('parent'); // getParent
8429 Util.merge(attrs, {
8430 x: innerBox.minX - padding[3],
8431 y: innerBox.minY - padding[0],
8432 width: innerBox.width + padding[1] + padding[3],
8433 height: innerBox.height + padding[0] + padding[2]
8434 });
8435 if (backShape) {
8436 backShape.attr(attrs);
8437 } else {
8438 backShape = this.addShape('rect', {
8439 zIndex: -1,
8440 attrs: attrs
8441 });
8442 }
8443 this.set('backShape', backShape);
8444 this.sort();
8445 return backShape;
8446 },
8447 removeChild: function removeChild(item, destroy) {
8448 if (arguments.length >= 2) {
8449 if (this.contain(item)) {
8450 item.remove(destroy);
8451 }
8452 } else {
8453 if (arguments.length === 1) {
8454 if (Util.isBoolean(item)) {
8455 destroy = item;
8456 } else {
8457 if (this.contain(item)) {
8458 item.remove(true);
8459 }
8460 return this;
8461 }
8462 }
8463 if (arguments.length === 0) {
8464 destroy = true;
8465 }
8466
8467 Group.superclass.remove.call(this, destroy);
8468 }
8469 return this;
8470 },
8471
8472 /**
8473 * 向组中添加shape或者group
8474 * @param {Object} items 图形或者分组
8475 * @return {Object} group 本尊
8476 */
8477 add: function add(items) {
8478 var self = this;
8479 var children = self.get('children');
8480 if (Util.isArray(items)) {
8481 Util.each(items, function (item) {
8482 var parent = item.get('parent');
8483 if (parent) {
8484 parent.removeChild(item, false);
8485 }
8486 self._setEvn(item);
8487 });
8488 children.push.apply(children, items);
8489 } else {
8490 var item = items;
8491 var parent = item.get('parent');
8492 if (parent) {
8493 parent.removeChild(item, false);
8494 }
8495 self._setEvn(item);
8496 children.push(item);
8497 }
8498 return self;
8499 },
8500 contain: function contain(item) {
8501 var children = this.get('children');
8502 return children.indexOf(item) > -1;
8503 },
8504 getChildByIndex: function getChildByIndex(index) {
8505 var children = this.get('children');
8506 return children[index];
8507 },
8508 getFirst: function getFirst() {
8509 return this.getChildByIndex(0);
8510 },
8511 getLast: function getLast() {
8512 var lastIndex = this.get('children').length - 1;
8513 return this.getChildByIndex(lastIndex);
8514 },
8515 _setEvn: function _setEvn(item) {
8516 var self = this;
8517 item.__cfg.parent = self;
8518 item.__cfg.context = self.__cfg.context;
8519 item.__cfg.canvas = self.__cfg.canvas;
8520 var clip = item.__attrs.clip;
8521 if (clip) {
8522 clip.setSilent('parent', self);
8523 clip.setSilent('context', self.get('context'));
8524 }
8525 var children = item.__cfg.children;
8526 if (children) {
8527 Util.each(children, function (child) {
8528 item._setEvn(child);
8529 });
8530 }
8531 },
8532 getBBox: function getBBox() {
8533 var self = this;
8534 var minX = Infinity;
8535 var maxX = -Infinity;
8536 var minY = Infinity;
8537 var maxY = -Infinity;
8538 var children = self.get('children');
8539 if (children.length > 0) {
8540 Util.each(children, function (child) {
8541 if (child.get('visible')) {
8542 var _box = child.getBBox();
8543 if (!_box) {
8544 return true;
8545 }
8546
8547 var leftTop = [_box.minX, _box.minY, 1];
8548 var leftBottom = [_box.minX, _box.maxY, 1];
8549 var rightTop = [_box.maxX, _box.minY, 1];
8550 var rightBottom = [_box.maxX, _box.maxY, 1];
8551
8552 child.apply(leftTop);
8553 child.apply(leftBottom);
8554 child.apply(rightTop);
8555 child.apply(rightBottom);
8556
8557 var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
8558 var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);
8559 var boxMinY = Math.min(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
8560 var boxMaxY = Math.max(leftTop[1], leftBottom[1], rightTop[1], rightBottom[1]);
8561
8562 if (boxMinX < minX) {
8563 minX = boxMinX;
8564 }
8565
8566 if (boxMaxX > maxX) {
8567 maxX = boxMaxX;
8568 }
8569
8570 if (boxMinY < minY) {
8571 minY = boxMinY;
8572 }
8573
8574 if (boxMaxY > maxY) {
8575 maxY = boxMaxY;
8576 }
8577 }
8578 });
8579 } else {
8580 minX = 0;
8581 maxX = 0;
8582 minY = 0;
8583 maxY = 0;
8584 }
8585
8586 var box = {
8587 minX: minX,
8588 minY: minY,
8589 maxX: maxX,
8590 maxY: maxY
8591 };
8592 box.x = box.minX;
8593 box.y = box.minY;
8594 box.width = box.maxX - box.minX;
8595 box.height = box.maxY - box.minY;
8596 return box;
8597 },
8598 drawInner: function drawInner(context) {
8599 var children = this.get('children');
8600 for (var i = 0; i < children.length; i++) {
8601 var child = children[i];
8602 child.draw(context);
8603 }
8604 return this;
8605 },
8606 getCount: function getCount() {
8607 return this.get('children').length;
8608 },
8609 sort: function sort() {
8610 var children = this.get('children');
8611 // 稳定排序
8612 Util.each(children, function (child, index) {
8613 child[INDEX] = index;
8614 return child;
8615 });
8616
8617 children.sort(getComparer(function (obj1, obj2) {
8618 return obj1.get('zIndex') - obj2.get('zIndex');
8619 }));
8620
8621 return this;
8622 },
8623 findById: function findById(id) {
8624 return this.find(function (item) {
8625 return item.get('id') === id;
8626 });
8627 },
8628
8629 /**
8630 * 根据查找函数查找分组或者图形
8631 * @param {Function} fn 匹配函数
8632 * @return {Canvas.Base} 分组或者图形
8633 */
8634 find: function find(fn) {
8635 if (Util.isString(fn)) {
8636 return this.findById(fn);
8637 }
8638 var children = this.get('children');
8639 var rst = null;
8640
8641 Util.each(children, function (item) {
8642 if (fn(item)) {
8643 rst = item;
8644 } else if (item.find) {
8645 rst = item.find(fn);
8646 }
8647 if (rst) {
8648 return false;
8649 }
8650 });
8651 return rst;
8652 },
8653
8654 /**
8655 * @param {Function} fn filter mathod
8656 * @return {Array} all the matching shapes and groups
8657 */
8658 findAll: function findAll(fn) {
8659 var children = this.get('children');
8660 var rst = [];
8661 var childRst = [];
8662 Util.each(children, function (item) {
8663 if (fn(item)) {
8664 rst.push(item);
8665 }
8666 if (item.findAllBy) {
8667 childRst = item.findAllBy(fn);
8668 rst = rst.concat(childRst);
8669 }
8670 });
8671 return rst;
8672 },
8673
8674 /**
8675 * @Deprecated
8676 * @param {Function} fn filter method
8677 * @return {Object} found shape or group
8678 */
8679 findBy: function findBy(fn) {
8680 var children = this.get('children');
8681 var rst = null;
8682
8683 Util.each(children, function (item) {
8684 if (fn(item)) {
8685 rst = item;
8686 } else if (item.findBy) {
8687 rst = item.findBy(fn);
8688 }
8689 if (rst) {
8690 return false;
8691 }
8692 });
8693 return rst;
8694 },
8695
8696 /**
8697 * @Deprecated
8698 * @param {Function} fn filter mathod
8699 * @return {Array} all the matching shapes and groups
8700 */
8701 findAllBy: function findAllBy(fn) {
8702 var children = this.get('children');
8703 var rst = [];
8704 var childRst = [];
8705 Util.each(children, function (item) {
8706 if (fn(item)) {
8707 rst.push(item);
8708 }
8709 if (item.findAllBy) {
8710 childRst = item.findAllBy(fn);
8711 rst = rst.concat(childRst);
8712 }
8713 });
8714 return rst;
8715 },
8716
8717 /**
8718 * 根据x,y轴坐标获取对应的图形
8719 * @param {Number} x x坐标
8720 * @param {Number} y y坐标
8721 * @return {Object} 最上面的图形
8722 */
8723 getShape: function getShape(x, y) {
8724 var self = this;
8725 var clip = self.__attrs.clip;
8726 var children = self.__cfg.children;
8727 var rst = void 0;
8728 if (clip) {
8729 if (clip.inside(x, y)) {
8730 rst = find(children, x, y);
8731 }
8732 } else {
8733 rst = find(children, x, y);
8734 }
8735 return rst;
8736 },
8737 clearTotalMatrix: function clearTotalMatrix() {
8738 var m = this.get('totalMatrix');
8739 if (m) {
8740 this.setSilent('totalMatrix', null);
8741 var children = this.__cfg.children;
8742 for (var i = 0; i < children.length; i++) {
8743 var child = children[i];
8744 child.clearTotalMatrix();
8745 }
8746 }
8747 },
8748 clear: function clear() {
8749 var children = this.get('children');
8750
8751 while (children.length !== 0) {
8752 children[children.length - 1].remove();
8753 }
8754 return this;
8755 },
8756 destroy: function destroy() {
8757 if (this.get('destroyed')) {
8758 return;
8759 }
8760 this.clear();
8761 Group.superclass.destroy.call(this);
8762 }
8763});
8764
8765module.exports = Group;
8766
8767/***/ }),
8768/* 55 */
8769/***/ (function(module, exports, __webpack_require__) {
8770
8771var Util = __webpack_require__(0);
8772var Attribute = __webpack_require__(112);
8773var Transform = __webpack_require__(113);
8774var Animate = __webpack_require__(32);
8775var Format = __webpack_require__(21);
8776var EventEmitter = __webpack_require__(41);
8777
8778var SHAPE_ATTRS = ['fillStyle', 'font', 'globalAlpha', 'lineCap', 'lineWidth', 'lineJoin', 'miterLimit', 'shadowBlur', 'shadowColor', 'shadowOffsetX', 'shadowOffsetY', 'strokeStyle', 'textAlign', 'textBaseline', 'lineDash', 'lineDashOffset'];
8779
8780var Element = function Element(cfg) {
8781 this.__cfg = {
8782 zIndex: 0,
8783 capture: true,
8784 visible: true,
8785 destroyed: false
8786 }; // 配置存放地
8787
8788 Util.assign(this.__cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
8789 this.initAttrs(this.__cfg.attrs); // 初始化绘图属性
8790 this.initTransform(); // 初始化变换
8791 this.init(); // 类型初始化
8792};
8793
8794Element.CFG = {
8795 /**
8796 * 唯一标示
8797 * @type {Number}
8798 */
8799 id: null,
8800 /**
8801 * Z轴的层叠关系,Z值越大离用户越近
8802 * @type {Number}
8803 */
8804 zIndex: 0,
8805 /**
8806 * Canvas对象
8807 * @type: {Object}
8808 */
8809 canvas: null,
8810 /**
8811 * 父元素指针
8812 * @type {Object}
8813 */
8814 parent: null,
8815 /**
8816 * 用来设置当前对象是否能被捕捉
8817 * true 能
8818 * false 不能
8819 * 对象默认是都可以被捕捉的, 当capture为false时,group.getShape(x, y)方法无法获得该元素
8820 * 通过将不必要捕捉的元素的该属性设置成false, 来提高捕捉性能
8821 * @type {Boolean}
8822 **/
8823 capture: true,
8824 /**
8825 * 画布的上下文
8826 * @type {Object}
8827 */
8828 context: null,
8829 /**
8830 * 是否显示
8831 * @type {Boolean}
8832 */
8833 visible: true,
8834 /**
8835 * 是否被销毁
8836 * @type: {Boolean}
8837 */
8838 destroyed: false
8839};
8840
8841Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {
8842 init: function init() {
8843 this.setSilent('animable', true);
8844 this.setSilent('animating', false); // 初始时不处于动画状态
8845 var attrs = this.__attrs;
8846 if (attrs && attrs.rotate) {
8847 this.rotateAtStart(attrs.rotate);
8848 }
8849 },
8850 getParent: function getParent() {
8851 return this.get('parent');
8852 },
8853
8854 /**
8855 * 获取默认的配置信息
8856 * @protected
8857 * @return {Object} 默认的属性
8858 */
8859 getDefaultCfg: function getDefaultCfg() {
8860 return {};
8861 },
8862 set: function set(name, value) {
8863 if (name === 'zIndex' && this._beforeSetZIndex) {
8864 this._beforeSetZIndex(value);
8865 }
8866 if (name === 'loading' && this._beforeSetLoading) {
8867 this._beforeSetLoading(value);
8868 }
8869 this.__cfg[name] = value;
8870 return this;
8871 },
8872 setSilent: function setSilent(name, value) {
8873 this.__cfg[name] = value;
8874 },
8875 get: function get(name) {
8876 return this.__cfg[name];
8877 },
8878 draw: function draw(context) {
8879 if (this.get('destroyed')) {
8880 return;
8881 }
8882 if (this.get('visible')) {
8883 this.setContext(context);
8884 this.drawInner(context);
8885 this.restoreContext(context);
8886 }
8887 },
8888 setContext: function setContext(context) {
8889 var clip = this.__attrs.clip;
8890 context.save();
8891 if (clip) {
8892 // context.save();
8893 clip.resetTransform(context);
8894 clip.createPath(context);
8895 context.clip();
8896 // context.restore();
8897 }
8898 this.resetContext(context);
8899 this.resetTransform(context);
8900 },
8901 restoreContext: function restoreContext(context) {
8902 context.restore();
8903 },
8904 resetContext: function resetContext(context) {
8905 var elAttrs = this.__attrs;
8906 // var canvas = this.get('canvas');
8907 if (!this.isGroup) {
8908 // canvas.registShape(this); // 快速拾取方案暂时不执行
8909 for (var k in elAttrs) {
8910 if (SHAPE_ATTRS.indexOf(k) > -1) {
8911 // 非canvas属性不附加
8912 var v = elAttrs[k];
8913 if (k === 'fillStyle') {
8914 v = Format.parseStyle(v, this);
8915 }
8916 if (k === 'strokeStyle') {
8917 v = Format.parseStyle(v, this);
8918 }
8919 if (k === 'lineDash' && context.setLineDash) {
8920 if (Util.isArray(v)) {
8921 context.setLineDash(v);
8922 } else if (Util.isString(v)) {
8923 context.setLineDash(v.split(' '));
8924 }
8925 } else {
8926 context[k] = v;
8927 }
8928 }
8929 }
8930 }
8931 },
8932 drawInner: function drawInner() /* context */{},
8933 show: function show() {
8934 this.set('visible', true);
8935 return this;
8936 },
8937 hide: function hide() {
8938 this.set('visible', false);
8939 return this;
8940 },
8941 remove: function remove(destroy) {
8942 if (destroy === undefined) {
8943 destroy = true;
8944 }
8945
8946 if (this.get('parent')) {
8947 var parent = this.get('parent');
8948 var children = parent.get('children');
8949 Util.remove(children, this);
8950 }
8951
8952 if (destroy) {
8953 this.destroy();
8954 }
8955
8956 return this;
8957 },
8958 destroy: function destroy() {
8959 var destroyed = this.get('destroyed');
8960 if (destroyed) {
8961 return;
8962 }
8963 // 如果正在执行动画,清理动画
8964 if (this.get('animating')) {
8965 var timer = this.get('animateTimer');
8966 timer && timer.stop();
8967 }
8968 this.__cfg = {};
8969 this.__attrs = null;
8970 this.removeEvent(); // 移除所有的事件
8971 this.set('destroyed', true);
8972 },
8973 _beforeSetZIndex: function _beforeSetZIndex(zIndex) {
8974 this.__cfg.zIndex = zIndex;
8975
8976 if (!Util.isNil(this.get('parent'))) {
8977 this.get('parent').sort();
8978 }
8979 return zIndex;
8980 },
8981 _setAttrs: function _setAttrs(attrs) {
8982 this.attr(attrs);
8983 return attrs;
8984 },
8985 setZIndex: function setZIndex(zIndex) {
8986 this.__cfg.zIndex = zIndex;
8987 return zIndex;
8988 },
8989 clone: function clone() {
8990 return Util.clone(this);
8991 },
8992 getBBox: function getBBox() {
8993 return {
8994 minX: 0,
8995 maxX: 0,
8996 minY: 0,
8997 maxY: 0
8998 };
8999 }
9000});
9001
9002module.exports = Element;
9003
9004/***/ }),
9005/* 56 */
9006/***/ (function(module, exports, __webpack_require__) {
9007
9008var Util = __webpack_require__(0);
9009var Shape = __webpack_require__(1);
9010var Inside = __webpack_require__(3);
9011
9012var Circle = function Circle(cfg) {
9013 Circle.superclass.constructor.call(this, cfg);
9014};
9015
9016Circle.ATTRS = {
9017 x: 0,
9018 y: 0,
9019 r: 0,
9020 lineWidth: 1
9021};
9022
9023Util.extend(Circle, Shape);
9024
9025Util.augment(Circle, {
9026 canFill: true,
9027 canStroke: true,
9028 type: 'circle',
9029 getDefaultAttrs: function getDefaultAttrs() {
9030 return {
9031 lineWidth: 1
9032 };
9033 },
9034 calculateBox: function calculateBox() {
9035 var attrs = this.__attrs;
9036 var cx = attrs.x;
9037 var cy = attrs.y;
9038 var r = attrs.r;
9039 var lineWidth = this.getHitLineWidth();
9040 var halfWidth = lineWidth / 2 + r;
9041 return {
9042 minX: cx - halfWidth,
9043 minY: cy - halfWidth,
9044 maxX: cx + halfWidth,
9045 maxY: cy + halfWidth
9046 };
9047 },
9048 isPointInPath: function isPointInPath(x, y) {
9049 var fill = this.hasFill();
9050 var stroke = this.hasStroke();
9051 if (fill && stroke) {
9052 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
9053 }
9054
9055 if (fill) {
9056 return this._isPointInFill(x, y);
9057 }
9058
9059 if (stroke) {
9060 return this._isPointInStroke(x, y);
9061 }
9062
9063 return false;
9064 },
9065 _isPointInFill: function _isPointInFill(x, y) {
9066 var attrs = this.__attrs;
9067 var cx = attrs.x;
9068 var cy = attrs.y;
9069 var r = attrs.r;
9070
9071 return Inside.circle(cx, cy, r, x, y);
9072 },
9073 _isPointInStroke: function _isPointInStroke(x, y) {
9074 var attrs = this.__attrs;
9075 var cx = attrs.x;
9076 var cy = attrs.y;
9077 var r = attrs.r;
9078 var lineWidth = this.getHitLineWidth();
9079
9080 return Inside.arcline(cx, cy, r, 0, Math.PI * 2, false, lineWidth, x, y);
9081 },
9082 createPath: function createPath(context) {
9083 var attrs = this.__attrs;
9084 var cx = attrs.x;
9085 var cy = attrs.y;
9086 var r = attrs.r;
9087 context = context || self.get('context');
9088
9089 context.beginPath();
9090 context.arc(cx, cy, r, 0, Math.PI * 2, false);
9091 }
9092});
9093
9094module.exports = Circle;
9095
9096/***/ }),
9097/* 57 */
9098/***/ (function(module, exports, __webpack_require__) {
9099
9100var Util = __webpack_require__(0);
9101var Shape = __webpack_require__(1);
9102var Inside = __webpack_require__(3);
9103var mat3 = __webpack_require__(2).mat3;
9104var vec3 = __webpack_require__(2).vec3;
9105
9106var Ellipse = function Ellipse(cfg) {
9107 Ellipse.superclass.constructor.call(this, cfg);
9108};
9109
9110Ellipse.ATTRS = {
9111 x: 0,
9112 y: 0,
9113 rx: 1,
9114 ry: 1,
9115 lineWidth: 1
9116};
9117
9118Util.extend(Ellipse, Shape);
9119
9120Util.augment(Ellipse, {
9121 canFill: true,
9122 canStroke: true,
9123 type: 'ellipse',
9124 getDefaultAttrs: function getDefaultAttrs() {
9125 return {
9126 lineWidth: 1
9127 };
9128 },
9129 calculateBox: function calculateBox() {
9130 var attrs = this.__attrs;
9131 var cx = attrs.x;
9132 var cy = attrs.y;
9133 var rx = attrs.rx;
9134 var ry = attrs.ry;
9135 var lineWidth = this.getHitLineWidth();
9136 var halfXWidth = rx + lineWidth / 2;
9137 var halfYWidth = ry + lineWidth / 2;
9138
9139 return {
9140 minX: cx - halfXWidth,
9141 minY: cy - halfYWidth,
9142 maxX: cx + halfXWidth,
9143 maxY: cy + halfYWidth
9144 };
9145 },
9146 isPointInPath: function isPointInPath(x, y) {
9147 var fill = this.hasFill();
9148 var stroke = this.hasStroke();
9149
9150 if (fill && stroke) {
9151 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
9152 }
9153
9154 if (fill) {
9155 return this._isPointInFill(x, y);
9156 }
9157
9158 if (stroke) {
9159 return this._isPointInStroke(x, y);
9160 }
9161
9162 return false;
9163 },
9164 _isPointInFill: function _isPointInFill(x, y) {
9165 var attrs = this.__attrs;
9166 var cx = attrs.x;
9167 var cy = attrs.y;
9168 var rx = attrs.rx;
9169 var ry = attrs.ry;
9170
9171 var r = rx > ry ? rx : ry;
9172 var scaleX = rx > ry ? 1 : rx / ry;
9173 var scaleY = rx > ry ? ry / rx : 1;
9174
9175 var p = [x, y, 1];
9176 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
9177 mat3.scale(m, m, [scaleX, scaleY]);
9178 mat3.translate(m, m, [cx, cy]);
9179 var inm = mat3.invert([], m);
9180 vec3.transformMat3(p, p, inm);
9181
9182 return Inside.circle(0, 0, r, p[0], p[1]);
9183 },
9184 _isPointInStroke: function _isPointInStroke(x, y) {
9185 var attrs = this.__attrs;
9186 var cx = attrs.x;
9187 var cy = attrs.y;
9188 var rx = attrs.rx;
9189 var ry = attrs.ry;
9190 var lineWidth = this.getHitLineWidth();
9191
9192 var r = rx > ry ? rx : ry;
9193 var scaleX = rx > ry ? 1 : rx / ry;
9194 var scaleY = rx > ry ? ry / rx : 1;
9195 var p = [x, y, 1];
9196 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
9197 mat3.scale(m, m, [scaleX, scaleY]);
9198 mat3.translate(m, m, [cx, cy]);
9199 var inm = mat3.invert([], m);
9200 vec3.transformMat3(p, p, inm);
9201
9202 return Inside.arcline(0, 0, r, 0, Math.PI * 2, false, lineWidth, p[0], p[1]);
9203 },
9204 createPath: function createPath(context) {
9205 var attrs = this.__attrs;
9206 var cx = attrs.x;
9207 var cy = attrs.y;
9208 var rx = attrs.rx;
9209 var ry = attrs.ry;
9210
9211 context = context || self.get('context');
9212 var r = rx > ry ? rx : ry;
9213 var scaleX = rx > ry ? 1 : rx / ry;
9214 var scaleY = rx > ry ? ry / rx : 1;
9215
9216 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
9217 mat3.scale(m, m, [scaleX, scaleY]);
9218 mat3.translate(m, m, [cx, cy]);
9219 context.beginPath();
9220 context.save();
9221 context.transform(m[0], m[1], m[3], m[4], m[6], m[7]);
9222 context.arc(0, 0, r, 0, Math.PI * 2);
9223 context.restore();
9224 context.closePath();
9225 }
9226});
9227
9228module.exports = Ellipse;
9229
9230/***/ }),
9231/* 58 */
9232/***/ (function(module, exports, __webpack_require__) {
9233
9234var Util = __webpack_require__(0);
9235var Shape = __webpack_require__(1);
9236var PathSegment = __webpack_require__(26);
9237var Format = __webpack_require__(21);
9238var Arrow = __webpack_require__(6);
9239var PathUtil = __webpack_require__(15);
9240var CubicMath = __webpack_require__(12);
9241
9242var Path = function Path(cfg) {
9243 Path.superclass.constructor.call(this, cfg);
9244};
9245
9246Path.ATTRS = {
9247 path: null,
9248 lineWidth: 1,
9249 curve: null, // 曲线path
9250 tCache: null,
9251 startArrow: false,
9252 endArrow: false
9253};
9254
9255Util.extend(Path, Shape);
9256
9257Util.augment(Path, {
9258 canFill: true,
9259 canStroke: true,
9260 type: 'path',
9261 getDefaultAttrs: function getDefaultAttrs() {
9262 return {
9263 lineWidth: 1,
9264 startArrow: false,
9265 endArrow: false
9266 };
9267 },
9268 _afterSetAttrPath: function _afterSetAttrPath(path) {
9269 var self = this;
9270 if (Util.isNil(path)) {
9271 self.setSilent('segments', null);
9272 self.setSilent('box', undefined);
9273 return;
9274 }
9275 var pathArray = Format.parsePath(path);
9276 var preSegment = void 0;
9277 var segments = [];
9278
9279 if (!Util.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {
9280 return;
9281 }
9282 var count = pathArray.length;
9283 for (var i = 0; i < pathArray.length; i++) {
9284 var item = pathArray[i];
9285 preSegment = new PathSegment(item, preSegment, i === count - 1);
9286 segments.push(preSegment);
9287 }
9288 self.setSilent('segments', segments);
9289 self.set('tCache', null);
9290 this.setSilent('box', null);
9291 },
9292 _afterSetAttrAll: function _afterSetAttrAll(objs) {
9293 if (objs.path) {
9294 this._afterSetAttrPath(objs.path);
9295 }
9296 },
9297 calculateBox: function calculateBox() {
9298 var self = this;
9299 var segments = self.get('segments');
9300
9301 if (!segments) {
9302 return null;
9303 }
9304 var lineWidth = this.getHitLineWidth();
9305 var minX = Infinity;
9306 var maxX = -Infinity;
9307 var minY = Infinity;
9308 var maxY = -Infinity;
9309 Util.each(segments, function (segment) {
9310 segment.getBBox(lineWidth);
9311 var box = segment.box;
9312 if (box) {
9313 if (box.minX < minX) {
9314 minX = box.minX;
9315 }
9316
9317 if (box.maxX > maxX) {
9318 maxX = box.maxX;
9319 }
9320
9321 if (box.minY < minY) {
9322 minY = box.minY;
9323 }
9324
9325 if (box.maxY > maxY) {
9326 maxY = box.maxY;
9327 }
9328 }
9329 });
9330 return {
9331 minX: minX,
9332 minY: minY,
9333 maxX: maxX,
9334 maxY: maxY
9335 };
9336 },
9337 isPointInPath: function isPointInPath(x, y) {
9338 var self = this;
9339 var fill = self.hasFill();
9340 var stroke = self.hasStroke();
9341
9342 if (fill && stroke) {
9343 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
9344 }
9345
9346 if (fill) {
9347 return self._isPointInFill(x, y);
9348 }
9349
9350 if (stroke) {
9351 return self._isPointInStroke(x, y);
9352 }
9353
9354 return false;
9355 },
9356 _isPointInFill: function _isPointInFill(x, y) {
9357 var self = this;
9358 var context = self.get('context');
9359 if (!context) return undefined;
9360 self.createPath();
9361 return context.isPointInPath(x, y);
9362 },
9363 _isPointInStroke: function _isPointInStroke(x, y) {
9364 var self = this;
9365 var segments = self.get('segments');
9366 if (!Util.isEmpty(segments)) {
9367 var lineWidth = self.getHitLineWidth();
9368 for (var i = 0, l = segments.length; i < l; i++) {
9369 if (segments[i].isInside(x, y, lineWidth)) {
9370 return true;
9371 }
9372 }
9373 }
9374
9375 return false;
9376 },
9377 _setTcache: function _setTcache() {
9378 var totalLength = 0;
9379 var tempLength = 0;
9380 var tCache = [];
9381 var segmentT = void 0;
9382 var segmentL = void 0;
9383 var segmentN = void 0;
9384 var l = void 0;
9385 var curve = this.curve;
9386
9387 if (!curve) {
9388 return;
9389 }
9390
9391 Util.each(curve, function (segment, i) {
9392 segmentN = curve[i + 1];
9393 l = segment.length;
9394 if (segmentN) {
9395 totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
9396 }
9397 });
9398
9399 Util.each(curve, function (segment, i) {
9400 segmentN = curve[i + 1];
9401 l = segment.length;
9402 if (segmentN) {
9403 segmentT = [];
9404 segmentT[0] = tempLength / totalLength;
9405 segmentL = CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);
9406 tempLength += segmentL;
9407 segmentT[1] = tempLength / totalLength;
9408 tCache.push(segmentT);
9409 }
9410 });
9411
9412 this.tCache = tCache;
9413 },
9414 _calculateCurve: function _calculateCurve() {
9415 var self = this;
9416 var attrs = self.__attrs;
9417 var path = attrs.path;
9418 this.curve = PathUtil.pathTocurve(path);
9419 },
9420 getPoint: function getPoint(t) {
9421 var tCache = this.tCache;
9422 var subt = void 0;
9423 var index = void 0;
9424
9425 if (!tCache) {
9426 this._calculateCurve();
9427 this._setTcache();
9428 tCache = this.tCache;
9429 }
9430
9431 var curve = this.curve;
9432
9433 if (!tCache) {
9434 if (curve) {
9435 return {
9436 x: curve[0][1],
9437 y: curve[0][2]
9438 };
9439 }
9440 return null;
9441 }
9442 Util.each(tCache, function (v, i) {
9443 if (t >= v[0] && t <= v[1]) {
9444 subt = (t - v[0]) / (v[1] - v[0]);
9445 index = i;
9446 }
9447 });
9448 var seg = curve[index];
9449 if (Util.isNil(seg) || Util.isNil(index)) {
9450 return null;
9451 }
9452 var l = seg.length;
9453 var nextSeg = curve[index + 1];
9454 return {
9455 x: CubicMath.at(seg[l - 2], nextSeg[1], nextSeg[3], nextSeg[5], 1 - subt),
9456 y: CubicMath.at(seg[l - 1], nextSeg[2], nextSeg[4], nextSeg[6], 1 - subt)
9457 };
9458 },
9459 createPath: function createPath(context) {
9460 var self = this;
9461 var segments = self.get('segments');
9462 if (!Util.isArray(segments)) return;
9463
9464 context = context || self.get('context');
9465
9466 context.beginPath();
9467 var segmentsLen = segments.length;
9468
9469 for (var i = 0; i < segmentsLen; i++) {
9470 segments[i].draw(context);
9471 }
9472 },
9473 afterPath: function afterPath(context) {
9474 var self = this;
9475 var attrs = self.__attrs;
9476 var segments = self.get('segments');
9477 var path = attrs.path;
9478 var startPoint = void 0,
9479 endPoint = void 0,
9480 tangent = void 0;
9481 context = context || self.get('context');
9482 if (!Util.isArray(segments)) return;
9483 if (!attrs.startArrow && !attrs.endArrow) {
9484 return;
9485 }
9486 if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) {
9487 // 闭合路径不绘制箭头
9488 return;
9489 }
9490 var segmentsLen = segments.length;
9491 if (segmentsLen > 1) {
9492 startPoint = segments[0].endPoint;
9493 endPoint = segments[1].endPoint;
9494 tangent = segments[1].startTangent;
9495 if (Util.isFunction(tangent)) {
9496 var v = tangent();
9497 Arrow.addStartArrow(context, attrs, startPoint.x - v[0], startPoint.y - v[1], startPoint.x, startPoint.y);
9498 } else {
9499 Arrow.addStartArrow(context, attrs, endPoint.x, endPoint.y, startPoint.x, startPoint.y);
9500 }
9501 }
9502
9503 if (segmentsLen > 1 && !closed) {
9504 startPoint = segments[segmentsLen - 2].endPoint;
9505 endPoint = segments[segmentsLen - 1].endPoint;
9506 tangent = segments[segmentsLen - 1].endTangent;
9507 if (Util.isFunction(tangent)) {
9508 var _v = tangent();
9509 Arrow.addEndArrow(context, attrs, endPoint.x - _v[0], endPoint.y - _v[1], endPoint.x, endPoint.y, tangent());
9510 } else {
9511 Arrow.addEndArrow(context, attrs, startPoint.x, startPoint.y, endPoint.x, endPoint.y);
9512 }
9513 }
9514 }
9515});
9516
9517module.exports = Path;
9518
9519/***/ }),
9520/* 59 */
9521/***/ (function(module, exports, __webpack_require__) {
9522
9523var Util = __webpack_require__(0);
9524var Shape = __webpack_require__(1);
9525var Inside = __webpack_require__(3);
9526
9527var CText = function CText(cfg) {
9528 CText.superclass.constructor.call(this, cfg);
9529};
9530
9531CText.ATTRS = {
9532 x: 0,
9533 y: 0,
9534 text: null,
9535 fontSize: 12,
9536 fontFamily: 'sans-serif',
9537 fontStyle: 'normal',
9538 fontWeight: 'normal',
9539 fontVariant: 'normal',
9540 textAlign: 'start',
9541 textBaseline: 'bottom',
9542 lineHeight: null,
9543 textArr: null
9544};
9545
9546Util.extend(CText, Shape);
9547
9548Util.augment(CText, {
9549 canFill: true,
9550 canStroke: true,
9551 type: 'text',
9552 getDefaultAttrs: function getDefaultAttrs() {
9553 return {
9554 lineWidth: 1,
9555 lineCount: 1,
9556 fontSize: 12,
9557 fontFamily: 'sans-serif',
9558 fontStyle: 'normal',
9559 fontWeight: 'normal',
9560 fontVariant: 'normal',
9561 textAlign: 'start',
9562 textBaseline: 'bottom'
9563 };
9564 },
9565 initTransform: function initTransform() {
9566 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
9567 var fontSize = this.__attrs.fontSize;
9568 if (fontSize && +fontSize < 12) {
9569 // 小于 12 像素的文本进行 scale 处理
9570 this.transform([['t', -1 * this.__attrs.x, -1 * this.__attrs.y], ['s', +fontSize / 12, +fontSize / 12], ['t', this.__attrs.x, this.__attrs.y]]);
9571 }
9572 },
9573 _assembleFont: function _assembleFont() {
9574 // var self = this;
9575 var attrs = this.__attrs;
9576 var fontSize = attrs.fontSize;
9577 var fontFamily = attrs.fontFamily;
9578 var fontWeight = attrs.fontWeight;
9579 var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
9580 var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
9581 // self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
9582 attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');
9583 },
9584 _afterSetAttrFontSize: function _afterSetAttrFontSize() {
9585 /* this.attr({
9586 height: this.__getTextHeight()
9587 }); */
9588 this._assembleFont();
9589 },
9590 _afterSetAttrFontFamily: function _afterSetAttrFontFamily() {
9591 this._assembleFont();
9592 },
9593 _afterSetAttrFontWeight: function _afterSetAttrFontWeight() {
9594 this._assembleFont();
9595 },
9596 _afterSetAttrFontStyle: function _afterSetAttrFontStyle() {
9597 this._assembleFont();
9598 },
9599 _afterSetAttrFontVariant: function _afterSetAttrFontVariant() {
9600 this._assembleFont();
9601 },
9602 _afterSetAttrFont: function _afterSetAttrFont() {
9603 // this.attr('width', this.measureText());
9604 },
9605 _afterSetAttrText: function _afterSetAttrText() {
9606 var attrs = this.__attrs;
9607 var text = attrs.text;
9608 var textArr = void 0;
9609 if (Util.isString(text) && text.indexOf('\n') !== -1) {
9610 textArr = text.split('\n');
9611 var lineCount = textArr.length;
9612 attrs.lineCount = lineCount;
9613 attrs.textArr = textArr;
9614 }
9615 // attrs.height = this.__getTextHeight();
9616 // attrs.width = this.measureText();
9617 },
9618 _getTextHeight: function _getTextHeight() {
9619 var attrs = this.__attrs;
9620 var lineCount = attrs.lineCount;
9621 var fontSize = attrs.fontSize * 1;
9622 if (lineCount > 1) {
9623 var spaceingY = this._getSpaceingY();
9624 return fontSize * lineCount + spaceingY * (lineCount - 1);
9625 }
9626 return fontSize;
9627 },
9628
9629 // 计算浪费,效率低,待优化
9630 _afterSetAttrAll: function _afterSetAttrAll(objs) {
9631 var self = this;
9632 if ('fontSize' in objs || 'fontWeight' in objs || 'fontStyle' in objs || 'fontVariant' in objs || 'fontFamily' in objs) {
9633 self._assembleFont();
9634 }
9635
9636 if ('text' in objs) {
9637 self._afterSetAttrText(objs.text);
9638 }
9639 },
9640 isHitBox: function isHitBox() {
9641 return false;
9642 },
9643 calculateBox: function calculateBox() {
9644 var self = this;
9645 var attrs = self.__attrs;
9646 var x = attrs.x;
9647 var y = attrs.y;
9648 var width = self.measureText(); // attrs.width
9649 if (!width) {
9650 // 如果width不存在,四点共其实点
9651 return {
9652 minX: x,
9653 minY: y,
9654 maxX: x,
9655 maxY: y
9656 };
9657 }
9658 var height = self._getTextHeight(); // attrs.height
9659 var textAlign = attrs.textAlign;
9660 var textBaseline = attrs.textBaseline;
9661 var lineWidth = self.getHitLineWidth();
9662 var point = {
9663 x: x,
9664 y: y - height
9665 };
9666
9667 if (textAlign) {
9668 if (textAlign === 'end' || textAlign === 'right') {
9669 point.x -= width;
9670 } else if (textAlign === 'center') {
9671 point.x -= width / 2;
9672 }
9673 }
9674
9675 if (textBaseline) {
9676 if (textBaseline === 'top') {
9677 point.y += height;
9678 } else if (textBaseline === 'middle') {
9679 point.y += height / 2;
9680 }
9681 }
9682
9683 this.set('startPoint', point);
9684 var halfWidth = lineWidth / 2;
9685 return {
9686 minX: point.x - halfWidth,
9687 minY: point.y - halfWidth,
9688 maxX: point.x + width + halfWidth,
9689 maxY: point.y + height + halfWidth
9690 };
9691 },
9692 _getSpaceingY: function _getSpaceingY() {
9693 var attrs = this.__attrs;
9694 var lineHeight = attrs.lineHeight;
9695 var fontSize = attrs.fontSize * 1;
9696 return lineHeight ? lineHeight - fontSize : fontSize * 0.14;
9697 },
9698 isPointInPath: function isPointInPath(x, y) {
9699 var self = this;
9700 var box = self.getBBox();
9701 if (self.hasFill() || self.hasStroke()) {
9702 return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y);
9703 }
9704 },
9705 drawInner: function drawInner(context) {
9706 var self = this;
9707 var attrs = self.__attrs;
9708 var text = attrs.text;
9709 if (!text) {
9710 return;
9711 }
9712 var textArr = attrs.textArr;
9713 var x = attrs.x;
9714 var y = attrs.y;
9715
9716 context.beginPath();
9717 if (self.hasStroke()) {
9718 if (textArr) {
9719 self._drawTextArr(context, false);
9720 } else {
9721 context.strokeText(text, x, y);
9722 }
9723 }
9724 if (self.hasFill()) {
9725 var fillOpacity = attrs.fillOpacity;
9726 if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
9727 context.globalAlpha = fillOpacity;
9728 }
9729 if (textArr) {
9730 self._drawTextArr(context, true);
9731 } else {
9732 context.fillText(text, x, y);
9733 }
9734 }
9735 },
9736 _drawTextArr: function _drawTextArr(context, fill) {
9737 var textArr = this.__attrs.textArr;
9738 var textBaseline = this.__attrs.textBaseline;
9739 var fontSize = this.__attrs.fontSize * 1;
9740 var spaceingY = this._getSpaceingY();
9741 var x = this.__attrs.x;
9742 var y = this.__attrs.y;
9743 var box = this.getBBox();
9744 var height = box.maxY - box.minY;
9745 var subY = void 0;
9746
9747 Util.each(textArr, function (subText, index) {
9748 subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;
9749 if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;
9750 if (textBaseline === 'top') subY += height - fontSize;
9751 if (fill) {
9752 context.fillText(subText, x, subY);
9753 } else {
9754 context.strokeText(subText, x, subY);
9755 }
9756 });
9757 },
9758 measureText: function measureText() {
9759 var self = this;
9760 var attrs = self.__attrs;
9761 var text = attrs.text;
9762 var font = attrs.font;
9763 var textArr = attrs.textArr;
9764 var measureWidth = void 0;
9765 var width = 0;
9766
9767 if (Util.isNil(text)) return undefined;
9768 var context = document.createElement('canvas').getContext('2d');
9769 context.save();
9770 context.font = font;
9771 if (textArr) {
9772 Util.each(textArr, function (subText) {
9773 measureWidth = context.measureText(subText).width;
9774 if (width < measureWidth) {
9775 width = measureWidth;
9776 }
9777 context.restore();
9778 });
9779 } else {
9780 width = context.measureText(text).width;
9781 context.restore();
9782 }
9783 return width;
9784 }
9785});
9786
9787module.exports = CText;
9788
9789/***/ }),
9790/* 60 */
9791/***/ (function(module, exports, __webpack_require__) {
9792
9793var Util = __webpack_require__(0);
9794var Shape = __webpack_require__(1);
9795var Inside = __webpack_require__(3);
9796var Arrow = __webpack_require__(6);
9797var LineMath = __webpack_require__(22);
9798
9799var Line = function Line(cfg) {
9800 Line.superclass.constructor.call(this, cfg);
9801};
9802
9803Line.ATTRS = {
9804 x1: 0,
9805 y1: 0,
9806 x2: 0,
9807 y2: 0,
9808 lineWidth: 1,
9809 startArrow: false,
9810 endArrow: false
9811};
9812
9813Util.extend(Line, Shape);
9814
9815Util.augment(Line, {
9816 canStroke: true,
9817 type: 'line',
9818 getDefaultAttrs: function getDefaultAttrs() {
9819 return {
9820 lineWidth: 1,
9821 startArrow: false,
9822 endArrow: false
9823 };
9824 },
9825 calculateBox: function calculateBox() {
9826 var attrs = this.__attrs;
9827 var x1 = attrs.x1,
9828 y1 = attrs.y1,
9829 x2 = attrs.x2,
9830 y2 = attrs.y2;
9831
9832 var lineWidth = this.getHitLineWidth();
9833 return LineMath.box(x1, y1, x2, y2, lineWidth);
9834 },
9835 isPointInPath: function isPointInPath(x, y) {
9836 var attrs = this.__attrs;
9837 var x1 = attrs.x1,
9838 y1 = attrs.y1,
9839 x2 = attrs.x2,
9840 y2 = attrs.y2;
9841
9842 var lineWidth = this.getHitLineWidth();
9843
9844 if (this.hasStroke()) {
9845 return Inside.line(x1, y1, x2, y2, lineWidth, x, y);
9846 }
9847
9848 return false;
9849 },
9850 createPath: function createPath(context) {
9851 var attrs = this.__attrs;
9852 var x1 = attrs.x1,
9853 y1 = attrs.y1,
9854 x2 = attrs.x2,
9855 y2 = attrs.y2;
9856
9857 context = context || self.get('context');
9858 context.beginPath();
9859 context.moveTo(x1, y1);
9860 context.lineTo(x2, y2);
9861 },
9862 afterPath: function afterPath(context) {
9863 var attrs = this.__attrs;
9864 var x1 = attrs.x1,
9865 y1 = attrs.y1,
9866 x2 = attrs.x2,
9867 y2 = attrs.y2;
9868
9869 context = context || this.get('context');
9870 if (attrs.startArrow) {
9871 Arrow.addStartArrow(context, attrs, x2, y2, x1, y1);
9872 }
9873 if (attrs.endArrow) {
9874 Arrow.addEndArrow(context, attrs, x1, y1, x2, y2);
9875 }
9876 },
9877 getPoint: function getPoint(t) {
9878 var attrs = this.__attrs;
9879 return {
9880 x: LineMath.at(attrs.x1, attrs.x2, t),
9881 y: LineMath.at(attrs.y1, attrs.y2, t)
9882 };
9883 }
9884});
9885
9886module.exports = Line;
9887
9888/***/ }),
9889/* 61 */
9890/***/ (function(module, exports, __webpack_require__) {
9891
9892var Util = __webpack_require__(0);
9893var Shape = __webpack_require__(1);
9894var Inside = __webpack_require__(3);
9895
9896var CImage = function CImage(cfg) {
9897 CImage.superclass.constructor.call(this, cfg);
9898};
9899
9900CImage.ATTRS = {
9901 x: 0,
9902 y: 0,
9903 img: undefined,
9904 width: 0,
9905 height: 0,
9906 sx: null,
9907 sy: null,
9908 swidth: null,
9909 sheight: null
9910};
9911
9912Util.extend(CImage, Shape);
9913
9914Util.augment(CImage, {
9915 type: 'image',
9916 _afterSetAttrImg: function _afterSetAttrImg(img) {
9917 this._setAttrImg(img);
9918 },
9919 _afterSetAttrAll: function _afterSetAttrAll(params) {
9920 if (params.img) {
9921 this._setAttrImg(params.img);
9922 }
9923 },
9924 isHitBox: function isHitBox() {
9925 return false;
9926 },
9927 calculateBox: function calculateBox() {
9928 var attrs = this.__attrs;
9929 var x = attrs.x;
9930 var y = attrs.y;
9931 var width = attrs.width;
9932 var height = attrs.height;
9933
9934 return {
9935 minX: x,
9936 minY: y,
9937 maxX: x + width,
9938 maxY: y + height
9939 };
9940 },
9941 isPointInPath: function isPointInPath(x, y) {
9942 var attrs = this.__attrs;
9943 if (this.get('toDraw') || !attrs.img) {
9944 return false;
9945 }
9946 var rx = attrs.x;
9947 var ry = attrs.y;
9948 var width = attrs.width;
9949 var height = attrs.height;
9950 return Inside.rect(rx, ry, width, height, x, y);
9951 },
9952 _beforeSetLoading: function _beforeSetLoading(loading) {
9953 var canvas = this.get('canvas');
9954 if (loading === false && this.get('toDraw') === true) {
9955 this.__cfg.loading = false;
9956 canvas.draw();
9957 }
9958 return loading;
9959 },
9960 _setAttrImg: function _setAttrImg(img) {
9961 var self = this;
9962 var attrs = self.__attrs;
9963 if (Util.isString(img)) {
9964 var image = new Image();
9965 image.onload = function () {
9966 if (self.get('destroyed')) return false;
9967 self.attr('imgSrc', img);
9968 self.attr('img', image);
9969 var callback = self.get('callback');
9970 if (callback) {
9971 callback.call(self);
9972 }
9973 self.set('loading', false);
9974 };
9975 image.src = img;
9976 self.set('loading', true);
9977 } else if (img instanceof Image) {
9978 if (!attrs.width) {
9979 self.attr('width', img.width);
9980 }
9981
9982 if (!attrs.height) {
9983 self.attr('height', img.height);
9984 }
9985 return img;
9986 } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
9987 if (!attrs.width) {
9988 self.attr('width', Number(img.getAttribute('width')));
9989 }
9990
9991 if (!attrs.height) {
9992 self.attr('height', Number(img.getAttribute('height')));
9993 }
9994 return img;
9995 } else if (img instanceof ImageData) {
9996 if (!attrs.width) {
9997 self.attr('width', img.width);
9998 }
9999
10000 if (!attrs.height) {
10001 self.attr('height', img.height);
10002 }
10003 return img;
10004 } else {
10005 return null;
10006 }
10007 },
10008 drawInner: function drawInner(context) {
10009 if (this.get('loading')) {
10010 this.set('toDraw', true);
10011 return;
10012 }
10013 this._drawImage(context);
10014 },
10015 _drawImage: function _drawImage(context) {
10016 var attrs = this.__attrs;
10017 var x = attrs.x;
10018 var y = attrs.y;
10019 var image = attrs.img;
10020 var width = attrs.width;
10021 var height = attrs.height;
10022 var sx = attrs.sx;
10023 var sy = attrs.sy;
10024 var swidth = attrs.swidth;
10025 var sheight = attrs.sheight;
10026 this.set('toDraw', false);
10027
10028 var img = image;
10029 if (img instanceof ImageData) {
10030 img = new Image();
10031 img.src = image;
10032 }
10033 if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {
10034 if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) {
10035 context.drawImage(img, x, y, width, height);
10036 return;
10037 }
10038 if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) {
10039 context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);
10040 return;
10041 }
10042 }
10043 return;
10044 }
10045});
10046
10047module.exports = CImage;
10048
10049/***/ }),
10050/* 62 */
10051/***/ (function(module, exports, __webpack_require__) {
10052
10053var Util = __webpack_require__(0);
10054var Shape = __webpack_require__(1);
10055var Inside = __webpack_require__(3);
10056
10057var Polygon = function Polygon(cfg) {
10058 Polygon.superclass.constructor.call(this, cfg);
10059};
10060
10061Polygon.ATTRS = {
10062 points: null,
10063 lineWidth: 1
10064};
10065
10066Util.extend(Polygon, Shape);
10067
10068Util.augment(Polygon, {
10069 canFill: true,
10070 canStroke: true,
10071 type: 'polygon',
10072 getDefaultAttrs: function getDefaultAttrs() {
10073 return {
10074 lineWidth: 1
10075 };
10076 },
10077 calculateBox: function calculateBox() {
10078 var self = this;
10079 var attrs = self.__attrs;
10080 var points = attrs.points;
10081 var lineWidth = this.getHitLineWidth();
10082 if (!points || points.length === 0) {
10083 return null;
10084 }
10085 var minX = Infinity;
10086 var minY = Infinity;
10087 var maxX = -Infinity;
10088 var maxY = -Infinity;
10089
10090 Util.each(points, function (point) {
10091 var x = point[0];
10092 var y = point[1];
10093 if (x < minX) {
10094 minX = x;
10095 }
10096 if (x > maxX) {
10097 maxX = x;
10098 }
10099
10100 if (y < minY) {
10101 minY = y;
10102 }
10103
10104 if (y > maxY) {
10105 maxY = y;
10106 }
10107 });
10108
10109 var halfWidth = lineWidth / 2;
10110 return {
10111 minX: minX - halfWidth,
10112 minY: minY - halfWidth,
10113 maxX: maxX + halfWidth,
10114 maxY: maxY + halfWidth
10115 };
10116 },
10117 isPointInPath: function isPointInPath(x, y) {
10118 var self = this;
10119 var fill = self.hasFill();
10120 var stroke = self.hasStroke();
10121
10122 if (fill && stroke) {
10123 return self._isPointInFill(x, y) || self._isPointInStroke(x, y);
10124 }
10125
10126 if (fill) {
10127 return self._isPointInFill(x, y);
10128 }
10129
10130 if (stroke) {
10131 return self._isPointInStroke(x, y);
10132 }
10133
10134 return false;
10135 },
10136 _isPointInFill: function _isPointInFill(x, y) {
10137 var self = this;
10138 var context = self.get('context');
10139 self.createPath();
10140 return context.isPointInPath(x, y);
10141 },
10142 _isPointInStroke: function _isPointInStroke(x, y) {
10143 var self = this;
10144 var attrs = self.__attrs;
10145 var points = attrs.points;
10146 if (points.length < 2) {
10147 return false;
10148 }
10149 var lineWidth = this.getHitLineWidth();
10150 var outPoints = points.slice(0);
10151 if (points.length >= 3) {
10152 outPoints.push(points[0]);
10153 }
10154
10155 return Inside.polyline(outPoints, lineWidth, x, y);
10156 },
10157 createPath: function createPath(context) {
10158 var self = this;
10159 var attrs = self.__attrs;
10160 var points = attrs.points;
10161 if (points.length < 2) {
10162 return;
10163 }
10164 context = context || self.get('context');
10165 context.beginPath();
10166 Util.each(points, function (point, index) {
10167 if (index === 0) {
10168 context.moveTo(point[0], point[1]);
10169 } else {
10170 context.lineTo(point[0], point[1]);
10171 }
10172 });
10173 context.closePath();
10174 }
10175});
10176
10177module.exports = Polygon;
10178
10179/***/ }),
10180/* 63 */
10181/***/ (function(module, exports, __webpack_require__) {
10182
10183var Util = __webpack_require__(0);
10184var Shape = __webpack_require__(1);
10185var Inside = __webpack_require__(3);
10186var Arrow = __webpack_require__(6);
10187var LineMath = __webpack_require__(22);
10188
10189var Polyline = function Polyline(cfg) {
10190 Polyline.superclass.constructor.call(this, cfg);
10191};
10192
10193Polyline.ATTRS = {
10194 points: null,
10195 lineWidth: 1,
10196 startArrow: false,
10197 endArrow: false,
10198 tCache: null
10199};
10200
10201Util.extend(Polyline, Shape);
10202
10203Util.augment(Polyline, {
10204 canStroke: true,
10205 type: 'polyline',
10206 tCache: null, // 缓存各点的t
10207 getDefaultAttrs: function getDefaultAttrs() {
10208 return {
10209 lineWidth: 1,
10210 startArrow: false,
10211 endArrow: false
10212 };
10213 },
10214 calculateBox: function calculateBox() {
10215 var self = this;
10216 var attrs = self.__attrs;
10217 var lineWidth = this.getHitLineWidth();
10218 var points = attrs.points;
10219 if (!points || points.length === 0) {
10220 return null;
10221 }
10222 var minX = Infinity;
10223 var minY = Infinity;
10224 var maxX = -Infinity;
10225 var maxY = -Infinity;
10226
10227 Util.each(points, function (point) {
10228 var x = point[0];
10229 var y = point[1];
10230 if (x < minX) {
10231 minX = x;
10232 }
10233 if (x > maxX) {
10234 maxX = x;
10235 }
10236
10237 if (y < minY) {
10238 minY = y;
10239 }
10240
10241 if (y > maxY) {
10242 maxY = y;
10243 }
10244 });
10245
10246 var halfWidth = lineWidth / 2;
10247 return {
10248 minX: minX - halfWidth,
10249 minY: minY - halfWidth,
10250 maxX: maxX + halfWidth,
10251 maxY: maxY + halfWidth
10252 };
10253 },
10254 _setTcache: function _setTcache() {
10255 var self = this;
10256 var attrs = self.__attrs;
10257 var points = attrs.points;
10258 var totalLength = 0;
10259 var tempLength = 0;
10260 var tCache = [];
10261 var segmentT = void 0;
10262 var segmentL = void 0;
10263 if (!points || points.length === 0) {
10264 return;
10265 }
10266
10267 Util.each(points, function (p, i) {
10268 if (points[i + 1]) {
10269 totalLength += LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
10270 }
10271 });
10272 if (totalLength <= 0) {
10273 return;
10274 }
10275 Util.each(points, function (p, i) {
10276 if (points[i + 1]) {
10277 segmentT = [];
10278 segmentT[0] = tempLength / totalLength;
10279 segmentL = LineMath.len(p[0], p[1], points[i + 1][0], points[i + 1][1]);
10280 tempLength += segmentL;
10281 segmentT[1] = tempLength / totalLength;
10282 tCache.push(segmentT);
10283 }
10284 });
10285 this.tCache = tCache;
10286 },
10287 isPointInPath: function isPointInPath(x, y) {
10288 var self = this;
10289 var attrs = self.__attrs;
10290 if (self.hasStroke()) {
10291 var points = attrs.points;
10292 if (points.length < 2) {
10293 return false;
10294 }
10295 var lineWidth = attrs.lineWidth;
10296 return Inside.polyline(points, lineWidth, x, y);
10297 }
10298 return false;
10299 },
10300 createPath: function createPath(context) {
10301 var self = this;
10302 var attrs = self.__attrs;
10303 var points = attrs.points;
10304 var l = void 0;
10305 var i = void 0;
10306
10307 if (points.length < 2) {
10308 return;
10309 }
10310 context = context || self.get('context');
10311 context.beginPath();
10312
10313 context.moveTo(points[0][0], points[0][1]);
10314 for (i = 1, l = points.length - 1; i < l; i++) {
10315 context.lineTo(points[i][0], points[i][1]);
10316 }
10317 context.lineTo(points[l][0], points[l][1]);
10318 },
10319 afterPath: function afterPath(context) {
10320 var self = this;
10321 var attrs = self.__attrs;
10322 var points = attrs.points;
10323 var l = points.length - 1;
10324 context = context || self.get('context');
10325
10326 if (attrs.startArrow) {
10327 Arrow.addStartArrow(context, attrs, points[1][0], points[1][1], points[0][0], points[0][1]);
10328 }
10329 if (attrs.endArrow) {
10330 Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]);
10331 }
10332 },
10333 getPoint: function getPoint(t) {
10334 var attrs = this.__attrs;
10335 var points = attrs.points;
10336 var tCache = this.tCache;
10337 var subt = void 0;
10338 var index = void 0;
10339 if (!tCache) {
10340 this._setTcache();
10341 tCache = this.tCache;
10342 }
10343 Util.each(tCache, function (v, i) {
10344 if (t >= v[0] && t <= v[1]) {
10345 subt = (t - v[0]) / (v[1] - v[0]);
10346 index = i;
10347 }
10348 });
10349 return {
10350 x: LineMath.at(points[index][0], points[index + 1][0], subt),
10351 y: LineMath.at(points[index][1], points[index + 1][1], subt)
10352 };
10353 }
10354});
10355
10356module.exports = Polyline;
10357
10358/***/ }),
10359/* 64 */
10360/***/ (function(module, exports, __webpack_require__) {
10361
10362var Util = __webpack_require__(0);
10363var Shape = __webpack_require__(1);
10364var Inside = __webpack_require__(3);
10365var ArcMath = __webpack_require__(24);
10366var Arrow = __webpack_require__(6);
10367
10368function _getArcX(x, radius, angle) {
10369 return x + radius * Math.cos(angle);
10370}
10371function _getArcY(y, radius, angle) {
10372 return y + radius * Math.sin(angle);
10373}
10374
10375var Arc = function Arc(cfg) {
10376 Arc.superclass.constructor.call(this, cfg);
10377};
10378
10379Arc.ATTRS = {
10380 x: 0,
10381 y: 0,
10382 r: 0,
10383 startAngle: 0,
10384 endAngle: 0,
10385 clockwise: false,
10386 lineWidth: 1,
10387 startArrow: false,
10388 endArrow: false
10389};
10390
10391Util.extend(Arc, Shape);
10392
10393Util.augment(Arc, {
10394 canStroke: true,
10395 type: 'arc',
10396 getDefaultAttrs: function getDefaultAttrs() {
10397 return {
10398 x: 0,
10399 y: 0,
10400 r: 0,
10401 startAngle: 0,
10402 endAngle: 0,
10403 clockwise: false,
10404 lineWidth: 1,
10405 startArrow: false,
10406 endArrow: false
10407 };
10408 },
10409 calculateBox: function calculateBox() {
10410 var attrs = this.__attrs;
10411 var x = attrs.x,
10412 y = attrs.y,
10413 r = attrs.r,
10414 startAngle = attrs.startAngle,
10415 endAngle = attrs.endAngle,
10416 clockwise = attrs.clockwise;
10417
10418 var lineWidth = this.getHitLineWidth();
10419 var halfWidth = lineWidth / 2;
10420 var box = ArcMath.box(x, y, r, startAngle, endAngle, clockwise);
10421 box.minX -= halfWidth;
10422 box.minY -= halfWidth;
10423 box.maxX += halfWidth;
10424 box.maxY += halfWidth;
10425 return box;
10426 },
10427 isPointInPath: function isPointInPath(x, y) {
10428 var attrs = this.__attrs;
10429 var cx = attrs.x;
10430 var cy = attrs.y;
10431 var r = attrs.r,
10432 startAngle = attrs.startAngle,
10433 endAngle = attrs.endAngle,
10434 clockwise = attrs.clockwise;
10435
10436 var lineWidth = this.getHitLineWidth();
10437 if (this.hasStroke()) {
10438 return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y);
10439 }
10440 return false;
10441 },
10442 createPath: function createPath(context) {
10443 var attrs = this.__attrs;
10444 var x = attrs.x,
10445 y = attrs.y,
10446 r = attrs.r,
10447 startAngle = attrs.startAngle,
10448 endAngle = attrs.endAngle,
10449 clockwise = attrs.clockwise;
10450
10451 context = context || self.get('context');
10452
10453 context.beginPath();
10454 context.arc(x, y, r, startAngle, endAngle, clockwise);
10455 },
10456 afterPath: function afterPath(context) {
10457 var attrs = this.__attrs;
10458 var x = attrs.x,
10459 y = attrs.y,
10460 r = attrs.r,
10461 startAngle = attrs.startAngle,
10462 endAngle = attrs.endAngle,
10463 clockwise = attrs.clockwise;
10464
10465 context = context || this.get('context');
10466 var diff = void 0;
10467 var x1 = void 0;
10468 var y1 = void 0;
10469 var x2 = void 0;
10470 var y2 = void 0;
10471
10472 if (attrs.startArrow) {
10473 diff = Math.PI / 180;
10474 if (clockwise) {
10475 diff *= -1;
10476 }
10477 x1 = _getArcX(x, r, startAngle + diff);
10478 y1 = _getArcY(y, r, startAngle + diff);
10479 x2 = _getArcX(x, r, startAngle);
10480 y2 = _getArcY(y, r, startAngle);
10481 Arrow.addStartArrow(context, attrs, x1, y1, x2, y2);
10482 }
10483
10484 if (attrs.endArrow) {
10485 diff = Math.PI / 180;
10486 if (clockwise) {
10487 diff *= -1;
10488 }
10489 x1 = _getArcX(x, r, endAngle + diff);
10490 y1 = _getArcY(y, r, endAngle + diff);
10491 x2 = _getArcX(x, r, endAngle);
10492 y2 = _getArcY(y, r, endAngle);
10493 Arrow.addEndArrow(context, attrs, x2, y2, x1, y1);
10494 }
10495 }
10496});
10497
10498module.exports = Arc;
10499
10500/***/ }),
10501/* 65 */
10502/***/ (function(module, exports, __webpack_require__) {
10503
10504var Util = __webpack_require__(0);
10505var Shape = __webpack_require__(1);
10506var Inside = __webpack_require__(3);
10507var ArcMath = __webpack_require__(24);
10508var vec2 = __webpack_require__(2).vec2;
10509
10510var Fan = function Fan(cfg) {
10511 Fan.superclass.constructor.call(this, cfg);
10512};
10513
10514Fan.ATTRS = {
10515 x: 0,
10516 y: 0,
10517 rs: 0,
10518 re: 0,
10519 startAngle: 0,
10520 endAngle: 0,
10521 clockwise: false,
10522 lineWidth: 1
10523};
10524
10525Util.extend(Fan, Shape);
10526
10527Util.augment(Fan, {
10528 canFill: true,
10529 canStroke: true,
10530 type: 'fan',
10531 getDefaultAttrs: function getDefaultAttrs() {
10532 return {
10533 clockwise: false,
10534 lineWidth: 1,
10535 rs: 0,
10536 re: 0
10537 };
10538 },
10539 calculateBox: function calculateBox() {
10540 var self = this;
10541 var attrs = self.__attrs;
10542 var cx = attrs.x;
10543 var cy = attrs.y;
10544 var rs = attrs.rs;
10545 var re = attrs.re;
10546 var startAngle = attrs.startAngle;
10547 var endAngle = attrs.endAngle;
10548 var clockwise = attrs.clockwise;
10549 var lineWidth = this.getHitLineWidth();
10550
10551 var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise);
10552 var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise);
10553 var minX = Math.min(boxs.minX, boxe.minX);
10554 var minY = Math.min(boxs.minY, boxe.minY);
10555 var maxX = Math.max(boxs.maxX, boxe.maxX);
10556 var maxY = Math.max(boxs.maxY, boxe.maxY);
10557
10558 var halfWidth = lineWidth / 2;
10559 return {
10560 minX: minX - halfWidth,
10561 minY: minY - halfWidth,
10562 maxX: maxX + halfWidth,
10563 maxY: maxY + halfWidth
10564 };
10565 },
10566 isPointInPath: function isPointInPath(x, y) {
10567 var fill = this.hasFill();
10568 var stroke = this.hasStroke();
10569
10570 if (fill && stroke) {
10571 return this._isPointInFill(x, y) || this._isPointInStroke(x, y);
10572 }
10573
10574 if (fill) {
10575 return this._isPointInFill(x, y);
10576 }
10577
10578 if (stroke) {
10579 return this._isPointInStroke(x, y);
10580 }
10581 return false;
10582 },
10583 _isPointInFill: function _isPointInFill(x, y) {
10584 var attrs = this.__attrs;
10585 var cx = attrs.x;
10586 var cy = attrs.y;
10587 var rs = attrs.rs;
10588 var re = attrs.re;
10589 var startAngle = attrs.startAngle;
10590 var endAngle = attrs.endAngle;
10591 var clockwise = attrs.clockwise;
10592 var v1 = [1, 0];
10593 var subv = [x - cx, y - cy];
10594 var angle = vec2.angleTo(v1, subv);
10595
10596 var angle1 = ArcMath.nearAngle(angle, startAngle, endAngle, clockwise);
10597
10598 if (Util.isNumberEqual(angle, angle1)) {
10599 var ls = vec2.squaredLength(subv);
10600 if (rs * rs <= ls && ls <= re * re) {
10601 return true;
10602 }
10603 }
10604 return false;
10605 },
10606 _isPointInStroke: function _isPointInStroke(x, y) {
10607 var attrs = this.__attrs;
10608 var cx = attrs.x;
10609 var cy = attrs.y;
10610 var rs = attrs.rs;
10611 var re = attrs.re;
10612 var startAngle = attrs.startAngle;
10613 var endAngle = attrs.endAngle;
10614 var clockwise = attrs.clockwise;
10615 var lineWidth = this.getHitLineWidth();
10616
10617 var ssp = {
10618 x: Math.cos(startAngle) * rs + cx,
10619 y: Math.sin(startAngle) * rs + cy
10620 };
10621 var sep = {
10622 x: Math.cos(startAngle) * re + cx,
10623 y: Math.sin(startAngle) * re + cy
10624 };
10625 var esp = {
10626 x: Math.cos(endAngle) * rs + cx,
10627 y: Math.sin(endAngle) * rs + cy
10628 };
10629 var eep = {
10630 x: Math.cos(endAngle) * re + cx,
10631 y: Math.sin(endAngle) * re + cy
10632 };
10633
10634 if (Inside.line(ssp.x, ssp.y, sep.x, sep.y, lineWidth, x, y)) {
10635 return true;
10636 }
10637
10638 if (Inside.line(esp.x, esp.y, eep.x, eep.y, lineWidth, x, y)) {
10639 return true;
10640 }
10641
10642 if (Inside.arcline(cx, cy, rs, startAngle, endAngle, clockwise, lineWidth, x, y)) {
10643 return true;
10644 }
10645
10646 if (Inside.arcline(cx, cy, re, startAngle, endAngle, clockwise, lineWidth, x, y)) {
10647 return true;
10648 }
10649
10650 return false;
10651 },
10652 createPath: function createPath(context) {
10653 var attrs = this.__attrs;
10654 var cx = attrs.x;
10655 var cy = attrs.y;
10656 var rs = attrs.rs;
10657 var re = attrs.re;
10658 var startAngle = attrs.startAngle;
10659 var endAngle = attrs.endAngle;
10660 var clockwise = attrs.clockwise;
10661
10662 var ssp = {
10663 x: Math.cos(startAngle) * rs + cx,
10664 y: Math.sin(startAngle) * rs + cy
10665 };
10666 var sep = {
10667 x: Math.cos(startAngle) * re + cx,
10668 y: Math.sin(startAngle) * re + cy
10669 };
10670 var esp = {
10671 x: Math.cos(endAngle) * rs + cx,
10672 y: Math.sin(endAngle) * rs + cy
10673 };
10674
10675 context = context || self.get('context');
10676 context.beginPath();
10677 context.moveTo(ssp.x, ssp.y);
10678 context.lineTo(sep.x, sep.y);
10679 context.arc(cx, cy, re, startAngle, endAngle, clockwise);
10680 context.lineTo(esp.x, esp.y);
10681 context.arc(cx, cy, rs, endAngle, startAngle, !clockwise);
10682 context.closePath();
10683 }
10684});
10685
10686module.exports = Fan;
10687
10688/***/ }),
10689/* 66 */
10690/***/ (function(module, exports, __webpack_require__) {
10691
10692var Util = __webpack_require__(0);
10693var Shape = __webpack_require__(1);
10694var Inside = __webpack_require__(3);
10695var Arrow = __webpack_require__(6);
10696var CubicMath = __webpack_require__(12);
10697
10698var Cubic = function Cubic(cfg) {
10699 Cubic.superclass.constructor.call(this, cfg);
10700};
10701
10702Cubic.ATTRS = {
10703 p1: null, // 起始点
10704 p2: null, // 第一个控制点
10705 p3: null, // 第二个控制点
10706 p4: null, // 终点
10707 lineWidth: 1,
10708 startArrow: false,
10709 endArrow: false
10710};
10711
10712Util.extend(Cubic, Shape);
10713
10714Util.augment(Cubic, {
10715 canStroke: true,
10716 type: 'cubic',
10717 getDefaultAttrs: function getDefaultAttrs() {
10718 return {
10719 lineWidth: 1,
10720 startArrow: false,
10721 endArrow: false
10722 };
10723 },
10724 calculateBox: function calculateBox() {
10725 var attrs = this.__attrs;
10726 var p1 = attrs.p1,
10727 p2 = attrs.p2,
10728 p3 = attrs.p3,
10729 p4 = attrs.p4;
10730
10731 var lineWidth = this.getHitLineWidth();
10732 var i = void 0;
10733 var l = void 0;
10734
10735 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
10736 return null;
10737 }
10738 var halfWidth = lineWidth / 2;
10739
10740 var xDim = CubicMath.extrema(p1[0], p2[0], p3[0], p4[0]);
10741 for (i = 0, l = xDim.length; i < l; i++) {
10742 xDim[i] = CubicMath.at(p1[0], p2[0], p3[0], p4[0], xDim[i]);
10743 }
10744 var yDim = CubicMath.extrema(p1[1], p2[1], p3[1], p4[1]);
10745 for (i = 0, l = yDim.length; i < l; i++) {
10746 yDim[i] = CubicMath.at(p1[1], p2[1], p3[1], p4[1], yDim[i]);
10747 }
10748 xDim.push(p1[0], p4[0]);
10749 yDim.push(p1[1], p4[1]);
10750
10751 return {
10752 minX: Math.min.apply(Math, xDim) - halfWidth,
10753 maxX: Math.max.apply(Math, xDim) + halfWidth,
10754 minY: Math.min.apply(Math, yDim) - halfWidth,
10755 maxY: Math.max.apply(Math, yDim) + halfWidth
10756 };
10757 },
10758 isPointInPath: function isPointInPath(x, y) {
10759 var attrs = this.__attrs;
10760 var p1 = attrs.p1,
10761 p2 = attrs.p2,
10762 p3 = attrs.p3,
10763 p4 = attrs.p4;
10764
10765 var lineWidth = this.getHitLineWidth();
10766 return Inside.cubicline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], p4[0], p4[1], lineWidth, x, y);
10767 },
10768 createPath: function createPath(context) {
10769 var attrs = this.__attrs;
10770 var p1 = attrs.p1,
10771 p2 = attrs.p2,
10772 p3 = attrs.p3,
10773 p4 = attrs.p4;
10774
10775 context = context || self.get('context');
10776 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3) || Util.isNil(p4)) {
10777 return;
10778 }
10779 context.beginPath();
10780 context.moveTo(p1[0], p1[1]);
10781 context.bezierCurveTo(p2[0], p2[1], p3[0], p3[1], p4[0], p4[1]);
10782 },
10783 afterPath: function afterPath(context) {
10784 var attrs = this.__attrs;
10785 var p1 = attrs.p1,
10786 p2 = attrs.p2,
10787 p3 = attrs.p3,
10788 p4 = attrs.p4;
10789
10790 context = context || this.get('context');
10791 if (attrs.startArrow) {
10792 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
10793 }
10794 if (attrs.endArrow) {
10795 Arrow.addEndArrow(context, attrs, p3[0], p3[1], p4[0], p4[1]);
10796 }
10797 },
10798 getPoint: function getPoint(t) {
10799 var attrs = this.__attrs;
10800 return {
10801 x: CubicMath.at(attrs.p4[0], attrs.p3[0], attrs.p2[0], attrs.p1[0], t),
10802 y: CubicMath.at(attrs.p4[1], attrs.p3[1], attrs.p2[1], attrs.p1[1], t)
10803 };
10804 }
10805});
10806
10807module.exports = Cubic;
10808
10809/***/ }),
10810/* 67 */
10811/***/ (function(module, exports, __webpack_require__) {
10812
10813var Util = __webpack_require__(0);
10814var Shape = __webpack_require__(1);
10815var Inside = __webpack_require__(3);
10816var Arrow = __webpack_require__(6);
10817var QuadraticMath = __webpack_require__(23);
10818
10819var Quadratic = function Quadratic(cfg) {
10820 Quadratic.superclass.constructor.call(this, cfg);
10821};
10822
10823Quadratic.ATTRS = {
10824 p1: null, // 起始点
10825 p2: null, // 控制点
10826 p3: null, // 结束点
10827 lineWidth: 1,
10828 startArrow: false,
10829 endArrow: false
10830};
10831
10832Util.extend(Quadratic, Shape);
10833
10834Util.augment(Quadratic, {
10835 canStroke: true,
10836 type: 'quadratic',
10837 getDefaultAttrs: function getDefaultAttrs() {
10838 return {
10839 lineWidth: 1,
10840 startArrow: false,
10841 endArrow: false
10842 };
10843 },
10844 calculateBox: function calculateBox() {
10845 var self = this;
10846 var attrs = self.__attrs;
10847 var p1 = attrs.p1,
10848 p2 = attrs.p2,
10849 p3 = attrs.p3;
10850
10851 var lineWidth = this.getHitLineWidth();
10852 var i = void 0;
10853 var l = void 0;
10854
10855 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
10856 return null;
10857 }
10858 var halfWidth = lineWidth / 2;
10859 var xDims = QuadraticMath.extrema(p1[0], p2[0], p3[0]);
10860 for (i = 0, l = xDims.length; i < l; i++) {
10861 xDims[i] = QuadraticMath.at(p1[0], p2[0], p3[0], xDims[i]);
10862 }
10863 xDims.push(p1[0], p3[0]);
10864 var yDims = QuadraticMath.extrema(p1[1], p2[1], p3[1]);
10865 for (i = 0, l = yDims.length; i < l; i++) {
10866 yDims[i] = QuadraticMath.at(p1[1], p2[1], p3[1], yDims[i]);
10867 }
10868 yDims.push(p1[1], p3[1]);
10869
10870 return {
10871 minX: Math.min.apply(Math, xDims) - halfWidth,
10872 maxX: Math.max.apply(Math, xDims) + halfWidth,
10873 minY: Math.min.apply(Math, yDims) - halfWidth,
10874 maxY: Math.max.apply(Math, yDims) + halfWidth
10875 };
10876 },
10877 isPointInPath: function isPointInPath(x, y) {
10878 var self = this;
10879 var attrs = self.__attrs;
10880 var p1 = attrs.p1,
10881 p2 = attrs.p2,
10882 p3 = attrs.p3;
10883
10884 var lineWidth = this.getHitLineWidth();
10885
10886 return Inside.quadraticline(p1[0], p1[1], p2[0], p2[1], p3[0], p3[1], lineWidth, x, y);
10887 },
10888 createPath: function createPath(context) {
10889 var self = this;
10890 var attrs = self.__attrs;
10891 var p1 = attrs.p1,
10892 p2 = attrs.p2,
10893 p3 = attrs.p3;
10894
10895
10896 if (Util.isNil(p1) || Util.isNil(p2) || Util.isNil(p3)) {
10897 return;
10898 }
10899 context = context || self.get('context');
10900 context.beginPath();
10901 context.moveTo(p1[0], p1[1]);
10902 context.quadraticCurveTo(p2[0], p2[1], p3[0], p3[1]);
10903 },
10904 afterPath: function afterPath(context) {
10905 var self = this;
10906 var attrs = self.__attrs;
10907 var p1 = attrs.p1,
10908 p2 = attrs.p2,
10909 p3 = attrs.p3;
10910
10911 context = context || self.get('context');
10912
10913 if (attrs.startArrow) {
10914 Arrow.addStartArrow(context, attrs, p2[0], p2[1], p1[0], p1[1]);
10915 }
10916
10917 if (attrs.endArrow) {
10918 Arrow.addEndArrow(context, attrs, p2[0], p2[1], p3[0], p3[1]);
10919 }
10920 },
10921 getPoint: function getPoint(t) {
10922 var attrs = this.__attrs;
10923 return {
10924 x: QuadraticMath.at(attrs.p1[0], attrs.p2[0], attrs.p3[0], t),
10925 y: QuadraticMath.at(attrs.p1[1], attrs.p2[1], attrs.p3[1], t)
10926 };
10927 }
10928});
10929
10930module.exports = Quadratic;
10931
10932/***/ }),
10933/* 68 */
10934/***/ (function(module, exports, __webpack_require__) {
10935
10936/**
10937 * @fileOverview Interaction
10938 * @author leungwensen@gmail.com
10939 */
10940
10941var Interactions = {
10942 Base: __webpack_require__(9),
10943 Brush: __webpack_require__(119),
10944 Drag: __webpack_require__(120),
10945 Zoom: __webpack_require__(121),
10946 helper: {
10947 bindInteraction: __webpack_require__(122)
10948 }
10949};
10950
10951module.exports = Interactions;
10952
10953/***/ }),
10954/* 69 */
10955/***/ (function(module, exports, __webpack_require__) {
10956
10957module.exports = {
10958 Canvas: __webpack_require__(70),
10959 Group: __webpack_require__(31),
10960 Shape: __webpack_require__(4),
10961 Rect: __webpack_require__(42),
10962 Circle: __webpack_require__(43),
10963 Ellipse: __webpack_require__(44),
10964 Path: __webpack_require__(45),
10965 Text: __webpack_require__(46),
10966 Line: __webpack_require__(47),
10967 Image: __webpack_require__(48),
10968 Polygon: __webpack_require__(49),
10969 Marker: __webpack_require__(50),
10970 Dom: __webpack_require__(51),
10971 Fan: __webpack_require__(52),
10972 Event: __webpack_require__(30)
10973};
10974
10975/***/ }),
10976/* 70 */
10977/***/ (function(module, exports, __webpack_require__) {
10978
10979var Util = __webpack_require__(0);
10980var Event = __webpack_require__(30);
10981var Group = __webpack_require__(31);
10982var Defs = __webpack_require__(105);
10983
10984var Canvas = function Canvas(cfg) {
10985 Canvas.superclass.constructor.call(this, cfg);
10986};
10987
10988var defs = new Defs();
10989
10990Canvas.CFG = {
10991 eventEnable: true,
10992 /**
10993 * 像素宽度
10994 * @type {Number}
10995 */
10996 width: null,
10997 /**
10998 * 像素高度
10999 * @type {Number}
11000 */
11001 height: null,
11002 /**
11003 * 画布宽度
11004 * @type {Number}
11005 */
11006 widthCanvas: null,
11007 /**
11008 * 画布高度
11009 * @type {Number}
11010 */
11011 heightCanvas: null,
11012 /**
11013 * CSS宽
11014 * CSS宽
11015 * @type {String}
11016 */
11017 widthStyle: null,
11018 /**
11019 * CSS高
11020 * @type {String}
11021 */
11022 heightStyle: null,
11023 /**
11024 * 容器DOM
11025 * @type {Object}
11026 */
11027 containerDOM: null,
11028 /**
11029 * 当前Canvas的DOM
11030 * @type {Object}
11031 */
11032 canvasDOM: null,
11033 /**
11034 * 屏幕像素比
11035 * @type {Number}
11036 */
11037 pixelRatio: Util.getRatio()
11038};
11039
11040Util.extend(Canvas, Group);
11041
11042Util.augment(Canvas, {
11043 init: function init() {
11044 Canvas.superclass.init.call(this);
11045 this._setDOM();
11046 this._setInitSize();
11047 // this._scale();
11048 if (this.get('eventEnable')) {
11049 this._registEvents();
11050 }
11051 },
11052 getEmitter: function getEmitter(element, event) {
11053 if (element) {
11054 if (Util.isEmpty(element._getEvents())) {
11055 var parent = element.get('parent');
11056 if (parent && !event.propagationStopped) {
11057 return this.getEmitter(parent, event);
11058 }
11059 } else {
11060 return element;
11061 }
11062 }
11063 },
11064 _getEventObj: function _getEventObj(type, e, point, target) {
11065 var event = new Event(type, e, true, true);
11066 event.x = point.x;
11067 event.y = point.y;
11068 event.clientX = e.clientX;
11069 event.clientY = e.clientY;
11070 event.currentTarget = target;
11071 event.target = target;
11072 return event;
11073 },
11074 _triggerEvent: function _triggerEvent(type, e) {
11075 var point = this.getPointByClient(e.clientX, e.clientY);
11076 var shape = this.findShape(e.srcElement);
11077 var emitObj = void 0;
11078 if (type === 'mousemove') {
11079 var preShape = this.get('preShape');
11080 if (preShape && preShape !== shape) {
11081 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
11082 emitObj = this.getEmitter(preShape, e);
11083 emitObj && emitObj.emit('mouseleave', mouseleave);
11084 }
11085
11086 if (shape) {
11087 var mousemove = this._getEventObj('mousemove', e, point, shape);
11088 emitObj = this.getEmitter(shape, e);
11089 emitObj && emitObj.emit('mousemove', mousemove);
11090
11091 if (preShape !== shape) {
11092 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
11093 emitObj && emitObj.emit('mouseenter', mouseenter, e);
11094 }
11095 } else {
11096 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
11097 this.emit('mousemove', canvasmousemove);
11098 }
11099 this.set('preShape', shape);
11100 } else {
11101 var event = this._getEventObj(type, e, point, shape || this);
11102 emitObj = this.getEmitter(shape, e);
11103 if (emitObj && emitObj !== this) {
11104 emitObj.emit(type, event);
11105 }
11106 this.emit(type, event);
11107 }
11108
11109 var el = this.get('el');
11110 if (shape && !shape.get('destroyed')) {
11111 el.style.cursor = shape.attr('cursor') || 'default';
11112 }
11113 },
11114 _registEvents: function _registEvents() {
11115 var self = this;
11116 var el = self.get('el');
11117 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
11118
11119 Util.each(events, function (event) {
11120 el.addEventListener(event, function (e) {
11121 self._triggerEvent(event, e);
11122 }, false);
11123 });
11124 el.addEventListener('touchstart', function (e) {
11125 if (!Util.isEmpty(e.touches)) {
11126 self._triggerEvent('touchstart', e.touches[0]);
11127 }
11128 }, false);
11129
11130 el.addEventListener('touchmove', function (e) {
11131 if (!Util.isEmpty(e.touches)) {
11132 self._triggerEvent('touchmove', e.touches[0]);
11133 }
11134 }, false);
11135
11136 el.addEventListener('touchend', function (e) {
11137 if (!Util.isEmpty(e.changedTouches)) {
11138 self._triggerEvent('touchend', e.changedTouches[0]);
11139 }
11140 }, false);
11141 },
11142 _setDOM: function _setDOM() {
11143 this._setContainer();
11144 this._setLayer();
11145 },
11146 _setContainer: function _setContainer() {
11147 var containerId = this.get('containerId');
11148 var containerDOM = this.get('containerDOM');
11149 if (!containerDOM) {
11150 containerDOM = document.getElementById(containerId);
11151 this.set('containerDOM', containerDOM);
11152 }
11153 Util.modifyCSS(containerDOM, {
11154 position: 'relative'
11155 });
11156 },
11157 _setLayer: function _setLayer() {
11158 var containerDOM = this.get('containerDOM');
11159 var canvasId = Util.uniqueId('svg_');
11160 if (containerDOM) {
11161 var _canvasDOM = Util.createDom('<svg id="' + canvasId + '"></svg>');
11162 containerDOM.appendChild(_canvasDOM);
11163 _canvasDOM.appendChild(defs.get('el'));
11164 this.set('canvasDOM', _canvasDOM);
11165 this.set('el', _canvasDOM);
11166 this.set('defs', defs);
11167 this.set('canvas', this);
11168 }
11169 var canvasDOM = this.get('canvasDOM');
11170 this.set('context', canvasDOM);
11171 },
11172 _setInitSize: function _setInitSize() {
11173 this.changeSize(this.get('width'), this.get('height'));
11174 this.set('pixelRatio', 1);
11175 },
11176 _resize: function _resize() {
11177 var canvasDOM = this.get('canvasDOM');
11178 var widthCanvas = this.get('widthCanvas');
11179 var heightCanvas = this.get('heightCanvas');
11180 var widthStyle = this.get('widthStyle');
11181 var heightStyle = this.get('heightStyle');
11182
11183 canvasDOM.style.width = widthStyle;
11184 canvasDOM.style.height = heightStyle;
11185 canvasDOM.setAttribute('width', widthCanvas);
11186 canvasDOM.setAttribute('height', heightCanvas);
11187 },
11188 getWidth: function getWidth() {
11189 return this.get('width');
11190 },
11191 getHeight: function getHeight() {
11192 return this.get('height');
11193 },
11194 changeSize: function changeSize(width, height) {
11195 this.set('widthCanvas', width);
11196 this.set('heightCanvas', height);
11197 this.set('widthStyle', width + 'px');
11198 this.set('heightStyle', height + 'px');
11199 this.set('width', width);
11200 this.set('height', height);
11201 this._resize();
11202 },
11203
11204 /**
11205 * 将窗口坐标转变成 canvas 坐标
11206 * @param {Number} clientX 窗口x坐标
11207 * @param {Number} clientY 窗口y坐标
11208 * @return {Object} canvas坐标
11209 */
11210 getPointByClient: function getPointByClient(clientX, clientY) {
11211 var el = this.get('el');
11212 var bbox = el.getBoundingClientRect();
11213 return {
11214 x: clientX - bbox.left,
11215 y: clientY - bbox.top
11216 };
11217 },
11218 getClientByPoint: function getClientByPoint(x, y) {
11219 var el = this.get('el');
11220 var bbox = el.getBoundingClientRect();
11221 return {
11222 clientX: x + bbox.left,
11223 clientY: y + bbox.top
11224 };
11225 },
11226 beforeDraw: function beforeDraw() {
11227 var el = this.get('el');
11228 // canvas版本用盖一个canvas大小的矩阵清空画布,svg换成清空html
11229 el.innerHTML = '';
11230 },
11231 _beginDraw: function _beginDraw() {
11232 this.setSilent('toDraw', true);
11233 },
11234 _endDraw: function _endDraw() {
11235 this.setSilent('toDraw', false);
11236 },
11237
11238 // svg实时渲染,兼容canvas版本留个空接口
11239 draw: function draw() {},
11240 destroy: function destroy() {
11241 var containerDOM = this.get('containerDOM');
11242 var canvasDOM = this.get('canvasDOM');
11243 if (canvasDOM && containerDOM) {
11244 containerDOM.removeChild(canvasDOM);
11245 }
11246 Canvas.superclass.destroy.call(this);
11247 }
11248});
11249
11250module.exports = Canvas;
11251
11252/***/ }),
11253/* 71 */
11254/***/ (function(module, exports) {
11255
11256module.exports = function (module) {
11257 if (!module.webpackPolyfill) {
11258 module.deprecate = function () {};
11259 module.paths = [];
11260 // module.parent = undefined by default
11261 if (!module.children) module.children = [];
11262 Object.defineProperty(module, "loaded", {
11263 enumerable: true,
11264 get: function get() {
11265 return module.l;
11266 }
11267 });
11268 Object.defineProperty(module, "id", {
11269 enumerable: true,
11270 get: function get() {
11271 return module.i;
11272 }
11273 });
11274 module.webpackPolyfill = 1;
11275 }
11276 return module;
11277};
11278
11279/***/ }),
11280/* 72 */
11281/***/ (function(module, exports, __webpack_require__) {
11282
11283var Util = __webpack_require__(0);
11284
11285var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
11286var CAPITALIZED_ATTRS_MAP = {
11287 r: 'R',
11288 opacity: 'Opacity',
11289 lineWidth: 'LineWidth',
11290 clip: 'Clip',
11291 stroke: 'Stroke',
11292 fill: 'Fill',
11293 strokeOpacity: 'Stroke',
11294 fillOpacity: 'Fill',
11295 x: 'X',
11296 y: 'Y',
11297 rx: 'Rx',
11298 ry: 'Ry',
11299 re: 'Re',
11300 rs: 'Rs',
11301 width: 'Width',
11302 height: 'Height',
11303 img: 'Img',
11304 x1: 'X1',
11305 x2: 'X2',
11306 y1: 'Y1',
11307 y2: 'Y2',
11308 points: 'Points',
11309 p1: 'P1',
11310 p2: 'P2',
11311 p3: 'P3',
11312 p4: 'P4',
11313 text: 'Text',
11314 radius: 'Radius',
11315 textAlign: 'TextAlign',
11316 textBaseline: 'TextBaseline',
11317 font: 'Font',
11318 fontSize: 'FontSize',
11319 fontStyle: 'FontStyle',
11320 fontVariant: 'FontVariant',
11321 fontWeight: 'FontWeight',
11322 fontFamily: 'FontFamily',
11323 clockwise: 'Clockwise',
11324 startAngle: 'StartAngle',
11325 endAngle: 'EndAngle',
11326 path: 'Path',
11327 outline: 'Outline',
11328 html: 'Html'
11329};
11330var SVG_ATTR_MAP = {
11331 opacity: 'opacity',
11332 clip: 'clip',
11333 stroke: 'stroke',
11334 fill: 'fill',
11335 strokeOpacity: 'stroke-opacity',
11336 fillOpacity: 'fill-opacity',
11337 strokeStyle: 'stroke',
11338 fillStyle: 'fill',
11339 x: 'x',
11340 y: 'y',
11341 r: 'r',
11342 rx: 'rx',
11343 ry: 'ry',
11344 re: 're',
11345 rs: 'rs',
11346 width: 'width',
11347 height: 'height',
11348 image: 'href',
11349 x1: 'x1',
11350 x2: 'x2',
11351 y1: 'y1',
11352 y2: 'y2',
11353 lineCap: 'stroke-linecap',
11354 lineJoin: 'stroke-linejoin',
11355 lineWidth: 'stroke-width',
11356 lineDash: 'stroke-dasharray',
11357 miterLimit: 'stroke-miterlimit',
11358 font: 'font',
11359 fontSize: 'font-size',
11360 fontStyle: 'font-style',
11361 fontVariant: 'font-variant',
11362 fontWeight: 'font-weight',
11363 fontFamily: 'font-family',
11364 startArrow: 'marker-start',
11365 endArrow: 'marker-end',
11366 preserveAspectRatio: 'preserveAspectRatio'
11367};
11368var ALIAS_ATTRS_MAP = {
11369 stroke: 'strokeStyle',
11370 fill: 'fillStyle',
11371 opacity: 'globalAlpha'
11372};
11373
11374module.exports = {
11375 canFill: false,
11376 canStroke: false,
11377 initAttrs: function initAttrs(attrs) {
11378 this.__attrs = {
11379 opacity: 1,
11380 fillOpacity: 1,
11381 strokeOpacity: 1
11382 };
11383 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
11384 return this;
11385 },
11386 getDefaultAttrs: function getDefaultAttrs() {
11387 return {};
11388 },
11389
11390 /**
11391 * 设置或者设置属性,有以下 4 种情形:
11392 * - name 不存在, 则返回属性集合
11393 * - name 为字符串,value 为空,获取属性值
11394 * - name 为字符串,value 不为空,设置属性值,返回 this
11395 * - name 为键值对,value 为空,设置属性值
11396 *
11397 * @param {String | Object} name 属性名
11398 * @param {*} value 属性值
11399 * @return {*} 属性值
11400 */
11401 attr: function attr(name, value) {
11402 var self = this;
11403 if (arguments.length === 0) {
11404 return self.__attrs;
11405 }
11406 if (Util.isObject(name)) {
11407 for (var k in name) {
11408 if (ALIAS_ATTRS.indexOf(k) === -1) {
11409 var v = name[k];
11410 self._setAttr(k, v);
11411 }
11412 }
11413 if (self._afterSetAttrAll) {
11414 self._afterSetAttrAll(name);
11415 }
11416 // self.setSilent('box', null);
11417 self.clearBBox();
11418 return self;
11419 }
11420 if (arguments.length === 2) {
11421 self._setAttr(name, value);
11422 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
11423 if (CAPITALIZED_ATTRS_MAP[name] && self[m]) {
11424 self[m](value);
11425 }
11426 self.clearBBox();
11427 return self;
11428 }
11429 return self._getAttr(name);
11430 },
11431 clearBBox: function clearBBox() {
11432 this.setSilent('box', null);
11433 },
11434 _afterSetAttrAll: function _afterSetAttrAll() {},
11435
11436 // 属性获取触发函数
11437 _getAttr: function _getAttr(name) {
11438 return this.__attrs[name];
11439 },
11440
11441 // 属性设置触发函数
11442 _setAttr: function _setAttr(name, value) {
11443 var self = this;
11444 var el = self.get('el');
11445
11446 if (name === 'clip') {
11447 self._setAttrClip(name, value);
11448 return;
11449 }
11450 self.__attrs[name] = value;
11451 if (typeof value === 'number' && isNaN(value)) {
11452 return;
11453 }
11454 if (self.get('destroyed')) {
11455 return;
11456 }
11457 if (name === 'transform' || name === 'rotate') {
11458 self._setAttrTrans(name, value);
11459 } else if (name.startsWith('shadow')) {
11460 self._setAttrShadow(name, value);
11461 } else if (~['stroke', 'strokeStyle', 'fill', 'fillStyle'].indexOf(name) && el) {
11462 if (!value) {
11463 el.setAttribute(SVG_ATTR_MAP[name], 'none');
11464 } else if (/^[r,R,L,l]{1}[\s]*\(/.test(value.trim())) {
11465 self._setAttrGradients(name, value.trim());
11466 } else {
11467 el.setAttribute(SVG_ATTR_MAP[name], value);
11468 }
11469 } else if (~name.toLowerCase().indexOf('arrow')) {
11470 if (!value) {
11471 return self;
11472 }
11473 self._setAttrArrow(name, value);
11474 } else {
11475 // 先存好属性,然后对一些svg和canvas中不同的属性进行特判
11476 if (~['circle', 'ellipse', 'marker'].indexOf(self.type) && ~['x', 'y'].indexOf(name)) {
11477 /**
11478 * 本来考虑想写到对应图形里面的,但是x,y又是svg通用属性,这样会同时存在x,y, cx,cy
11479 * 如果在下面svgAttr设置的时候还是要特判,不如就在这边特殊处理一下吧
11480 */
11481 if (self.type !== 'marker' && typeof value === 'number') {
11482 el.setAttribute('c' + name, value);
11483 }
11484 } else {
11485 var svgAttr = SVG_ATTR_MAP[name];
11486 if (el && svgAttr) {
11487 el.setAttribute(svgAttr, value);
11488 }
11489 var alias = ALIAS_ATTRS_MAP[name];
11490 if (alias) {
11491 svgAttr = SVG_ATTR_MAP[alias];
11492 if (el && svgAttr) {
11493 el.setAttribute(svgAttr, value);
11494 }
11495 self.__attrs[alias] = value;
11496 }
11497 }
11498 }
11499 return self;
11500 },
11501 hasFill: function hasFill() {
11502 return this.canFill && this.__attrs.fillStyle;
11503 },
11504 hasStroke: function hasStroke() {
11505 return this.canStroke && this.__attrs.strokeStyle;
11506 },
11507 _setAttrArrow: function _setAttrArrow(name, value) {
11508 var self = this;
11509 var el = self.get('el');
11510 var defs = self.get('defs');
11511 if (!defs) {
11512 var canvas = self.get('canvas');
11513 if (!canvas) {
11514 this._setAttrDependency(name, value);
11515 return this;
11516 }
11517 defs = canvas.get('defs');
11518 }
11519 name = SVG_ATTR_MAP[name];
11520 if (!name) {
11521 return this;
11522 }
11523 if (!value) {
11524 el.removeAttribute(name);
11525 return this;
11526 }
11527 var id = defs.find(name, { value: value, stroke: self.__attrs.stroke });
11528 if (!id) {
11529 id = defs.addArrow(name, value, self.__attrs.stroke);
11530 }
11531 self.__cfg[name] = id;
11532 self.get('el').setAttribute(name, 'url(#' + id + ')');
11533 },
11534 _setAttrShadow: function _setAttrShadow(name, value) {
11535 var attrs = this.__attrs;
11536 var filter = this.get('filter');
11537 var defs = this.get('defs');
11538 if (!value) {
11539 this.get('el').removeAttribute('filter');
11540 return this;
11541 }
11542 if (filter) {
11543 defs.findById(filter).update(name, value);
11544 return this;
11545 }
11546 if (!defs) {
11547 var canvas = this.get('canvas');
11548 if (!canvas) {
11549 this._setAttrDependency(name, value);
11550 return this;
11551 }
11552 defs = canvas.get('defs');
11553 }
11554 var cfg = {
11555 dx: attrs.shadowOffsetX,
11556 dy: attrs.shadowOffsetY,
11557 blur: attrs.shadowBlur,
11558 color: attrs.shadowColor
11559 };
11560 if (isNaN(Number(cfg.dx)) || isNaN(Number(cfg.dy))) {
11561 return this;
11562 }
11563 var id = defs.find('filter', cfg);
11564 if (!id) {
11565 id = defs.addShadow(cfg, this);
11566 }
11567 this.__cfg.filter = id;
11568 this.get('el').setAttribute('filter', 'url(#' + id + ')');
11569 },
11570 _setAttrGradients: function _setAttrGradients(name, value) {
11571 name = name.replace('Style', '');
11572 var defs = this.get('defs');
11573 if (!value) {
11574 this.get('el').removeAttribute('gradient');
11575 return this;
11576 }
11577 if (!defs) {
11578 var canvas = this.get('canvas');
11579 if (!canvas) {
11580 this._setAttrDependency(name, value);
11581 return this;
11582 }
11583 defs = canvas.get('defs');
11584 }
11585 var id = defs.find('gradient', value);
11586 if (!id) {
11587 id = defs.addGradient(value, this);
11588 }
11589 this.get('el').setAttribute(name, 'url(#' + id + ')');
11590 },
11591 _setAttrDependency: function _setAttrDependency(name, value) {
11592 var dependencies = this.get('dependencies');
11593 if (!dependencies) {
11594 dependencies = {};
11595 }
11596 dependencies[name] = value;
11597 this.__cfg.dependencies = dependencies;
11598 return this;
11599 },
11600 _setAttrClip: function _setAttrClip(name, value) {
11601 var defs = this.get('defs');
11602 var canvas = this.get('canvas');
11603 if (!value) {
11604 this.get('el').removeAttribute('clip-path');
11605 return this;
11606 }
11607 if (!defs) {
11608 var _canvas = this.get('canvas');
11609 if (!_canvas) {
11610 this._setAttrDependency(name, value);
11611 return this;
11612 }
11613 defs = _canvas.get('defs');
11614 }
11615 value.__cfg.canvas = canvas;
11616 var id = defs.addClip(value);
11617 this.get('el').setAttribute('clip-path', 'url(#' + id + ')');
11618 },
11619 _setAttrTrans: function _setAttrTrans(name, value) {
11620 var attrs = this.__attrs;
11621 if (!value) {
11622 this.get('el').removeAttribute('transform');
11623 }
11624 if (!attrs.matrix) {
11625 this.initTransform();
11626 }
11627 if (name === 'transform') {
11628 this.transform(value);
11629 } else {
11630 if (typeof attrs.x === 'undefined' || typeof attrs.y === 'undefined') {
11631 this._setAttrDependency(name, value);
11632 return this;
11633 }
11634 this.rotateAtStart(value);
11635 }
11636 return this;
11637 }
11638};
11639
11640/***/ }),
11641/* 73 */
11642/***/ (function(module, exports, __webpack_require__) {
11643
11644var Util = __webpack_require__(0);
11645var mat3 = __webpack_require__(2).mat3;
11646var vec3 = __webpack_require__(2).vec3;
11647
11648// 是否未改变
11649function isUnchanged(m) {
11650 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
11651}
11652
11653// 是否仅仅是scale
11654function isScale(m) {
11655 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
11656}
11657
11658/* function multiple(m1, m2) {
11659 if (!isUnchanged(m2)) {
11660 if (isScale(m2)) {
11661 m1[0] *= m2[0];
11662 m1[4] *= m2[4];
11663 } else {
11664 mat3.multiply(m1, m1, m2);
11665 mat3.multiply(m1, m1, m2);
11666 }
11667 }
11668}*/
11669
11670module.exports = {
11671 initTransform: function initTransform() {
11672 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
11673 },
11674 translate: function translate(tx, ty, perform) {
11675 var matrix = this.attr('matrix');
11676 mat3.translate(matrix, matrix, [tx, ty]);
11677 this.attr('matrix', matrix);
11678 if (arguments.length === 2 || perform) {
11679 this._performTransform();
11680 }
11681 return this;
11682 },
11683 rotate: function rotate(radian, perform) {
11684 var matrix = this.attr('matrix');
11685 if (Math.abs(radian) > Math.PI * 2) {
11686 radian = radian / 180 * Math.PI;
11687 }
11688 mat3.rotate(matrix, matrix, radian);
11689 this.attr('matrix', matrix);
11690 if (arguments.length === 1 || perform) {
11691 this._performTransform();
11692 }
11693 return this;
11694 },
11695
11696 /**
11697 * 绕起始点旋转
11698 * @param {Number} rotate 0~360
11699 */
11700 rotateAtStart: function rotateAtStart(rotate) {
11701 var x = this.attr('x');
11702 var y = this.attr('y');
11703 if (Math.abs(rotate) > Math.PI * 2) {
11704 rotate = rotate / 180 * Math.PI;
11705 }
11706 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
11707 },
11708 scale: function scale(s1, s2, perform) {
11709 var matrix = this.attr('matrix');
11710 mat3.scale(matrix, matrix, [s1, s2]);
11711 this.attr('matrix', matrix);
11712 if (arguments.length === 2 || perform) {
11713 this._performTransform();
11714 }
11715 return this;
11716 },
11717
11718 /**
11719 * 移动的到位置
11720 * @param {Number} x 移动到x
11721 * @param {Number} y 移动到y
11722 */
11723 move: function move(x, y) {
11724 var cx = this.get('x') || 0; // 当前的x
11725 var cy = this.get('y') || 0; // 当前的y
11726 this.translate(x - cx, y - cy);
11727 this.set('x', x);
11728 this.set('y', y);
11729 },
11730 _performTransform: function _performTransform() {
11731 var matrix = this.__attrs.matrix;
11732 var transform = [];
11733 for (var i = 0; i < 9; i += 3) {
11734 transform.push(matrix[i] + ',' + matrix[i + 1]);
11735 }
11736 var el = this.get('el');
11737 if (el) {
11738 el.setAttribute('transform', 'matrix(' + transform.join(',') + ')');
11739 }
11740 },
11741 transform: function transform(ts) {
11742 var self = this;
11743 var matrix = self.attr('matrix');
11744 Util.each(ts, function (t) {
11745 switch (t[0]) {
11746 case 't':
11747 self.translate(t[1], t[2], false);
11748 break;
11749 case 's':
11750 self.scale(t[1], t[2], false);
11751 break;
11752 case 'r':
11753 self.rotate(t[1], false);
11754 break;
11755 case 'm':
11756 self.attr('matrix', mat3.multiply([], matrix, t[1]));
11757 break;
11758 default:
11759 break;
11760 }
11761 });
11762 this._performTransform();
11763 return self;
11764 },
11765 setTransform: function setTransform(ts) {
11766 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
11767 return this.transform(ts);
11768 },
11769 getMatrix: function getMatrix() {
11770 return this.attr('matrix');
11771 },
11772 setMatrix: function setMatrix(m) {
11773 this.attr('matrix', m);
11774 this._performTransform();
11775 this.clearTotalMatrix();
11776 return this;
11777 },
11778 apply: function apply(v, root) {
11779 var m = void 0;
11780 if (root) {
11781 m = this._getMatrixByRoot(root);
11782 } else {
11783 m = this.attr('matrix');
11784 }
11785 vec3.transformMat3(v, v, m);
11786 return this;
11787 },
11788 invert: function invert(v) {
11789 var m = this.attr('matrix');
11790 // 单精屏幕下大多数矩阵没变化
11791 if (isScale(m)) {
11792 v[0] /= m[0];
11793 v[1] /= m[4];
11794 } else {
11795 var inm = mat3.invert([], m);
11796 if (inm) {
11797 vec3.transformMat3(v, v, inm);
11798 }
11799 }
11800 return this;
11801 },
11802 resetTransform: function resetTransform(context) {
11803 var mo = this.attr('matrix');
11804 // 不改变时
11805 if (!isUnchanged(mo)) {
11806 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
11807 }
11808 }
11809};
11810
11811/***/ }),
11812/* 74 */
11813/***/ (function(module, __webpack_exports__, __webpack_require__) {
11814
11815"use strict";
11816Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
11817/* harmony export (immutable) */ __webpack_exports__["create"] = create;
11818/* harmony export (immutable) */ __webpack_exports__["fromMat4"] = fromMat4;
11819/* harmony export (immutable) */ __webpack_exports__["clone"] = clone;
11820/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
11821/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues;
11822/* harmony export (immutable) */ __webpack_exports__["set"] = set;
11823/* harmony export (immutable) */ __webpack_exports__["identity"] = identity;
11824/* harmony export (immutable) */ __webpack_exports__["transpose"] = transpose;
11825/* harmony export (immutable) */ __webpack_exports__["invert"] = invert;
11826/* harmony export (immutable) */ __webpack_exports__["adjoint"] = adjoint;
11827/* harmony export (immutable) */ __webpack_exports__["determinant"] = determinant;
11828/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply;
11829/* harmony export (immutable) */ __webpack_exports__["translate"] = translate;
11830/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate;
11831/* harmony export (immutable) */ __webpack_exports__["scale"] = scale;
11832/* harmony export (immutable) */ __webpack_exports__["fromTranslation"] = fromTranslation;
11833/* harmony export (immutable) */ __webpack_exports__["fromRotation"] = fromRotation;
11834/* harmony export (immutable) */ __webpack_exports__["fromScaling"] = fromScaling;
11835/* harmony export (immutable) */ __webpack_exports__["fromMat2d"] = fromMat2d;
11836/* harmony export (immutable) */ __webpack_exports__["fromQuat"] = fromQuat;
11837/* harmony export (immutable) */ __webpack_exports__["normalFromMat4"] = normalFromMat4;
11838/* harmony export (immutable) */ __webpack_exports__["projection"] = projection;
11839/* harmony export (immutable) */ __webpack_exports__["str"] = str;
11840/* harmony export (immutable) */ __webpack_exports__["frob"] = frob;
11841/* harmony export (immutable) */ __webpack_exports__["add"] = add;
11842/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract;
11843/* harmony export (immutable) */ __webpack_exports__["multiplyScalar"] = multiplyScalar;
11844/* harmony export (immutable) */ __webpack_exports__["multiplyScalarAndAdd"] = multiplyScalarAndAdd;
11845/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals;
11846/* harmony export (immutable) */ __webpack_exports__["equals"] = equals;
11847/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
11848/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
11849/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(14);
11850
11851
11852/**
11853 * 3x3 Matrix
11854 * @module mat3
11855 */
11856
11857/**
11858 * Creates a new identity mat3
11859 *
11860 * @returns {mat3} a new 3x3 matrix
11861 */
11862function create() {
11863 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
11864 out[0] = 1;
11865 out[1] = 0;
11866 out[2] = 0;
11867 out[3] = 0;
11868 out[4] = 1;
11869 out[5] = 0;
11870 out[6] = 0;
11871 out[7] = 0;
11872 out[8] = 1;
11873 return out;
11874}
11875
11876/**
11877 * Copies the upper-left 3x3 values into the given mat3.
11878 *
11879 * @param {mat3} out the receiving 3x3 matrix
11880 * @param {mat4} a the source 4x4 matrix
11881 * @returns {mat3} out
11882 */
11883function fromMat4(out, a) {
11884 out[0] = a[0];
11885 out[1] = a[1];
11886 out[2] = a[2];
11887 out[3] = a[4];
11888 out[4] = a[5];
11889 out[5] = a[6];
11890 out[6] = a[8];
11891 out[7] = a[9];
11892 out[8] = a[10];
11893 return out;
11894}
11895
11896/**
11897 * Creates a new mat3 initialized with values from an existing matrix
11898 *
11899 * @param {mat3} a matrix to clone
11900 * @returns {mat3} a new 3x3 matrix
11901 */
11902function clone(a) {
11903 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
11904 out[0] = a[0];
11905 out[1] = a[1];
11906 out[2] = a[2];
11907 out[3] = a[3];
11908 out[4] = a[4];
11909 out[5] = a[5];
11910 out[6] = a[6];
11911 out[7] = a[7];
11912 out[8] = a[8];
11913 return out;
11914}
11915
11916/**
11917 * Copy the values from one mat3 to another
11918 *
11919 * @param {mat3} out the receiving matrix
11920 * @param {mat3} a the source matrix
11921 * @returns {mat3} out
11922 */
11923function copy(out, a) {
11924 out[0] = a[0];
11925 out[1] = a[1];
11926 out[2] = a[2];
11927 out[3] = a[3];
11928 out[4] = a[4];
11929 out[5] = a[5];
11930 out[6] = a[6];
11931 out[7] = a[7];
11932 out[8] = a[8];
11933 return out;
11934}
11935
11936/**
11937 * Create a new mat3 with the given values
11938 *
11939 * @param {Number} m00 Component in column 0, row 0 position (index 0)
11940 * @param {Number} m01 Component in column 0, row 1 position (index 1)
11941 * @param {Number} m02 Component in column 0, row 2 position (index 2)
11942 * @param {Number} m10 Component in column 1, row 0 position (index 3)
11943 * @param {Number} m11 Component in column 1, row 1 position (index 4)
11944 * @param {Number} m12 Component in column 1, row 2 position (index 5)
11945 * @param {Number} m20 Component in column 2, row 0 position (index 6)
11946 * @param {Number} m21 Component in column 2, row 1 position (index 7)
11947 * @param {Number} m22 Component in column 2, row 2 position (index 8)
11948 * @returns {mat3} A new mat3
11949 */
11950function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
11951 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](9);
11952 out[0] = m00;
11953 out[1] = m01;
11954 out[2] = m02;
11955 out[3] = m10;
11956 out[4] = m11;
11957 out[5] = m12;
11958 out[6] = m20;
11959 out[7] = m21;
11960 out[8] = m22;
11961 return out;
11962}
11963
11964/**
11965 * Set the components of a mat3 to the given values
11966 *
11967 * @param {mat3} out the receiving matrix
11968 * @param {Number} m00 Component in column 0, row 0 position (index 0)
11969 * @param {Number} m01 Component in column 0, row 1 position (index 1)
11970 * @param {Number} m02 Component in column 0, row 2 position (index 2)
11971 * @param {Number} m10 Component in column 1, row 0 position (index 3)
11972 * @param {Number} m11 Component in column 1, row 1 position (index 4)
11973 * @param {Number} m12 Component in column 1, row 2 position (index 5)
11974 * @param {Number} m20 Component in column 2, row 0 position (index 6)
11975 * @param {Number} m21 Component in column 2, row 1 position (index 7)
11976 * @param {Number} m22 Component in column 2, row 2 position (index 8)
11977 * @returns {mat3} out
11978 */
11979function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
11980 out[0] = m00;
11981 out[1] = m01;
11982 out[2] = m02;
11983 out[3] = m10;
11984 out[4] = m11;
11985 out[5] = m12;
11986 out[6] = m20;
11987 out[7] = m21;
11988 out[8] = m22;
11989 return out;
11990}
11991
11992/**
11993 * Set a mat3 to the identity matrix
11994 *
11995 * @param {mat3} out the receiving matrix
11996 * @returns {mat3} out
11997 */
11998function identity(out) {
11999 out[0] = 1;
12000 out[1] = 0;
12001 out[2] = 0;
12002 out[3] = 0;
12003 out[4] = 1;
12004 out[5] = 0;
12005 out[6] = 0;
12006 out[7] = 0;
12007 out[8] = 1;
12008 return out;
12009}
12010
12011/**
12012 * Transpose the values of a mat3
12013 *
12014 * @param {mat3} out the receiving matrix
12015 * @param {mat3} a the source matrix
12016 * @returns {mat3} out
12017 */
12018function transpose(out, a) {
12019 // If we are transposing ourselves we can skip a few steps but have to cache some values
12020 if (out === a) {
12021 var a01 = a[1],
12022 a02 = a[2],
12023 a12 = a[5];
12024 out[1] = a[3];
12025 out[2] = a[6];
12026 out[3] = a01;
12027 out[5] = a[7];
12028 out[6] = a02;
12029 out[7] = a12;
12030 } else {
12031 out[0] = a[0];
12032 out[1] = a[3];
12033 out[2] = a[6];
12034 out[3] = a[1];
12035 out[4] = a[4];
12036 out[5] = a[7];
12037 out[6] = a[2];
12038 out[7] = a[5];
12039 out[8] = a[8];
12040 }
12041
12042 return out;
12043}
12044
12045/**
12046 * Inverts a mat3
12047 *
12048 * @param {mat3} out the receiving matrix
12049 * @param {mat3} a the source matrix
12050 * @returns {mat3} out
12051 */
12052function invert(out, a) {
12053 var a00 = a[0],
12054 a01 = a[1],
12055 a02 = a[2];
12056 var a10 = a[3],
12057 a11 = a[4],
12058 a12 = a[5];
12059 var a20 = a[6],
12060 a21 = a[7],
12061 a22 = a[8];
12062
12063 var b01 = a22 * a11 - a12 * a21;
12064 var b11 = -a22 * a10 + a12 * a20;
12065 var b21 = a21 * a10 - a11 * a20;
12066
12067 // Calculate the determinant
12068 var det = a00 * b01 + a01 * b11 + a02 * b21;
12069
12070 if (!det) {
12071 return null;
12072 }
12073 det = 1.0 / det;
12074
12075 out[0] = b01 * det;
12076 out[1] = (-a22 * a01 + a02 * a21) * det;
12077 out[2] = (a12 * a01 - a02 * a11) * det;
12078 out[3] = b11 * det;
12079 out[4] = (a22 * a00 - a02 * a20) * det;
12080 out[5] = (-a12 * a00 + a02 * a10) * det;
12081 out[6] = b21 * det;
12082 out[7] = (-a21 * a00 + a01 * a20) * det;
12083 out[8] = (a11 * a00 - a01 * a10) * det;
12084 return out;
12085}
12086
12087/**
12088 * Calculates the adjugate of a mat3
12089 *
12090 * @param {mat3} out the receiving matrix
12091 * @param {mat3} a the source matrix
12092 * @returns {mat3} out
12093 */
12094function adjoint(out, a) {
12095 var a00 = a[0],
12096 a01 = a[1],
12097 a02 = a[2];
12098 var a10 = a[3],
12099 a11 = a[4],
12100 a12 = a[5];
12101 var a20 = a[6],
12102 a21 = a[7],
12103 a22 = a[8];
12104
12105 out[0] = a11 * a22 - a12 * a21;
12106 out[1] = a02 * a21 - a01 * a22;
12107 out[2] = a01 * a12 - a02 * a11;
12108 out[3] = a12 * a20 - a10 * a22;
12109 out[4] = a00 * a22 - a02 * a20;
12110 out[5] = a02 * a10 - a00 * a12;
12111 out[6] = a10 * a21 - a11 * a20;
12112 out[7] = a01 * a20 - a00 * a21;
12113 out[8] = a00 * a11 - a01 * a10;
12114 return out;
12115}
12116
12117/**
12118 * Calculates the determinant of a mat3
12119 *
12120 * @param {mat3} a the source matrix
12121 * @returns {Number} determinant of a
12122 */
12123function determinant(a) {
12124 var a00 = a[0],
12125 a01 = a[1],
12126 a02 = a[2];
12127 var a10 = a[3],
12128 a11 = a[4],
12129 a12 = a[5];
12130 var a20 = a[6],
12131 a21 = a[7],
12132 a22 = a[8];
12133
12134 return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
12135}
12136
12137/**
12138 * Multiplies two mat3's
12139 *
12140 * @param {mat3} out the receiving matrix
12141 * @param {mat3} a the first operand
12142 * @param {mat3} b the second operand
12143 * @returns {mat3} out
12144 */
12145function multiply(out, a, b) {
12146 var a00 = a[0],
12147 a01 = a[1],
12148 a02 = a[2];
12149 var a10 = a[3],
12150 a11 = a[4],
12151 a12 = a[5];
12152 var a20 = a[6],
12153 a21 = a[7],
12154 a22 = a[8];
12155
12156 var b00 = b[0],
12157 b01 = b[1],
12158 b02 = b[2];
12159 var b10 = b[3],
12160 b11 = b[4],
12161 b12 = b[5];
12162 var b20 = b[6],
12163 b21 = b[7],
12164 b22 = b[8];
12165
12166 out[0] = b00 * a00 + b01 * a10 + b02 * a20;
12167 out[1] = b00 * a01 + b01 * a11 + b02 * a21;
12168 out[2] = b00 * a02 + b01 * a12 + b02 * a22;
12169
12170 out[3] = b10 * a00 + b11 * a10 + b12 * a20;
12171 out[4] = b10 * a01 + b11 * a11 + b12 * a21;
12172 out[5] = b10 * a02 + b11 * a12 + b12 * a22;
12173
12174 out[6] = b20 * a00 + b21 * a10 + b22 * a20;
12175 out[7] = b20 * a01 + b21 * a11 + b22 * a21;
12176 out[8] = b20 * a02 + b21 * a12 + b22 * a22;
12177 return out;
12178}
12179
12180/**
12181 * Translate a mat3 by the given vector
12182 *
12183 * @param {mat3} out the receiving matrix
12184 * @param {mat3} a the matrix to translate
12185 * @param {vec2} v vector to translate by
12186 * @returns {mat3} out
12187 */
12188function translate(out, a, v) {
12189 var a00 = a[0],
12190 a01 = a[1],
12191 a02 = a[2],
12192 a10 = a[3],
12193 a11 = a[4],
12194 a12 = a[5],
12195 a20 = a[6],
12196 a21 = a[7],
12197 a22 = a[8],
12198 x = v[0],
12199 y = v[1];
12200
12201 out[0] = a00;
12202 out[1] = a01;
12203 out[2] = a02;
12204
12205 out[3] = a10;
12206 out[4] = a11;
12207 out[5] = a12;
12208
12209 out[6] = x * a00 + y * a10 + a20;
12210 out[7] = x * a01 + y * a11 + a21;
12211 out[8] = x * a02 + y * a12 + a22;
12212 return out;
12213}
12214
12215/**
12216 * Rotates a mat3 by the given angle
12217 *
12218 * @param {mat3} out the receiving matrix
12219 * @param {mat3} a the matrix to rotate
12220 * @param {Number} rad the angle to rotate the matrix by
12221 * @returns {mat3} out
12222 */
12223function rotate(out, a, rad) {
12224 var a00 = a[0],
12225 a01 = a[1],
12226 a02 = a[2],
12227 a10 = a[3],
12228 a11 = a[4],
12229 a12 = a[5],
12230 a20 = a[6],
12231 a21 = a[7],
12232 a22 = a[8],
12233 s = Math.sin(rad),
12234 c = Math.cos(rad);
12235
12236 out[0] = c * a00 + s * a10;
12237 out[1] = c * a01 + s * a11;
12238 out[2] = c * a02 + s * a12;
12239
12240 out[3] = c * a10 - s * a00;
12241 out[4] = c * a11 - s * a01;
12242 out[5] = c * a12 - s * a02;
12243
12244 out[6] = a20;
12245 out[7] = a21;
12246 out[8] = a22;
12247 return out;
12248};
12249
12250/**
12251 * Scales the mat3 by the dimensions in the given vec2
12252 *
12253 * @param {mat3} out the receiving matrix
12254 * @param {mat3} a the matrix to rotate
12255 * @param {vec2} v the vec2 to scale the matrix by
12256 * @returns {mat3} out
12257 **/
12258function scale(out, a, v) {
12259 var x = v[0],
12260 y = v[1];
12261
12262 out[0] = x * a[0];
12263 out[1] = x * a[1];
12264 out[2] = x * a[2];
12265
12266 out[3] = y * a[3];
12267 out[4] = y * a[4];
12268 out[5] = y * a[5];
12269
12270 out[6] = a[6];
12271 out[7] = a[7];
12272 out[8] = a[8];
12273 return out;
12274}
12275
12276/**
12277 * Creates a matrix from a vector translation
12278 * This is equivalent to (but much faster than):
12279 *
12280 * mat3.identity(dest);
12281 * mat3.translate(dest, dest, vec);
12282 *
12283 * @param {mat3} out mat3 receiving operation result
12284 * @param {vec2} v Translation vector
12285 * @returns {mat3} out
12286 */
12287function fromTranslation(out, v) {
12288 out[0] = 1;
12289 out[1] = 0;
12290 out[2] = 0;
12291 out[3] = 0;
12292 out[4] = 1;
12293 out[5] = 0;
12294 out[6] = v[0];
12295 out[7] = v[1];
12296 out[8] = 1;
12297 return out;
12298}
12299
12300/**
12301 * Creates a matrix from a given angle
12302 * This is equivalent to (but much faster than):
12303 *
12304 * mat3.identity(dest);
12305 * mat3.rotate(dest, dest, rad);
12306 *
12307 * @param {mat3} out mat3 receiving operation result
12308 * @param {Number} rad the angle to rotate the matrix by
12309 * @returns {mat3} out
12310 */
12311function fromRotation(out, rad) {
12312 var s = Math.sin(rad),
12313 c = Math.cos(rad);
12314
12315 out[0] = c;
12316 out[1] = s;
12317 out[2] = 0;
12318
12319 out[3] = -s;
12320 out[4] = c;
12321 out[5] = 0;
12322
12323 out[6] = 0;
12324 out[7] = 0;
12325 out[8] = 1;
12326 return out;
12327}
12328
12329/**
12330 * Creates a matrix from a vector scaling
12331 * This is equivalent to (but much faster than):
12332 *
12333 * mat3.identity(dest);
12334 * mat3.scale(dest, dest, vec);
12335 *
12336 * @param {mat3} out mat3 receiving operation result
12337 * @param {vec2} v Scaling vector
12338 * @returns {mat3} out
12339 */
12340function fromScaling(out, v) {
12341 out[0] = v[0];
12342 out[1] = 0;
12343 out[2] = 0;
12344
12345 out[3] = 0;
12346 out[4] = v[1];
12347 out[5] = 0;
12348
12349 out[6] = 0;
12350 out[7] = 0;
12351 out[8] = 1;
12352 return out;
12353}
12354
12355/**
12356 * Copies the values from a mat2d into a mat3
12357 *
12358 * @param {mat3} out the receiving matrix
12359 * @param {mat2d} a the matrix to copy
12360 * @returns {mat3} out
12361 **/
12362function fromMat2d(out, a) {
12363 out[0] = a[0];
12364 out[1] = a[1];
12365 out[2] = 0;
12366
12367 out[3] = a[2];
12368 out[4] = a[3];
12369 out[5] = 0;
12370
12371 out[6] = a[4];
12372 out[7] = a[5];
12373 out[8] = 1;
12374 return out;
12375}
12376
12377/**
12378* Calculates a 3x3 matrix from the given quaternion
12379*
12380* @param {mat3} out mat3 receiving operation result
12381* @param {quat} q Quaternion to create matrix from
12382*
12383* @returns {mat3} out
12384*/
12385function fromQuat(out, q) {
12386 var x = q[0],
12387 y = q[1],
12388 z = q[2],
12389 w = q[3];
12390 var x2 = x + x;
12391 var y2 = y + y;
12392 var z2 = z + z;
12393
12394 var xx = x * x2;
12395 var yx = y * x2;
12396 var yy = y * y2;
12397 var zx = z * x2;
12398 var zy = z * y2;
12399 var zz = z * z2;
12400 var wx = w * x2;
12401 var wy = w * y2;
12402 var wz = w * z2;
12403
12404 out[0] = 1 - yy - zz;
12405 out[3] = yx - wz;
12406 out[6] = zx + wy;
12407
12408 out[1] = yx + wz;
12409 out[4] = 1 - xx - zz;
12410 out[7] = zy - wx;
12411
12412 out[2] = zx - wy;
12413 out[5] = zy + wx;
12414 out[8] = 1 - xx - yy;
12415
12416 return out;
12417}
12418
12419/**
12420* Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
12421*
12422* @param {mat3} out mat3 receiving operation result
12423* @param {mat4} a Mat4 to derive the normal matrix from
12424*
12425* @returns {mat3} out
12426*/
12427function normalFromMat4(out, a) {
12428 var a00 = a[0],
12429 a01 = a[1],
12430 a02 = a[2],
12431 a03 = a[3];
12432 var a10 = a[4],
12433 a11 = a[5],
12434 a12 = a[6],
12435 a13 = a[7];
12436 var a20 = a[8],
12437 a21 = a[9],
12438 a22 = a[10],
12439 a23 = a[11];
12440 var a30 = a[12],
12441 a31 = a[13],
12442 a32 = a[14],
12443 a33 = a[15];
12444
12445 var b00 = a00 * a11 - a01 * a10;
12446 var b01 = a00 * a12 - a02 * a10;
12447 var b02 = a00 * a13 - a03 * a10;
12448 var b03 = a01 * a12 - a02 * a11;
12449 var b04 = a01 * a13 - a03 * a11;
12450 var b05 = a02 * a13 - a03 * a12;
12451 var b06 = a20 * a31 - a21 * a30;
12452 var b07 = a20 * a32 - a22 * a30;
12453 var b08 = a20 * a33 - a23 * a30;
12454 var b09 = a21 * a32 - a22 * a31;
12455 var b10 = a21 * a33 - a23 * a31;
12456 var b11 = a22 * a33 - a23 * a32;
12457
12458 // Calculate the determinant
12459 var det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
12460
12461 if (!det) {
12462 return null;
12463 }
12464 det = 1.0 / det;
12465
12466 out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
12467 out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
12468 out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
12469
12470 out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
12471 out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
12472 out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
12473
12474 out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
12475 out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
12476 out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
12477
12478 return out;
12479}
12480
12481/**
12482 * Generates a 2D projection matrix with the given bounds
12483 *
12484 * @param {mat3} out mat3 frustum matrix will be written into
12485 * @param {number} width Width of your gl context
12486 * @param {number} height Height of gl context
12487 * @returns {mat3} out
12488 */
12489function projection(out, width, height) {
12490 out[0] = 2 / width;
12491 out[1] = 0;
12492 out[2] = 0;
12493 out[3] = 0;
12494 out[4] = -2 / height;
12495 out[5] = 0;
12496 out[6] = -1;
12497 out[7] = 1;
12498 out[8] = 1;
12499 return out;
12500}
12501
12502/**
12503 * Returns a string representation of a mat3
12504 *
12505 * @param {mat3} a matrix to represent as a string
12506 * @returns {String} string representation of the matrix
12507 */
12508function str(a) {
12509 return 'mat3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ', ' + a[3] + ', ' + a[4] + ', ' + a[5] + ', ' + a[6] + ', ' + a[7] + ', ' + a[8] + ')';
12510}
12511
12512/**
12513 * Returns Frobenius norm of a mat3
12514 *
12515 * @param {mat3} a the matrix to calculate Frobenius norm of
12516 * @returns {Number} Frobenius norm
12517 */
12518function frob(a) {
12519 return Math.sqrt(Math.pow(a[0], 2) + Math.pow(a[1], 2) + Math.pow(a[2], 2) + Math.pow(a[3], 2) + Math.pow(a[4], 2) + Math.pow(a[5], 2) + Math.pow(a[6], 2) + Math.pow(a[7], 2) + Math.pow(a[8], 2));
12520}
12521
12522/**
12523 * Adds two mat3's
12524 *
12525 * @param {mat3} out the receiving matrix
12526 * @param {mat3} a the first operand
12527 * @param {mat3} b the second operand
12528 * @returns {mat3} out
12529 */
12530function add(out, a, b) {
12531 out[0] = a[0] + b[0];
12532 out[1] = a[1] + b[1];
12533 out[2] = a[2] + b[2];
12534 out[3] = a[3] + b[3];
12535 out[4] = a[4] + b[4];
12536 out[5] = a[5] + b[5];
12537 out[6] = a[6] + b[6];
12538 out[7] = a[7] + b[7];
12539 out[8] = a[8] + b[8];
12540 return out;
12541}
12542
12543/**
12544 * Subtracts matrix b from matrix a
12545 *
12546 * @param {mat3} out the receiving matrix
12547 * @param {mat3} a the first operand
12548 * @param {mat3} b the second operand
12549 * @returns {mat3} out
12550 */
12551function subtract(out, a, b) {
12552 out[0] = a[0] - b[0];
12553 out[1] = a[1] - b[1];
12554 out[2] = a[2] - b[2];
12555 out[3] = a[3] - b[3];
12556 out[4] = a[4] - b[4];
12557 out[5] = a[5] - b[5];
12558 out[6] = a[6] - b[6];
12559 out[7] = a[7] - b[7];
12560 out[8] = a[8] - b[8];
12561 return out;
12562}
12563
12564/**
12565 * Multiply each element of the matrix by a scalar.
12566 *
12567 * @param {mat3} out the receiving matrix
12568 * @param {mat3} a the matrix to scale
12569 * @param {Number} b amount to scale the matrix's elements by
12570 * @returns {mat3} out
12571 */
12572function multiplyScalar(out, a, b) {
12573 out[0] = a[0] * b;
12574 out[1] = a[1] * b;
12575 out[2] = a[2] * b;
12576 out[3] = a[3] * b;
12577 out[4] = a[4] * b;
12578 out[5] = a[5] * b;
12579 out[6] = a[6] * b;
12580 out[7] = a[7] * b;
12581 out[8] = a[8] * b;
12582 return out;
12583}
12584
12585/**
12586 * Adds two mat3's after multiplying each element of the second operand by a scalar value.
12587 *
12588 * @param {mat3} out the receiving vector
12589 * @param {mat3} a the first operand
12590 * @param {mat3} b the second operand
12591 * @param {Number} scale the amount to scale b's elements by before adding
12592 * @returns {mat3} out
12593 */
12594function multiplyScalarAndAdd(out, a, b, scale) {
12595 out[0] = a[0] + b[0] * scale;
12596 out[1] = a[1] + b[1] * scale;
12597 out[2] = a[2] + b[2] * scale;
12598 out[3] = a[3] + b[3] * scale;
12599 out[4] = a[4] + b[4] * scale;
12600 out[5] = a[5] + b[5] * scale;
12601 out[6] = a[6] + b[6] * scale;
12602 out[7] = a[7] + b[7] * scale;
12603 out[8] = a[8] + b[8] * scale;
12604 return out;
12605}
12606
12607/**
12608 * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
12609 *
12610 * @param {mat3} a The first matrix.
12611 * @param {mat3} b The second matrix.
12612 * @returns {Boolean} True if the matrices are equal, false otherwise.
12613 */
12614function exactEquals(a, b) {
12615 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
12616}
12617
12618/**
12619 * Returns whether or not the matrices have approximately the same elements in the same position.
12620 *
12621 * @param {mat3} a The first matrix.
12622 * @param {mat3} b The second matrix.
12623 * @returns {Boolean} True if the matrices are equal, false otherwise.
12624 */
12625function equals(a, b) {
12626 var a0 = a[0],
12627 a1 = a[1],
12628 a2 = a[2],
12629 a3 = a[3],
12630 a4 = a[4],
12631 a5 = a[5],
12632 a6 = a[6],
12633 a7 = a[7],
12634 a8 = a[8];
12635 var b0 = b[0],
12636 b1 = b[1],
12637 b2 = b[2],
12638 b3 = b[3],
12639 b4 = b[4],
12640 b5 = b[5],
12641 b6 = b[6],
12642 b7 = b[7],
12643 b8 = b[8];
12644 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a8), Math.abs(b8));
12645}
12646
12647/**
12648 * Alias for {@link mat3.multiply}
12649 * @function
12650 */
12651var mul = multiply;
12652
12653/**
12654 * Alias for {@link mat3.subtract}
12655 * @function
12656 */
12657var sub = subtract;
12658
12659/***/ }),
12660/* 75 */
12661/***/ (function(module, __webpack_exports__, __webpack_require__) {
12662
12663"use strict";
12664Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
12665/* harmony export (immutable) */ __webpack_exports__["create"] = create;
12666/* harmony export (immutable) */ __webpack_exports__["clone"] = clone;
12667/* harmony export (immutable) */ __webpack_exports__["length"] = length;
12668/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues;
12669/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
12670/* harmony export (immutable) */ __webpack_exports__["set"] = set;
12671/* harmony export (immutable) */ __webpack_exports__["add"] = add;
12672/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract;
12673/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply;
12674/* harmony export (immutable) */ __webpack_exports__["divide"] = divide;
12675/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil;
12676/* harmony export (immutable) */ __webpack_exports__["floor"] = floor;
12677/* harmony export (immutable) */ __webpack_exports__["min"] = min;
12678/* harmony export (immutable) */ __webpack_exports__["max"] = max;
12679/* harmony export (immutable) */ __webpack_exports__["round"] = round;
12680/* harmony export (immutable) */ __webpack_exports__["scale"] = scale;
12681/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd;
12682/* harmony export (immutable) */ __webpack_exports__["distance"] = distance;
12683/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance;
12684/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength;
12685/* harmony export (immutable) */ __webpack_exports__["negate"] = negate;
12686/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse;
12687/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize;
12688/* harmony export (immutable) */ __webpack_exports__["dot"] = dot;
12689/* harmony export (immutable) */ __webpack_exports__["cross"] = cross;
12690/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp;
12691/* harmony export (immutable) */ __webpack_exports__["hermite"] = hermite;
12692/* harmony export (immutable) */ __webpack_exports__["bezier"] = bezier;
12693/* harmony export (immutable) */ __webpack_exports__["random"] = random;
12694/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4;
12695/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3;
12696/* harmony export (immutable) */ __webpack_exports__["transformQuat"] = transformQuat;
12697/* harmony export (immutable) */ __webpack_exports__["rotateX"] = rotateX;
12698/* harmony export (immutable) */ __webpack_exports__["rotateY"] = rotateY;
12699/* harmony export (immutable) */ __webpack_exports__["rotateZ"] = rotateZ;
12700/* harmony export (immutable) */ __webpack_exports__["angle"] = angle;
12701/* harmony export (immutable) */ __webpack_exports__["str"] = str;
12702/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals;
12703/* harmony export (immutable) */ __webpack_exports__["equals"] = equals;
12704/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
12705/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
12706/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
12707/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
12708/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
12709/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
12710/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
12711/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
12712/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(14);
12713
12714
12715/**
12716 * 3 Dimensional Vector
12717 * @module vec3
12718 */
12719
12720/**
12721 * Creates a new, empty vec3
12722 *
12723 * @returns {vec3} a new 3D vector
12724 */
12725function create() {
12726 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
12727 out[0] = 0;
12728 out[1] = 0;
12729 out[2] = 0;
12730 return out;
12731}
12732
12733/**
12734 * Creates a new vec3 initialized with values from an existing vector
12735 *
12736 * @param {vec3} a vector to clone
12737 * @returns {vec3} a new 3D vector
12738 */
12739function clone(a) {
12740 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
12741 out[0] = a[0];
12742 out[1] = a[1];
12743 out[2] = a[2];
12744 return out;
12745}
12746
12747/**
12748 * Calculates the length of a vec3
12749 *
12750 * @param {vec3} a vector to calculate length of
12751 * @returns {Number} length of a
12752 */
12753function length(a) {
12754 var x = a[0];
12755 var y = a[1];
12756 var z = a[2];
12757 return Math.sqrt(x * x + y * y + z * z);
12758}
12759
12760/**
12761 * Creates a new vec3 initialized with the given values
12762 *
12763 * @param {Number} x X component
12764 * @param {Number} y Y component
12765 * @param {Number} z Z component
12766 * @returns {vec3} a new 3D vector
12767 */
12768function fromValues(x, y, z) {
12769 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](3);
12770 out[0] = x;
12771 out[1] = y;
12772 out[2] = z;
12773 return out;
12774}
12775
12776/**
12777 * Copy the values from one vec3 to another
12778 *
12779 * @param {vec3} out the receiving vector
12780 * @param {vec3} a the source vector
12781 * @returns {vec3} out
12782 */
12783function copy(out, a) {
12784 out[0] = a[0];
12785 out[1] = a[1];
12786 out[2] = a[2];
12787 return out;
12788}
12789
12790/**
12791 * Set the components of a vec3 to the given values
12792 *
12793 * @param {vec3} out the receiving vector
12794 * @param {Number} x X component
12795 * @param {Number} y Y component
12796 * @param {Number} z Z component
12797 * @returns {vec3} out
12798 */
12799function set(out, x, y, z) {
12800 out[0] = x;
12801 out[1] = y;
12802 out[2] = z;
12803 return out;
12804}
12805
12806/**
12807 * Adds two vec3's
12808 *
12809 * @param {vec3} out the receiving vector
12810 * @param {vec3} a the first operand
12811 * @param {vec3} b the second operand
12812 * @returns {vec3} out
12813 */
12814function add(out, a, b) {
12815 out[0] = a[0] + b[0];
12816 out[1] = a[1] + b[1];
12817 out[2] = a[2] + b[2];
12818 return out;
12819}
12820
12821/**
12822 * Subtracts vector b from vector a
12823 *
12824 * @param {vec3} out the receiving vector
12825 * @param {vec3} a the first operand
12826 * @param {vec3} b the second operand
12827 * @returns {vec3} out
12828 */
12829function subtract(out, a, b) {
12830 out[0] = a[0] - b[0];
12831 out[1] = a[1] - b[1];
12832 out[2] = a[2] - b[2];
12833 return out;
12834}
12835
12836/**
12837 * Multiplies two vec3's
12838 *
12839 * @param {vec3} out the receiving vector
12840 * @param {vec3} a the first operand
12841 * @param {vec3} b the second operand
12842 * @returns {vec3} out
12843 */
12844function multiply(out, a, b) {
12845 out[0] = a[0] * b[0];
12846 out[1] = a[1] * b[1];
12847 out[2] = a[2] * b[2];
12848 return out;
12849}
12850
12851/**
12852 * Divides two vec3's
12853 *
12854 * @param {vec3} out the receiving vector
12855 * @param {vec3} a the first operand
12856 * @param {vec3} b the second operand
12857 * @returns {vec3} out
12858 */
12859function divide(out, a, b) {
12860 out[0] = a[0] / b[0];
12861 out[1] = a[1] / b[1];
12862 out[2] = a[2] / b[2];
12863 return out;
12864}
12865
12866/**
12867 * Math.ceil the components of a vec3
12868 *
12869 * @param {vec3} out the receiving vector
12870 * @param {vec3} a vector to ceil
12871 * @returns {vec3} out
12872 */
12873function ceil(out, a) {
12874 out[0] = Math.ceil(a[0]);
12875 out[1] = Math.ceil(a[1]);
12876 out[2] = Math.ceil(a[2]);
12877 return out;
12878}
12879
12880/**
12881 * Math.floor the components of a vec3
12882 *
12883 * @param {vec3} out the receiving vector
12884 * @param {vec3} a vector to floor
12885 * @returns {vec3} out
12886 */
12887function floor(out, a) {
12888 out[0] = Math.floor(a[0]);
12889 out[1] = Math.floor(a[1]);
12890 out[2] = Math.floor(a[2]);
12891 return out;
12892}
12893
12894/**
12895 * Returns the minimum of two vec3's
12896 *
12897 * @param {vec3} out the receiving vector
12898 * @param {vec3} a the first operand
12899 * @param {vec3} b the second operand
12900 * @returns {vec3} out
12901 */
12902function min(out, a, b) {
12903 out[0] = Math.min(a[0], b[0]);
12904 out[1] = Math.min(a[1], b[1]);
12905 out[2] = Math.min(a[2], b[2]);
12906 return out;
12907}
12908
12909/**
12910 * Returns the maximum of two vec3's
12911 *
12912 * @param {vec3} out the receiving vector
12913 * @param {vec3} a the first operand
12914 * @param {vec3} b the second operand
12915 * @returns {vec3} out
12916 */
12917function max(out, a, b) {
12918 out[0] = Math.max(a[0], b[0]);
12919 out[1] = Math.max(a[1], b[1]);
12920 out[2] = Math.max(a[2], b[2]);
12921 return out;
12922}
12923
12924/**
12925 * Math.round the components of a vec3
12926 *
12927 * @param {vec3} out the receiving vector
12928 * @param {vec3} a vector to round
12929 * @returns {vec3} out
12930 */
12931function round(out, a) {
12932 out[0] = Math.round(a[0]);
12933 out[1] = Math.round(a[1]);
12934 out[2] = Math.round(a[2]);
12935 return out;
12936}
12937
12938/**
12939 * Scales a vec3 by a scalar number
12940 *
12941 * @param {vec3} out the receiving vector
12942 * @param {vec3} a the vector to scale
12943 * @param {Number} b amount to scale the vector by
12944 * @returns {vec3} out
12945 */
12946function scale(out, a, b) {
12947 out[0] = a[0] * b;
12948 out[1] = a[1] * b;
12949 out[2] = a[2] * b;
12950 return out;
12951}
12952
12953/**
12954 * Adds two vec3's after scaling the second operand by a scalar value
12955 *
12956 * @param {vec3} out the receiving vector
12957 * @param {vec3} a the first operand
12958 * @param {vec3} b the second operand
12959 * @param {Number} scale the amount to scale b by before adding
12960 * @returns {vec3} out
12961 */
12962function scaleAndAdd(out, a, b, scale) {
12963 out[0] = a[0] + b[0] * scale;
12964 out[1] = a[1] + b[1] * scale;
12965 out[2] = a[2] + b[2] * scale;
12966 return out;
12967}
12968
12969/**
12970 * Calculates the euclidian distance between two vec3's
12971 *
12972 * @param {vec3} a the first operand
12973 * @param {vec3} b the second operand
12974 * @returns {Number} distance between a and b
12975 */
12976function distance(a, b) {
12977 var x = b[0] - a[0];
12978 var y = b[1] - a[1];
12979 var z = b[2] - a[2];
12980 return Math.sqrt(x * x + y * y + z * z);
12981}
12982
12983/**
12984 * Calculates the squared euclidian distance between two vec3's
12985 *
12986 * @param {vec3} a the first operand
12987 * @param {vec3} b the second operand
12988 * @returns {Number} squared distance between a and b
12989 */
12990function squaredDistance(a, b) {
12991 var x = b[0] - a[0];
12992 var y = b[1] - a[1];
12993 var z = b[2] - a[2];
12994 return x * x + y * y + z * z;
12995}
12996
12997/**
12998 * Calculates the squared length of a vec3
12999 *
13000 * @param {vec3} a vector to calculate squared length of
13001 * @returns {Number} squared length of a
13002 */
13003function squaredLength(a) {
13004 var x = a[0];
13005 var y = a[1];
13006 var z = a[2];
13007 return x * x + y * y + z * z;
13008}
13009
13010/**
13011 * Negates the components of a vec3
13012 *
13013 * @param {vec3} out the receiving vector
13014 * @param {vec3} a vector to negate
13015 * @returns {vec3} out
13016 */
13017function negate(out, a) {
13018 out[0] = -a[0];
13019 out[1] = -a[1];
13020 out[2] = -a[2];
13021 return out;
13022}
13023
13024/**
13025 * Returns the inverse of the components of a vec3
13026 *
13027 * @param {vec3} out the receiving vector
13028 * @param {vec3} a vector to invert
13029 * @returns {vec3} out
13030 */
13031function inverse(out, a) {
13032 out[0] = 1.0 / a[0];
13033 out[1] = 1.0 / a[1];
13034 out[2] = 1.0 / a[2];
13035 return out;
13036}
13037
13038/**
13039 * Normalize a vec3
13040 *
13041 * @param {vec3} out the receiving vector
13042 * @param {vec3} a vector to normalize
13043 * @returns {vec3} out
13044 */
13045function normalize(out, a) {
13046 var x = a[0];
13047 var y = a[1];
13048 var z = a[2];
13049 var len = x * x + y * y + z * z;
13050 if (len > 0) {
13051 //TODO: evaluate use of glm_invsqrt here?
13052 len = 1 / Math.sqrt(len);
13053 out[0] = a[0] * len;
13054 out[1] = a[1] * len;
13055 out[2] = a[2] * len;
13056 }
13057 return out;
13058}
13059
13060/**
13061 * Calculates the dot product of two vec3's
13062 *
13063 * @param {vec3} a the first operand
13064 * @param {vec3} b the second operand
13065 * @returns {Number} dot product of a and b
13066 */
13067function dot(a, b) {
13068 return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
13069}
13070
13071/**
13072 * Computes the cross product of two vec3's
13073 *
13074 * @param {vec3} out the receiving vector
13075 * @param {vec3} a the first operand
13076 * @param {vec3} b the second operand
13077 * @returns {vec3} out
13078 */
13079function cross(out, a, b) {
13080 var ax = a[0],
13081 ay = a[1],
13082 az = a[2];
13083 var bx = b[0],
13084 by = b[1],
13085 bz = b[2];
13086
13087 out[0] = ay * bz - az * by;
13088 out[1] = az * bx - ax * bz;
13089 out[2] = ax * by - ay * bx;
13090 return out;
13091}
13092
13093/**
13094 * Performs a linear interpolation between two vec3's
13095 *
13096 * @param {vec3} out the receiving vector
13097 * @param {vec3} a the first operand
13098 * @param {vec3} b the second operand
13099 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13100 * @returns {vec3} out
13101 */
13102function lerp(out, a, b, t) {
13103 var ax = a[0];
13104 var ay = a[1];
13105 var az = a[2];
13106 out[0] = ax + t * (b[0] - ax);
13107 out[1] = ay + t * (b[1] - ay);
13108 out[2] = az + t * (b[2] - az);
13109 return out;
13110}
13111
13112/**
13113 * Performs a hermite interpolation with two control points
13114 *
13115 * @param {vec3} out the receiving vector
13116 * @param {vec3} a the first operand
13117 * @param {vec3} b the second operand
13118 * @param {vec3} c the third operand
13119 * @param {vec3} d the fourth operand
13120 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13121 * @returns {vec3} out
13122 */
13123function hermite(out, a, b, c, d, t) {
13124 var factorTimes2 = t * t;
13125 var factor1 = factorTimes2 * (2 * t - 3) + 1;
13126 var factor2 = factorTimes2 * (t - 2) + t;
13127 var factor3 = factorTimes2 * (t - 1);
13128 var factor4 = factorTimes2 * (3 - 2 * t);
13129
13130 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
13131 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
13132 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
13133
13134 return out;
13135}
13136
13137/**
13138 * Performs a bezier interpolation with two control points
13139 *
13140 * @param {vec3} out the receiving vector
13141 * @param {vec3} a the first operand
13142 * @param {vec3} b the second operand
13143 * @param {vec3} c the third operand
13144 * @param {vec3} d the fourth operand
13145 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13146 * @returns {vec3} out
13147 */
13148function bezier(out, a, b, c, d, t) {
13149 var inverseFactor = 1 - t;
13150 var inverseFactorTimesTwo = inverseFactor * inverseFactor;
13151 var factorTimes2 = t * t;
13152 var factor1 = inverseFactorTimesTwo * inverseFactor;
13153 var factor2 = 3 * t * inverseFactorTimesTwo;
13154 var factor3 = 3 * factorTimes2 * inverseFactor;
13155 var factor4 = factorTimes2 * t;
13156
13157 out[0] = a[0] * factor1 + b[0] * factor2 + c[0] * factor3 + d[0] * factor4;
13158 out[1] = a[1] * factor1 + b[1] * factor2 + c[1] * factor3 + d[1] * factor4;
13159 out[2] = a[2] * factor1 + b[2] * factor2 + c[2] * factor3 + d[2] * factor4;
13160
13161 return out;
13162}
13163
13164/**
13165 * Generates a random vector with the given scale
13166 *
13167 * @param {vec3} out the receiving vector
13168 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
13169 * @returns {vec3} out
13170 */
13171function random(out, scale) {
13172 scale = scale || 1.0;
13173
13174 var r = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 * Math.PI;
13175 var z = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 - 1.0;
13176 var zScale = Math.sqrt(1.0 - z * z) * scale;
13177
13178 out[0] = Math.cos(r) * zScale;
13179 out[1] = Math.sin(r) * zScale;
13180 out[2] = z * scale;
13181 return out;
13182}
13183
13184/**
13185 * Transforms the vec3 with a mat4.
13186 * 4th vector component is implicitly '1'
13187 *
13188 * @param {vec3} out the receiving vector
13189 * @param {vec3} a the vector to transform
13190 * @param {mat4} m matrix to transform with
13191 * @returns {vec3} out
13192 */
13193function transformMat4(out, a, m) {
13194 var x = a[0],
13195 y = a[1],
13196 z = a[2];
13197 var w = m[3] * x + m[7] * y + m[11] * z + m[15];
13198 w = w || 1.0;
13199 out[0] = (m[0] * x + m[4] * y + m[8] * z + m[12]) / w;
13200 out[1] = (m[1] * x + m[5] * y + m[9] * z + m[13]) / w;
13201 out[2] = (m[2] * x + m[6] * y + m[10] * z + m[14]) / w;
13202 return out;
13203}
13204
13205/**
13206 * Transforms the vec3 with a mat3.
13207 *
13208 * @param {vec3} out the receiving vector
13209 * @param {vec3} a the vector to transform
13210 * @param {mat3} m the 3x3 matrix to transform with
13211 * @returns {vec3} out
13212 */
13213function transformMat3(out, a, m) {
13214 var x = a[0],
13215 y = a[1],
13216 z = a[2];
13217 out[0] = x * m[0] + y * m[3] + z * m[6];
13218 out[1] = x * m[1] + y * m[4] + z * m[7];
13219 out[2] = x * m[2] + y * m[5] + z * m[8];
13220 return out;
13221}
13222
13223/**
13224 * Transforms the vec3 with a quat
13225 * Can also be used for dual quaternions. (Multiply it with the real part)
13226 *
13227 * @param {vec3} out the receiving vector
13228 * @param {vec3} a the vector to transform
13229 * @param {quat} q quaternion to transform with
13230 * @returns {vec3} out
13231 */
13232function transformQuat(out, a, q) {
13233 // benchmarks: https://jsperf.com/quaternion-transform-vec3-implementations-fixed
13234 var qx = q[0],
13235 qy = q[1],
13236 qz = q[2],
13237 qw = q[3];
13238 var x = a[0],
13239 y = a[1],
13240 z = a[2];
13241 // var qvec = [qx, qy, qz];
13242 // var uv = vec3.cross([], qvec, a);
13243 var uvx = qy * z - qz * y,
13244 uvy = qz * x - qx * z,
13245 uvz = qx * y - qy * x;
13246 // var uuv = vec3.cross([], qvec, uv);
13247 var uuvx = qy * uvz - qz * uvy,
13248 uuvy = qz * uvx - qx * uvz,
13249 uuvz = qx * uvy - qy * uvx;
13250 // vec3.scale(uv, uv, 2 * w);
13251 var w2 = qw * 2;
13252 uvx *= w2;
13253 uvy *= w2;
13254 uvz *= w2;
13255 // vec3.scale(uuv, uuv, 2);
13256 uuvx *= 2;
13257 uuvy *= 2;
13258 uuvz *= 2;
13259 // return vec3.add(out, a, vec3.add(out, uv, uuv));
13260 out[0] = x + uvx + uuvx;
13261 out[1] = y + uvy + uuvy;
13262 out[2] = z + uvz + uuvz;
13263 return out;
13264}
13265
13266/**
13267 * Rotate a 3D vector around the x-axis
13268 * @param {vec3} out The receiving vec3
13269 * @param {vec3} a The vec3 point to rotate
13270 * @param {vec3} b The origin of the rotation
13271 * @param {Number} c The angle of rotation
13272 * @returns {vec3} out
13273 */
13274function rotateX(out, a, b, c) {
13275 var p = [],
13276 r = [];
13277 //Translate point to the origin
13278 p[0] = a[0] - b[0];
13279 p[1] = a[1] - b[1];
13280 p[2] = a[2] - b[2];
13281
13282 //perform rotation
13283 r[0] = p[0];
13284 r[1] = p[1] * Math.cos(c) - p[2] * Math.sin(c);
13285 r[2] = p[1] * Math.sin(c) + p[2] * Math.cos(c);
13286
13287 //translate to correct position
13288 out[0] = r[0] + b[0];
13289 out[1] = r[1] + b[1];
13290 out[2] = r[2] + b[2];
13291
13292 return out;
13293}
13294
13295/**
13296 * Rotate a 3D vector around the y-axis
13297 * @param {vec3} out The receiving vec3
13298 * @param {vec3} a The vec3 point to rotate
13299 * @param {vec3} b The origin of the rotation
13300 * @param {Number} c The angle of rotation
13301 * @returns {vec3} out
13302 */
13303function rotateY(out, a, b, c) {
13304 var p = [],
13305 r = [];
13306 //Translate point to the origin
13307 p[0] = a[0] - b[0];
13308 p[1] = a[1] - b[1];
13309 p[2] = a[2] - b[2];
13310
13311 //perform rotation
13312 r[0] = p[2] * Math.sin(c) + p[0] * Math.cos(c);
13313 r[1] = p[1];
13314 r[2] = p[2] * Math.cos(c) - p[0] * Math.sin(c);
13315
13316 //translate to correct position
13317 out[0] = r[0] + b[0];
13318 out[1] = r[1] + b[1];
13319 out[2] = r[2] + b[2];
13320
13321 return out;
13322}
13323
13324/**
13325 * Rotate a 3D vector around the z-axis
13326 * @param {vec3} out The receiving vec3
13327 * @param {vec3} a The vec3 point to rotate
13328 * @param {vec3} b The origin of the rotation
13329 * @param {Number} c The angle of rotation
13330 * @returns {vec3} out
13331 */
13332function rotateZ(out, a, b, c) {
13333 var p = [],
13334 r = [];
13335 //Translate point to the origin
13336 p[0] = a[0] - b[0];
13337 p[1] = a[1] - b[1];
13338 p[2] = a[2] - b[2];
13339
13340 //perform rotation
13341 r[0] = p[0] * Math.cos(c) - p[1] * Math.sin(c);
13342 r[1] = p[0] * Math.sin(c) + p[1] * Math.cos(c);
13343 r[2] = p[2];
13344
13345 //translate to correct position
13346 out[0] = r[0] + b[0];
13347 out[1] = r[1] + b[1];
13348 out[2] = r[2] + b[2];
13349
13350 return out;
13351}
13352
13353/**
13354 * Get the angle between two 3D vectors
13355 * @param {vec3} a The first operand
13356 * @param {vec3} b The second operand
13357 * @returns {Number} The angle in radians
13358 */
13359function angle(a, b) {
13360 var tempA = fromValues(a[0], a[1], a[2]);
13361 var tempB = fromValues(b[0], b[1], b[2]);
13362
13363 normalize(tempA, tempA);
13364 normalize(tempB, tempB);
13365
13366 var cosine = dot(tempA, tempB);
13367
13368 if (cosine > 1.0) {
13369 return 0;
13370 } else if (cosine < -1.0) {
13371 return Math.PI;
13372 } else {
13373 return Math.acos(cosine);
13374 }
13375}
13376
13377/**
13378 * Returns a string representation of a vector
13379 *
13380 * @param {vec3} a vector to represent as a string
13381 * @returns {String} string representation of the vector
13382 */
13383function str(a) {
13384 return 'vec3(' + a[0] + ', ' + a[1] + ', ' + a[2] + ')';
13385}
13386
13387/**
13388 * Returns whether or not the vectors have exactly the same elements in the same position (when compared with ===)
13389 *
13390 * @param {vec3} a The first vector.
13391 * @param {vec3} b The second vector.
13392 * @returns {Boolean} True if the vectors are equal, false otherwise.
13393 */
13394function exactEquals(a, b) {
13395 return a[0] === b[0] && a[1] === b[1] && a[2] === b[2];
13396}
13397
13398/**
13399 * Returns whether or not the vectors have approximately the same elements in the same position.
13400 *
13401 * @param {vec3} a The first vector.
13402 * @param {vec3} b The second vector.
13403 * @returns {Boolean} True if the vectors are equal, false otherwise.
13404 */
13405function equals(a, b) {
13406 var a0 = a[0],
13407 a1 = a[1],
13408 a2 = a[2];
13409 var b0 = b[0],
13410 b1 = b[1],
13411 b2 = b[2];
13412 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a2), Math.abs(b2));
13413}
13414
13415/**
13416 * Alias for {@link vec3.subtract}
13417 * @function
13418 */
13419var sub = subtract;
13420
13421/**
13422 * Alias for {@link vec3.multiply}
13423 * @function
13424 */
13425var mul = multiply;
13426
13427/**
13428 * Alias for {@link vec3.divide}
13429 * @function
13430 */
13431var div = divide;
13432
13433/**
13434 * Alias for {@link vec3.distance}
13435 * @function
13436 */
13437var dist = distance;
13438
13439/**
13440 * Alias for {@link vec3.squaredDistance}
13441 * @function
13442 */
13443var sqrDist = squaredDistance;
13444
13445/**
13446 * Alias for {@link vec3.length}
13447 * @function
13448 */
13449var len = length;
13450
13451/**
13452 * Alias for {@link vec3.squaredLength}
13453 * @function
13454 */
13455var sqrLen = squaredLength;
13456
13457/**
13458 * Perform some operation over an array of vec3s.
13459 *
13460 * @param {Array} a the array of vectors to iterate over
13461 * @param {Number} stride Number of elements between the start of each vec3. If 0 assumes tightly packed
13462 * @param {Number} offset Number of elements to skip at the beginning of the array
13463 * @param {Number} count Number of vec3s to iterate over. If 0 iterates over entire array
13464 * @param {Function} fn Function to call for each vector in the array
13465 * @param {Object} [arg] additional argument to pass to fn
13466 * @returns {Array} a
13467 * @function
13468 */
13469var forEach = function () {
13470 var vec = create();
13471
13472 return function (a, stride, offset, count, fn, arg) {
13473 var i = void 0,
13474 l = void 0;
13475 if (!stride) {
13476 stride = 3;
13477 }
13478
13479 if (!offset) {
13480 offset = 0;
13481 }
13482
13483 if (count) {
13484 l = Math.min(count * stride + offset, a.length);
13485 } else {
13486 l = a.length;
13487 }
13488
13489 for (i = offset; i < l; i += stride) {
13490 vec[0] = a[i];vec[1] = a[i + 1];vec[2] = a[i + 2];
13491 fn(vec, vec, arg);
13492 a[i] = vec[0];a[i + 1] = vec[1];a[i + 2] = vec[2];
13493 }
13494
13495 return a;
13496 };
13497}();
13498
13499/***/ }),
13500/* 76 */
13501/***/ (function(module, __webpack_exports__, __webpack_require__) {
13502
13503"use strict";
13504Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
13505/* harmony export (immutable) */ __webpack_exports__["create"] = create;
13506/* harmony export (immutable) */ __webpack_exports__["clone"] = clone;
13507/* harmony export (immutable) */ __webpack_exports__["fromValues"] = fromValues;
13508/* harmony export (immutable) */ __webpack_exports__["copy"] = copy;
13509/* harmony export (immutable) */ __webpack_exports__["set"] = set;
13510/* harmony export (immutable) */ __webpack_exports__["add"] = add;
13511/* harmony export (immutable) */ __webpack_exports__["subtract"] = subtract;
13512/* harmony export (immutable) */ __webpack_exports__["multiply"] = multiply;
13513/* harmony export (immutable) */ __webpack_exports__["divide"] = divide;
13514/* harmony export (immutable) */ __webpack_exports__["ceil"] = ceil;
13515/* harmony export (immutable) */ __webpack_exports__["floor"] = floor;
13516/* harmony export (immutable) */ __webpack_exports__["min"] = min;
13517/* harmony export (immutable) */ __webpack_exports__["max"] = max;
13518/* harmony export (immutable) */ __webpack_exports__["round"] = round;
13519/* harmony export (immutable) */ __webpack_exports__["scale"] = scale;
13520/* harmony export (immutable) */ __webpack_exports__["scaleAndAdd"] = scaleAndAdd;
13521/* harmony export (immutable) */ __webpack_exports__["distance"] = distance;
13522/* harmony export (immutable) */ __webpack_exports__["squaredDistance"] = squaredDistance;
13523/* harmony export (immutable) */ __webpack_exports__["length"] = length;
13524/* harmony export (immutable) */ __webpack_exports__["squaredLength"] = squaredLength;
13525/* harmony export (immutable) */ __webpack_exports__["negate"] = negate;
13526/* harmony export (immutable) */ __webpack_exports__["inverse"] = inverse;
13527/* harmony export (immutable) */ __webpack_exports__["normalize"] = normalize;
13528/* harmony export (immutable) */ __webpack_exports__["dot"] = dot;
13529/* harmony export (immutable) */ __webpack_exports__["cross"] = cross;
13530/* harmony export (immutable) */ __webpack_exports__["lerp"] = lerp;
13531/* harmony export (immutable) */ __webpack_exports__["random"] = random;
13532/* harmony export (immutable) */ __webpack_exports__["transformMat2"] = transformMat2;
13533/* harmony export (immutable) */ __webpack_exports__["transformMat2d"] = transformMat2d;
13534/* harmony export (immutable) */ __webpack_exports__["transformMat3"] = transformMat3;
13535/* harmony export (immutable) */ __webpack_exports__["transformMat4"] = transformMat4;
13536/* harmony export (immutable) */ __webpack_exports__["rotate"] = rotate;
13537/* harmony export (immutable) */ __webpack_exports__["angle"] = angle;
13538/* harmony export (immutable) */ __webpack_exports__["str"] = str;
13539/* harmony export (immutable) */ __webpack_exports__["exactEquals"] = exactEquals;
13540/* harmony export (immutable) */ __webpack_exports__["equals"] = equals;
13541/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "len", function() { return len; });
13542/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sub", function() { return sub; });
13543/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mul", function() { return mul; });
13544/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "div", function() { return div; });
13545/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dist", function() { return dist; });
13546/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrDist", function() { return sqrDist; });
13547/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sqrLen", function() { return sqrLen; });
13548/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "forEach", function() { return forEach; });
13549/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__common_js__ = __webpack_require__(14);
13550
13551
13552/**
13553 * 2 Dimensional Vector
13554 * @module vec2
13555 */
13556
13557/**
13558 * Creates a new, empty vec2
13559 *
13560 * @returns {vec2} a new 2D vector
13561 */
13562function create() {
13563 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
13564 out[0] = 0;
13565 out[1] = 0;
13566 return out;
13567}
13568
13569/**
13570 * Creates a new vec2 initialized with values from an existing vector
13571 *
13572 * @param {vec2} a vector to clone
13573 * @returns {vec2} a new 2D vector
13574 */
13575function clone(a) {
13576 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
13577 out[0] = a[0];
13578 out[1] = a[1];
13579 return out;
13580}
13581
13582/**
13583 * Creates a new vec2 initialized with the given values
13584 *
13585 * @param {Number} x X component
13586 * @param {Number} y Y component
13587 * @returns {vec2} a new 2D vector
13588 */
13589function fromValues(x, y) {
13590 var out = new __WEBPACK_IMPORTED_MODULE_0__common_js__["a" /* ARRAY_TYPE */](2);
13591 out[0] = x;
13592 out[1] = y;
13593 return out;
13594}
13595
13596/**
13597 * Copy the values from one vec2 to another
13598 *
13599 * @param {vec2} out the receiving vector
13600 * @param {vec2} a the source vector
13601 * @returns {vec2} out
13602 */
13603function copy(out, a) {
13604 out[0] = a[0];
13605 out[1] = a[1];
13606 return out;
13607}
13608
13609/**
13610 * Set the components of a vec2 to the given values
13611 *
13612 * @param {vec2} out the receiving vector
13613 * @param {Number} x X component
13614 * @param {Number} y Y component
13615 * @returns {vec2} out
13616 */
13617function set(out, x, y) {
13618 out[0] = x;
13619 out[1] = y;
13620 return out;
13621}
13622
13623/**
13624 * Adds two vec2's
13625 *
13626 * @param {vec2} out the receiving vector
13627 * @param {vec2} a the first operand
13628 * @param {vec2} b the second operand
13629 * @returns {vec2} out
13630 */
13631function add(out, a, b) {
13632 out[0] = a[0] + b[0];
13633 out[1] = a[1] + b[1];
13634 return out;
13635}
13636
13637/**
13638 * Subtracts vector b from vector a
13639 *
13640 * @param {vec2} out the receiving vector
13641 * @param {vec2} a the first operand
13642 * @param {vec2} b the second operand
13643 * @returns {vec2} out
13644 */
13645function subtract(out, a, b) {
13646 out[0] = a[0] - b[0];
13647 out[1] = a[1] - b[1];
13648 return out;
13649}
13650
13651/**
13652 * Multiplies two vec2's
13653 *
13654 * @param {vec2} out the receiving vector
13655 * @param {vec2} a the first operand
13656 * @param {vec2} b the second operand
13657 * @returns {vec2} out
13658 */
13659function multiply(out, a, b) {
13660 out[0] = a[0] * b[0];
13661 out[1] = a[1] * b[1];
13662 return out;
13663}
13664
13665/**
13666 * Divides two vec2's
13667 *
13668 * @param {vec2} out the receiving vector
13669 * @param {vec2} a the first operand
13670 * @param {vec2} b the second operand
13671 * @returns {vec2} out
13672 */
13673function divide(out, a, b) {
13674 out[0] = a[0] / b[0];
13675 out[1] = a[1] / b[1];
13676 return out;
13677}
13678
13679/**
13680 * Math.ceil the components of a vec2
13681 *
13682 * @param {vec2} out the receiving vector
13683 * @param {vec2} a vector to ceil
13684 * @returns {vec2} out
13685 */
13686function ceil(out, a) {
13687 out[0] = Math.ceil(a[0]);
13688 out[1] = Math.ceil(a[1]);
13689 return out;
13690}
13691
13692/**
13693 * Math.floor the components of a vec2
13694 *
13695 * @param {vec2} out the receiving vector
13696 * @param {vec2} a vector to floor
13697 * @returns {vec2} out
13698 */
13699function floor(out, a) {
13700 out[0] = Math.floor(a[0]);
13701 out[1] = Math.floor(a[1]);
13702 return out;
13703}
13704
13705/**
13706 * Returns the minimum of two vec2's
13707 *
13708 * @param {vec2} out the receiving vector
13709 * @param {vec2} a the first operand
13710 * @param {vec2} b the second operand
13711 * @returns {vec2} out
13712 */
13713function min(out, a, b) {
13714 out[0] = Math.min(a[0], b[0]);
13715 out[1] = Math.min(a[1], b[1]);
13716 return out;
13717}
13718
13719/**
13720 * Returns the maximum of two vec2's
13721 *
13722 * @param {vec2} out the receiving vector
13723 * @param {vec2} a the first operand
13724 * @param {vec2} b the second operand
13725 * @returns {vec2} out
13726 */
13727function max(out, a, b) {
13728 out[0] = Math.max(a[0], b[0]);
13729 out[1] = Math.max(a[1], b[1]);
13730 return out;
13731}
13732
13733/**
13734 * Math.round the components of a vec2
13735 *
13736 * @param {vec2} out the receiving vector
13737 * @param {vec2} a vector to round
13738 * @returns {vec2} out
13739 */
13740function round(out, a) {
13741 out[0] = Math.round(a[0]);
13742 out[1] = Math.round(a[1]);
13743 return out;
13744}
13745
13746/**
13747 * Scales a vec2 by a scalar number
13748 *
13749 * @param {vec2} out the receiving vector
13750 * @param {vec2} a the vector to scale
13751 * @param {Number} b amount to scale the vector by
13752 * @returns {vec2} out
13753 */
13754function scale(out, a, b) {
13755 out[0] = a[0] * b;
13756 out[1] = a[1] * b;
13757 return out;
13758}
13759
13760/**
13761 * Adds two vec2's after scaling the second operand by a scalar value
13762 *
13763 * @param {vec2} out the receiving vector
13764 * @param {vec2} a the first operand
13765 * @param {vec2} b the second operand
13766 * @param {Number} scale the amount to scale b by before adding
13767 * @returns {vec2} out
13768 */
13769function scaleAndAdd(out, a, b, scale) {
13770 out[0] = a[0] + b[0] * scale;
13771 out[1] = a[1] + b[1] * scale;
13772 return out;
13773}
13774
13775/**
13776 * Calculates the euclidian distance between two vec2's
13777 *
13778 * @param {vec2} a the first operand
13779 * @param {vec2} b the second operand
13780 * @returns {Number} distance between a and b
13781 */
13782function distance(a, b) {
13783 var x = b[0] - a[0],
13784 y = b[1] - a[1];
13785 return Math.sqrt(x * x + y * y);
13786}
13787
13788/**
13789 * Calculates the squared euclidian distance between two vec2's
13790 *
13791 * @param {vec2} a the first operand
13792 * @param {vec2} b the second operand
13793 * @returns {Number} squared distance between a and b
13794 */
13795function squaredDistance(a, b) {
13796 var x = b[0] - a[0],
13797 y = b[1] - a[1];
13798 return x * x + y * y;
13799}
13800
13801/**
13802 * Calculates the length of a vec2
13803 *
13804 * @param {vec2} a vector to calculate length of
13805 * @returns {Number} length of a
13806 */
13807function length(a) {
13808 var x = a[0],
13809 y = a[1];
13810 return Math.sqrt(x * x + y * y);
13811}
13812
13813/**
13814 * Calculates the squared length of a vec2
13815 *
13816 * @param {vec2} a vector to calculate squared length of
13817 * @returns {Number} squared length of a
13818 */
13819function squaredLength(a) {
13820 var x = a[0],
13821 y = a[1];
13822 return x * x + y * y;
13823}
13824
13825/**
13826 * Negates the components of a vec2
13827 *
13828 * @param {vec2} out the receiving vector
13829 * @param {vec2} a vector to negate
13830 * @returns {vec2} out
13831 */
13832function negate(out, a) {
13833 out[0] = -a[0];
13834 out[1] = -a[1];
13835 return out;
13836}
13837
13838/**
13839 * Returns the inverse of the components of a vec2
13840 *
13841 * @param {vec2} out the receiving vector
13842 * @param {vec2} a vector to invert
13843 * @returns {vec2} out
13844 */
13845function inverse(out, a) {
13846 out[0] = 1.0 / a[0];
13847 out[1] = 1.0 / a[1];
13848 return out;
13849}
13850
13851/**
13852 * Normalize a vec2
13853 *
13854 * @param {vec2} out the receiving vector
13855 * @param {vec2} a vector to normalize
13856 * @returns {vec2} out
13857 */
13858function normalize(out, a) {
13859 var x = a[0],
13860 y = a[1];
13861 var len = x * x + y * y;
13862 if (len > 0) {
13863 //TODO: evaluate use of glm_invsqrt here?
13864 len = 1 / Math.sqrt(len);
13865 out[0] = a[0] * len;
13866 out[1] = a[1] * len;
13867 }
13868 return out;
13869}
13870
13871/**
13872 * Calculates the dot product of two vec2's
13873 *
13874 * @param {vec2} a the first operand
13875 * @param {vec2} b the second operand
13876 * @returns {Number} dot product of a and b
13877 */
13878function dot(a, b) {
13879 return a[0] * b[0] + a[1] * b[1];
13880}
13881
13882/**
13883 * Computes the cross product of two vec2's
13884 * Note that the cross product must by definition produce a 3D vector
13885 *
13886 * @param {vec3} out the receiving vector
13887 * @param {vec2} a the first operand
13888 * @param {vec2} b the second operand
13889 * @returns {vec3} out
13890 */
13891function cross(out, a, b) {
13892 var z = a[0] * b[1] - a[1] * b[0];
13893 out[0] = out[1] = 0;
13894 out[2] = z;
13895 return out;
13896}
13897
13898/**
13899 * Performs a linear interpolation between two vec2's
13900 *
13901 * @param {vec2} out the receiving vector
13902 * @param {vec2} a the first operand
13903 * @param {vec2} b the second operand
13904 * @param {Number} t interpolation amount, in the range [0-1], between the two inputs
13905 * @returns {vec2} out
13906 */
13907function lerp(out, a, b, t) {
13908 var ax = a[0],
13909 ay = a[1];
13910 out[0] = ax + t * (b[0] - ax);
13911 out[1] = ay + t * (b[1] - ay);
13912 return out;
13913}
13914
13915/**
13916 * Generates a random vector with the given scale
13917 *
13918 * @param {vec2} out the receiving vector
13919 * @param {Number} [scale] Length of the resulting vector. If ommitted, a unit vector will be returned
13920 * @returns {vec2} out
13921 */
13922function random(out, scale) {
13923 scale = scale || 1.0;
13924 var r = __WEBPACK_IMPORTED_MODULE_0__common_js__["c" /* RANDOM */]() * 2.0 * Math.PI;
13925 out[0] = Math.cos(r) * scale;
13926 out[1] = Math.sin(r) * scale;
13927 return out;
13928}
13929
13930/**
13931 * Transforms the vec2 with a mat2
13932 *
13933 * @param {vec2} out the receiving vector
13934 * @param {vec2} a the vector to transform
13935 * @param {mat2} m matrix to transform with
13936 * @returns {vec2} out
13937 */
13938function transformMat2(out, a, m) {
13939 var x = a[0],
13940 y = a[1];
13941 out[0] = m[0] * x + m[2] * y;
13942 out[1] = m[1] * x + m[3] * y;
13943 return out;
13944}
13945
13946/**
13947 * Transforms the vec2 with a mat2d
13948 *
13949 * @param {vec2} out the receiving vector
13950 * @param {vec2} a the vector to transform
13951 * @param {mat2d} m matrix to transform with
13952 * @returns {vec2} out
13953 */
13954function transformMat2d(out, a, m) {
13955 var x = a[0],
13956 y = a[1];
13957 out[0] = m[0] * x + m[2] * y + m[4];
13958 out[1] = m[1] * x + m[3] * y + m[5];
13959 return out;
13960}
13961
13962/**
13963 * Transforms the vec2 with a mat3
13964 * 3rd vector component is implicitly '1'
13965 *
13966 * @param {vec2} out the receiving vector
13967 * @param {vec2} a the vector to transform
13968 * @param {mat3} m matrix to transform with
13969 * @returns {vec2} out
13970 */
13971function transformMat3(out, a, m) {
13972 var x = a[0],
13973 y = a[1];
13974 out[0] = m[0] * x + m[3] * y + m[6];
13975 out[1] = m[1] * x + m[4] * y + m[7];
13976 return out;
13977}
13978
13979/**
13980 * Transforms the vec2 with a mat4
13981 * 3rd vector component is implicitly '0'
13982 * 4th vector component is implicitly '1'
13983 *
13984 * @param {vec2} out the receiving vector
13985 * @param {vec2} a the vector to transform
13986 * @param {mat4} m matrix to transform with
13987 * @returns {vec2} out
13988 */
13989function transformMat4(out, a, m) {
13990 var x = a[0];
13991 var y = a[1];
13992 out[0] = m[0] * x + m[4] * y + m[12];
13993 out[1] = m[1] * x + m[5] * y + m[13];
13994 return out;
13995}
13996
13997/**
13998 * Rotate a 2D vector
13999 * @param {vec2} out The receiving vec2
14000 * @param {vec2} a The vec2 point to rotate
14001 * @param {vec2} b The origin of the rotation
14002 * @param {Number} c The angle of rotation
14003 * @returns {vec2} out
14004 */
14005function rotate(out, a, b, c) {
14006 //Translate point to the origin
14007 var p0 = a[0] - b[0],
14008 p1 = a[1] - b[1],
14009 sinC = Math.sin(c),
14010 cosC = Math.cos(c);
14011
14012 //perform rotation and translate to correct position
14013 out[0] = p0 * cosC - p1 * sinC + b[0];
14014 out[1] = p0 * sinC + p1 * cosC + b[1];
14015
14016 return out;
14017}
14018
14019/**
14020 * Get the angle between two 2D vectors
14021 * @param {vec2} a The first operand
14022 * @param {vec2} b The second operand
14023 * @returns {Number} The angle in radians
14024 */
14025function angle(a, b) {
14026 var x1 = a[0],
14027 y1 = a[1],
14028 x2 = b[0],
14029 y2 = b[1];
14030
14031 var len1 = x1 * x1 + y1 * y1;
14032 if (len1 > 0) {
14033 //TODO: evaluate use of glm_invsqrt here?
14034 len1 = 1 / Math.sqrt(len1);
14035 }
14036
14037 var len2 = x2 * x2 + y2 * y2;
14038 if (len2 > 0) {
14039 //TODO: evaluate use of glm_invsqrt here?
14040 len2 = 1 / Math.sqrt(len2);
14041 }
14042
14043 var cosine = (x1 * x2 + y1 * y2) * len1 * len2;
14044
14045 if (cosine > 1.0) {
14046 return 0;
14047 } else if (cosine < -1.0) {
14048 return Math.PI;
14049 } else {
14050 return Math.acos(cosine);
14051 }
14052}
14053
14054/**
14055 * Returns a string representation of a vector
14056 *
14057 * @param {vec2} a vector to represent as a string
14058 * @returns {String} string representation of the vector
14059 */
14060function str(a) {
14061 return 'vec2(' + a[0] + ', ' + a[1] + ')';
14062}
14063
14064/**
14065 * Returns whether or not the vectors exactly have the same elements in the same position (when compared with ===)
14066 *
14067 * @param {vec2} a The first vector.
14068 * @param {vec2} b The second vector.
14069 * @returns {Boolean} True if the vectors are equal, false otherwise.
14070 */
14071function exactEquals(a, b) {
14072 return a[0] === b[0] && a[1] === b[1];
14073}
14074
14075/**
14076 * Returns whether or not the vectors have approximately the same elements in the same position.
14077 *
14078 * @param {vec2} a The first vector.
14079 * @param {vec2} b The second vector.
14080 * @returns {Boolean} True if the vectors are equal, false otherwise.
14081 */
14082function equals(a, b) {
14083 var a0 = a[0],
14084 a1 = a[1];
14085 var b0 = b[0],
14086 b1 = b[1];
14087 return Math.abs(a0 - b0) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= __WEBPACK_IMPORTED_MODULE_0__common_js__["b" /* EPSILON */] * Math.max(1.0, Math.abs(a1), Math.abs(b1));
14088}
14089
14090/**
14091 * Alias for {@link vec2.length}
14092 * @function
14093 */
14094var len = length;
14095
14096/**
14097 * Alias for {@link vec2.subtract}
14098 * @function
14099 */
14100var sub = subtract;
14101
14102/**
14103 * Alias for {@link vec2.multiply}
14104 * @function
14105 */
14106var mul = multiply;
14107
14108/**
14109 * Alias for {@link vec2.divide}
14110 * @function
14111 */
14112var div = divide;
14113
14114/**
14115 * Alias for {@link vec2.distance}
14116 * @function
14117 */
14118var dist = distance;
14119
14120/**
14121 * Alias for {@link vec2.squaredDistance}
14122 * @function
14123 */
14124var sqrDist = squaredDistance;
14125
14126/**
14127 * Alias for {@link vec2.squaredLength}
14128 * @function
14129 */
14130var sqrLen = squaredLength;
14131
14132/**
14133 * Perform some operation over an array of vec2s.
14134 *
14135 * @param {Array} a the array of vectors to iterate over
14136 * @param {Number} stride Number of elements between the start of each vec2. If 0 assumes tightly packed
14137 * @param {Number} offset Number of elements to skip at the beginning of the array
14138 * @param {Number} count Number of vec2s to iterate over. If 0 iterates over entire array
14139 * @param {Function} fn Function to call for each vector in the array
14140 * @param {Object} [arg] additional argument to pass to fn
14141 * @returns {Array} a
14142 * @function
14143 */
14144var forEach = function () {
14145 var vec = create();
14146
14147 return function (a, stride, offset, count, fn, arg) {
14148 var i = void 0,
14149 l = void 0;
14150 if (!stride) {
14151 stride = 2;
14152 }
14153
14154 if (!offset) {
14155 offset = 0;
14156 }
14157
14158 if (count) {
14159 l = Math.min(count * stride + offset, a.length);
14160 } else {
14161 l = a.length;
14162 }
14163
14164 for (i = offset; i < l; i += stride) {
14165 vec[0] = a[i];vec[1] = a[i + 1];
14166 fn(vec, vec, arg);
14167 a[i] = vec[0];a[i + 1] = vec[1];
14168 }
14169
14170 return a;
14171 };
14172}();
14173
14174/***/ }),
14175/* 77 */
14176/***/ (function(module, __webpack_exports__, __webpack_require__) {
14177
14178"use strict";
14179Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14180/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_linear__ = __webpack_require__(78);
14181/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeLinear", function() { return __WEBPACK_IMPORTED_MODULE_0__src_linear__["a"]; });
14182/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_quad__ = __webpack_require__(79);
14183/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuad", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; });
14184/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadIn", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["a"]; });
14185/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadOut", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["c"]; });
14186/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeQuadInOut", function() { return __WEBPACK_IMPORTED_MODULE_1__src_quad__["b"]; });
14187/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_cubic__ = __webpack_require__(80);
14188/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubic", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; });
14189/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicIn", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["a"]; });
14190/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicOut", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["c"]; });
14191/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCubicInOut", function() { return __WEBPACK_IMPORTED_MODULE_2__src_cubic__["b"]; });
14192/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_poly__ = __webpack_require__(81);
14193/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePoly", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; });
14194/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyIn", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["a"]; });
14195/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyOut", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["c"]; });
14196/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easePolyInOut", function() { return __WEBPACK_IMPORTED_MODULE_3__src_poly__["b"]; });
14197/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_sin__ = __webpack_require__(82);
14198/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSin", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; });
14199/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinIn", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["a"]; });
14200/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinOut", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["c"]; });
14201/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeSinInOut", function() { return __WEBPACK_IMPORTED_MODULE_4__src_sin__["b"]; });
14202/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_exp__ = __webpack_require__(83);
14203/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExp", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; });
14204/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpIn", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["a"]; });
14205/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpOut", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["c"]; });
14206/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeExpInOut", function() { return __WEBPACK_IMPORTED_MODULE_5__src_exp__["b"]; });
14207/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_circle__ = __webpack_require__(84);
14208/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircle", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; });
14209/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleIn", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["a"]; });
14210/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleOut", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["c"]; });
14211/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeCircleInOut", function() { return __WEBPACK_IMPORTED_MODULE_6__src_circle__["b"]; });
14212/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_bounce__ = __webpack_require__(85);
14213/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounce", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; });
14214/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceIn", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["a"]; });
14215/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceOut", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["c"]; });
14216/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBounceInOut", function() { return __WEBPACK_IMPORTED_MODULE_7__src_bounce__["b"]; });
14217/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_back__ = __webpack_require__(86);
14218/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBack", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; });
14219/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackIn", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["a"]; });
14220/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackOut", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["c"]; });
14221/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeBackInOut", function() { return __WEBPACK_IMPORTED_MODULE_8__src_back__["b"]; });
14222/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_elastic__ = __webpack_require__(87);
14223/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElastic", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; });
14224/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticIn", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["a"]; });
14225/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticOut", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["c"]; });
14226/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "easeElasticInOut", function() { return __WEBPACK_IMPORTED_MODULE_9__src_elastic__["b"]; });
14227
14228
14229
14230
14231
14232
14233
14234
14235
14236
14237
14238
14239
14240
14241
14242
14243
14244
14245
14246
14247/***/ }),
14248/* 78 */
14249/***/ (function(module, __webpack_exports__, __webpack_require__) {
14250
14251"use strict";
14252/* harmony export (immutable) */ __webpack_exports__["a"] = linear;
14253function linear(t) {
14254 return +t;
14255}
14256
14257/***/ }),
14258/* 79 */
14259/***/ (function(module, __webpack_exports__, __webpack_require__) {
14260
14261"use strict";
14262/* harmony export (immutable) */ __webpack_exports__["a"] = quadIn;
14263/* harmony export (immutable) */ __webpack_exports__["c"] = quadOut;
14264/* harmony export (immutable) */ __webpack_exports__["b"] = quadInOut;
14265function quadIn(t) {
14266 return t * t;
14267}
14268
14269function quadOut(t) {
14270 return t * (2 - t);
14271}
14272
14273function quadInOut(t) {
14274 return ((t *= 2) <= 1 ? t * t : --t * (2 - t) + 1) / 2;
14275}
14276
14277/***/ }),
14278/* 80 */
14279/***/ (function(module, __webpack_exports__, __webpack_require__) {
14280
14281"use strict";
14282/* harmony export (immutable) */ __webpack_exports__["a"] = cubicIn;
14283/* harmony export (immutable) */ __webpack_exports__["c"] = cubicOut;
14284/* harmony export (immutable) */ __webpack_exports__["b"] = cubicInOut;
14285function cubicIn(t) {
14286 return t * t * t;
14287}
14288
14289function cubicOut(t) {
14290 return --t * t * t + 1;
14291}
14292
14293function cubicInOut(t) {
14294 return ((t *= 2) <= 1 ? t * t * t : (t -= 2) * t * t + 2) / 2;
14295}
14296
14297/***/ }),
14298/* 81 */
14299/***/ (function(module, __webpack_exports__, __webpack_require__) {
14300
14301"use strict";
14302/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return polyIn; });
14303/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return polyOut; });
14304/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return polyInOut; });
14305var exponent = 3;
14306
14307var polyIn = function custom(e) {
14308 e = +e;
14309
14310 function polyIn(t) {
14311 return Math.pow(t, e);
14312 }
14313
14314 polyIn.exponent = custom;
14315
14316 return polyIn;
14317}(exponent);
14318
14319var polyOut = function custom(e) {
14320 e = +e;
14321
14322 function polyOut(t) {
14323 return 1 - Math.pow(1 - t, e);
14324 }
14325
14326 polyOut.exponent = custom;
14327
14328 return polyOut;
14329}(exponent);
14330
14331var polyInOut = function custom(e) {
14332 e = +e;
14333
14334 function polyInOut(t) {
14335 return ((t *= 2) <= 1 ? Math.pow(t, e) : 2 - Math.pow(2 - t, e)) / 2;
14336 }
14337
14338 polyInOut.exponent = custom;
14339
14340 return polyInOut;
14341}(exponent);
14342
14343/***/ }),
14344/* 82 */
14345/***/ (function(module, __webpack_exports__, __webpack_require__) {
14346
14347"use strict";
14348/* harmony export (immutable) */ __webpack_exports__["a"] = sinIn;
14349/* harmony export (immutable) */ __webpack_exports__["c"] = sinOut;
14350/* harmony export (immutable) */ __webpack_exports__["b"] = sinInOut;
14351var pi = Math.PI,
14352 halfPi = pi / 2;
14353
14354function sinIn(t) {
14355 return 1 - Math.cos(t * halfPi);
14356}
14357
14358function sinOut(t) {
14359 return Math.sin(t * halfPi);
14360}
14361
14362function sinInOut(t) {
14363 return (1 - Math.cos(pi * t)) / 2;
14364}
14365
14366/***/ }),
14367/* 83 */
14368/***/ (function(module, __webpack_exports__, __webpack_require__) {
14369
14370"use strict";
14371/* harmony export (immutable) */ __webpack_exports__["a"] = expIn;
14372/* harmony export (immutable) */ __webpack_exports__["c"] = expOut;
14373/* harmony export (immutable) */ __webpack_exports__["b"] = expInOut;
14374function expIn(t) {
14375 return Math.pow(2, 10 * t - 10);
14376}
14377
14378function expOut(t) {
14379 return 1 - Math.pow(2, -10 * t);
14380}
14381
14382function expInOut(t) {
14383 return ((t *= 2) <= 1 ? Math.pow(2, 10 * t - 10) : 2 - Math.pow(2, 10 - 10 * t)) / 2;
14384}
14385
14386/***/ }),
14387/* 84 */
14388/***/ (function(module, __webpack_exports__, __webpack_require__) {
14389
14390"use strict";
14391/* harmony export (immutable) */ __webpack_exports__["a"] = circleIn;
14392/* harmony export (immutable) */ __webpack_exports__["c"] = circleOut;
14393/* harmony export (immutable) */ __webpack_exports__["b"] = circleInOut;
14394function circleIn(t) {
14395 return 1 - Math.sqrt(1 - t * t);
14396}
14397
14398function circleOut(t) {
14399 return Math.sqrt(1 - --t * t);
14400}
14401
14402function circleInOut(t) {
14403 return ((t *= 2) <= 1 ? 1 - Math.sqrt(1 - t * t) : Math.sqrt(1 - (t -= 2) * t) + 1) / 2;
14404}
14405
14406/***/ }),
14407/* 85 */
14408/***/ (function(module, __webpack_exports__, __webpack_require__) {
14409
14410"use strict";
14411/* harmony export (immutable) */ __webpack_exports__["a"] = bounceIn;
14412/* harmony export (immutable) */ __webpack_exports__["c"] = bounceOut;
14413/* harmony export (immutable) */ __webpack_exports__["b"] = bounceInOut;
14414var b1 = 4 / 11,
14415 b2 = 6 / 11,
14416 b3 = 8 / 11,
14417 b4 = 3 / 4,
14418 b5 = 9 / 11,
14419 b6 = 10 / 11,
14420 b7 = 15 / 16,
14421 b8 = 21 / 22,
14422 b9 = 63 / 64,
14423 b0 = 1 / b1 / b1;
14424
14425function bounceIn(t) {
14426 return 1 - bounceOut(1 - t);
14427}
14428
14429function bounceOut(t) {
14430 return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9;
14431}
14432
14433function bounceInOut(t) {
14434 return ((t *= 2) <= 1 ? 1 - bounceOut(1 - t) : bounceOut(t - 1) + 1) / 2;
14435}
14436
14437/***/ }),
14438/* 86 */
14439/***/ (function(module, __webpack_exports__, __webpack_require__) {
14440
14441"use strict";
14442/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return backIn; });
14443/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return backOut; });
14444/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return backInOut; });
14445var overshoot = 1.70158;
14446
14447var backIn = function custom(s) {
14448 s = +s;
14449
14450 function backIn(t) {
14451 return t * t * ((s + 1) * t - s);
14452 }
14453
14454 backIn.overshoot = custom;
14455
14456 return backIn;
14457}(overshoot);
14458
14459var backOut = function custom(s) {
14460 s = +s;
14461
14462 function backOut(t) {
14463 return --t * t * ((s + 1) * t + s) + 1;
14464 }
14465
14466 backOut.overshoot = custom;
14467
14468 return backOut;
14469}(overshoot);
14470
14471var backInOut = function custom(s) {
14472 s = +s;
14473
14474 function backInOut(t) {
14475 return ((t *= 2) < 1 ? t * t * ((s + 1) * t - s) : (t -= 2) * t * ((s + 1) * t + s) + 2) / 2;
14476 }
14477
14478 backInOut.overshoot = custom;
14479
14480 return backInOut;
14481}(overshoot);
14482
14483/***/ }),
14484/* 87 */
14485/***/ (function(module, __webpack_exports__, __webpack_require__) {
14486
14487"use strict";
14488/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return elasticIn; });
14489/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return elasticOut; });
14490/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return elasticInOut; });
14491var tau = 2 * Math.PI,
14492 amplitude = 1,
14493 period = 0.3;
14494
14495var elasticIn = function custom(a, p) {
14496 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14497
14498 function elasticIn(t) {
14499 return a * Math.pow(2, 10 * --t) * Math.sin((s - t) / p);
14500 }
14501
14502 elasticIn.amplitude = function (a) {
14503 return custom(a, p * tau);
14504 };
14505 elasticIn.period = function (p) {
14506 return custom(a, p);
14507 };
14508
14509 return elasticIn;
14510}(amplitude, period);
14511
14512var elasticOut = function custom(a, p) {
14513 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14514
14515 function elasticOut(t) {
14516 return 1 - a * Math.pow(2, -10 * (t = +t)) * Math.sin((t + s) / p);
14517 }
14518
14519 elasticOut.amplitude = function (a) {
14520 return custom(a, p * tau);
14521 };
14522 elasticOut.period = function (p) {
14523 return custom(a, p);
14524 };
14525
14526 return elasticOut;
14527}(amplitude, period);
14528
14529var elasticInOut = function custom(a, p) {
14530 var s = Math.asin(1 / (a = Math.max(1, a))) * (p /= tau);
14531
14532 function elasticInOut(t) {
14533 return ((t = t * 2 - 1) < 0 ? a * Math.pow(2, 10 * t) * Math.sin((s - t) / p) : 2 - a * Math.pow(2, -10 * t) * Math.sin((s + t) / p)) / 2;
14534 }
14535
14536 elasticInOut.amplitude = function (a) {
14537 return custom(a, p * tau);
14538 };
14539 elasticInOut.period = function (p) {
14540 return custom(a, p);
14541 };
14542
14543 return elasticInOut;
14544}(amplitude, period);
14545
14546/***/ }),
14547/* 88 */
14548/***/ (function(module, __webpack_exports__, __webpack_require__) {
14549
14550"use strict";
14551Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14552/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_timer__ = __webpack_require__(16);
14553/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "now", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["b"]; });
14554/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timer", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["c"]; });
14555/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timerFlush", function() { return __WEBPACK_IMPORTED_MODULE_0__src_timer__["d"]; });
14556/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_timeout__ = __webpack_require__(89);
14557/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "timeout", function() { return __WEBPACK_IMPORTED_MODULE_1__src_timeout__["a"]; });
14558/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_interval__ = __webpack_require__(90);
14559/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interval", function() { return __WEBPACK_IMPORTED_MODULE_2__src_interval__["a"]; });
14560
14561
14562
14563
14564
14565
14566/***/ }),
14567/* 89 */
14568/***/ (function(module, __webpack_exports__, __webpack_require__) {
14569
14570"use strict";
14571/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(16);
14572
14573
14574/* harmony default export */ __webpack_exports__["a"] = (function (callback, delay, time) {
14575 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */]();
14576 delay = delay == null ? 0 : +delay;
14577 t.restart(function (elapsed) {
14578 t.stop();
14579 callback(elapsed + delay);
14580 }, delay, time);
14581 return t;
14582});
14583
14584/***/ }),
14585/* 90 */
14586/***/ (function(module, __webpack_exports__, __webpack_require__) {
14587
14588"use strict";
14589/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__timer__ = __webpack_require__(16);
14590
14591
14592/* harmony default export */ __webpack_exports__["a"] = (function (callback, delay, time) {
14593 var t = new __WEBPACK_IMPORTED_MODULE_0__timer__["a" /* Timer */](),
14594 total = delay;
14595 if (delay == null) return t.restart(callback, delay, time), t;
14596 delay = +delay, time = time == null ? Object(__WEBPACK_IMPORTED_MODULE_0__timer__["b" /* now */])() : +time;
14597 t.restart(function tick(elapsed) {
14598 elapsed += total;
14599 t.restart(tick, total += delay, time);
14600 callback(elapsed);
14601 }, delay, time);
14602 return t;
14603});
14604
14605/***/ }),
14606/* 91 */
14607/***/ (function(module, __webpack_exports__, __webpack_require__) {
14608
14609"use strict";
14610Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
14611/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__src_value__ = __webpack_require__(17);
14612/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolate", function() { return __WEBPACK_IMPORTED_MODULE_0__src_value__["a"]; });
14613/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__src_array__ = __webpack_require__(37);
14614/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateArray", function() { return __WEBPACK_IMPORTED_MODULE_1__src_array__["a"]; });
14615/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__src_basis__ = __webpack_require__(20);
14616/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasis", function() { return __WEBPACK_IMPORTED_MODULE_2__src_basis__["b"]; });
14617/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__ = __webpack_require__(35);
14618/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_3__src_basisClosed__["a"]; });
14619/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__src_date__ = __webpack_require__(38);
14620/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateDate", function() { return __WEBPACK_IMPORTED_MODULE_4__src_date__["a"]; });
14621/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__src_number__ = __webpack_require__(11);
14622/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateNumber", function() { return __WEBPACK_IMPORTED_MODULE_5__src_number__["a"]; });
14623/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__src_object__ = __webpack_require__(39);
14624/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateObject", function() { return __WEBPACK_IMPORTED_MODULE_6__src_object__["a"]; });
14625/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__src_round__ = __webpack_require__(94);
14626/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRound", function() { return __WEBPACK_IMPORTED_MODULE_7__src_round__["a"]; });
14627/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__src_string__ = __webpack_require__(40);
14628/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateString", function() { return __WEBPACK_IMPORTED_MODULE_8__src_string__["a"]; });
14629/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__src_transform_index__ = __webpack_require__(95);
14630/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformCss", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["a"]; });
14631/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateTransformSvg", function() { return __WEBPACK_IMPORTED_MODULE_9__src_transform_index__["b"]; });
14632/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__src_zoom__ = __webpack_require__(98);
14633/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateZoom", function() { return __WEBPACK_IMPORTED_MODULE_10__src_zoom__["a"]; });
14634/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__src_rgb__ = __webpack_require__(34);
14635/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgb", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["a"]; });
14636/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasis", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["b"]; });
14637/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateRgbBasisClosed", function() { return __WEBPACK_IMPORTED_MODULE_11__src_rgb__["c"]; });
14638/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__src_hsl__ = __webpack_require__(99);
14639/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHsl", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["a"]; });
14640/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHslLong", function() { return __WEBPACK_IMPORTED_MODULE_12__src_hsl__["b"]; });
14641/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__src_lab__ = __webpack_require__(100);
14642/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateLab", function() { return __WEBPACK_IMPORTED_MODULE_13__src_lab__["a"]; });
14643/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__src_hcl__ = __webpack_require__(101);
14644/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHcl", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["a"]; });
14645/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateHclLong", function() { return __WEBPACK_IMPORTED_MODULE_14__src_hcl__["b"]; });
14646/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__ = __webpack_require__(102);
14647/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelix", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["b"]; });
14648/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "interpolateCubehelixLong", function() { return __WEBPACK_IMPORTED_MODULE_15__src_cubehelix__["a"]; });
14649/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__src_quantize__ = __webpack_require__(103);
14650/* harmony reexport (binding) */ __webpack_require__.d(__webpack_exports__, "quantize", function() { return __WEBPACK_IMPORTED_MODULE_16__src_quantize__["a"]; });
14651
14652
14653
14654
14655
14656
14657
14658
14659
14660
14661
14662
14663
14664
14665
14666
14667
14668
14669/***/ }),
14670/* 92 */
14671/***/ (function(module, __webpack_exports__, __webpack_require__) {
14672
14673"use strict";
14674/* unused harmony export gray */
14675/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
14676/* unused harmony export Lab */
14677/* unused harmony export lch */
14678/* harmony export (immutable) */ __webpack_exports__["b"] = hcl;
14679/* unused harmony export Hcl */
14680/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(19);
14681/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(18);
14682/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(33);
14683
14684
14685
14686
14687// https://beta.observablehq.com/@mbostock/lab-and-rgb
14688var K = 18,
14689 Xn = 0.96422,
14690 Yn = 1,
14691 Zn = 0.82521,
14692 t0 = 4 / 29,
14693 t1 = 6 / 29,
14694 t2 = 3 * t1 * t1,
14695 t3 = t1 * t1 * t1;
14696
14697function labConvert(o) {
14698 if (o instanceof Lab) return new Lab(o.l, o.a, o.b, o.opacity);
14699 if (o instanceof Hcl) {
14700 if (isNaN(o.h)) return new Lab(o.l, 0, 0, o.opacity);
14701 var h = o.h * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */];
14702 return new Lab(o.l, Math.cos(h) * o.c, Math.sin(h) * o.c, o.opacity);
14703 }
14704 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
14705 var r = rgb2lrgb(o.r),
14706 g = rgb2lrgb(o.g),
14707 b = rgb2lrgb(o.b),
14708 y = xyz2lab((0.2225045 * r + 0.7168786 * g + 0.0606169 * b) / Yn),
14709 x,
14710 z;
14711 if (r === g && g === b) x = z = y;else {
14712 x = xyz2lab((0.4360747 * r + 0.3850649 * g + 0.1430804 * b) / Xn);
14713 z = xyz2lab((0.0139322 * r + 0.0971045 * g + 0.7141733 * b) / Zn);
14714 }
14715 return new Lab(116 * y - 16, 500 * (x - y), 200 * (y - z), o.opacity);
14716}
14717
14718function gray(l, opacity) {
14719 return new Lab(l, 0, 0, opacity == null ? 1 : opacity);
14720}
14721
14722function lab(l, a, b, opacity) {
14723 return arguments.length === 1 ? labConvert(l) : new Lab(l, a, b, opacity == null ? 1 : opacity);
14724}
14725
14726function Lab(l, a, b, opacity) {
14727 this.l = +l;
14728 this.a = +a;
14729 this.b = +b;
14730 this.opacity = +opacity;
14731}
14732
14733Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Lab, lab, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14734 brighter: function brighter(k) {
14735 return new Lab(this.l + K * (k == null ? 1 : k), this.a, this.b, this.opacity);
14736 },
14737 darker: function darker(k) {
14738 return new Lab(this.l - K * (k == null ? 1 : k), this.a, this.b, this.opacity);
14739 },
14740 rgb: function rgb() {
14741 var y = (this.l + 16) / 116,
14742 x = isNaN(this.a) ? y : y + this.a / 500,
14743 z = isNaN(this.b) ? y : y - this.b / 200;
14744 x = Xn * lab2xyz(x);
14745 y = Yn * lab2xyz(y);
14746 z = Zn * lab2xyz(z);
14747 return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](lrgb2rgb(3.1338561 * x - 1.6168667 * y - 0.4906146 * z), lrgb2rgb(-0.9787684 * x + 1.9161415 * y + 0.0334540 * z), lrgb2rgb(0.0719453 * x - 0.2289914 * y + 1.4052427 * z), this.opacity);
14748 }
14749}));
14750
14751function xyz2lab(t) {
14752 return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0;
14753}
14754
14755function lab2xyz(t) {
14756 return t > t1 ? t * t * t : t2 * (t - t0);
14757}
14758
14759function lrgb2rgb(x) {
14760 return 255 * (x <= 0.0031308 ? 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055);
14761}
14762
14763function rgb2lrgb(x) {
14764 return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4);
14765}
14766
14767function hclConvert(o) {
14768 if (o instanceof Hcl) return new Hcl(o.h, o.c, o.l, o.opacity);
14769 if (!(o instanceof Lab)) o = labConvert(o);
14770 if (o.a === 0 && o.b === 0) return new Hcl(NaN, 0, o.l, o.opacity);
14771 var h = Math.atan2(o.b, o.a) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */];
14772 return new Hcl(h < 0 ? h + 360 : h, Math.sqrt(o.a * o.a + o.b * o.b), o.l, o.opacity);
14773}
14774
14775function lch(l, c, h, opacity) {
14776 return arguments.length === 1 ? hclConvert(l) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
14777}
14778
14779function hcl(h, c, l, opacity) {
14780 return arguments.length === 1 ? hclConvert(h) : new Hcl(h, c, l, opacity == null ? 1 : opacity);
14781}
14782
14783function Hcl(h, c, l, opacity) {
14784 this.h = +h;
14785 this.c = +c;
14786 this.l = +l;
14787 this.opacity = +opacity;
14788}
14789
14790Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Hcl, hcl, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14791 brighter: function brighter(k) {
14792 return new Hcl(this.h, this.c, this.l + K * (k == null ? 1 : k), this.opacity);
14793 },
14794 darker: function darker(k) {
14795 return new Hcl(this.h, this.c, this.l - K * (k == null ? 1 : k), this.opacity);
14796 },
14797 rgb: function rgb() {
14798 return labConvert(this).rgb();
14799 }
14800}));
14801
14802/***/ }),
14803/* 93 */
14804/***/ (function(module, __webpack_exports__, __webpack_require__) {
14805
14806"use strict";
14807/* harmony export (immutable) */ __webpack_exports__["a"] = cubehelix;
14808/* unused harmony export Cubehelix */
14809/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__define__ = __webpack_require__(19);
14810/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(18);
14811/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__math__ = __webpack_require__(33);
14812
14813
14814
14815
14816var A = -0.14861,
14817 B = +1.78277,
14818 C = -0.29227,
14819 D = -0.90649,
14820 E = +1.97294,
14821 ED = E * D,
14822 EB = E * B,
14823 BC_DA = B * C - D * A;
14824
14825function cubehelixConvert(o) {
14826 if (o instanceof Cubehelix) return new Cubehelix(o.h, o.s, o.l, o.opacity);
14827 if (!(o instanceof __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */])) o = Object(__WEBPACK_IMPORTED_MODULE_1__color__["h" /* rgbConvert */])(o);
14828 var r = o.r / 255,
14829 g = o.g / 255,
14830 b = o.b / 255,
14831 l = (BC_DA * b + ED * r - EB * g) / (BC_DA + ED - EB),
14832 bl = b - l,
14833 k = (E * (g - l) - C * bl) / D,
14834 s = Math.sqrt(k * k + bl * bl) / (E * l * (1 - l)),
14835 // NaN if l=0 or l=1
14836 h = s ? Math.atan2(k, bl) * __WEBPACK_IMPORTED_MODULE_2__math__["b" /* rad2deg */] - 120 : NaN;
14837 return new Cubehelix(h < 0 ? h + 360 : h, s, l, o.opacity);
14838}
14839
14840function cubehelix(h, s, l, opacity) {
14841 return arguments.length === 1 ? cubehelixConvert(h) : new Cubehelix(h, s, l, opacity == null ? 1 : opacity);
14842}
14843
14844function Cubehelix(h, s, l, opacity) {
14845 this.h = +h;
14846 this.s = +s;
14847 this.l = +l;
14848 this.opacity = +opacity;
14849}
14850
14851Object(__WEBPACK_IMPORTED_MODULE_0__define__["a" /* default */])(Cubehelix, cubehelix, Object(__WEBPACK_IMPORTED_MODULE_0__define__["b" /* extend */])(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* Color */], {
14852 brighter: function brighter(k) {
14853 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* brighter */], k);
14854 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
14855 },
14856 darker: function darker(k) {
14857 k = k == null ? __WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */] : Math.pow(__WEBPACK_IMPORTED_MODULE_1__color__["d" /* darker */], k);
14858 return new Cubehelix(this.h, this.s, this.l * k, this.opacity);
14859 },
14860 rgb: function rgb() {
14861 var h = isNaN(this.h) ? 0 : (this.h + 120) * __WEBPACK_IMPORTED_MODULE_2__math__["a" /* deg2rad */],
14862 l = +this.l,
14863 a = isNaN(this.s) ? 0 : this.s * l * (1 - l),
14864 cosh = Math.cos(h),
14865 sinh = Math.sin(h);
14866 return new __WEBPACK_IMPORTED_MODULE_1__color__["b" /* Rgb */](255 * (l + a * (A * cosh + B * sinh)), 255 * (l + a * (C * cosh + D * sinh)), 255 * (l + a * (E * cosh)), this.opacity);
14867 }
14868}));
14869
14870/***/ }),
14871/* 94 */
14872/***/ (function(module, __webpack_exports__, __webpack_require__) {
14873
14874"use strict";
14875/* harmony default export */ __webpack_exports__["a"] = (function (a, b) {
14876 return a = +a, b -= a, function (t) {
14877 return Math.round(a + b * t);
14878 };
14879});
14880
14881/***/ }),
14882/* 95 */
14883/***/ (function(module, __webpack_exports__, __webpack_require__) {
14884
14885"use strict";
14886/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return interpolateTransformCss; });
14887/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return interpolateTransformSvg; });
14888/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__number__ = __webpack_require__(11);
14889/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__parse__ = __webpack_require__(96);
14890
14891
14892
14893function interpolateTransform(parse, pxComma, pxParen, degParen) {
14894
14895 function pop(s) {
14896 return s.length ? s.pop() + " " : "";
14897 }
14898
14899 function translate(xa, ya, xb, yb, s, q) {
14900 if (xa !== xb || ya !== yb) {
14901 var i = s.push("translate(", null, pxComma, null, pxParen);
14902 q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) });
14903 } else if (xb || yb) {
14904 s.push("translate(" + xb + pxComma + yb + pxParen);
14905 }
14906 }
14907
14908 function rotate(a, b, s, q) {
14909 if (a !== b) {
14910 if (a - b > 180) b += 360;else if (b - a > 180) a += 360; // shortest path
14911 q.push({ i: s.push(pop(s) + "rotate(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
14912 } else if (b) {
14913 s.push(pop(s) + "rotate(" + b + degParen);
14914 }
14915 }
14916
14917 function skewX(a, b, s, q) {
14918 if (a !== b) {
14919 q.push({ i: s.push(pop(s) + "skewX(", null, degParen) - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(a, b) });
14920 } else if (b) {
14921 s.push(pop(s) + "skewX(" + b + degParen);
14922 }
14923 }
14924
14925 function scale(xa, ya, xb, yb, s, q) {
14926 if (xa !== xb || ya !== yb) {
14927 var i = s.push(pop(s) + "scale(", null, ",", null, ")");
14928 q.push({ i: i - 4, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(xa, xb) }, { i: i - 2, x: Object(__WEBPACK_IMPORTED_MODULE_0__number__["a" /* default */])(ya, yb) });
14929 } else if (xb !== 1 || yb !== 1) {
14930 s.push(pop(s) + "scale(" + xb + "," + yb + ")");
14931 }
14932 }
14933
14934 return function (a, b) {
14935 var s = [],
14936 // string constants and placeholders
14937 q = []; // number interpolators
14938 a = parse(a), b = parse(b);
14939 translate(a.translateX, a.translateY, b.translateX, b.translateY, s, q);
14940 rotate(a.rotate, b.rotate, s, q);
14941 skewX(a.skewX, b.skewX, s, q);
14942 scale(a.scaleX, a.scaleY, b.scaleX, b.scaleY, s, q);
14943 a = b = null; // gc
14944 return function (t) {
14945 var i = -1,
14946 n = q.length,
14947 o;
14948 while (++i < n) {
14949 s[(o = q[i]).i] = o.x(t);
14950 }return s.join("");
14951 };
14952 };
14953}
14954
14955var interpolateTransformCss = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["a" /* parseCss */], "px, ", "px)", "deg)");
14956var interpolateTransformSvg = interpolateTransform(__WEBPACK_IMPORTED_MODULE_1__parse__["b" /* parseSvg */], ", ", ")", ")");
14957
14958/***/ }),
14959/* 96 */
14960/***/ (function(module, __webpack_exports__, __webpack_require__) {
14961
14962"use strict";
14963/* harmony export (immutable) */ __webpack_exports__["a"] = parseCss;
14964/* harmony export (immutable) */ __webpack_exports__["b"] = parseSvg;
14965/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__decompose__ = __webpack_require__(97);
14966
14967
14968var cssNode, cssRoot, cssView, svgNode;
14969
14970function parseCss(value) {
14971 if (value === "none") return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
14972 if (!cssNode) cssNode = document.createElement("DIV"), cssRoot = document.documentElement, cssView = document.defaultView;
14973 cssNode.style.transform = value;
14974 value = cssView.getComputedStyle(cssRoot.appendChild(cssNode), null).getPropertyValue("transform");
14975 cssRoot.removeChild(cssNode);
14976 value = value.slice(7, -1).split(",");
14977 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(+value[0], +value[1], +value[2], +value[3], +value[4], +value[5]);
14978}
14979
14980function parseSvg(value) {
14981 if (value == null) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
14982 if (!svgNode) svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
14983 svgNode.setAttribute("transform", value);
14984 if (!(value = svgNode.transform.baseVal.consolidate())) return __WEBPACK_IMPORTED_MODULE_0__decompose__["b" /* identity */];
14985 value = value.matrix;
14986 return Object(__WEBPACK_IMPORTED_MODULE_0__decompose__["a" /* default */])(value.a, value.b, value.c, value.d, value.e, value.f);
14987}
14988
14989/***/ }),
14990/* 97 */
14991/***/ (function(module, __webpack_exports__, __webpack_require__) {
14992
14993"use strict";
14994/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return identity; });
14995var degrees = 180 / Math.PI;
14996
14997var identity = {
14998 translateX: 0,
14999 translateY: 0,
15000 rotate: 0,
15001 skewX: 0,
15002 scaleX: 1,
15003 scaleY: 1
15004};
15005
15006/* harmony default export */ __webpack_exports__["a"] = (function (a, b, c, d, e, f) {
15007 var scaleX, scaleY, skewX;
15008 if (scaleX = Math.sqrt(a * a + b * b)) a /= scaleX, b /= scaleX;
15009 if (skewX = a * c + b * d) c -= a * skewX, d -= b * skewX;
15010 if (scaleY = Math.sqrt(c * c + d * d)) c /= scaleY, d /= scaleY, skewX /= scaleY;
15011 if (a * d < b * c) a = -a, b = -b, skewX = -skewX, scaleX = -scaleX;
15012 return {
15013 translateX: e,
15014 translateY: f,
15015 rotate: Math.atan2(b, a) * degrees,
15016 skewX: Math.atan(skewX) * degrees,
15017 scaleX: scaleX,
15018 scaleY: scaleY
15019 };
15020});
15021
15022/***/ }),
15023/* 98 */
15024/***/ (function(module, __webpack_exports__, __webpack_require__) {
15025
15026"use strict";
15027var rho = Math.SQRT2,
15028 rho2 = 2,
15029 rho4 = 4,
15030 epsilon2 = 1e-12;
15031
15032function cosh(x) {
15033 return ((x = Math.exp(x)) + 1 / x) / 2;
15034}
15035
15036function sinh(x) {
15037 return ((x = Math.exp(x)) - 1 / x) / 2;
15038}
15039
15040function tanh(x) {
15041 return ((x = Math.exp(2 * x)) - 1) / (x + 1);
15042}
15043
15044// p0 = [ux0, uy0, w0]
15045// p1 = [ux1, uy1, w1]
15046/* harmony default export */ __webpack_exports__["a"] = (function (p0, p1) {
15047 var ux0 = p0[0],
15048 uy0 = p0[1],
15049 w0 = p0[2],
15050 ux1 = p1[0],
15051 uy1 = p1[1],
15052 w1 = p1[2],
15053 dx = ux1 - ux0,
15054 dy = uy1 - uy0,
15055 d2 = dx * dx + dy * dy,
15056 i,
15057 S;
15058
15059 // Special case for u0 ≅ u1.
15060 if (d2 < epsilon2) {
15061 S = Math.log(w1 / w0) / rho;
15062 i = function i(t) {
15063 return [ux0 + t * dx, uy0 + t * dy, w0 * Math.exp(rho * t * S)];
15064 };
15065 }
15066
15067 // General case.
15068 else {
15069 var d1 = Math.sqrt(d2),
15070 b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1),
15071 b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1),
15072 r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0),
15073 r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
15074 S = (r1 - r0) / rho;
15075 i = function i(t) {
15076 var s = t * S,
15077 coshr0 = cosh(r0),
15078 u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0));
15079 return [ux0 + u * dx, uy0 + u * dy, w0 * coshr0 / cosh(rho * s + r0)];
15080 };
15081 }
15082
15083 i.duration = S * 1000;
15084
15085 return i;
15086});
15087
15088/***/ }),
15089/* 99 */
15090/***/ (function(module, __webpack_exports__, __webpack_require__) {
15091
15092"use strict";
15093/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hslLong; });
15094/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15095/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15096
15097
15098
15099function hsl(hue) {
15100 return function (start, end) {
15101 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["d" /* hsl */])(end)).h),
15102 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
15103 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15104 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15105 return function (t) {
15106 start.h = h(t);
15107 start.s = s(t);
15108 start.l = l(t);
15109 start.opacity = opacity(t);
15110 return start + "";
15111 };
15112 };
15113}
15114
15115/* harmony default export */ __webpack_exports__["a"] = (hsl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15116var hslLong = hsl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15117
15118/***/ }),
15119/* 100 */
15120/***/ (function(module, __webpack_exports__, __webpack_require__) {
15121
15122"use strict";
15123/* harmony export (immutable) */ __webpack_exports__["a"] = lab;
15124/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15125/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15126
15127
15128
15129function lab(start, end) {
15130 var l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(start)).l, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["e" /* lab */])(end)).l),
15131 a = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.a, end.a),
15132 b = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.b, end.b),
15133 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15134 return function (t) {
15135 start.l = l(t);
15136 start.a = a(t);
15137 start.b = b(t);
15138 start.opacity = opacity(t);
15139 return start + "";
15140 };
15141}
15142
15143/***/ }),
15144/* 101 */
15145/***/ (function(module, __webpack_exports__, __webpack_require__) {
15146
15147"use strict";
15148/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hclLong; });
15149/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15150/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15151
15152
15153
15154function hcl(hue) {
15155 return function (start, end) {
15156 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["c" /* hcl */])(end)).h),
15157 c = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.c, end.c),
15158 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15159 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15160 return function (t) {
15161 start.h = h(t);
15162 start.c = c(t);
15163 start.l = l(t);
15164 start.opacity = opacity(t);
15165 return start + "";
15166 };
15167 };
15168}
15169
15170/* harmony default export */ __webpack_exports__["a"] = (hcl(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15171var hclLong = hcl(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15172
15173/***/ }),
15174/* 102 */
15175/***/ (function(module, __webpack_exports__, __webpack_require__) {
15176
15177"use strict";
15178/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return cubehelixLong; });
15179/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_d3_color__ = __webpack_require__(5);
15180/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__color__ = __webpack_require__(8);
15181
15182
15183
15184function cubehelix(hue) {
15185 return function cubehelixGamma(y) {
15186 y = +y;
15187
15188 function cubehelix(start, end) {
15189 var h = hue((start = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(start)).h, (end = Object(__WEBPACK_IMPORTED_MODULE_0_d3_color__["b" /* cubehelix */])(end)).h),
15190 s = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.s, end.s),
15191 l = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.l, end.l),
15192 opacity = Object(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */])(start.opacity, end.opacity);
15193 return function (t) {
15194 start.h = h(t);
15195 start.s = s(t);
15196 start.l = l(Math.pow(t, y));
15197 start.opacity = opacity(t);
15198 return start + "";
15199 };
15200 }
15201
15202 cubehelix.gamma = cubehelixGamma;
15203
15204 return cubehelix;
15205 }(1);
15206}
15207
15208/* harmony default export */ __webpack_exports__["b"] = (cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["c" /* hue */]));
15209var cubehelixLong = cubehelix(__WEBPACK_IMPORTED_MODULE_1__color__["a" /* default */]);
15210
15211/***/ }),
15212/* 103 */
15213/***/ (function(module, __webpack_exports__, __webpack_require__) {
15214
15215"use strict";
15216/* harmony default export */ __webpack_exports__["a"] = (function (interpolator, n) {
15217 var samples = new Array(n);
15218 for (var i = 0; i < n; ++i) {
15219 samples[i] = interpolator(i / (n - 1));
15220 }return samples;
15221});
15222
15223/***/ }),
15224/* 104 */
15225/***/ (function(module, exports, __webpack_require__) {
15226
15227var Shape = __webpack_require__(4);
15228Shape.Rect = __webpack_require__(42);
15229Shape.Circle = __webpack_require__(43);
15230Shape.Ellipse = __webpack_require__(44);
15231Shape.Path = __webpack_require__(45);
15232Shape.Text = __webpack_require__(46);
15233Shape.Line = __webpack_require__(47);
15234Shape.Image = __webpack_require__(48);
15235Shape.Polygon = __webpack_require__(49);
15236Shape.Marker = __webpack_require__(50);
15237Shape.Dom = __webpack_require__(51);
15238Shape.Fa = __webpack_require__(52);
15239
15240module.exports = Shape;
15241
15242/***/ }),
15243/* 105 */
15244/***/ (function(module, exports, __webpack_require__) {
15245
15246/**
15247 * Created by Elaine on 2018/5/9.
15248 */
15249var Util = __webpack_require__(0);
15250var Element = __webpack_require__(13);
15251var Gradient = __webpack_require__(106);
15252var Shadow = __webpack_require__(107);
15253var Arrow = __webpack_require__(108);
15254var Clip = __webpack_require__(109);
15255
15256var Defs = function Defs(cfg) {
15257 Defs.superclass.constructor.call(this, cfg);
15258 this.set('children', []);
15259};
15260
15261Util.extend(Defs, Element);
15262
15263Util.augment(Defs, {
15264 isGroup: false,
15265 canFill: false,
15266 canStroke: false,
15267 capture: false,
15268 visible: false,
15269 init: function init() {
15270 var el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');
15271 var id = Util.uniqueId('defs_');
15272 el.setAttribute('id', id);
15273 this.set('el', el);
15274 this.set('children', []);
15275 },
15276 find: function find(type, attr) {
15277 var children = this.get('children');
15278 var result = null;
15279 for (var i = 0; i < children.length; i++) {
15280 if (children[i].match(type, attr)) {
15281 result = children[i].__cfg.id;
15282 break;
15283 }
15284 }
15285 return result;
15286 },
15287 findById: function findById(id) {
15288 var children = this.get('children');
15289 var flag = null;
15290 for (var i = 0; i < children.length; i++) {
15291 if (children[i].__cfg.id === id) {
15292 flag = children[i];
15293 break;
15294 }
15295 }
15296 return flag;
15297 },
15298 add: function add(items) {
15299 var el = this.get('el');
15300 var self = this;
15301 var children = this.get('children');
15302 if (Util.isArray(items)) {
15303 Util.each(items, function (item) {
15304 var parent = item.get('parent');
15305 if (parent) {
15306 parent.removeChild(item, false);
15307 self._setContext(item);
15308 }
15309 el.appendChild(item.get('el'));
15310 });
15311 children.push.apply(children, items);
15312 return self;
15313 }
15314 if (self.findById(items.get('id'))) {
15315 return self;
15316 }
15317 var parent = items.get('parent');
15318 if (parent) {
15319 parent.removeChild(items, false);
15320 }
15321 self._add(items);
15322 el.appendChild(items.get('el'));
15323 return self;
15324 },
15325 _add: function _add(item) {
15326 this.get('el').appendChild(item.__cfg.el);
15327 this.get('children').push(item);
15328 item.__cfg.parent = this;
15329 item.__cfg.defs = this;
15330 item.__cfg.canvas = this.__cfg.canvas;
15331 },
15332 addGradient: function addGradient(cfg) {
15333 var gradient = new Gradient(cfg);
15334 this._add(gradient);
15335 return gradient.__cfg.id;
15336 },
15337 addShadow: function addShadow(cfg) {
15338 var shadow = new Shadow(cfg);
15339 this._add(shadow);
15340 return shadow.__cfg.id;
15341 },
15342 addArrow: function addArrow(name, cfg, stroke) {
15343 var arrow = new Arrow(name, cfg, stroke);
15344 this._add(arrow);
15345 return arrow.__cfg.id;
15346 },
15347 addClip: function addClip(cfg) {
15348 var clip = new Clip(cfg);
15349 this._add(clip);
15350 return clip.__cfg.id;
15351 }
15352});
15353
15354module.exports = Defs;
15355
15356/***/ }),
15357/* 106 */
15358/***/ (function(module, exports, __webpack_require__) {
15359
15360/**
15361 * Created by Elaine on 2018/5/9.
15362 */
15363var Util = __webpack_require__(0);
15364
15365var regexLG = /^l\s*\(\s*([\d.]+)\s*\)\s*(.*)/i;
15366var regexRG = /^r\s*\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)\s*(.*)/i;
15367var regexColorStop = /[\d.]+:(#[^\s]+|[^\)]+\))/ig;
15368
15369function addStop(steps) {
15370 var arr = steps.match(regexColorStop);
15371 if (!arr) {
15372 return '';
15373 }
15374 var stops = '';
15375 arr.sort(function (a, b) {
15376 a = a.split(':');
15377 b = b.split(':');
15378 return Number(a[0]) - Number(b[0]);
15379 });
15380 Util.each(arr, function (item) {
15381 item = item.split(':');
15382 stops += '<stop offset="' + item[0] + '" stop-color="' + item[1] + '"></stop>';
15383 });
15384 return stops;
15385}
15386
15387function parseLineGradient(color, el) {
15388 var arr = regexLG.exec(color);
15389 var angle = Util.mod(Util.toRadian(parseFloat(arr[1])), Math.PI * 2);
15390 var steps = arr[2];
15391 var start = void 0;
15392 var end = void 0;
15393
15394 if (angle >= 0 && angle < 0.5 * Math.PI) {
15395 start = {
15396 x: 0,
15397 y: 0
15398 };
15399 end = {
15400 x: 1,
15401 y: 1
15402 };
15403 } else if (0.5 * Math.PI <= angle && angle < Math.PI) {
15404 start = {
15405 x: 1,
15406 y: 0
15407 };
15408 end = {
15409 x: 0,
15410 y: 1
15411 };
15412 } else if (Math.PI <= angle && angle < 1.5 * Math.PI) {
15413 start = {
15414 x: 1,
15415 y: 1
15416 };
15417 end = {
15418 x: 0,
15419 y: 0
15420 };
15421 } else {
15422 start = {
15423 x: 0,
15424 y: 1
15425 };
15426 end = {
15427 x: 1,
15428 y: 0
15429 };
15430 }
15431
15432 var tanTheta = Math.tan(angle);
15433 var tanTheta2 = tanTheta * tanTheta;
15434
15435 var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;
15436 var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;
15437 el.setAttribute('x1', start.x);
15438 el.setAttribute('y1', start.y);
15439 el.setAttribute('x2', x);
15440 el.setAttribute('y2', y);
15441 el.innerHTML = addStop(steps);
15442}
15443
15444function parseRadialGradient(color, self) {
15445 var arr = regexRG.exec(color);
15446 var cx = parseFloat(arr[1]);
15447 var cy = parseFloat(arr[2]);
15448 var r = parseFloat(arr[3]);
15449 var steps = arr[4];
15450 self.setAttribute('cx', cx);
15451 self.setAttribute('cy', cy);
15452 self.setAttribute('r', r);
15453 self.innerHTML = addStop(steps);
15454}
15455
15456var Gradient = function Gradient(cfg) {
15457 var el = null;
15458 var id = Util.uniqueId('gradient_');
15459 if (cfg.toLowerCase().startsWith('l')) {
15460 el = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');
15461 parseLineGradient(cfg, el);
15462 } else {
15463 el = document.createElementNS('http://www.w3.org/2000/svg', 'radialGradient');
15464 parseRadialGradient(cfg, el);
15465 }
15466 el.setAttribute('id', id);
15467 this.__cfg = { el: el, id: id };
15468 this.__attrs = { config: cfg };
15469 return this;
15470};
15471
15472Util.augment(Gradient, {
15473 type: 'gradient',
15474 match: function match(type, attr) {
15475 return this.type === type && this.__attrs.config === attr;
15476 }
15477});
15478
15479module.exports = Gradient;
15480
15481/***/ }),
15482/* 107 */
15483/***/ (function(module, exports, __webpack_require__) {
15484
15485/**
15486 * Created by Elaine on 2018/5/10.
15487 */
15488var Util = __webpack_require__(0);
15489
15490var ATTR_MAP = {
15491 shadowColor: 'color',
15492 shadowOpacity: 'opacity',
15493 shadowBlur: 'blur',
15494 shadowOffsetX: 'dx',
15495 shadowOffsetY: 'dy'
15496};
15497
15498function parseShadow(config, el) {
15499 var child = '<feDropShadow \n dx="' + config.dx + '" \n dy="' + config.dy + '" \n stdDeviation="' + (config.blur ? config.blur / 10 : 0) + '"\n flood-color="' + (config.color ? config.color : '#000') + '"\n flood-opacity="' + (config.opacity ? config.opacity : 1) + '"\n />';
15500 el.innerHTML = child;
15501}
15502
15503var Shadow = function Shadow(cfg) {
15504 var el = document.createElementNS('http://www.w3.org/2000/svg', 'filter');
15505 var id = Util.uniqueId('filter_');
15506 el.setAttribute('id', id);
15507 parseShadow(cfg, el);
15508 this.__cfg = { el: el, id: id };
15509 this.__attrs = { config: cfg };
15510 return this;
15511};
15512Util.augment(Shadow, {
15513 type: 'filter',
15514 match: function match(type, cfg) {
15515 if (this.type !== type) {
15516 return false;
15517 }
15518 var flag = false;
15519 var config = this.__attrs.config;
15520 Util.each(Object.keys(config), function (attr) {
15521 if (!flag) {
15522 flag = config[attr] === cfg[attr];
15523 }
15524 });
15525 return flag;
15526 },
15527 update: function update(name, value) {
15528 var config = this.__attrs.config;
15529 config[ATTR_MAP[name]] = value;
15530 parseShadow(config, this.__cfg.el);
15531 return this;
15532 }
15533});
15534
15535module.exports = Shadow;
15536
15537/***/ }),
15538/* 108 */
15539/***/ (function(module, exports, __webpack_require__) {
15540
15541var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
15542
15543/**
15544 * Created by Elaine on 2018/5/11.
15545 */
15546var Util = __webpack_require__(0);
15547
15548var DEFAULT_PATH = {
15549 'marker-start': 'M6,0 L0,3 L6,6 L3,3Z',
15550 'marker-end': 'M0,0 L6,3 L0,6 L3,3Z'
15551};
15552
15553function setDefaultPath(parent, name, stroke) {
15554 var el = document.createElementNS('http://www.w3.org/2000/svg', 'path');
15555 el.setAttribute('d', DEFAULT_PATH[name]);
15556 el.setAttribute('stroke', 'none');
15557 el.setAttribute('fill', stroke || '#000');
15558 parent.appendChild(el);
15559 parent.setAttribute('refX', 3);
15560 parent.setAttribute('refY', 3);
15561 parent.setAttribute('markerWidth', 16);
15562 parent.setAttribute('markerHeight', 16);
15563 parent.setAttribute('orient', 'auto');
15564 return el;
15565}
15566
15567function setMarker(shape, parent, name, stroke) {
15568 if (!shape) {
15569 return setDefaultPath(parent, name);
15570 }
15571 if (shape.type !== 'marker') {
15572 throw new TypeError('the shape of an arrow should be an instance of Marker');
15573 }
15574 shape.attr({ stroke: 'none', fill: stroke });
15575 parent.append(shape.get('el'));
15576 var width = shape.__attrs.x;
15577 var height = shape.__attrs.y;
15578 parent.setAttribute('refX', width);
15579 parent.setAttribute('refY', height);
15580 parent.setAttribute('markerWidth', width * 2);
15581 parent.setAttribute('markerHeight', height * 2);
15582 parent.setAttribute('orient', 'auto');
15583 return shape;
15584}
15585
15586var Arrow = function Arrow(name, cfg, stroke) {
15587 var el = document.createElementNS('http://www.w3.org/2000/svg', 'marker');
15588 var id = Util.uniqueId('marker_');
15589 el.setAttribute('id', id);
15590 this.__cfg = { el: el, id: id, stroke: stroke || '#000' };
15591 this.__cfg[name] = true;
15592 var child = null;
15593 if (typeof cfg === 'boolean' && cfg) {
15594 child = setDefaultPath(el, name, stroke);
15595 this._setChild(child, true);
15596 } else if ((typeof cfg === 'undefined' ? 'undefined' : _typeof(cfg)) === 'object') {
15597 child = setMarker(cfg, el, name, stroke);
15598 this._setChild(child, false);
15599 }
15600 this.__attrs = { config: cfg };
15601 return this;
15602};
15603
15604Util.augment(Arrow, {
15605 type: 'arrow',
15606 match: function match(type, attr) {
15607 if (!this.__cfg[type]) {
15608 return false;
15609 }
15610 if (_typeof(attr.value) === 'object') {
15611 return false;
15612 }
15613 if (attr.stroke !== '#000') {
15614 return false;
15615 }
15616 if (typeof attr.value === 'boolean' && !this.__cfg.default) {
15617 return false;
15618 }
15619 return true;
15620 },
15621 _setChild: function _setChild(child, isDefault) {
15622 this.__cfg.child = child;
15623 this.__cfg.default = isDefault;
15624 },
15625 update: function update(fill) {
15626 var child = this.__cfg.child;
15627 this.__cfg.default = false;
15628 if (child.attr) {
15629 child.attr('fill', fill);
15630 } else {
15631 child.setAttribute('fill', fill);
15632 }
15633 }
15634});
15635
15636module.exports = Arrow;
15637
15638/***/ }),
15639/* 109 */
15640/***/ (function(module, exports, __webpack_require__) {
15641
15642/**
15643 * Created by Elaine on 2018/5/14.
15644 */
15645var Util = __webpack_require__(0);
15646
15647var Clip = function Clip(cfg) {
15648 var el = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');
15649 var id = Util.uniqueId('clip_');
15650 if (cfg.get('el')) {
15651 el.appendChild(cfg.get('el'));
15652 } else if (Util.isString(cfg.nodeName)) {
15653 el.appendChild(cfg);
15654 } else {
15655 throw 'clip element should be a instance of Shape or a SVG node';
15656 }
15657 el.setAttribute('id', id);
15658 this.__cfg = { el: el, id: id };
15659 this.__attrs = { config: cfg };
15660 return this;
15661};
15662
15663Util.augment(Clip, {
15664 type: 'clip',
15665 match: function match() {
15666 return false;
15667 }
15668});
15669
15670module.exports = Clip;
15671
15672/***/ }),
15673/* 110 */
15674/***/ (function(module, exports, __webpack_require__) {
15675
15676module.exports = {
15677 Canvas: __webpack_require__(111),
15678 Group: __webpack_require__(54),
15679 Shape: __webpack_require__(1),
15680 Rect: __webpack_require__(25),
15681 Circle: __webpack_require__(56),
15682 Ellipse: __webpack_require__(57),
15683 Path: __webpack_require__(58),
15684 Text: __webpack_require__(59),
15685 Line: __webpack_require__(60),
15686 Image: __webpack_require__(61),
15687 Polygon: __webpack_require__(62),
15688 Polyline: __webpack_require__(63),
15689 Arc: __webpack_require__(64),
15690 Fan: __webpack_require__(65),
15691 Cubic: __webpack_require__(66),
15692 Quadratic: __webpack_require__(67),
15693 Marker: __webpack_require__(27),
15694 PathSegment: __webpack_require__(26),
15695 Event: __webpack_require__(53)
15696};
15697
15698/***/ }),
15699/* 111 */
15700/***/ (function(module, exports, __webpack_require__) {
15701
15702var Util = __webpack_require__(0);
15703var Event = __webpack_require__(53);
15704var Group = __webpack_require__(54);
15705
15706var Canvas = function Canvas(cfg) {
15707 Canvas.superclass.constructor.call(this, cfg);
15708};
15709
15710Canvas.CFG = {
15711 eventEnable: true,
15712 /**
15713 * 像素宽度
15714 * @type {Number}
15715 */
15716 width: null,
15717 /**
15718 * 像素高度
15719 * @type {Number}
15720 */
15721 height: null,
15722 /**
15723 * 画布宽度
15724 * @type {Number}
15725 */
15726 widthCanvas: null,
15727 /**
15728 * 画布高度
15729 * @type {Number}
15730 */
15731 heightCanvas: null,
15732 /**
15733 * CSS宽
15734 * @type {String}
15735 */
15736 widthStyle: null,
15737 /**
15738 * CSS高
15739 * @type {String}
15740 */
15741 heightStyle: null,
15742 /**
15743 * 容器DOM
15744 * @type {Object}
15745 */
15746 containerDOM: null,
15747 /**
15748 * 当前Canvas的DOM
15749 * @type {Object}
15750 */
15751 canvasDOM: null,
15752 /**
15753 * 屏幕像素比
15754 * @type {Number}
15755 */
15756 pixelRatio: null
15757};
15758
15759Util.extend(Canvas, Group);
15760
15761Util.augment(Canvas, {
15762 init: function init() {
15763 Canvas.superclass.init.call(this);
15764 this._setGlobalParam();
15765 this._setDOM();
15766 this._setInitSize();
15767 this._setCanvas();
15768 this._scale();
15769 if (this.get('eventEnable')) {
15770 this._registEvents();
15771 }
15772 },
15773 getEmitter: function getEmitter(element, event) {
15774 if (element) {
15775 if (Util.isEmpty(element._getEvents())) {
15776 var parent = element.get('parent');
15777 if (parent && !event.propagationStopped) {
15778 return this.getEmitter(parent, event);
15779 }
15780 } else {
15781 return element;
15782 }
15783 }
15784 },
15785 _getEventObj: function _getEventObj(type, e, point, target) {
15786 var event = new Event(type, e, true, true);
15787 event.x = point.x;
15788 event.y = point.y;
15789 event.clientX = e.clientX;
15790 event.clientY = e.clientY;
15791 event.currentTarget = target;
15792 event.target = target;
15793 return event;
15794 },
15795 _triggerEvent: function _triggerEvent(type, e) {
15796 var point = this.getPointByClient(e.clientX, e.clientY);
15797 var shape = this.getShape(point.x, point.y);
15798 var emitObj = void 0;
15799 if (type === 'mousemove') {
15800 var preShape = this.get('preShape');
15801 if (preShape && preShape !== shape) {
15802 var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
15803 emitObj = this.getEmitter(preShape, e);
15804 emitObj && emitObj.emit('mouseleave', mouseleave);
15805 }
15806
15807 if (shape) {
15808 var mousemove = this._getEventObj('mousemove', e, point, shape);
15809 emitObj = this.getEmitter(shape, e);
15810 emitObj && emitObj.emit('mousemove', mousemove);
15811
15812 if (preShape !== shape) {
15813 var mouseenter = this._getEventObj('mouseenter', e, point, shape);
15814 emitObj && emitObj.emit('mouseenter', mouseenter, e);
15815 }
15816 } else {
15817 var canvasmousemove = this._getEventObj('mousemove', e, point, this);
15818 this.emit('mousemove', canvasmousemove);
15819 }
15820
15821 this.set('preShape', shape);
15822 } else {
15823 var event = this._getEventObj(type, e, point, shape || this);
15824 emitObj = this.getEmitter(shape, e);
15825 if (emitObj && emitObj !== this) {
15826 emitObj.emit(type, event);
15827 }
15828 this.emit(type, event);
15829 }
15830
15831 var el = this.get('el');
15832 if (shape && !shape.get('destroyed')) {
15833 el.style.cursor = shape.attr('cursor') || 'default';
15834 }
15835 },
15836 _registEvents: function _registEvents() {
15837 var self = this;
15838 var el = self.get('el');
15839 var events = ['mouseout', 'mouseover', 'mousemove', 'mousedown', 'mouseup', 'click', 'dblclick'];
15840
15841 Util.each(events, function (event) {
15842 el.addEventListener(event, function (e) {
15843 self._triggerEvent(event, e);
15844 }, false);
15845 });
15846 el.addEventListener('touchstart', function (e) {
15847 if (!Util.isEmpty(e.touches)) {
15848 self._triggerEvent('touchstart', e.touches[0]);
15849 }
15850 }, false);
15851
15852 el.addEventListener('touchmove', function (e) {
15853 if (!Util.isEmpty(e.touches)) {
15854 self._triggerEvent('touchmove', e.touches[0]);
15855 }
15856 }, false);
15857
15858 el.addEventListener('touchend', function (e) {
15859 if (!Util.isEmpty(e.changedTouches)) {
15860 self._triggerEvent('touchend', e.changedTouches[0]);
15861 }
15862 }, false);
15863 },
15864 _scale: function _scale() {
15865 var pixelRatio = this.get('pixelRatio');
15866 this.scale(pixelRatio, pixelRatio);
15867 },
15868 _setCanvas: function _setCanvas() {
15869 var canvasDOM = this.get('canvasDOM');
15870 this.set('el', canvasDOM);
15871 this.set('context', canvasDOM.getContext('2d'));
15872 this.set('canvas', this);
15873 },
15874 _setGlobalParam: function _setGlobalParam() {
15875 var pixelRatio = this.get('pixelRatio');
15876 if (!pixelRatio) {
15877 this.set('pixelRatio', Util.getRatio());
15878 }
15879 return;
15880 },
15881 _setDOM: function _setDOM() {
15882 this._setContainer();
15883 this._setLayer();
15884 },
15885 _setContainer: function _setContainer() {
15886 var containerId = this.get('containerId');
15887 var containerDOM = this.get('containerDOM');
15888 if (!containerDOM) {
15889 containerDOM = document.getElementById(containerId);
15890 this.set('containerDOM', containerDOM);
15891 }
15892 Util.modifyCSS(containerDOM, {
15893 position: 'relative'
15894 });
15895 },
15896 _setLayer: function _setLayer() {
15897 var containerDOM = this.get('containerDOM');
15898 var canvasId = Util.uniqueId('canvas_');
15899 if (containerDOM) {
15900 var canvasDOM = Util.createDom('<canvas id="' + canvasId + '"></canvas>');
15901 containerDOM.appendChild(canvasDOM);
15902 this.set('canvasDOM', canvasDOM);
15903 }
15904 },
15905 _setInitSize: function _setInitSize() {
15906 this.changeSize(this.get('width'), this.get('height'));
15907 },
15908 _resize: function _resize() {
15909 var canvasDOM = this.get('canvasDOM');
15910 var widthCanvas = this.get('widthCanvas');
15911 var heightCanvas = this.get('heightCanvas');
15912 var widthStyle = this.get('widthStyle');
15913 var heightStyle = this.get('heightStyle');
15914
15915 canvasDOM.style.width = widthStyle;
15916 canvasDOM.style.height = heightStyle;
15917 canvasDOM.setAttribute('width', widthCanvas);
15918 canvasDOM.setAttribute('height', heightCanvas);
15919 },
15920 getWidth: function getWidth() {
15921 var pixelRatio = this.get('pixelRatio');
15922 var width = this.get('width');
15923 return width * pixelRatio;
15924 },
15925 getHeight: function getHeight() {
15926 var pixelRatio = this.get('pixelRatio');
15927 var height = this.get('height');
15928 return height * pixelRatio;
15929 },
15930 changeSize: function changeSize(width, height) {
15931 var pixelRatio = this.get('pixelRatio');
15932 var widthCanvas = width * pixelRatio;
15933 var heightCanvas = height * pixelRatio;
15934
15935 this.set('widthCanvas', widthCanvas);
15936 this.set('heightCanvas', heightCanvas);
15937 this.set('widthStyle', width + 'px');
15938 this.set('heightStyle', height + 'px');
15939 this.set('width', width);
15940 this.set('height', height);
15941 this._resize();
15942 },
15943
15944 /**
15945 * 将窗口坐标转变成 canvas 坐标
15946 * @param {Number} clientX 窗口x坐标
15947 * @param {Number} clientY 窗口y坐标
15948 * @return {Object} canvas坐标
15949 */
15950 getPointByClient: function getPointByClient(clientX, clientY) {
15951 var el = this.get('el');
15952 var bbox = el.getBoundingClientRect();
15953 var width = bbox.right - bbox.left;
15954 var height = bbox.bottom - bbox.top;
15955 return {
15956 x: (clientX - bbox.left) * (el.width / width),
15957 y: (clientY - bbox.top) * (el.height / height)
15958 };
15959 },
15960 getClientByPoint: function getClientByPoint(x, y) {
15961 var el = this.get('el');
15962 var bbox = el.getBoundingClientRect();
15963 var width = bbox.right - bbox.left;
15964 var height = bbox.bottom - bbox.top;
15965 return {
15966 clientX: x / (el.width / width) + bbox.left,
15967 clientY: y / (el.height / height) + bbox.top
15968 };
15969 },
15970 beforeDraw: function beforeDraw() {
15971 var context = this.get('context');
15972 var el = this.get('el');
15973 context && context.clearRect(0, 0, el.width, el.height);
15974 },
15975 _beginDraw: function _beginDraw() {
15976 this.setSilent('toDraw', true);
15977 },
15978 _endDraw: function _endDraw() {
15979 this.setSilent('toDraw', false);
15980 },
15981 draw: function draw() {
15982 var self = this;
15983 function drawInner() {
15984 self.setSilent('animateHandler', Util.requestAnimationFrame(function () {
15985 self.setSilent('animateHandler', undefined);
15986 if (self.get('toDraw')) {
15987 drawInner();
15988 }
15989 }));
15990 self.beforeDraw();
15991 try {
15992 var context = self.get('context');
15993 Canvas.superclass.draw.call(self, context);
15994 // self._drawCanvas();
15995 } catch (ev) {
15996 // 绘制时异常,中断重绘
15997 console.warn('error in draw canvas, detail as:');
15998 console.warn(ev);
15999 self._endDraw();
16000 }
16001 self._endDraw();
16002 }
16003
16004 if (self.get('destroyed')) {
16005 return;
16006 }
16007 if (self.get('animateHandler')) {
16008 this._beginDraw();
16009 } else {
16010 drawInner();
16011 }
16012 },
16013 destroy: function destroy() {
16014 var containerDOM = this.get('containerDOM');
16015 var canvasDOM = this.get('canvasDOM');
16016 if (canvasDOM && containerDOM) {
16017 containerDOM.removeChild(canvasDOM);
16018 }
16019 Canvas.superclass.destroy.call(this);
16020 }
16021});
16022
16023module.exports = Canvas;
16024
16025/***/ }),
16026/* 112 */
16027/***/ (function(module, exports, __webpack_require__) {
16028
16029var Util = __webpack_require__(0);
16030
16031var ALIAS_ATTRS = ['strokeStyle', 'fillStyle', 'globalAlpha'];
16032var CLIP_SHAPES = ['circle', 'ellipse', 'fan', 'polygon', 'rect', 'path'];
16033var CAPITALIZED_ATTRS_MAP = {
16034 r: 'R',
16035 opacity: 'Opacity',
16036 lineWidth: 'LineWidth',
16037 clip: 'Clip',
16038 stroke: 'Stroke',
16039 fill: 'Fill',
16040 strokeOpacity: 'Stroke',
16041 fillOpacity: 'Fill',
16042 x: 'X',
16043 y: 'Y',
16044 rx: 'Rx',
16045 ry: 'Ry',
16046 re: 'Re',
16047 rs: 'Rs',
16048 width: 'Width',
16049 height: 'Height',
16050 img: 'Img',
16051 x1: 'X1',
16052 x2: 'X2',
16053 y1: 'Y1',
16054 y2: 'Y2',
16055 points: 'Points',
16056 p1: 'P1',
16057 p2: 'P2',
16058 p3: 'P3',
16059 p4: 'P4',
16060 text: 'Text',
16061 radius: 'Radius',
16062 textAlign: 'TextAlign',
16063 textBaseline: 'TextBaseline',
16064 font: 'Font',
16065 fontSize: 'FontSize',
16066 fontStyle: 'FontStyle',
16067 fontVariant: 'FontVariant',
16068 fontWeight: 'FontWeight',
16069 fontFamily: 'FontFamily',
16070 clockwise: 'Clockwise',
16071 startAngle: 'StartAngle',
16072 endAngle: 'EndAngle',
16073 path: 'Path'
16074};
16075var ALIAS_ATTRS_MAP = {
16076 stroke: 'strokeStyle',
16077 fill: 'fillStyle',
16078 opacity: 'globalAlpha'
16079};
16080
16081module.exports = {
16082 canFill: false,
16083 canStroke: false,
16084 initAttrs: function initAttrs(attrs) {
16085 this.__attrs = {
16086 opacity: 1,
16087 fillOpacity: 1,
16088 strokeOpacity: 1
16089 };
16090 this.attr(Util.assign(this.getDefaultAttrs(), attrs));
16091 return this;
16092 },
16093 getDefaultAttrs: function getDefaultAttrs() {
16094 return {};
16095 },
16096
16097 /**
16098 * 设置或者设置属性,有以下 4 种情形:
16099 * - name 不存在, 则返回属性集合
16100 * - name 为字符串,value 为空,获取属性值
16101 * - name 为字符串,value 不为空,设置属性值,返回 this
16102 * - name 为键值对,value 为空,设置属性值
16103 *
16104 * @param {String | Object} name 属性名
16105 * @param {*} value 属性值
16106 * @return {*} 属性值
16107 */
16108 attr: function attr(name, value) {
16109 var self = this;
16110 if (arguments.length === 0) {
16111 return self.__attrs;
16112 }
16113
16114 if (Util.isObject(name)) {
16115 for (var k in name) {
16116 if (ALIAS_ATTRS.indexOf(k) === -1) {
16117 var v = name[k];
16118 self._setAttr(k, v);
16119 }
16120 }
16121 if (self._afterSetAttrAll) {
16122 self._afterSetAttrAll(name);
16123 }
16124 // self.setSilent('box', null);
16125 self.clearBBox();
16126 return self;
16127 }
16128 if (arguments.length === 2) {
16129 if (self._setAttr(name, value) !== false) {
16130 var m = '_afterSetAttr' + CAPITALIZED_ATTRS_MAP[name];
16131 if (self[m]) {
16132 self[m](value);
16133 }
16134 }
16135 // self.setSilent('box', null);
16136 self.clearBBox();
16137 return self;
16138 }
16139 return self._getAttr(name);
16140 },
16141 clearBBox: function clearBBox() {
16142 this.setSilent('box', null);
16143 },
16144 _afterSetAttrAll: function _afterSetAttrAll() {},
16145
16146 // 属性获取触发函数
16147 _getAttr: function _getAttr(name) {
16148 return this.__attrs[name];
16149 },
16150
16151 // 属性设置触发函数
16152 _setAttr: function _setAttr(name, value) {
16153 var self = this;
16154 if (name === 'clip') {
16155 self._setAttrClip(value);
16156 self.__attrs.clip = value;
16157 } else if (name === 'transform') {
16158 self._setAttrTrans(value);
16159 } else {
16160 self.__attrs[name] = value;
16161 var alias = ALIAS_ATTRS_MAP[name];
16162 if (alias) {
16163 self.__attrs[alias] = value;
16164 }
16165 }
16166 return self;
16167 },
16168 hasFill: function hasFill() {
16169 return this.canFill && this.__attrs.fillStyle;
16170 },
16171 hasStroke: function hasStroke() {
16172 return this.canStroke && this.__attrs.strokeStyle;
16173 },
16174
16175 // 设置透明度
16176 _setAttrOpacity: function _setAttrOpacity(v) {
16177 this.__attrs.globalAlpha = v;
16178 return v;
16179 },
16180 _setAttrClip: function _setAttrClip(clip) {
16181 var self = this;
16182 if (clip && CLIP_SHAPES.indexOf(clip.type) > -1) {
16183 if (clip.get('canvas') === null) {
16184 clip = Util.clone(clip);
16185 }
16186 clip.set('parent', self.get('parent'));
16187 clip.set('canvas', self.get('canvas'));
16188 clip.set('context', self.get('context'));
16189 clip.inside = function (x, y) {
16190 var v = [x, y, 1];
16191 clip.invert(v, self.get('canvas')); // 已经在外面转换
16192 return clip._isPointInFill(v[0], v[1]);
16193 };
16194 return clip;
16195 }
16196 return null;
16197 },
16198 _setAttrTrans: function _setAttrTrans(value) {
16199 return this.transform(value);
16200 }
16201};
16202
16203/***/ }),
16204/* 113 */
16205/***/ (function(module, exports, __webpack_require__) {
16206
16207var Util = __webpack_require__(0);
16208var mat3 = __webpack_require__(2).mat3;
16209var vec3 = __webpack_require__(2).vec3;
16210
16211// 是否未改变
16212function isUnchanged(m) {
16213 return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
16214}
16215
16216// 是否仅仅是scale
16217function isScale(m) {
16218 return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;
16219}
16220
16221function multiple(m1, m2) {
16222 if (!isUnchanged(m2)) {
16223 if (isScale(m2)) {
16224 m1[0] *= m2[0];
16225 m1[4] *= m2[4];
16226 } else {
16227 mat3.multiply(m1, m1, m2);
16228 }
16229 }
16230}
16231
16232module.exports = {
16233 initTransform: function initTransform() {
16234 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
16235 },
16236 translate: function translate(tx, ty) {
16237 var matrix = this.attr('matrix');
16238 mat3.translate(matrix, matrix, [tx, ty]);
16239 this.clearTotalMatrix();
16240 this.attr('matrix', matrix);
16241 return this;
16242 },
16243 rotate: function rotate(radian) {
16244 var matrix = this.attr('matrix');
16245 mat3.rotate(matrix, matrix, radian);
16246 this.clearTotalMatrix();
16247 this.attr('matrix', matrix);
16248 return this;
16249 },
16250 scale: function scale(s1, s2) {
16251 var matrix = this.attr('matrix');
16252 mat3.scale(matrix, matrix, [s1, s2]);
16253 this.clearTotalMatrix();
16254 this.attr('matrix', matrix);
16255 return this;
16256 },
16257
16258 /**
16259 * 绕起始点旋转
16260 * @param {Number} rotate 0~360
16261 */
16262 rotateAtStart: function rotateAtStart(rotate) {
16263 var x = this.attr('x');
16264 var y = this.attr('y');
16265 if (Math.abs(rotate) > Math.PI * 2) {
16266 rotate = rotate / 180 * Math.PI;
16267 }
16268 this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);
16269 },
16270
16271 /**
16272 * 移动的到位置
16273 * @param {Number} x 移动到x
16274 * @param {Number} y 移动到y
16275 */
16276 move: function move(x, y) {
16277 var cx = this.get('x') || 0; // 当前的x
16278 var cy = this.get('y') || 0; // 当前的y
16279 this.translate(x - cx, y - cy);
16280 this.set('x', x);
16281 this.set('y', y);
16282 },
16283 transform: function transform(ts) {
16284 var self = this;
16285 var matrix = self.attr('matrix');
16286
16287 Util.each(ts, function (t) {
16288 switch (t[0]) {
16289 case 't':
16290 self.translate(t[1], t[2]);
16291 break;
16292 case 's':
16293 self.scale(t[1], t[2]);
16294 break;
16295 case 'r':
16296 self.rotate(t[1]);
16297 break;
16298 case 'm':
16299 self.attr('matrix', mat3.multiply([], matrix, t[1]));
16300 self.clearTotalMatrix();
16301 break;
16302 default:
16303 break;
16304 }
16305 });
16306 return self;
16307 },
16308 setTransform: function setTransform(ts) {
16309 this.attr('matrix', [1, 0, 0, 0, 1, 0, 0, 0, 1]);
16310 return this.transform(ts);
16311 },
16312 getMatrix: function getMatrix() {
16313 return this.attr('matrix');
16314 },
16315 setMatrix: function setMatrix(m) {
16316 this.attr('matrix', m);
16317 this.clearTotalMatrix();
16318 return this;
16319 },
16320 apply: function apply(v, root) {
16321 var m = void 0;
16322 if (root) {
16323 m = this._getMatrixByRoot(root);
16324 } else {
16325 m = this.attr('matrix');
16326 }
16327 vec3.transformMat3(v, v, m);
16328 return this;
16329 },
16330
16331 // 获取到达指定根节点的矩阵
16332 _getMatrixByRoot: function _getMatrixByRoot(root) {
16333 var self = this;
16334 root = root || self;
16335 var parent = self;
16336 var parents = [];
16337
16338 while (parent !== root) {
16339 parents.unshift(parent);
16340 parent = parent.get('parent');
16341 }
16342 parents.unshift(parent);
16343
16344 var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
16345 Util.each(parents, function (child) {
16346 mat3.multiply(m, child.attr('matrix'), m);
16347 });
16348 return m;
16349 },
16350
16351 /**
16352 * 应用到当前元素上的总的矩阵
16353 * @return {Matrix} 矩阵
16354 */
16355 getTotalMatrix: function getTotalMatrix() {
16356 var m = this.__cfg.totalMatrix;
16357 if (!m) {
16358 m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
16359 var parent = this.__cfg.parent;
16360 if (parent) {
16361 var pm = parent.getTotalMatrix();
16362 multiple(m, pm);
16363 }
16364
16365 multiple(m, this.attr('matrix'));
16366 this.__cfg.totalMatrix = m;
16367 }
16368 return m;
16369 },
16370
16371 // 清除当前的矩阵
16372 clearTotalMatrix: function clearTotalMatrix() {
16373 // this.__cfg.totalMatrix = null;
16374 },
16375 invert: function invert(v) {
16376 var m = this.getTotalMatrix();
16377 // 单精屏幕下大多数矩阵没变化
16378 if (isScale(m)) {
16379 v[0] /= m[0];
16380 v[1] /= m[4];
16381 } else {
16382 var inm = mat3.invert([], m);
16383 if (inm) {
16384 vec3.transformMat3(v, v, inm);
16385 }
16386 }
16387 return this;
16388 },
16389 resetTransform: function resetTransform(context) {
16390 var mo = this.attr('matrix');
16391 // 不改变时
16392 if (!isUnchanged(mo)) {
16393 context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);
16394 }
16395 }
16396};
16397
16398/***/ }),
16399/* 114 */
16400/***/ (function(module, exports, __webpack_require__) {
16401
16402var Shape = __webpack_require__(1);
16403Shape.Rect = __webpack_require__(25);
16404Shape.Rect = __webpack_require__(25);
16405Shape.Circle = __webpack_require__(56);
16406Shape.Ellipse = __webpack_require__(57);
16407Shape.Path = __webpack_require__(58);
16408Shape.Text = __webpack_require__(59);
16409Shape.Line = __webpack_require__(60);
16410Shape.Image = __webpack_require__(61);
16411Shape.Polygon = __webpack_require__(62);
16412Shape.Polyline = __webpack_require__(63);
16413Shape.Arc = __webpack_require__(64);
16414Shape.Fan = __webpack_require__(65);
16415Shape.Cubic = __webpack_require__(66);
16416Shape.Quadratic = __webpack_require__(67);
16417Shape.Marker = __webpack_require__(27);
16418
16419module.exports = Shape;
16420
16421/***/ }),
16422/* 115 */
16423/***/ (function(module, exports) {
16424
16425module.exports = {
16426 xAt: function xAt(psi, rx, ry, cx, t) {
16427 return rx * Math.cos(psi) * Math.cos(t) - ry * Math.sin(psi) * Math.sin(t) + cx;
16428 },
16429 yAt: function yAt(psi, rx, ry, cy, t) {
16430 return rx * Math.sin(psi) * Math.cos(t) + ry * Math.cos(psi) * Math.sin(t) + cy;
16431 },
16432 xExtrema: function xExtrema(psi, rx, ry) {
16433 return Math.atan(-ry / rx * Math.tan(psi));
16434 },
16435 yExtrema: function yExtrema(psi, rx, ry) {
16436 return Math.atan(ry / (rx * Math.tan(psi)));
16437 }
16438};
16439
16440/***/ }),
16441/* 116 */
16442/***/ (function(module, exports, __webpack_require__) {
16443
16444
16445module.exports = {
16446 getWrapBehavior: __webpack_require__(117),
16447 wrapBehavior: __webpack_require__(118)
16448};
16449
16450/***/ }),
16451/* 117 */
16452/***/ (function(module, exports) {
16453
16454/**
16455 * 获取封装的事件
16456 * @protected
16457 * @param {Object} obj 对象
16458 * @param {String} action 事件名称
16459 * @return {Function} 返回事件处理函数
16460 */
16461function getWrapBehavior(obj, action) {
16462 return obj['_wrap_' + action];
16463}
16464
16465module.exports = getWrapBehavior;
16466
16467/***/ }),
16468/* 118 */
16469/***/ (function(module, exports) {
16470
16471/**
16472 * 封装事件,便于使用上下文this,和便于解除事件时使用
16473 * @protected
16474 * @param {Object} obj 对象
16475 * @param {String} action 事件名称
16476 * @return {Function} 返回事件处理函数
16477 */
16478function wrapBehavior(obj, action) {
16479 if (obj['_wrap_' + action]) {
16480 return obj['_wrap_' + action];
16481 }
16482 var method = function method(e) {
16483 obj[action](e);
16484 };
16485 obj['_wrap_' + action] = method;
16486 return method;
16487}
16488
16489module.exports = wrapBehavior;
16490
16491/***/ }),
16492/* 119 */
16493/***/ (function(module, exports, __webpack_require__) {
16494
16495function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16496
16497function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
16498
16499function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
16500
16501var Util = __webpack_require__(10);
16502var Interaction = __webpack_require__(9);
16503// const G2 = require('../core.js');
16504
16505var BRUSH_TYPES = ['X', 'Y', 'XY', 'POLYGON'];
16506var DEFAULT_TYPE = 'XY';
16507
16508var Brush = function (_Interaction) {
16509 _inherits(Brush, _Interaction);
16510
16511 Brush.prototype.getDefaultCfg = function getDefaultCfg() {
16512 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
16513 return Util.mix({}, cfg, {
16514 type: DEFAULT_TYPE,
16515 startPoint: null,
16516 brushing: false,
16517 dragging: false,
16518 brushShape: null,
16519 container: null,
16520 polygonPath: null,
16521 style: {
16522 fill: '#C5D4EB',
16523 opacity: 0.3,
16524 lineWidth: 1,
16525 stroke: '#82A6DD'
16526 },
16527 draggable: false,
16528 dragOffX: 0,
16529 dragOffY: 0,
16530 inPlot: true,
16531 xField: null,
16532 yField: null
16533 });
16534 };
16535
16536 function Brush(cfg, view) {
16537 _classCallCheck(this, Brush);
16538
16539 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
16540
16541 var me = _this;
16542 me.filter = !me.draggable;
16543 me.type = me.type.toUpperCase();
16544 me.chart = view;
16545
16546 if (BRUSH_TYPES.indexOf(me.type) === -1) {
16547 me.type = DEFAULT_TYPE;
16548 }
16549 var canvas = me.canvas;
16550 if (canvas) {
16551 var plotRange = void 0;
16552 canvas.get('children').map(function (child) {
16553 if (child.get('type') === 'plotBack') {
16554 plotRange = child.get('plotRange');
16555 return false;
16556 }
16557 return child;
16558 });
16559 me.plot = {
16560 start: plotRange.bl,
16561 end: plotRange.tr
16562 };
16563 }
16564 if (view) {
16565 var coord = view.get('coord');
16566 me.plot = {
16567 start: coord.start,
16568 end: coord.end
16569 };
16570 var xScales = view._getScales('x');
16571 var yScales = view._getScales('y');
16572 me.xScale = me.xField ? xScales[me.xField] : view.getXScale();
16573 me.yScale = me.yField ? yScales[me.yField] : view.getYScales()[0];
16574 }
16575 return _this;
16576 }
16577
16578 // onBurshstart() { }
16579 // onBrushmove() { }
16580 // onBrushend() {}
16581 // onDragstart() {}
16582 // onDragmove() {}
16583 // onDragend() {}
16584
16585 Brush.prototype.start = function start(ev) {
16586 var me = this;
16587 var canvas = me.canvas,
16588 type = me.type,
16589 brushShape = me.brushShape;
16590
16591
16592 if (!type) return;
16593
16594 var startPoint = { x: ev.offsetX, y: ev.offsetY };
16595 if (!startPoint.x) return;
16596 var isInPlot = me.plot && me.inPlot;
16597 var canvasDOM = canvas.get('canvasDOM');
16598 var pixelRatio = canvas.get('pixelRatio');
16599
16600 if (me.selection) me.selection = null;
16601
16602 if (me.draggable && brushShape && !brushShape.get('destroyed')) {
16603 // allow drag the brushShape
16604 if (brushShape.isHit(startPoint.x * pixelRatio, startPoint.y * pixelRatio)) {
16605 canvasDOM.style.cursor = 'move';
16606 me.selection = brushShape;
16607 me.dragging = true;
16608 if (type === 'X') {
16609 me.dragoffX = startPoint.x - brushShape.attr('x');
16610 me.dragoffY = 0;
16611 } else if (type === 'Y') {
16612 me.dragoffX = 0;
16613 me.dragoffY = startPoint.y - brushShape.attr('y');
16614 } else if (type === 'XY') {
16615 me.dragoffX = startPoint.x - brushShape.attr('x');
16616 me.dragoffY = startPoint.y - brushShape.attr('y');
16617 } else if (type === 'POLYGON') {
16618 var box = brushShape.getBBox();
16619 me.dragoffX = startPoint.x - box.minX;
16620 me.dragoffY = startPoint.y - box.minY;
16621 }
16622
16623 if (isInPlot) {
16624 me.selection.attr('clip', canvas.addShape('rect', {
16625 attrs: {
16626 x: this.plot.start.x,
16627 y: this.plot.end.y,
16628 width: this.plot.end.x - this.plot.start.x,
16629 height: this.plot.start.y - this.plot.end.y,
16630 fill: '#fff',
16631 fillOpacity: 0
16632 }
16633 }));
16634 }
16635 me.onDragstart && me.onDragstart(ev);
16636 }
16637 me.prePoint = startPoint;
16638 }
16639
16640 if (!me.dragging) {
16641 // brush start
16642 me.onBrushstart && me.onBrushstart(startPoint);
16643 var container = me.container;
16644 if (isInPlot) {
16645 var _me$plot = me.plot,
16646 start = _me$plot.start,
16647 end = _me$plot.end;
16648
16649 if (startPoint.x < start.x || startPoint.x > end.x || startPoint.y < end.y || startPoint.y > start.y) return;
16650 }
16651 canvasDOM.style.cursor = 'crosshair';
16652 me.startPoint = startPoint;
16653 me.brushShape = null;
16654 me.brushing = true;
16655
16656 if (!container) {
16657 container = canvas.addGroup({
16658 zIndex: 5 // upper
16659 });
16660 container.initTransform();
16661 } else {
16662 container.clear();
16663 }
16664 me.container = container;
16665
16666 if (type === 'POLYGON') me.polygonPath = 'M ' + startPoint.x + ' ' + startPoint.y;
16667 }
16668 };
16669
16670 Brush.prototype.process = function process(ev) {
16671 var me = this;
16672 var brushing = me.brushing,
16673 dragging = me.dragging,
16674 type = me.type,
16675 plot = me.plot,
16676 startPoint = me.startPoint,
16677 xScale = me.xScale,
16678 yScale = me.yScale,
16679 canvas = me.canvas;
16680
16681
16682 if (!brushing && !dragging) {
16683 return;
16684 }
16685 var currentPoint = {
16686 x: ev.offsetX,
16687 y: ev.offsetY
16688 };
16689 var canvasDOM = canvas.get('canvasDOM');
16690
16691 if (brushing) {
16692 canvasDOM.style.cursor = 'crosshair';
16693 var start = plot.start,
16694 end = plot.end;
16695
16696 var polygonPath = me.polygonPath;
16697 var brushShape = me.brushShape;
16698 var container = me.container;
16699 if (me.plot && me.inPlot) {
16700 currentPoint = me._limitCoordScope(currentPoint);
16701 }
16702
16703 var rectStartX = void 0;
16704 var rectStartY = void 0;
16705 var rectWidth = void 0;
16706 var rectHeight = void 0;
16707
16708 if (type === 'Y') {
16709 rectStartX = start.x;
16710 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16711 rectWidth = Math.abs(start.x - end.x);
16712 rectHeight = Math.abs(startPoint.y - currentPoint.y);
16713 } else if (type === 'X') {
16714 rectStartX = currentPoint.x >= startPoint.x ? startPoint.x : currentPoint.x;
16715 rectStartY = end.y;
16716 rectWidth = Math.abs(startPoint.x - currentPoint.x);
16717 rectHeight = Math.abs(end.y - start.y);
16718 } else if (type === 'XY') {
16719 if (currentPoint.x >= startPoint.x) {
16720 rectStartX = startPoint.x;
16721 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16722 } else {
16723 rectStartX = currentPoint.x;
16724 rectStartY = currentPoint.y >= startPoint.y ? startPoint.y : currentPoint.y;
16725 }
16726 rectWidth = Math.abs(startPoint.x - currentPoint.x);
16727 rectHeight = Math.abs(startPoint.y - currentPoint.y);
16728 } else if (type === 'POLYGON') {
16729 polygonPath += 'L ' + currentPoint.x + ' ' + currentPoint.y;
16730 me.polygonPath = polygonPath;
16731 if (!brushShape) {
16732 brushShape = container.addShape('path', {
16733 attrs: Util.mix(me.style, {
16734 path: polygonPath
16735 })
16736 });
16737 } else {
16738 !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape.__attrs, {
16739 path: polygonPath
16740 }));
16741 }
16742 }
16743 if (type !== 'POLYGON') {
16744 if (!brushShape) {
16745 brushShape = container.addShape('rect', {
16746 attrs: Util.mix(me.style, {
16747 x: rectStartX,
16748 y: rectStartY,
16749 width: rectWidth,
16750 height: rectHeight
16751 })
16752 });
16753 } else {
16754 !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape.__attrs, {
16755 x: rectStartX,
16756 y: rectStartY,
16757 width: rectWidth,
16758 height: rectHeight
16759 }));
16760 }
16761 }
16762
16763 me.brushShape = brushShape;
16764 } else if (dragging) {
16765 canvasDOM.style.cursor = 'move';
16766 var selection = me.selection;
16767 if (selection && !selection.get('destroyed')) {
16768 if (type === 'POLYGON') {
16769 var prePoint = me.prePoint;
16770 me.selection.translate(currentPoint.x - prePoint.x, currentPoint.y - prePoint.y);
16771 } else {
16772 me.dragoffX && selection.attr('x', currentPoint.x - me.dragoffX);
16773 me.dragoffY && selection.attr('y', currentPoint.y - me.dragoffY);
16774 }
16775 }
16776 }
16777
16778 me.prePoint = currentPoint;
16779 canvas.draw();
16780
16781 var _me$_getSelected = me._getSelected(),
16782 data = _me$_getSelected.data,
16783 shapes = _me$_getSelected.shapes,
16784 xValues = _me$_getSelected.xValues,
16785 yValues = _me$_getSelected.yValues;
16786
16787 var eventObj = {
16788 data: data,
16789 shapes: shapes,
16790 x: currentPoint.x,
16791 y: currentPoint.y
16792 };
16793
16794 if (xScale) {
16795 eventObj[xScale.field] = xValues;
16796 }
16797 if (yScale) {
16798 eventObj[yScale.field] = yValues;
16799 }
16800 me.onDragmove && me.onDragmove(eventObj);
16801 me.onBrushmove && me.onBrushmove(eventObj);
16802 };
16803
16804 Brush.prototype.end = function end(ev) {
16805 var me = this;
16806 var data = me.data,
16807 shapes = me.shapes,
16808 xValues = me.xValues,
16809 yValues = me.yValues,
16810 canvas = me.canvas,
16811 type = me.type,
16812 startPoint = me.startPoint,
16813 chart = me.chart,
16814 container = me.container,
16815 xScale = me.xScale,
16816 yScale = me.yScale;
16817 var offsetX = ev.offsetX,
16818 offsetY = ev.offsetY;
16819
16820 var canvasDOM = canvas.get('canvasDOM');
16821 canvasDOM.style.cursor = 'default';
16822
16823 if (Math.abs(startPoint.x - offsetX) <= 1 && Math.abs(startPoint.y - offsetY) <= 1) {
16824 // 防止点击事件
16825 me.brushing = false;
16826 me.dragging = false;
16827 return;
16828 }
16829
16830 var eventObj = {
16831 data: data,
16832 shapes: shapes,
16833 x: offsetX,
16834 y: offsetY
16835 };
16836 if (xScale) {
16837 eventObj[xScale.field] = xValues;
16838 }
16839 if (yScale) {
16840 eventObj[yScale.field] = yValues;
16841 }
16842
16843 if (me.dragging) {
16844 me.dragging = false;
16845 me.onDragend && me.onDragend(eventObj);
16846 } else if (me.brushing) {
16847 me.brushing = false;
16848 var brushShape = me.brushShape;
16849 var polygonPath = me.polygonPath;
16850
16851 if (type === 'POLYGON') {
16852 polygonPath += 'z';
16853
16854 brushShape && !brushShape.get('destroyed') && brushShape.attr(Util.mix({}, brushShape.__attrs, {
16855 path: polygonPath
16856 }));
16857 me.polygonPath = polygonPath;
16858 canvas.draw();
16859 }
16860
16861 if (me.onBrushend) {
16862 me.onBrushend(eventObj);
16863 } else if (chart && me.filter) {
16864 container.clear(); // clear the brush
16865 // filter data
16866 if (type === 'X') {
16867 xScale && chart.filter(xScale.field, function (val) {
16868 return xValues.indexOf(val) > -1;
16869 });
16870 } else if (type === 'Y') {
16871 yScale && chart.filter(yScale.field, function (val) {
16872 return yValues.indexOf(val) > -1;
16873 });
16874 } else {
16875 xScale && chart.filter(xScale.field, function (val) {
16876 return xValues.indexOf(val) > -1;
16877 });
16878 yScale && chart.filter(yScale.field, function (val) {
16879 return yValues.indexOf(val) > -1;
16880 });
16881 }
16882 chart.repaint();
16883 }
16884 }
16885 };
16886
16887 Brush.prototype.reset = function reset() {
16888 var me = this;
16889 var chart = me.chart,
16890 filter = me.filter;
16891
16892 if (chart && filter) {
16893 chart.get('options').filters = {};
16894 chart.repaint();
16895 }
16896 };
16897
16898 Brush.prototype._limitCoordScope = function _limitCoordScope(point) {
16899 var plot = this.plot;
16900 var start = plot.start,
16901 end = plot.end;
16902
16903
16904 if (point.x < start.x) {
16905 point.x = start.x;
16906 }
16907 if (point.x > end.x) {
16908 point.x = end.x;
16909 }
16910 if (point.y < end.y) {
16911 point.y = end.y;
16912 }
16913 if (point.y > start.y) {
16914 point.y = start.y;
16915 }
16916 return point;
16917 };
16918
16919 Brush.prototype._getSelected = function _getSelected() {
16920 var me = this;
16921 var chart = me.chart,
16922 xScale = me.xScale,
16923 yScale = me.yScale,
16924 brushShape = me.brushShape,
16925 canvas = me.canvas;
16926
16927 var pixelRatio = canvas.get('pixelRatio');
16928 var selectedShapes = [];
16929 var xValues = [];
16930 var yValues = [];
16931 var selectedData = [];
16932 if (chart) {
16933 var geoms = chart.get('geoms');
16934 geoms.map(function (geom) {
16935 var shapes = geom.getShapes();
16936 shapes.map(function (shape) {
16937 var shapeData = shape.get('origin');
16938 if (!Array.isArray(shapeData)) {
16939 // 线图、区域图等
16940 shapeData = [shapeData];
16941 }
16942
16943 shapeData.map(function (each) {
16944 if (brushShape.isHit(each.x * pixelRatio, each.y * pixelRatio)) {
16945 selectedShapes.push(shape);
16946 var origin = each._origin;
16947 selectedData.push(origin);
16948 xScale && xValues.push(origin[xScale.field]);
16949 yScale && yValues.push(origin[yScale.field]);
16950 }
16951 return each;
16952 });
16953
16954 return shape;
16955 });
16956 return geom;
16957 });
16958 }
16959 me.shapes = selectedShapes;
16960 me.xValues = xValues;
16961 me.yValues = yValues;
16962 me.data = selectedData;
16963 return {
16964 data: selectedData,
16965 xValues: xValues,
16966 yValues: yValues,
16967 shapes: selectedShapes
16968 };
16969 };
16970
16971 return Brush;
16972}(Interaction);
16973
16974// G2.registerInteraction('brush', Brush);
16975// G2.registerInteraction('Brush', Brush);
16976
16977module.exports = Brush;
16978
16979/***/ }),
16980/* 120 */
16981/***/ (function(module, exports, __webpack_require__) {
16982
16983function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
16984
16985function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
16986
16987function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
16988
16989var Util = __webpack_require__(10);
16990var Interaction = __webpack_require__(9);
16991// const G2 = require('../core.js');
16992
16993var DRAGGING_TYPES = ['X', 'Y', 'XY'];
16994var DEFAULT_TYPE = 'X';
16995
16996var Drag = function (_Interaction) {
16997 _inherits(Drag, _Interaction);
16998
16999 Drag.prototype.getDefaultCfg = function getDefaultCfg() {
17000 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
17001 return Util.mix({}, cfg, {
17002 type: DEFAULT_TYPE,
17003 stepRatio: 0.05,
17004 stepByField: {},
17005 originScaleDefsByField: {},
17006 previousPoint: null,
17007 isDragging: false
17008 });
17009 };
17010
17011 function Drag(cfg, view) {
17012 _classCallCheck(this, Drag);
17013
17014 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
17015
17016 var me = _this;
17017 me.type = me.type.toUpperCase();
17018 me.chart = view;
17019
17020 var scales = view.getYScales();
17021 var xScale = view.getXScale();
17022 scales.push(xScale);
17023 var scaleController = view.get('scaleController');
17024 scales.forEach(function (scale) {
17025 var field = scale.field;
17026 var def = scaleController.defs[field];
17027 me.originScaleDefsByField[field] = Util.mix(def, {
17028 nice: !!def.nice
17029 });
17030 if (scale.isLinear) {
17031 me.stepByField[field] = (scale.max - scale.min) * me.stepRatio;
17032 }
17033 });
17034
17035 if (DRAGGING_TYPES.indexOf(me.type) === -1) {
17036 me.type = DEFAULT_TYPE;
17037 }
17038 return _this;
17039 }
17040
17041 // onDragstart() { }
17042 // onDrag() { }
17043 // onDragend() { }
17044
17045 Drag.prototype._applyTranslate = function _applyTranslate(scale) {
17046 var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
17047
17048 var me = this;
17049 var chart = me.chart;
17050 var min = scale.min,
17051 max = scale.max,
17052 field = scale.field;
17053
17054 var range = max - min;
17055 chart.scale(field, {
17056 nice: false,
17057 min: min - offset * range,
17058 max: max - offset * range
17059 });
17060 };
17061
17062 Drag.prototype.start = function start(ev) {
17063 var me = this;
17064 var chart = me.chart,
17065 canvas = me.canvas;
17066
17067 var canvasDOM = canvas.get('canvasDOM');
17068 canvasDOM.style.cursor = 'pointer';
17069 var coord = chart.get('coord');
17070 me.isDragging = true;
17071 me.previousPoint = coord.invertPoint(ev);
17072 };
17073
17074 Drag.prototype.process = function process(ev) {
17075 var me = this;
17076 if (me.isDragging) {
17077 var chart = me.chart,
17078 type = me.type,
17079 canvas = me.canvas;
17080
17081 var canvasDOM = canvas.get('canvasDOM');
17082 canvasDOM.style.cursor = 'move';
17083 var coord = chart.get('coord');
17084 var previousPoint = me.previousPoint;
17085 var currentPoint = coord.invertPoint(ev);
17086 if (type.indexOf('X') > -1) {
17087 me._applyTranslate(chart.getXScale(), currentPoint.x - previousPoint.x);
17088 }
17089 if (type.indexOf('Y') > -1) {
17090 var yScales = chart.getYScales();
17091 yScales.forEach(function (yScale) {
17092 me._applyTranslate(yScale, currentPoint.y - previousPoint.y);
17093 });
17094 }
17095 me.previousPoint = currentPoint;
17096 chart.repaint();
17097 }
17098 };
17099
17100 Drag.prototype.end = function end() {
17101 var me = this;
17102 me.isDragging = false;
17103 var canvas = me.canvas;
17104
17105 var canvasDOM = canvas.get('canvasDOM');
17106 canvasDOM.style.cursor = 'default';
17107 };
17108
17109 Drag.prototype.reset = function reset() {
17110 var me = this;
17111 var view = me.view,
17112 originScaleDefsByField = me.originScaleDefsByField;
17113
17114 var scales = view.getYScales();
17115 var xScale = view.getXScale();
17116 scales.push(xScale);
17117 scales.forEach(function (scale) {
17118 if (scale.isLinear) {
17119 var field = scale.field;
17120 view.scale(field, originScaleDefsByField[field]);
17121 }
17122 });
17123 view.repaint();
17124 };
17125
17126 return Drag;
17127}(Interaction);
17128
17129// G2.registerInteraction('drag', Drag);
17130// G2.registerInteraction('Drag', Drag);
17131
17132module.exports = Drag;
17133
17134/***/ }),
17135/* 121 */
17136/***/ (function(module, exports, __webpack_require__) {
17137
17138function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17139
17140function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
17141
17142function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
17143
17144var Util = __webpack_require__(10);
17145var Interaction = __webpack_require__(9);
17146// const G2 = require('../core.js');
17147
17148var ZOOMING_TYPES = ['X', 'Y', 'XY'];
17149var DEFAULT_TYPE = 'X';
17150
17151// TODO zoom with center point
17152
17153var Zoom = function (_Interaction) {
17154 _inherits(Zoom, _Interaction);
17155
17156 Zoom.prototype.getDefaultCfg = function getDefaultCfg() {
17157 var cfg = _Interaction.prototype.getDefaultCfg.call(this);
17158 return Util.mix({}, cfg, {
17159 processEvent: 'mousewheel',
17160 type: DEFAULT_TYPE,
17161 stepRatio: 0.05,
17162 stepByField: {},
17163 originScaleDefsByField: {}
17164 });
17165 };
17166
17167 function Zoom(cfg, view) {
17168 _classCallCheck(this, Zoom);
17169
17170 var _this = _possibleConstructorReturn(this, _Interaction.call(this, cfg, view));
17171
17172 var me = _this;
17173 me.chart = view;
17174 me.type = me.type.toUpperCase();
17175
17176 var scales = view.getYScales();
17177 var xScale = view.getXScale();
17178 scales.push(xScale);
17179 var scaleController = view.get('scaleController');
17180 scales.forEach(function (scale) {
17181 var field = scale.field;
17182 var def = scaleController.defs[field] || {};
17183 me.originScaleDefsByField[field] = Util.mix(def, {
17184 nice: !!def.nice
17185 });
17186 if (scale.isLinear) {
17187 me.stepByField[field] = (scale.max - scale.min) * me.stepRatio;
17188 }
17189 });
17190
17191 if (ZOOMING_TYPES.indexOf(me.type) === -1) {
17192 me.type = DEFAULT_TYPE;
17193 }
17194 return _this;
17195 }
17196
17197 // onZoom() { }
17198 // onZoomin() { }
17199 // onZoomout() { }
17200
17201 Zoom.prototype._applyScale = function _applyScale(scale, delta) {
17202 var minOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
17203
17204 var me = this;
17205 var chart = me.chart,
17206 stepByField = me.stepByField;
17207
17208 if (scale.isLinear) {
17209 var min = scale.min,
17210 max = scale.max,
17211 field = scale.field;
17212
17213 var maxOffset = 1 - minOffset;
17214 var step = stepByField[field] * delta;
17215 var newMin = min + step * minOffset;
17216 var newMax = max - step * maxOffset;
17217 if (newMax > newMin) {
17218 chart.scale(field, {
17219 nice: false,
17220 min: newMin,
17221 max: newMax
17222 });
17223 }
17224 }
17225 };
17226
17227 Zoom.prototype.process = function process(ev) {
17228 var me = this;
17229 var chart = me.chart,
17230 type = me.type;
17231
17232 var coord = chart.get('coord');
17233 var deltaY = ev.deltaY;
17234 var offsetPoint = coord.invertPoint(ev);
17235 if (deltaY) {
17236 me.onZoom && me.onZoom(deltaY, offsetPoint, me);
17237 if (deltaY > 0) {
17238 me.onZoomin && me.onZoomin(deltaY, offsetPoint, me);
17239 } else {
17240 me.onZoomout && me.onZoomout(deltaY, offsetPoint, me);
17241 }
17242 var delta = deltaY / Math.abs(deltaY);
17243 if (type.indexOf('X') > -1) {
17244 me._applyScale(chart.getXScale(), delta, offsetPoint.x);
17245 }
17246 if (type.indexOf('Y') > -1) {
17247 var yScales = chart.getYScales();
17248 yScales.forEach(function (yScale) {
17249 me._applyScale(yScale, delta, offsetPoint.y);
17250 });
17251 }
17252 }
17253 chart.repaint();
17254 };
17255
17256 Zoom.prototype.reset = function reset() {
17257 var me = this;
17258 var view = me.view,
17259 originScaleDefsByField = me.originScaleDefsByField;
17260
17261 var scales = view.getYScales();
17262 var xScale = view.getXScale();
17263 scales.push(xScale);
17264 scales.forEach(function (scale) {
17265 if (scale.isLinear) {
17266 var field = scale.field;
17267 view.scale(field, originScaleDefsByField[field]);
17268 }
17269 });
17270 view.repaint();
17271 };
17272
17273 return Zoom;
17274}(Interaction);
17275
17276// G2.registerInteraction('zoom', Zoom);
17277// G2.registerInteraction('Zoom', Zoom);
17278
17279module.exports = Zoom;
17280
17281/***/ }),
17282/* 122 */
17283/***/ (function(module, exports, __webpack_require__) {
17284
17285var G = __webpack_require__(28);
17286var CommonUtil = G.CommonUtil;
17287
17288function bindInteraction(Lib, View) {
17289 // binding on Library
17290 Lib._Interactions = {};
17291 Lib.registerInteraction = function (type, constructor) {
17292 Lib._Interactions[type] = constructor;
17293 };
17294 Lib.getInteraction = function (type) {
17295 return G2._Interactions[type];
17296 };
17297
17298 // binding on View
17299 View.prototype.getInteractions = function () {
17300 var me = this;
17301 if (!me._interactions) {
17302 me._interactions = {};
17303 }
17304 return me._interactions;
17305 };
17306 View.prototype._setInteraction = function (type, interaction) {
17307 var me = this;
17308 var interactions = me.getInteractions();
17309 if (interactions[type] && interactions[type] !== interaction) {
17310 // only one interaction for a key
17311 interactions[type].destroy();
17312 }
17313 interactions[type] = interaction;
17314 };
17315 View.prototype.clearInteraction = function (type) {
17316 var me = this;
17317 var interactions = me.getInteractions();
17318 if (type) {
17319 interactions[type] && interactions[type].destroy();
17320 delete interactions[type];
17321 } else {
17322 CommonUtil.each(interactions, function (interaction, key) {
17323 interaction.destroy();
17324 delete interactions[key];
17325 });
17326 }
17327 };
17328 View.prototype.interact = View.prototype.interaction = function (type, cfg) {
17329 var me = this;
17330 var Ctor = G2.getInteraction(type);
17331 var interaction = new Ctor(cfg, me);
17332 me._setInteraction(type, interaction);
17333 return me;
17334 };
17335}
17336
17337module.exports = bindInteraction;
17338
17339/***/ })
17340/******/ ]);
17341});
17342//# sourceMappingURL=interaction.js.map
\No newline at end of file