Socket
Socket
Sign inDemoInstall

@antv/g

Package Overview
Dependencies
Maintainers
7
Versions
349
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@antv/g - npm Package Compare versions

Comparing version 3.1.2 to 3.1.3

.idea/markdown-navigator.xml

53

lib/canvas.js
var Util = require('./util/index');
var Event = require('./event');
var Group = require('./core/group');
var Timeline = require('./core/mixin/timeline');
var renderers = require('./renderers/index');

@@ -13,2 +17,3 @@

eventEnable: true,
/**

@@ -19,2 +24,3 @@ * 像素宽度

width: null,
/**

@@ -25,2 +31,3 @@ * 像素高度

height: null,
/**

@@ -31,2 +38,3 @@ * 画布宽度

widthCanvas: null,
/**

@@ -37,2 +45,3 @@ * 画布高度

heightCanvas: null,
/**

@@ -43,2 +52,3 @@ * CSS宽

widthStyle: null,
/**

@@ -49,2 +59,3 @@ * CSS高

heightStyle: null,
/**

@@ -55,2 +66,3 @@ * 容器DOM

containerDOM: null,
/**

@@ -61,2 +73,3 @@ * 当前Canvas的DOM

canvasDOM: null,
/**

@@ -67,2 +80,3 @@ * 屏幕像素比

pixelRatio: null,
/**

@@ -74,12 +88,15 @@ * 渲染器,默认是canvas

};
Util.extend(Canvas, Group);
Util.augment(Canvas, {
init: function init() {
Canvas.superclass.init.call(this);
this._setGlobalParam();
this._setContainer();
this._initPainter();
this._scale();
if (this.get('eventEnable')) {

@@ -93,2 +110,3 @@ this._registEvents();

var parent = element.get('parent');
if (parent && !event.propagationStopped) {

@@ -115,9 +133,14 @@ return this.getEmitter(parent, event);

var shape = this.getShape(point.x, point.y, e);
var emitObj = void 0;
var el = this.get('el');
var emitObj;
if (type === 'mousemove') {
var preShape = this.get('preShape');
if (preShape && preShape !== shape) {
var mouseleave = this._getEventObj('mouseleave', e, point, preShape);
emitObj = this.getEmitter(preShape, e);
emitObj && emitObj.emit('mouseleave', mouseleave);
el.style.cursor = 'default';
}

@@ -127,2 +150,3 @@

var mousemove = this._getEventObj('mousemove', e, point, shape);
emitObj = this.getEmitter(shape, e);

@@ -133,2 +157,3 @@ emitObj && emitObj.emit('mousemove', mousemove);

var mouseenter = this._getEventObj('mouseenter', e, point, shape);
emitObj && emitObj.emit('mouseenter', mouseenter, e);

@@ -138,2 +163,3 @@ }

var canvasmousemove = this._getEventObj('mousemove', e, point, this);
this.emit('mousemove', canvasmousemove);

@@ -145,10 +171,12 @@ }

var event = this._getEventObj(type, e, point, shape || this);
emitObj = this.getEmitter(shape, e);
if (emitObj && emitObj !== this) {
emitObj.emit(type, event);
}
this.emit(type, event);
}
var el = this.get('el');
if (shape && !shape.get('destroyed')) {

@@ -166,4 +194,4 @@ el.style.cursor = shape.attr('cursor') || 'default';

}, false);
});
// special cases
}); // special cases
el.addEventListener('touchstart', function (e) {

@@ -174,3 +202,2 @@ if (!Util.isEmpty(e.touches)) {

}, false);
el.addEventListener('touchmove', function (e) {

@@ -181,3 +208,2 @@ if (!Util.isEmpty(e.touches)) {

}, false);
el.addEventListener('touchend', function (e) {

@@ -195,5 +221,7 @@ if (!Util.isEmpty(e.changedTouches)) {

var pixelRatio = this.get('pixelRatio');
if (!pixelRatio) {
this.set('pixelRatio', Util.getRatio());
}
var renderer = renderers[this.get('renderer') || 'canvas'];

@@ -208,2 +236,3 @@ this._cfg.renderer = renderer;

var containerDOM = this.get('containerDOM');
if (!containerDOM) {

@@ -213,2 +242,3 @@ containerDOM = document.getElementById(containerId);

}
Util.modifyCSS(containerDOM, {

@@ -231,3 +261,2 @@ position: 'relative'

var heightStyle = this.get('heightStyle');
canvasDOM.style.width = widthStyle;

@@ -252,3 +281,2 @@ canvasDOM.style.height = heightStyle;

var heightCanvas = height * pixelRatio;
this.set('widthCanvas', widthCanvas);

@@ -260,2 +288,3 @@ this.set('heightCanvas', heightCanvas);

this.set('height', height);
this._resize();

@@ -295,2 +324,3 @@ },

}
return Canvas.superclass.getShape.call(this, x, y);

@@ -305,5 +335,7 @@ },

var canvasDOM = cfg.canvasDOM;
if (canvasDOM && containerDOM) {
containerDOM.removeChild(canvasDOM);
}
cfg.timeline.stop();

@@ -313,3 +345,2 @@ Canvas.superclass.destroy.call(this);

});
module.exports = Canvas;
var Util = require('../util/index');
var Attribute = require('./mixin/attribute');
var Transform = require('./mixin/transform');
var Animate = require('./mixin/animation');
var EventEmitter = require('wolfy87-eventemitter');

@@ -16,5 +20,8 @@

Util.assign(this._cfg, this.getDefaultCfg(), cfg); // Element.CFG不合并,提升性能 合并默认配置,用户配置->继承默认配置->Element默认配置
this.initAttrs(this._cfg.attrs); // 初始化绘图属性
this._cfg.attrs = {};
this.initTransform(); // 初始化变换
this.init(); // 类型初始化

@@ -29,2 +36,3 @@ };

id: null,
/**

@@ -35,2 +43,3 @@ * Z轴的层叠关系,Z值越大离用户越近

zIndex: 0,
/**

@@ -41,2 +50,3 @@ * Canvas对象

canvas: null,
/**

@@ -47,2 +57,3 @@ * 父元素指针

parent: null,
/**

@@ -57,2 +68,3 @@ * 用来设置当前对象是否能被捕捉

capture: true,
/**

@@ -63,2 +75,3 @@ * 画布的上下文

context: null,
/**

@@ -69,2 +82,3 @@ * 是否显示

visible: true,
/**

@@ -76,3 +90,2 @@ * 是否被销毁

};
Util.augment(Element, Attribute, Transform, EventEmitter, Animate, {

@@ -99,9 +112,10 @@ init: function init() {

}
if (name === 'loading' && this._beforeSetLoading) {
this._beforeSetLoading(value);
}
this._cfg[name] = value;
return this;
},
// deprecated

@@ -126,2 +140,3 @@ setSilent: function setSilent(name, value) {

var el = cfg.el;
if (parent) {

@@ -131,2 +146,3 @@ if (el) {

}
Util.remove(parent.get('children'), this);

@@ -137,5 +153,8 @@ }

}*/
if (destroy || destroy === undefined) {
this.destroy();
}
return this;

@@ -145,7 +164,10 @@ },

var destroyed = this.get('destroyed');
if (destroyed) {
return;
}
this._attrs = null;
this.removeEvent(); // 移除所有的事件
this._cfg = {

@@ -158,5 +180,7 @@ destroyed: true

var parent = cfg.parent;
if (!parent) {
return;
}
var children = parent._cfg.children;

@@ -167,2 +191,3 @@ var el = cfg.el;

children.push(this);
if (el) {

@@ -176,5 +201,7 @@ el.parentNode.removeChild(el);

var parent = cfg.parent;
if (!parent) {
return;
}
var children = parent._cfg.children;

@@ -185,2 +212,3 @@ var el = cfg.el;

children.unshift(this);
if (el) {

@@ -194,8 +222,10 @@ var parentNode = el.parentNode;

var parent = this._cfg.parent;
this._cfg.zIndex = zIndex;
this._cfg.zIndex = zIndex;
if (!Util.isNil(parent)) {
parent.sort();
}
var el = this._cfg.el;
if (el) {

@@ -206,2 +236,3 @@ var children = parent._cfg.children;

parentNode.removeChild(el);
if (index === children.length - 1) {

@@ -213,2 +244,3 @@ parentNode.appendChild(el);

}
return zIndex;

@@ -229,3 +261,2 @@ },

});
module.exports = Element;
var Util = require('../util/index');
var Element = require('./element');
var Shape = require('../shapes/index');
var SHAPE_MAP = {}; // 缓存图形类型
var INDEX = '_INDEX';

@@ -15,5 +19,7 @@

function find(children, x, y) {
var rst = void 0;
var rst;
for (var i = children.length - 1; i >= 0; i--) {
var child = children[i];
if (child._cfg.visible && child._cfg.capture) {

@@ -26,2 +32,3 @@ if (child.isGroup) {

}
if (rst) {

@@ -31,2 +38,3 @@ break;

}
return rst;

@@ -41,3 +49,5 @@ }

this._beforeRenderUI();
this._renderUI();
this._bindUI();

@@ -50,8 +60,10 @@ };

}
var superCon = c.superclass.constructor;
if (superCon && !superCon._cfg) {
initClassCfgs(superCon);
}
c._cfg = {};
Util.merge(c._cfg, superCon._cfg);

@@ -62,3 +74,2 @@ Util.merge(c._cfg, c.CFG);

Util.extend(Group, Element);
Util.augment(Group, {

@@ -80,2 +91,3 @@ isGroup: true,

var shapeType = SHAPE_MAP[type];
if (!shapeType) {

@@ -85,7 +97,10 @@ shapeType = Util.upperFirst(type);

}
if (cfg.attrs && canvas) {
var attrs = cfg.attrs;
if (type === 'text') {
// 临时解决
var topFontFamily = canvas.get('fontFamily');
if (topFontFamily) {

@@ -96,2 +111,3 @@ attrs.fontFamily = attrs.fontFamily ? attrs.fontFamily : topFontFamily;

}
cfg.canvas = canvas;

@@ -111,4 +127,5 @@ cfg.type = type;

var canvas = this.get('canvas');
var rst = void 0;
var rst;
cfg = Util.merge({}, cfg);
if (Util.isFunction(param)) {

@@ -125,2 +142,3 @@ if (cfg) {

}
this.add(rst);

@@ -137,2 +155,3 @@ } else if (Util.isObject(param)) {

}
return rst;

@@ -149,4 +168,4 @@ },

var backShape = this.get('backShape');
var innerBox = this.getBBox();
// const parent = this.get('parent'); // getParent
var innerBox = this.getBBox(); // const parent = this.get('parent'); // getParent
Util.merge(attrs, {

@@ -158,2 +177,3 @@ x: innerBox.minX - padding[3],

});
if (backShape) {

@@ -167,2 +187,3 @@ backShape.attr(attrs);

}
this.set('backShape', backShape);

@@ -185,5 +206,7 @@ this.sort();

}
return this;
}
}
if (arguments.length === 0) {

@@ -195,2 +218,3 @@ destroy = true;

}
return this;

@@ -207,8 +231,11 @@ },

var children = self.get('children');
if (Util.isArray(items)) {
Util.each(items, function (item) {
var parent = item.get('parent');
if (parent) {
parent.removeChild(item, false);
}
self._setCfgProperty(item);

@@ -220,8 +247,12 @@ });

var parent = item.get('parent');
if (parent) {
parent.removeChild(item, false);
}
self._setCfgProperty(item);
children.push(item);
}
return self;

@@ -233,2 +264,3 @@ },

item.set('canvas', cfg.canvas);
if (cfg.timeline) {

@@ -260,2 +292,3 @@ item.set('timeline', cfg.timeline);

var children = self.get('children');
if (children.length > 0) {

@@ -265,5 +298,7 @@ Util.each(children, function (child) {

var _box = child.getBBox();
if (!_box) {
return true;
}
var leftTop = [_box.minX, _box.minY, 1];

@@ -273,3 +308,2 @@ var leftBottom = [_box.minX, _box.maxY, 1];

var rightBottom = [_box.maxX, _box.maxY, 1];
child.apply(leftTop);

@@ -279,3 +313,2 @@ child.apply(leftBottom);

child.apply(rightBottom);
var boxMinX = Math.min(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);

@@ -326,4 +359,4 @@ var boxMaxX = Math.max(leftTop[0], leftBottom[0], rightTop[0], rightBottom[0]);

sort: function sort() {
var children = this.get('children');
// 稳定排序
var children = this.get('children'); // 稳定排序
Util.each(children, function (child, index) {

@@ -333,7 +366,5 @@ child[INDEX] = index;

});
children.sort(getComparer(function (obj1, obj2) {
return obj1.get('zIndex') - obj2.get('zIndex');
}));
return this;

@@ -356,5 +387,5 @@ },

}
var children = this.get('children');
var rst = null;
Util.each(children, function (item) {

@@ -366,2 +397,3 @@ if (fn(item)) {

}
if (rst) {

@@ -386,2 +418,3 @@ return false;

}
if (item.findAllBy) {

@@ -403,3 +436,2 @@ childRst = item.findAllBy(fn);

var rst = null;
Util.each(children, function (item) {

@@ -411,2 +443,3 @@ if (fn(item)) {

}
if (rst) {

@@ -432,2 +465,3 @@ return false;

}
if (item.findAllBy) {

@@ -444,6 +478,8 @@ childRst = item.findAllBy(fn);

var children = self._cfg.children;
var rst = void 0;
var rst;
if (clip) {
var v = [x, y, 1];
clip.invert(v, self.get('canvas')); // 已经在外面转换
if (clip.isPointInPath(v[0], v[1])) {

@@ -455,2 +491,3 @@ rst = find(children, x, y);

}
return rst;

@@ -460,5 +497,7 @@ },

var m = this.get('totalMatrix');
if (m) {
this.setSilent('totalMatrix', null);
var children = this._cfg.children;
for (var i = 0; i < children.length; i++) {

@@ -472,5 +511,7 @@ var child = children[i];

var children = this._cfg.children;
for (var i = children.length - 1; i >= 0; i--) {
children[i].remove();
}
this._cfg.children = [];

@@ -483,2 +524,3 @@ return this;

}
this.clear();

@@ -488,3 +530,2 @@ Group.superclass.destroy.call(this);

});
module.exports = Group;
var Util = require('../../util/index');
var MatrixUtil = require('../../util/matrix');
var ReservedProps = { delay: 'delay', rotate: 'rotate' };
var ReservedProps = {
delay: 'delay',
rotate: 'rotate'
};

@@ -9,5 +13,7 @@ function getFromAttrs(toAttrs, shape) {

var attrs = shape._attrs;
for (var k in toAttrs.attrs) {
rst[k] = attrs[k];
}
return rst;

@@ -22,2 +28,3 @@ }

var attrs = shape._attrs;
for (var k in props) {

@@ -34,2 +41,3 @@ if (k === 'transform') {

}
return rst;

@@ -60,4 +68,6 @@ }

*/
animate: function animate(toProps, duration, easing, callback) {
var delay = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
animate: function animate(toProps, duration, easing, callback, delay) {
if (delay === void 0) {
delay = 0;
}

@@ -67,2 +77,3 @@ var self = this;

var timeline = self.get('timeline');
if (!timeline) {

@@ -72,7 +83,9 @@ timeline = self.get('canvas').get('timeline');

}
var animators = self.get('animators') || [];
// 初始化tick
var animators = self.get('animators') || []; // 初始化tick
if (!timeline._timer) {
timeline.initTimer();
}
if (Util.isNumber(callback)) {

@@ -82,2 +95,3 @@ delay = callback;

}
if (Util.isFunction(easing)) {

@@ -89,5 +103,5 @@ callback = easing;

}
var formatProps = getFormatProps(toProps, self);
// 记录动画属性
var formatProps = getFormatProps(toProps, self); // 记录动画属性
var animator = {

@@ -104,4 +118,4 @@ fromAttrs: getFromAttrs(formatProps, self),

id: Util.uniqueId()
};
// 如果动画队列中已经有这个图形了
}; // 如果动画队列中已经有这个图形了
if (animators.length > 0) {

@@ -114,5 +128,8 @@ // 先检查是否需要合并属性。若有相同的动画,将该属性从前一个动画中删除,直接用后一个动画中

}
animators.push(animator);
self.setSilent('animators', animators);
self.setSilent('pause', { isPaused: false });
self.setSilent('pause', {
isPaused: false
});
},

@@ -122,9 +139,11 @@ stopAnimate: function stopAnimate() {

var animators = this.get('animators');
// 将动画执行到最后一帧,执行回调
var animators = this.get('animators'); // 将动画执行到最后一帧,执行回调
Util.each(animators, function (animator) {
_this.attr(animator.toAttrs);
if (animator.toMatrix) {
_this.attr('matrix', animator.toMatrix);
}
if (animator.callback) {

@@ -139,4 +158,4 @@ animator.callback();

var self = this;
var timeline = self.get('timeline');
// 记录下是在什么时候暂停的
var timeline = self.get('timeline'); // 记录下是在什么时候暂停的
self.setSilent('pause', {

@@ -153,4 +172,4 @@ isPaused: true,

var animators = self.get('animators');
var pauseTime = self.get('pause').pauseTime;
// 之后更新属性需要计算动画已经执行的时长,如果暂停了,就把初始时间调后
var pauseTime = self.get('pause').pauseTime; // 之后更新属性需要计算动画已经执行的时长,如果暂停了,就把初始时间调后
Util.each(animators, function (animator) {

@@ -157,0 +176,0 @@ animator.startTime = animator.startTime + (current - pauseTime);

@@ -33,5 +33,7 @@ var Util = require('../../util/index');

var self = this;
if (arguments.length === 0) {
return self._attrs;
}
if (Util.isObject(name)) {

@@ -42,2 +44,3 @@ // self._attrs = Util.deepMix(self._attrs, name);

}
self.clearBBox();

@@ -47,4 +50,6 @@ this._cfg.hasUpdate = true;

}
if (arguments.length === 2) {
this._setAttr(name, value);
self.clearBBox();

@@ -54,2 +59,3 @@ this._cfg.hasUpdate = true;

}
return self._attrs[name];

@@ -61,2 +67,3 @@ },

attrs[name] = value;
if (name === 'fill' || name === 'stroke') {

@@ -66,2 +73,3 @@ attrs[name + 'Style'] = value;

}
if (name === 'opacity') {

@@ -71,10 +79,15 @@ attrs.globalAlpha = value;

}
if (name === 'clip' && value) {
self._setClip(value);
return;
}
if (name === 'path' && self._afterSetAttrPath) {
self._afterSetAttrPath(value);
return;
}
if (name === 'transform') {

@@ -84,2 +97,3 @@ self.transform(value);

}
if (name === 'rotate') {

@@ -102,2 +116,3 @@ self.rotateAtStart(value);

item._cfg.parent = this._cfg.parent;
item.hasFill = function () {

@@ -104,0 +119,0 @@ return true;

var Util = require('../../util/index');
var Inside = require('../../shapes/util/inside');
var mat3 = require('../../util/matrix').mat3;
var vec2 = require('../../util/matrix').vec2;
var vec3 = require('../../util/matrix').vec3;
var mathUtl = {

@@ -11,3 +16,2 @@ arc: require('../../shapes/math/arc'),

};
var canvas = Util.createDom('<canvas width="500" height="500"></canvas>');

@@ -29,7 +33,8 @@ var context = canvas.getContext('2d');

clockwise = attrs.clockwise;
var lineWidth = this.getHitLineWidth();
var lineWidth = this.getHitLineWidth();
if (this.hasStroke()) {
return Inside.arcline(cx, cy, r, startAngle, endAngle, clockwise, lineWidth, x, y);
}
return false;

@@ -58,2 +63,3 @@ };

}
return false;

@@ -92,2 +98,3 @@ };

}
return false;

@@ -117,2 +124,3 @@ };

var ls = vec2.squaredLength(subv);
if (rs * rs <= ls && ls <= re * re) {

@@ -122,2 +130,3 @@ return true;

}
return false;

@@ -128,3 +137,2 @@ }

var lineWidth = self.getHitLineWidth();
var ssp = {

@@ -177,2 +185,3 @@ x: Math.cos(startAngle) * rs + cx,

}
return false;

@@ -183,8 +192,11 @@ };

var attrs = this._attrs;
if (this.get('toDraw') || !attrs.img) {
return false;
}
if (!this._cfg.attrs || this._cfg.attrs.img !== attrs.img) {
this._setAttrImg();
}
var rx = attrs.x;

@@ -203,3 +215,2 @@ var ry = attrs.y;

y2 = attrs.y2;
var lineWidth = this.getHitLineWidth();

@@ -219,5 +230,7 @@

var stroke = self.hasStroke();
function _isPointInStroke() {
if (!Util.isEmpty(segments)) {
var lineWidth = self.getHitLineWidth();
for (var i = 0, l = segments.length; i < l; i++) {

@@ -228,2 +241,3 @@ if (segments[i].isInside(x, y, lineWidth)) {

}
return false;

@@ -244,2 +258,3 @@ }

}
return false;

@@ -256,12 +271,17 @@ };

var points = attrs.points;
if (points.length < 2) {
return false;
}
var lineWidth = self.getHitLineWidth();
var outPoints = points.slice(0);
if (points.length >= 3) {
outPoints.push(points[0]);
}
return Inside.polyline(outPoints, lineWidth, x, y);
}
if (fill && stroke) {

@@ -278,2 +298,3 @@ return isPointInPathByContext(x, y, self) || _isPointInStroke();

}
return false;

@@ -294,10 +315,14 @@ };

var attrs = self._attrs;
if (self.hasStroke()) {
var points = attrs.points;
if (points.length < 2) {
return false;
}
var lineWidth = attrs.lineWidth;
return Inside.polyline(points, lineWidth, x, y);
}
return false;

@@ -327,2 +352,3 @@ };

}
if (fill && stroke) {

@@ -339,2 +365,3 @@ return isPointInPathByContext(x, y, self) || _isPointInStroke();

}
return false;

@@ -346,2 +373,3 @@ };

var box = self.getBBox();
if (self.hasFill() || self.hasStroke()) {

@@ -354,2 +382,3 @@ return Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y);

var box = this._cfg.el.getBBox();
return Inside.box(box.x, box.x + box.width, box.y, box.y + box.height, x, y);

@@ -373,11 +402,12 @@ };

};
module.exports = {
isPointInPath: function isPointInPath(x, y) {
var shape = shapes[this.type];
if (shape) {
return shape.call(this, x, y);
}
return false;
}
};
var Util = require('../../util/index');
var PathUtil = require('../../util/path');
var d3Timer = require('d3-timer');
var d3Ease = require('d3-ease');

@@ -10,10 +13,11 @@

var Timeline = function Timeline(canvas) {
// 待执行动画的队列
this._animators = [];
// 当前时间
this._current = 0;
// 计时器实例
this._timer = null;
// 画布
this._animators = []; // 当前时间
this._current = 0; // 计时器实例
this._timer = null; // 画布
this.canvas = canvas;

@@ -24,9 +28,13 @@ };

var cProps = {}; // 此刻属性
var toAttrs = animator.toAttrs;
var fromAttrs = animator.fromAttrs;
var toMatrix = animator.toMatrix;
if (self.get('destroyed')) {
return;
}
var interf = void 0; // 差值函数
var interf; // 差值函数
for (var k in toAttrs) {

@@ -37,5 +45,8 @@ if (!Util.isEqual(fromAttrs[k], toAttrs[k])) {

var fromPath = fromAttrs[k];
if (toPath.length > fromPath.length) {
toPath = PathUtil.parsePathString(toAttrs[k]); // 终点状态
fromPath = PathUtil.parsePathString(fromAttrs[k]); // 起始状态
fromPath = PathUtil.fillPathByDiff(fromPath, toPath);

@@ -53,3 +64,5 @@ fromPath = PathUtil.formatPath(fromPath, toPath);

}
cProps[k] = [];
for (var i = 0; i < toPath.length; i++) {

@@ -59,2 +72,3 @@ var toPathPoint = toPath[i];

var cPathPoint = [];
for (var j = 0; j < toPathPoint.length; j++) {

@@ -68,2 +82,3 @@ if (Util.isNumber(toPathPoint[j]) && fromPathPoint && Util.isNumber(fromPathPoint[j])) {

}
cProps[k].push(cPathPoint);

@@ -77,2 +92,3 @@ }

}
if (toMatrix) {

@@ -83,2 +99,3 @@ var mf = interpolateArray(animator.fromMatrix, toMatrix);

}
self.attr(cProps);

@@ -88,12 +105,14 @@ }

function update(shape, animator, elapsed) {
var startTime = animator.startTime;
// 如果还没有开始执行或暂停,先不更新
var startTime = animator.startTime; // 如果还没有开始执行或暂停,先不更新
if (elapsed < startTime + animator.delay || animator.isPaused) {
return false;
}
var ratio = void 0;
var ratio;
var duration = animator.duration;
var easing = animator.easing;
// 已执行时间
var easing = animator.easing; // 已执行时间
elapsed = elapsed - startTime - animator.delay;
if (animator.toAttrs.repeat) {

@@ -104,2 +123,3 @@ ratio = elapsed % duration / duration;

ratio = elapsed / duration;
if (ratio < 1) {

@@ -109,5 +129,7 @@ ratio = d3Ease[easing](ratio);

shape.attr(animator.toAttrs);
if (animator.toMatrix) {
shape.setMatrix(animator.toMatrix);
}
return true;

@@ -118,2 +140,3 @@ }

_update(shape, animator, ratio);
return false;

@@ -128,10 +151,10 @@ }

var isFinished = false;
var shape = void 0,
animators = void 0,
animator = void 0;
var shape, animators, animator;
self._timer = d3Timer.timer(function (elapsed) {
self._current = elapsed;
if (_this._animators.length > 0) {
for (var i = _this._animators.length - 1; i >= 0; i--) {
shape = _this._animators[i];
if (shape.get('destroyed')) {

@@ -142,10 +165,14 @@ // 如果已经被销毁,直接移出队列

}
if (!shape.get('pause').isPaused) {
animators = shape.get('animators');
for (var j = animators.length - 1; j >= 0; j--) {
animator = animators[j];
isFinished = update(shape, animator, elapsed);
if (isFinished) {
animators.splice(j, 1);
isFinished = false;
if (animator.callback) {

@@ -157,2 +184,3 @@ animator.callback();

}
if (animators.length === 0) {

@@ -162,2 +190,3 @@ self.removeAnimator(i);

}
_this.canvas.draw();

@@ -185,2 +214,3 @@ }

});
this._animators = [];

@@ -193,3 +223,2 @@ this.canvas.draw();

});
module.exports = Timeline;
var Util = require('../../util/index');
var mat3 = require('../../util/matrix').mat3;
var vec3 = require('../../util/matrix').vec3;
// 是否未改变
var vec3 = require('../../util/matrix').vec3; // 是否未改变
function isUnchanged(m) {
return m[0] === 1 && m[1] === 0 && m[3] === 0 && m[4] === 1 && m[6] === 0 && m[7] === 0;
}
} // 是否仅仅是scale
// 是否仅仅是scale
function isScale(m) {

@@ -55,5 +57,7 @@ return m[1] === 0 && m[3] === 0 && m[6] === 0 && m[7] === 0;

var y = this._attrs.y || this._cfg.attrs.y;
if (Math.abs(rotate) > Math.PI * 2) {
rotate = rotate / 180 * Math.PI;
}
return this.transform([['t', -x, -y], ['r', rotate], ['t', x, y]]);

@@ -63,3 +67,5 @@ },

var cx = this.get('x') || 0; // 当前的x
var cy = this.get('y') || 0; // 当前的y
this.translate(x - cx, y - cy);

@@ -73,3 +79,2 @@ this.set('x', x);

var matrix = this._attrs.matrix;
Util.each(ts, function (t) {

@@ -80,8 +85,11 @@ switch (t[0]) {

break;
case 's':
self.scale(t[1], t[2]);
break;
case 'r':
self.rotate(t[1]);
break;
case 'm':

@@ -91,2 +99,3 @@ self.attr('matrix', mat3.multiply([], matrix, t[1]));

break;
default:

@@ -111,3 +120,4 @@ break;

apply: function apply(v, root) {
var m = void 0;
var m;
if (root) {

@@ -118,6 +128,6 @@ m = this._getMatrixByRoot(root);

}
vec3.transformMat3(v, v, m);
return this;
},
// 获取到达指定根节点的矩阵

@@ -134,4 +144,4 @@ _getMatrixByRoot: function _getMatrixByRoot(root) {

}
parents.unshift(parent);
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];

@@ -150,5 +160,7 @@ Util.each(parents, function (child) {

var m = this._cfg.totalMatrix;
if (!m) {
m = [1, 0, 0, 0, 1, 0, 0, 0, 1];
var parent = this._cfg.parent;
if (parent) {

@@ -162,12 +174,11 @@ var pm = parent.getTotalMatrix();

}
return m;
},
// 清除当前的矩阵
clearTotalMatrix: function clearTotalMatrix() {
// this._cfg.totalMatrix = null;
clearTotalMatrix: function clearTotalMatrix() {// this._cfg.totalMatrix = null;
},
invert: function invert(v) {
var m = this.getTotalMatrix();
// 单精屏幕下大多数矩阵没变化
var m = this.getTotalMatrix(); // 单精屏幕下大多数矩阵没变化
if (isScale(m)) {

@@ -178,2 +189,3 @@ v[0] /= m[0];

var inm = mat3.invert([], m);
if (inm) {

@@ -183,7 +195,8 @@ vec3.transformMat3(v, v, inm);

}
return this;
},
resetTransform: function resetTransform(context) {
var mo = this.attr('matrix');
// 不改变时
var mo = this.attr('matrix'); // 不改变时
if (!isUnchanged(mo)) {

@@ -190,0 +203,0 @@ context.transform(mo[0], mo[1], mo[3], mo[4], mo[6], mo[7]);

var Util = require('../util/index');
var isPointInPath = require('./mixin/isPointInPath');
var Element = require('./element');
var Inside = require('../shapes/util/inside');

@@ -11,5 +14,3 @@

Shape.ATTRS = {};
Util.extend(Shape, Element);
Util.augment(Shape, isPointInPath, {

@@ -22,4 +23,6 @@ isShape: true,

var originOpacity = context.globalAlpha;
if (self.hasFill()) {
var fillOpacity = attrs.fillOpacity;
if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {

@@ -33,12 +36,17 @@ context.globalAlpha = fillOpacity;

}
if (self.hasStroke()) {
var lineWidth = self._attrs.lineWidth;
if (lineWidth > 0) {
var strokeOpacity = attrs.strokeOpacity;
if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
context.globalAlpha = strokeOpacity;
}
context.stroke();
}
}
self.afterPath(context);

@@ -69,2 +77,3 @@ },

var box = self.getBBox();
if (box && !Inside.box(box.minX, box.maxX, box.minY, box.maxY, v[0], v[1])) {

@@ -74,5 +83,8 @@ return false;

}
var clip = self._attrs.clip;
if (clip) {
clip.invert(v, self.get('canvas'));
if (clip.isPointInPath(v[0], v[1])) {

@@ -84,2 +96,3 @@ return self.isPointInPath(v[0], v[1]);

}
return false;

@@ -96,9 +109,8 @@ },

},
// 获取拾取时线的宽度,需要考虑附加的线的宽度
getHitLineWidth: function getHitLineWidth() {
var attrs = this._attrs;
// if (!attrs.stroke) {
var attrs = this._attrs; // if (!attrs.stroke) {
// return 0;
// }
var lineAppendWidth = attrs.lineAppendWidth || 0;

@@ -108,3 +120,2 @@ var lineWidth = attrs.lineWidth || 0;

},
// 清除当前的矩阵

@@ -120,6 +131,7 @@ clearTotalMatrix: function clearTotalMatrix() {

getBBox: function getBBox() {
var box = this._cfg.box;
// 延迟计算
var box = this._cfg.box; // 延迟计算
if (!box) {
box = this.calculateBox();
if (box) {

@@ -131,8 +143,9 @@ box.x = box.minX;

}
this._cfg.box = box;
}
return box;
}
});
module.exports = Shape;

@@ -5,10 +5,19 @@ var Util = require('./util/index');

this.type = type; // 事件类型
this.target = null; // 目标
this.currentTarget = null; // 当前目标
this.bubbles = bubbles; // 冒泡
this.cancelable = cancelable; // 是否能够阻止
this.timeStamp = new Date().getTime(); // 时间戳
this.defaultPrevented = false; // 阻止默认
this.propagationStopped = false; // 阻止冒泡
this.removed = false; // 是否被移除
this.event = event; // 触发的原生事件

@@ -34,3 +43,2 @@ };

});
module.exports = Event;

@@ -26,3 +26,3 @@ module.exports = {

// version, etc.
version: '3.1.2'
version: '3.1.3'
};

@@ -1,4 +0,3 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Util = require('../../util');
var Util = require('../../util');
var renderUtil = require('./util');

@@ -8,9 +7,10 @@

var Painter = function () {
var Painter =
/*#__PURE__*/
function () {
function Painter(dom) {
_classCallCheck(this, Painter);
if (!dom) {
return null;
}
var canvasId = Util.uniqueId('canvas_');

@@ -26,3 +26,5 @@ var canvasDom = Util.createDom('<canvas id="' + canvasId + '"></canvas>');

Painter.prototype.beforeDraw = function beforeDraw() {
var _proto = Painter.prototype;
_proto.beforeDraw = function beforeDraw() {
var el = this.canvas;

@@ -32,7 +34,9 @@ this.context && this.context.clearRect(0, 0, el.width, el.height);

Painter.prototype.draw = function draw(model) {
_proto.draw = function draw(model) {
var self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(function () {
self.animateHandler = undefined;
if (self.toDraw) {

@@ -43,2 +47,3 @@ drawInner();

self.beforeDraw();
try {

@@ -52,4 +57,6 @@ self._drawGroup(model);

}
self.toDraw = false;
}
if (self.animateHandler) {

@@ -62,11 +69,13 @@ self.toDraw = true;

Painter.prototype.drawSync = function drawSync(model) {
_proto.drawSync = function drawSync(model) {
this.beforeDraw();
this._drawGroup(model);
};
Painter.prototype._drawGroup = function _drawGroup(group) {
_proto._drawGroup = function _drawGroup(group) {
if (group._cfg.removed || group._cfg.destroyed || !group._cfg.visible) {
return;
}
var self = this;

@@ -76,4 +85,6 @@ var children = group._cfg.children;

this.setContext(group);
for (var i = 0; i < children.length; i++) {
child = children[i];
if (children[i].isGroup) {

@@ -85,9 +96,11 @@ self._drawGroup(child);

}
this.restoreContext(group);
};
Painter.prototype._drawShape = function _drawShape(shape) {
_proto._drawShape = function _drawShape(shape) {
if (shape._cfg.removed || shape._cfg.destroyed || !shape._cfg.visible) {
return;
}
this.setContext(shape);

@@ -100,6 +113,7 @@ shape.drawInner(this.context);

Painter.prototype.setContext = function setContext(shape) {
_proto.setContext = function setContext(shape) {
var context = this.context;
var clip = shape._attrs.clip;
context.save();
if (clip) {

@@ -109,5 +123,5 @@ // context.save();

clip.createPath(context);
context.clip();
// context.restore();
context.clip(); // context.restore();
}
this.resetContext(shape);

@@ -117,10 +131,10 @@ shape.resetTransform(context);

Painter.prototype.restoreContext = function restoreContext() {
_proto.restoreContext = function restoreContext() {
this.context.restore();
};
Painter.prototype.resetContext = function resetContext(shape) {
_proto.resetContext = function resetContext(shape) {
var context = this.context;
var elAttrs = shape._attrs;
// var canvas = this.get('canvas');
var elAttrs = shape._attrs; // var canvas = this.get('canvas');
if (!shape.isGroup) {

@@ -131,8 +145,11 @@ for (var k in elAttrs) {

var v = elAttrs[k];
if (k === 'fillStyle') {
v = renderUtil.parseStyle(v, shape, context);
}
if (k === 'strokeStyle') {
v = renderUtil.parseStyle(v, shape, context);
}
if (k === 'lineDash' && context.setLineDash) {

@@ -139,0 +156,0 @@ if (Util.isArray(v)) {

@@ -24,4 +24,4 @@ var Util = require('../../util/index');

var box = self.getBBox();
var start = void 0;
var end = void 0;
var start;
var end;

@@ -68,3 +68,2 @@ if (angle >= 0 && angle < 0.5 * Math.PI) {

var tanTheta2 = tanTheta * tanTheta;
var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;

@@ -82,4 +81,4 @@ var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;

var fr = parseFloat(arr[3]);
var steps = arr[4];
// 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
var steps = arr[4]; // 环半径为0时,默认无渐变,取渐变序列的最后一个颜色
if (fr === 0) {

@@ -89,2 +88,3 @@ var colors = steps.match(regexColorStop);

}
var box = self.getBBox();

@@ -103,9 +103,9 @@ var width = box.maxX - box.minX;

}
var pattern = void 0;
var img = void 0;
var pattern;
var img;
var arr = regexPR.exec(color);
var repeat = arr[1];
var source = arr[2];
var source = arr[2]; // Function to be called when pattern loads
// Function to be called when pattern loads
function onload() {

@@ -115,2 +115,3 @@ // Create pattern

self.setSilent('pattern', pattern); // be a cache
self.setSilent('patternSource', color);

@@ -123,11 +124,15 @@ }

break;
case 'x':
repeat = 'repeat-x';
break;
case 'y':
repeat = 'repeat-y';
break;
case 'n':
repeat = 'no-repeat';
break;
default:

@@ -137,4 +142,4 @@ repeat = 'no-repeat';

img = new Image();
// If source URL is not a data URL
img = new Image(); // If source URL is not a data URL
if (!source.match(/^data:/i)) {

@@ -144,2 +149,3 @@ // Set crossOrigin for this image

}
img.src = source;

@@ -150,4 +156,4 @@

} else {
img.onload = onload;
// Fix onload() bug in IE9
img.onload = onload; // Fix onload() bug in IE9
img.src = img.src;

@@ -162,2 +168,3 @@ }

path = path || [];
if (Util.isArray(path)) {

@@ -171,2 +178,3 @@ return path;

item = item.match(regexDot);
if (item[0].length > 1) {

@@ -177,2 +185,3 @@ var tag = item[0].charAt(0);

}
Util.each(item, function (sub, i) {

@@ -202,2 +211,3 @@ if (!isNaN(sub)) {

}
return color;

@@ -209,12 +219,16 @@ }

var color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}
};

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -7,12 +5,17 @@ * Created by Elaine on 2018/5/9.

var Util = require('../../util/index');
var Gradient = require('./defs/gradient');
var Shadow = require('./defs/shadow');
var Arrow = require('./defs/arrow');
var Clip = require('./defs/clip');
var Pattern = require('./defs/pattern');
var Defs = function () {
var Defs =
/*#__PURE__*/
function () {
function Defs(canvas) {
_classCallCheck(this, Defs);
var el = document.createElementNS('http://www.w3.org/2000/svg', 'defs');

@@ -28,5 +31,8 @@ var id = Util.uniqueId('defs_');

Defs.prototype.find = function find(type, attr) {
var _proto = Defs.prototype;
_proto.find = function find(type, attr) {
var children = this.children;
var result = null;
for (var i = 0; i < children.length; i++) {

@@ -38,8 +44,10 @@ if (children[i].match(type, attr)) {

}
return result;
};
Defs.prototype.findById = function findById(id) {
_proto.findById = function findById(id) {
var children = this.children;
var flag = null;
for (var i = 0; i < children.length; i++) {

@@ -51,6 +59,7 @@ if (children[i].id === id) {

}
return flag;
};
Defs.prototype.add = function add(item) {
_proto.add = function add(item) {
this.children.push(item);

@@ -61,7 +70,9 @@ item.canvas = this.canvas;

Defs.prototype.getDefaultArrow = function getDefaultArrow(attrs, name) {
_proto.getDefaultArrow = function getDefaultArrow(attrs, name) {
var stroke = attrs.stroke || attrs.strokeStyle;
if (this.defaultArrow[stroke]) {
return this.defaultArrow[stroke].id;
}
var arrow = new Arrow(attrs, name);

@@ -73,3 +84,3 @@ this.defaultArrow[stroke] = arrow;

Defs.prototype.addGradient = function addGradient(cfg) {
_proto.addGradient = function addGradient(cfg) {
var gradient = new Gradient(cfg);

@@ -81,3 +92,3 @@ this.el.appendChild(gradient.el);

Defs.prototype.addArrow = function addArrow(attrs, name) {
_proto.addArrow = function addArrow(attrs, name) {
var arrow = new Arrow(attrs, name);

@@ -88,3 +99,3 @@ this.el.appendChild(arrow.el);

Defs.prototype.addShadow = function addShadow(cfg) {
_proto.addShadow = function addShadow(cfg) {
var shadow = new Shadow(cfg);

@@ -96,3 +107,3 @@ this.el.appendChild(shadow.el);

Defs.prototype.addPattern = function addPattern(cfg) {
_proto.addPattern = function addPattern(cfg) {
var pattern = new Pattern(cfg);

@@ -104,3 +115,3 @@ this.el.appendChild(pattern.el);

Defs.prototype.addClip = function addClip(cfg) {
_proto.addClip = function addClip(cfg) {
var clip = new Clip(cfg);

@@ -107,0 +118,0 @@ this.el.appendChild(clip.el);

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -8,6 +6,6 @@ * Created by Elaine on 2018/5/11.

var Arrow = function () {
var Arrow =
/*#__PURE__*/
function () {
function Arrow(attrs, type) {
_classCallCheck(this, Arrow);
var el = document.createElementNS('http://www.w3.org/2000/svg', 'marker');

@@ -27,2 +25,3 @@ var id = Util.uniqueId('marker_');

this.stroke = attrs.stroke || '#000';
if (this.cfg === true) {

@@ -33,10 +32,13 @@ this._setDefaultPath(type, shape);

}
return this;
}
Arrow.prototype.match = function match() {
var _proto = Arrow.prototype;
_proto.match = function match() {
return false;
};
Arrow.prototype._setDefaultPath = function _setDefaultPath(type, el) {
_proto._setDefaultPath = function _setDefaultPath(type, el) {
var parent = this.el;

@@ -48,3 +50,3 @@ el.setAttribute('d', 'M0,0 L6,3 L0,6 L3,3Z');

Arrow.prototype._setMarker = function _setMarker(r, el) {
_proto._setMarker = function _setMarker(r, el) {
var parent = this.el;

@@ -59,4 +61,6 @@ var path = this.cfg.path;

}
el.setAttribute('d', path);
parent.appendChild(el);
if (d) {

@@ -67,4 +71,5 @@ parent.setAttribute('refX', d / r);

Arrow.prototype.update = function update(fill) {
_proto.update = function update(fill) {
var child = this.child;
if (child.attr) {

@@ -71,0 +76,0 @@ child.attr('fill', fill);

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -8,6 +6,6 @@ * Created by Elaine on 2018/5/14.

var Clip = function () {
var Clip =
/*#__PURE__*/
function () {
function Clip(cfg) {
_classCallCheck(this, Clip);
this.type = 'clip';

@@ -23,7 +21,9 @@ var el = document.createElementNS('http://www.w3.org/2000/svg', 'clipPath');

Clip.prototype.match = function match() {
var _proto = Clip.prototype;
_proto.match = function match() {
return false;
};
Clip.prototype.remove = function remove() {
_proto.remove = function remove() {
var el = this.el;

@@ -30,0 +30,0 @@ el.parentNode.removeChild(el);

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -14,5 +12,7 @@ * Created by Elaine on 2018/5/9.

var arr = steps.match(regexColorStop);
if (!arr) {
return '';
}
var stops = '';

@@ -26,3 +26,3 @@ arr.sort(function (a, b) {

item = item.split(':');
stops += '<stop offset="' + item[0] + '" stop-color="' + item[1] + '"></stop>';
stops += "<stop offset=\"" + item[0] + "\" stop-color=\"" + item[1] + "\"></stop>";
});

@@ -36,4 +36,4 @@ return stops;

var steps = arr[2];
var start = void 0;
var end = void 0;
var start;
var end;

@@ -80,3 +80,2 @@ if (angle >= 0 && angle < 0.5 * Math.PI) {

var tanTheta2 = tanTheta * tanTheta;
var x = (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.x;

@@ -103,8 +102,9 @@ var y = tanTheta * (end.x - start.x + tanTheta * (end.y - start.y)) / (tanTheta2 + 1) + start.y;

var Gradient = function () {
var Gradient =
/*#__PURE__*/
function () {
function Gradient(cfg) {
_classCallCheck(this, Gradient);
var el = null;
var id = Util.uniqueId('gradient_');
if (cfg.toLowerCase()[0] === 'l') {

@@ -117,2 +117,3 @@ el = document.createElementNS('http://www.w3.org/2000/svg', 'linearGradient');

}
el.setAttribute('id', id);

@@ -125,3 +126,5 @@ this.el = el;

Gradient.prototype.match = function match(type, attr) {
var _proto = Gradient.prototype;
_proto.match = function match(type, attr) {
return this.cfg === attr;

@@ -128,0 +131,0 @@ };

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -10,6 +8,6 @@ * Created by Elaine on 2018/5/9.

var Pattern = function () {
var Pattern =
/*#__PURE__*/
function () {
function Pattern(cfg) {
_classCallCheck(this, Pattern);
var el = document.createElementNS('http://www.w3.org/2000/svg', 'pattern');

@@ -28,6 +26,9 @@ el.setAttribute('patternUnits', 'userSpaceOnUse');

var img = new Image();
if (!source.match(/^data:/i)) {
img.crossOrigin = 'Anonymous';
}
img.src = source;
function onload() {

@@ -38,7 +39,8 @@ console.log(img.width, img.height);

}
if (img.complete) {
onload();
} else {
img.onload = onload;
// Fix onload() bug in IE9
img.onload = onload; // Fix onload() bug in IE9
img.src = img.src;

@@ -50,3 +52,5 @@ }

Pattern.prototype.match = function match(type, attr) {
var _proto = Pattern.prototype;
_proto.match = function match(type, attr) {
return this.cfg === attr;

@@ -53,0 +57,0 @@ };

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -16,6 +14,6 @@ * Created by Elaine on 2018/5/10.

var Shadow = function () {
var Shadow =
/*#__PURE__*/
function () {
function Shadow(cfg) {
_classCallCheck(this, Shadow);
this.type = 'shadow';

@@ -27,10 +25,15 @@ var el = document.createElementNS('http://www.w3.org/2000/svg', 'filter');

this.cfg = cfg;
this._parseShadow(cfg, el);
return this;
}
Shadow.prototype.match = function match(type, cfg) {
var _proto = Shadow.prototype;
_proto.match = function match(type, cfg) {
if (this.type !== type) {
return false;
}
var flag = true;

@@ -47,11 +50,13 @@ var config = this.cfg;

Shadow.prototype.update = function update(name, value) {
_proto.update = function update(name, value) {
var config = this.cfg;
config[ATTR_MAP[name]] = value;
this._parseShadow(config, this.el);
return this;
};
Shadow.prototype._parseShadow = function _parseShadow(config, el) {
var child = '<feDropShadow \n dx="' + (config.dx || 0) + '" \n dy="' + (config.dy || 0) + '" \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 />';
_proto._parseShadow = function _parseShadow(config, el) {
var child = "<feDropShadow \n dx=\"" + (config.dx || 0) + "\" \n dy=\"" + (config.dy || 0) + "\" \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 />";
el.innerHTML = child;

@@ -58,0 +63,0 @@ };

@@ -15,12 +15,17 @@ var TAG_MAP = {

var target = e.target || e.srcElement;
if (!TAG_MAP[target.tagName]) {
var parent = target.parentNode;
while (parent && !TAG_MAP[parent.tagName]) {
parent = parent.parentNode;
}
target = parent;
}
if (this._cfg.el === target) {
return this;
}
return this.find(function (item) {

@@ -27,0 +32,0 @@ return item._cfg && item._cfg.el === target;

@@ -1,3 +0,1 @@

function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var Util = require('../../util');

@@ -9,2 +7,3 @@

var Marker = require('../../shapes/marker');
var Defs = require('./defs');

@@ -26,3 +25,2 @@

};
var SVG_ATTR_MAP = {

@@ -63,3 +61,2 @@ opacity: 'opacity',

};
var BASELINE_MAP = {

@@ -72,3 +69,2 @@ top: 'before-edge',

};
var ANCHOR_MAP = {

@@ -82,11 +78,12 @@ left: 'left',

var Painter = function () {
var Painter =
/*#__PURE__*/
function () {
function Painter(dom) {
_classCallCheck(this, Painter);
if (!dom) {
return null;
}
var svgId = Util.uniqueId('canvas_');
var canvasDom = Util.createDom('<svg id="' + svgId + '"></svg>');
var canvasDom = Util.createDom("<svg id=\"" + svgId + "\"></svg>");
dom.appendChild(canvasDom);

@@ -100,7 +97,11 @@ this.type = 'svg';

Painter.prototype.draw = function draw(model) {
var _proto = Painter.prototype;
_proto.draw = function draw(model) {
var self = this;
function drawInner() {
self.animateHandler = Util.requestAnimationFrame(function () {
self.animateHandler = undefined;
if (self.toDraw) {

@@ -110,2 +111,3 @@ drawInner();

});
try {

@@ -119,4 +121,6 @@ self._drawChildren(model._cfg.children, false);

}
self.toDraw = false;
}
if (self.animateHandler) {

@@ -129,8 +133,9 @@ self.toDraw = true;

Painter.prototype.drawSync = function drawSync(model) {
_proto.drawSync = function drawSync(model) {
this._drawChildren(model._cfg.children, false);
};
Painter.prototype._drawGroup = function _drawGroup(model, redraw) {
_proto._drawGroup = function _drawGroup(model, redraw) {
var cfg = model._cfg;
if (cfg.removed || cfg.destroyed) {

@@ -144,5 +149,8 @@ return;

*/
if (!cfg.el && cfg.attrs) {
redraw = true;
}
if (cfg.tobeRemoved) {

@@ -156,3 +164,5 @@ Util.each(cfg.tobeRemoved, function (item) {

}
this._drawShape(model, redraw);
if (cfg.children && cfg.children.length > 0) {

@@ -163,11 +173,13 @@ this._drawChildren(cfg.children, redraw);

Painter.prototype._drawChildren = function _drawChildren(children, redraw) {
_proto._drawChildren = function _drawChildren(children, redraw) {
var self = this;
var shape = void 0;
// 防止在画children的时候,父group已经被destroy
var shape; // 防止在画children的时候,父group已经被destroy
if (!children) {
return;
}
for (var i = 0; i < children.length; i++) {
shape = children[i];
if (shape.isGroup) {

@@ -181,8 +193,8 @@ self._drawGroup(shape, redraw);

Painter.prototype._drawShape = function _drawShape(model, redraw) {
_proto._drawShape = function _drawShape(model, redraw) {
var self = this;
var attrs = model._attrs;
var cfg = model._cfg;
var el = cfg.el;
// 删除
var el = cfg.el; // 删除
if (cfg.removed || cfg.destroyed) {

@@ -192,14 +204,16 @@ if (el) {

}
return;
}
} // 重绘节点
// 重绘节点
if (redraw && el) {
el.parentNode && el.parentNode.removeChild(el);
el = null;
}
} // 新增节点
// 新增节点
if (!el && cfg.parent) {
self._createDom(model);
self._updateShape(model);

@@ -214,7 +228,8 @@ }

}
if (cfg.visible && el.hasAttribute('visibility')) {
el.removeAttribute('visibility');
}
} // 更新
// 更新
if (cfg.hasUpdate) {

@@ -229,31 +244,41 @@ self._updateShape(model);

Painter.prototype._updateShape = function _updateShape(model) {
_proto._updateShape = function _updateShape(model) {
var self = this;
var attrs = model._attrs;
var formerAttrs = model._cfg.attrs;
if (!formerAttrs) {
return;
}
if (!model._cfg.el) {
self._createDom(model);
}
if ('clip' in attrs) {
this._setClip(model, attrs.clip);
}
if ('shadowOffsetX' in attrs || 'shadowOffsetY' in attrs || 'shadowBlur' in attrs || 'shadowColor' in attrs) {
this._setShadow(model);
}
if (model.type === 'text') {
self._updateText(model);
return;
}
if (model.type === 'fan') {
self._updateFan(model);
}
if (model.type === 'marker') {
model._cfg.el.setAttribute('d', self._assembleMarker(attrs));
}
if (model.type === 'rect') {
model._cfg.el.setAttribute('d', self._assembleRect(attrs));
}
for (var key in attrs) {

@@ -264,2 +289,3 @@ if (attrs[key] !== formerAttrs[key]) {

}
model._cfg.attrs = Util.deepMix({}, model._attrs);

@@ -269,18 +295,19 @@ model._cfg.hasUpdate = false;

Painter.prototype._setAttribute = function _setAttribute(model, name, value) {
_proto._setAttribute = function _setAttribute(model, name, value) {
var type = model.type;
var attrs = model._attrs;
var el = model._cfg.el;
var defs = this.context;
var defs = this.context; // 计算marker路径
// 计算marker路径
if ((type === 'marker' || type === 'rect') && ~['x', 'y', 'radius', 'r'].indexOf(name)) {
return;
}
// 圆和椭圆不是x, y, 是cx, cy。 marker的x,y 用于计算marker的路径,不需要写到dom
} // 圆和椭圆不是x, y, 是cx, cy。 marker的x,y 用于计算marker的路径,不需要写到dom
if (~['circle', 'ellipse'].indexOf(type) && ~['x', 'y'].indexOf(name)) {
el.setAttribute('c' + name, parseInt(value, 10));
return;
}
// 多边形
} // 多边形
if (type === 'polygon' && name === 'points') {

@@ -290,2 +317,3 @@ if (!value || value.length === 0) {

}
if (Util.isArray(value)) {

@@ -297,15 +325,20 @@ value = value.map(function (point) {

}
el.setAttribute('points', value);
return;
}
// 设置path
} // 设置path
if (name === 'path' && Util.isArray(value)) {
el.setAttribute('d', this._formatPath(value));
return;
}
// 设置图片
} // 设置图片
if (name === 'img') {
this._setImage(model, value);
return;
}
if (name === 'transform') {

@@ -316,5 +349,8 @@ if (!value) {

}
this._setTransform(model);
return;
}
if (name === 'rotate') {

@@ -325,18 +361,27 @@ if (!value) {

}
this._setTransform(model);
return;
}
if (name === 'matrix') {
this._setTransform(model);
return;
}
if (name === 'fillStyle' || name === 'strokeStyle') {
this._setColor(model, name, value);
return;
}
if (name === 'clip') {
return;
}
if (~name.indexOf('Arrow')) {
name = SVG_ATTR_MAP[name];
if (!value) {

@@ -347,2 +392,3 @@ model._cfg[name] = null;

var id = null;
if (typeof value === 'boolean') {

@@ -353,8 +399,11 @@ id = defs.getDefaultArrow(attrs, name);

}
el.setAttribute(name, 'url(#' + id + ')');
el.setAttribute(name, "url(#" + id + ")");
model._cfg[name] = id;
}
return;
}
// foreignObject
} // foreignObject
if (name === 'html') {

@@ -368,2 +417,3 @@ if (typeof value === 'string') {

}
if (SVG_ATTR_MAP[name]) {

@@ -374,14 +424,19 @@ el.setAttribute(SVG_ATTR_MAP[name], value);

Painter.prototype._createDom = function _createDom(model) {
_proto._createDom = function _createDom(model) {
var type = SHAPE_TO_TAGS[model.type];
var attrs = model._attrs;
if (!type) {
throw new Error('the type' + model.type + 'is not supported by svg');
}
var shape = document.createElementNS('http://www.w3.org/2000/svg', type);
model._cfg.el = shape;
if (model._cfg.parent) {
model._cfg.parent.get('el').appendChild(shape);
}
model._cfg.attrs = {};
if (model.type === 'text') {

@@ -394,2 +449,3 @@ shape.setAttribute('paint-order', 'stroke');

}
if (!attrs.fill && !attrs.fillStyle) {

@@ -399,14 +455,19 @@ attrs.fillStyle = 'none';

}
return shape;
};
Painter.prototype._assembleMarker = function _assembleMarker(attrs) {
_proto._assembleMarker = function _assembleMarker(attrs) {
var r = attrs.r;
if (typeof attrs.r === 'undefined') {
r = attrs.radius;
}
if (isNaN(Number(attrs.x)) || isNaN(Number(attrs.y)) || isNaN(Number(r))) {
return '';
}
var d = '';
if (typeof attrs.symbol === 'function') {

@@ -417,2 +478,3 @@ d = attrs.symbol(attrs.x, attrs.y, r);

}
if (Util.isArray(d)) {

@@ -423,6 +485,7 @@ d = d.map(function (path) {

}
return d;
};
Painter.prototype._assembleRect = function _assembleRect(attrs) {
_proto._assembleRect = function _assembleRect(attrs) {
var x = attrs.x;

@@ -435,5 +498,7 @@ var y = attrs.y;

if (!radius) {
return 'M ' + x + ',' + y + ' l ' + w + ',0 l 0,' + h + ' l' + -w + ' 0 z';
return "M " + x + "," + y + " l " + w + ",0 l 0," + h + " l" + -w + " 0 z";
}
var r = parseRadius(radius);
if (Util.isArray(radius)) {

@@ -458,29 +523,35 @@ if (radius.length === 1) {

}
var d = [['M ' + (x + r.r1) + ',' + y], ['l ' + (w - r.r1 - r.r2) + ',0'], ['a ' + r.r2 + ',' + r.r2 + ',0,0,1,' + r.r2 + ',' + r.r2], ['l 0,' + (h - r.r2 - r.r3)], ['a ' + r.r3 + ',' + r.r3 + ',0,0,1,' + -r.r3 + ',' + r.r3], ['l ' + (r.r3 + r.r4 - w) + ',0'], ['a ' + r.r4 + ',' + r.r4 + ',0,0,1,' + -r.r4 + ',' + -r.r4], ['l 0,' + (r.r4 + r.r1 - h)], ['a ' + r.r1 + ',' + r.r1 + ',0,0,1,' + r.r1 + ',' + -r.r1], ['z']];
var d = [["M " + (x + r.r1) + "," + y], ["l " + (w - r.r1 - r.r2) + ",0"], ["a " + r.r2 + "," + r.r2 + ",0,0,1," + r.r2 + "," + r.r2], ["l 0," + (h - r.r2 - r.r3)], ["a " + r.r3 + "," + r.r3 + ",0,0,1," + -r.r3 + "," + r.r3], ["l " + (r.r3 + r.r4 - w) + ",0"], ["a " + r.r4 + "," + r.r4 + ",0,0,1," + -r.r4 + "," + -r.r4], ["l 0," + (r.r4 + r.r1 - h)], ["a " + r.r1 + "," + r.r1 + ",0,0,1," + r.r1 + "," + -r.r1], ['z']];
return d.join(' ');
};
Painter.prototype._formatPath = function _formatPath(value) {
_proto._formatPath = function _formatPath(value) {
value = value.map(function (path) {
return path.join(' ');
}).join('');
if (~value.indexOf('NaN')) {
return '';
}
return value;
};
Painter.prototype._setTransform = function _setTransform(model) {
_proto._setTransform = function _setTransform(model) {
var matrix = model._attrs.matrix;
var el = model._cfg.el;
var transform = [];
for (var i = 0; i < 9; i += 3) {
transform.push(matrix[i] + ',' + matrix[i + 1]);
}
el.setAttribute('transform', 'matrix(' + transform.join(',') + ')');
el.setAttribute('transform', "matrix(" + transform.join(',') + ")");
};
Painter.prototype._setImage = function _setImage(model, img) {
_proto._setImage = function _setImage(model, img) {
var attrs = model._attrs;
var el = model._cfg.el;
if (Util.isString(img)) {

@@ -493,2 +564,3 @@ el.setAttribute('href', img);

}
if (!attrs.height) {

@@ -498,2 +570,3 @@ el.setAttribute('height', img.height);

}
el.setAttribute('href', img.src);

@@ -507,2 +580,3 @@ } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {

canvas.getContext('2d').putImageData(img, 0, 0);
if (!attrs.width) {

@@ -512,2 +586,3 @@ el.setAttribute('width', img.width);

}
if (!attrs.height) {

@@ -517,2 +592,3 @@ el.setAttribute('height', img.height);

}
el.setAttribute('href', canvas.toDataURL());

@@ -522,3 +598,3 @@ }

Painter.prototype._updateFan = function _updateFan(model) {
_proto._updateFan = function _updateFan(model) {
function getPoint(angle, radius, center) {

@@ -530,2 +606,3 @@ return {

}
var attrs = model._attrs;

@@ -540,5 +617,7 @@ var cfg = model._cfg;

var endAngle = attrs.endAngle;
if (Util.isNumberEqual(endAngle - startAngle, Math.PI * 2)) {
endAngle -= 0.00001;
}
var outerStart = getPoint(startAngle, attrs.re, center);

@@ -552,21 +631,25 @@ var outerEnd = getPoint(endAngle, attrs.re, center);

var innerEnd = getPoint(endAngle, attrs.rs, center);
if (attrs.rs > 0) {
d.push('M ' + outerEnd.x + ',' + outerEnd.y);
d.push('L ' + innerEnd.x + ',' + innerEnd.y);
d.push('A ' + rs + ',' + rs + ',0,' + fs + ',' + (fa === 1 ? 0 : 1) + ',' + innerStart.x + ',' + innerStart.y);
d.push('L ' + outerStart.x + ' ' + outerStart.y);
d.push("M " + outerEnd.x + "," + outerEnd.y);
d.push("L " + innerEnd.x + "," + innerEnd.y);
d.push("A " + rs + "," + rs + ",0," + fs + "," + (fa === 1 ? 0 : 1) + "," + innerStart.x + "," + innerStart.y);
d.push("L " + outerStart.x + " " + outerStart.y);
} else {
d.push('M ' + center.x + ',' + center.y);
d.push('L ' + outerStart.x + ',' + outerStart.y);
d.push("M " + center.x + "," + center.y);
d.push("L " + outerStart.x + "," + outerStart.y);
}
d.push('A ' + re + ',' + re + ',0,' + fs + ',' + fa + ',' + outerEnd.x + ',' + outerEnd.y);
d.push("A " + re + "," + re + ",0," + fs + "," + fa + "," + outerEnd.x + "," + outerEnd.y);
if (attrs.rs > 0) {
d.push('L ' + innerEnd.x + ',' + innerEnd.y);
d.push("L " + innerEnd.x + "," + innerEnd.y);
} else {
d.push('Z');
}
cfg.el.setAttribute('d', d.join(' '));
};
Painter.prototype._updateText = function _updateText(model) {
_proto._updateText = function _updateText(model) {
var self = this;

@@ -576,17 +659,25 @@ var attrs = model._attrs;

var el = model._cfg.el;
this._setFont(model);
for (var attr in attrs) {
if (attrs[attr] !== formerAttrs[attr]) {
if (attr === 'text') {
self._setText(model, '' + attrs[attr]);
self._setText(model, "" + attrs[attr]);
continue;
}
if (attr === 'fillStyle' || attr === 'strokeStyle') {
this._setColor(model, attr, attrs[attr]);
continue;
}
if (attr === 'matrix') {
this._setTransform(model);
continue;
}
if (SVG_ATTR_MAP[attr]) {

@@ -597,2 +688,3 @@ el.setAttribute(SVG_ATTR_MAP[attr], attrs[attr]);

}
model._cfg.attrs = Object.assign({}, model._attrs);

@@ -602,9 +694,9 @@ model._cfg.hasUpdate = false;

Painter.prototype._setFont = function _setFont(model) {
_proto._setFont = function _setFont(model) {
var el = model.get('el');
var attrs = model._attrs;
var fontSize = attrs.fontSize;
el.setAttribute('alignment-baseline', BASELINE_MAP[attrs.textBaseline] || 'baseline');
el.setAttribute('text-anchor', ANCHOR_MAP[attrs.textAlign] || 'left');
if (fontSize && +fontSize < 12) {

@@ -617,5 +709,6 @@ // 小于 12 像素的文本进行 scale 处理

Painter.prototype._setText = function _setText(model, text) {
_proto._setText = function _setText(model, text) {
var el = model._cfg.el;
var baseline = model._attrs.textBaseline || 'bottom';
if (!text) {

@@ -631,14 +724,14 @@ el.innerHTML = '';

if (baseline === 'alphabetic') {
arr += '<tspan x="' + x + '" dy="' + -textLen + 'em">' + segment + '</tspan>';
arr += "<tspan x=\"" + x + "\" dy=\"" + -textLen + "em\">" + segment + "</tspan>";
} else if (baseline === 'top') {
arr += '<tspan x="' + x + '" dy="' + textLen + 'em">' + segment + '</tspan>';
arr += "<tspan x=\"" + x + "\" dy=\"" + textLen + "em\">" + segment + "</tspan>";
} else if (baseline === 'middle') {
arr += '<tspan x="' + x + '" dy="0">' + segment + '</tspan>';
arr += "<tspan x=\"" + x + "\" dy=\"0\">" + segment + "</tspan>";
} else if (baseline === 'bottom') {
arr += '<tspan x="' + x + '" dy="-' + (textLen + 0.2) + 'em">' + segment + '</tspan>';
arr += "<tspan x=\"" + x + "\" dy=\"-" + (textLen + 0.2) + "em\">" + segment + "</tspan>";
} else if (baseline === 'hanging') {
arr += '<tspan x="' + x + '" dy="-0.2em">' + segment + '</tspan>';
arr += "<tspan x=\"" + x + "\" dy=\"-0.2em\">" + segment + "</tspan>";
}
} else {
arr += '<tspan x="' + x + '" dy="1em">' + segment + '</tspan>';
arr += "<tspan x=\"" + x + "\" dy=\"1em\">" + segment + "</tspan>";
}

@@ -652,4 +745,5 @@ });

Painter.prototype._setClip = function _setClip(model, value) {
_proto._setClip = function _setClip(model, value) {
var el = model._cfg.el;
if (!value) {

@@ -659,7 +753,10 @@ el.removeAttribute('clip-path');

}
if (!el.hasAttribute('clip-path')) {
this._createDom(value);
this._updateShape(value);
var id = this.context.addClip(value);
el.setAttribute('clip-path', 'url(#' + id + ')');
el.setAttribute('clip-path', "url(#" + id + ")");
} else if (value._cfg.hasUpdate) {

@@ -670,5 +767,6 @@ this._updateShape(value);

Painter.prototype._setColor = function _setColor(model, name, value) {
_proto._setColor = function _setColor(model, name, value) {
var el = model._cfg.el;
var defs = this.context;
if (!value) {

@@ -678,15 +776,21 @@ el.setAttribute(SVG_ATTR_MAP[name], 'none');

}
value = value.trim();
if (/^[r,R,L,l]{1}[\s]*\(/.test(value)) {
var id = defs.find('gradient', value);
if (!id) {
id = defs.addGradient(value);
}
el.setAttribute(SVG_ATTR_MAP[name], 'url(#' + id + ')');
el.setAttribute(SVG_ATTR_MAP[name], "url(#" + id + ")");
} else if (/^[p,P]{1}[\s]*\(/.test(value)) {
var _id = defs.find('pattern', value);
if (!_id) {
_id = defs.addPattern(value);
}
el.setAttribute(SVG_ATTR_MAP[name], 'url(#' + _id + ')');
el.setAttribute(SVG_ATTR_MAP[name], "url(#" + _id + ")");
} else {

@@ -697,3 +801,3 @@ el.setAttribute(SVG_ATTR_MAP[name], value);

Painter.prototype._setShadow = function _setShadow(model) {
_proto._setShadow = function _setShadow(model) {
var el = model._cfg.el;

@@ -708,6 +812,8 @@ var attrs = model._attrs;

var id = this.context.find('filter', cfg);
if (!id) {
id = this.context.addShadow(cfg, this);
}
el.setAttribute('filter', 'url(#' + id + ')');
el.setAttribute('filter', "url(#" + id + ")");
};

@@ -714,0 +820,0 @@

var Util = require('../util/index');
var Shape = require('../core/shape');
var ArcMath = require('./math/arc');
var Arrow = require('./util/arrow');

@@ -9,2 +12,3 @@

}
function _getArcY(y, radius, angle) {

@@ -29,5 +33,3 @@ return y + radius * Math.sin(angle);

};
Util.extend(Arc, Shape);
Util.augment(Arc, {

@@ -57,3 +59,2 @@ canStroke: true,

clockwise = attrs.clockwise;
var lineWidth = this.getHitLineWidth();

@@ -75,12 +76,18 @@ var halfWidth = lineWidth / 2;

clockwise = attrs.clockwise;
var diff = Math.PI / 180;
var diff = Math.PI / 180;
if (clockwise) {
diff *= -1;
}
var result = [];
var x1 = _getArcX(x, r, startAngle + diff);
var y1 = _getArcY(y, r, startAngle + diff);
var x2 = _getArcX(x, r, startAngle);
var y2 = _getArcY(y, r, startAngle);
result.push([x1, y1]);

@@ -97,12 +104,17 @@ result.push([x2, y2]);

clockwise = attrs.clockwise;
var diff = Math.PI / 180;
var result = [];
if (clockwise) {
diff *= -1;
}
var x1 = _getArcX(x, r, endAngle + diff);
var y1 = _getArcY(y, r, endAngle + diff);
var x2 = _getArcX(x, r, endAngle);
var y2 = _getArcY(y, r, endAngle);
result.push([x2, y2]);

@@ -120,5 +132,3 @@ result.push([x1, y1]);

clockwise = attrs.clockwise;
context = context || self.get('context');
context.beginPath();

@@ -142,3 +152,2 @@ context.arc(x, y, r, startAngle, endAngle, clockwise);

});
module.exports = Arc;
var Util = require('../util/index');
var Shape = require('../core/shape');

@@ -14,5 +15,3 @@

};
Util.extend(Circle, Shape);
Util.augment(Circle, {

@@ -51,3 +50,2 @@ canFill: true,

});
module.exports = Circle;
var Util = require('../util/index');
var Shape = require('../core/shape');

@@ -9,3 +10,2 @@

Util.extend(Dom, Shape);
Util.augment(Dom, {

@@ -23,3 +23,2 @@ canFill: true,

var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2;

@@ -34,3 +33,2 @@ return {

});
module.exports = Dom;
var Util = require('../util/index');
var Shape = require('../core/shape');
var mat3 = require('../util/matrix').mat3;

@@ -16,5 +18,3 @@

};
Util.extend(Ellipse, Shape);
Util.augment(Ellipse, {

@@ -38,3 +38,2 @@ canFill: true,

var halfYWidth = ry + lineWidth / 2;
return {

@@ -53,3 +52,2 @@ minX: cx - halfXWidth,

var ry = attrs.ry;
context = context || self.get('context');

@@ -59,3 +57,2 @@ var r = rx > ry ? rx : ry;

var scaleY = rx > ry ? ry / rx : 1;
var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];

@@ -72,3 +69,2 @@ mat3.scale(m, m, [scaleX, scaleY]);

});
module.exports = Ellipse;
var Util = require('../util/index');
var Shape = require('../core/shape');
var ArcMath = require('./math/arc');

@@ -19,5 +21,3 @@

};
Util.extend(Fan, Shape);
Util.augment(Fan, {

@@ -46,3 +46,2 @@ canFill: true,

var lineWidth = this.getHitLineWidth();
var boxs = ArcMath.box(cx, cy, rs, startAngle, endAngle, clockwise);

@@ -54,3 +53,2 @@ var boxe = ArcMath.box(cx, cy, re, startAngle, endAngle, clockwise);

var maxY = Math.max(boxs.maxY, boxe.maxY);
var halfWidth = lineWidth / 2;

@@ -73,3 +71,2 @@ return {

var clockwise = attrs.clockwise;
var ssp = {

@@ -87,3 +84,2 @@ x: Math.cos(startAngle) * rs + cx,

};
context = context || self.get('context');

@@ -99,3 +95,2 @@ context.beginPath();

});
module.exports = Fan;
var Util = require('../util/index');
var Shape = require('../core/shape');

@@ -19,5 +20,3 @@

};
Util.extend(CImage, Shape);
Util.augment(CImage, {

@@ -34,2 +33,3 @@ type: 'image',

}
var x = attrs.x;

@@ -39,3 +39,2 @@ var y = attrs.y;

var height = attrs.height;
return {

@@ -50,2 +49,3 @@ minX: x,

var canvas = this.get('canvas');
if (loading === false && this.get('toDraw') === true) {

@@ -55,2 +55,3 @@ this._cfg.loading = false;

}
return loading;

@@ -62,4 +63,6 @@ },

var img = attrs.img;
if (Util.isString(img)) {
var image = new Image();
image.onload = function () {

@@ -70,7 +73,10 @@ if (self.get('destroyed')) return false;

var callback = self.get('callback');
if (callback) {
callback.call(self);
}
self.set('loading', false);
};
image.src = img;

@@ -87,2 +93,3 @@ image.crossOrigin = 'Anonymous';

}
return img;

@@ -97,2 +104,3 @@ } else if (img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {

}
return img;

@@ -107,2 +115,3 @@ } else if (img instanceof ImageData) {

}
return img;

@@ -117,2 +126,3 @@ } else {

}
if (this.get('loading')) {

@@ -122,3 +132,5 @@ this.set('toDraw', true);

}
this._drawImage(context);
this._cfg.hasUpdate = false;

@@ -138,4 +150,4 @@ },

this.set('toDraw', false);
var img = image;
var img = image;
if (img instanceof ImageData) {

@@ -145,2 +157,3 @@ img = new Image();

}
if (img instanceof Image || img instanceof HTMLElement && Util.isString(img.nodeName) && img.nodeName.toUpperCase() === 'CANVAS') {

@@ -151,2 +164,3 @@ if (Util.isNil(sx) || Util.isNil(sy) || Util.isNil(swidth) || Util.isNil(sheight)) {

}
if (!Util.isNil(sx) && !Util.isNil(sy) && !Util.isNil(swidth) && !Util.isNil(sheight)) {

@@ -157,6 +171,6 @@ context.drawImage(img, sx, sy, swidth, sheight, x, y, width, height);

}
return;
}
});
module.exports = CImage;
var Shape = require('../core/shape');
Shape.Arc = require('./arc');

@@ -3,0 +4,0 @@ Shape.Circle = require('./circle');

var Util = require('../util/index');
var Shape = require('../core/shape');
var Arrow = require('./util/arrow');
var LineMath = require('./math/line');

@@ -19,5 +22,3 @@

};
Util.extend(Line, Shape);
Util.augment(Line, {

@@ -39,3 +40,2 @@ canStroke: true,

y2 = attrs.y2;
var lineWidth = this.getHitLineWidth();

@@ -50,3 +50,2 @@ return LineMath.box(x1, y1, x2, y2, lineWidth);

y2 = attrs.y2;
context = context || self.get('context');

@@ -63,7 +62,8 @@ context.beginPath();

y2 = attrs.y2;
context = context || this.get('context');
context = context || this.get('context');
if (attrs.startArrow) {
Arrow.addStartArrow(context, attrs, x2, y2, x1, y1);
}
if (attrs.endArrow) {

@@ -81,3 +81,2 @@ Arrow.addEndArrow(context, attrs, x1, y1, x2, y2);

});
module.exports = Line;
var Util = require('../util/index');
var Shape = require('../core/shape');
var Format = require('../util/format');
var PathSegment = require('./util/path-segment');

@@ -15,3 +18,2 @@

},
// 正方形

@@ -21,3 +23,2 @@ square: function square(x, y, r) {

},
// 菱形

@@ -27,3 +28,2 @@ diamond: function diamond(x, y, r) {

},
// 三角形

@@ -34,3 +34,2 @@ triangle: function triangle(x, y, r) {

},
// 倒三角形

@@ -42,3 +41,2 @@ 'triangle-down': function triangleDown(x, y, r) {

};
Marker.ATTRS = {

@@ -48,5 +46,3 @@ path: null,

};
Util.extend(Marker, Shape);
Util.augment(Marker, {

@@ -83,3 +79,4 @@ type: 'marker',

var symbol = attrs.symbol || 'circle';
var method = void 0;
var method;
if (Util.isFunction(symbol)) {

@@ -90,2 +87,3 @@ method = symbol;

}
return method(x, y, r);

@@ -95,7 +93,10 @@ },

var segments = this._cfg.segments;
if (segments && !this._cfg.hasUpdate) {
context.beginPath();
for (var i = 0; i < segments.length; i++) {
segments[i].draw(context);
}
return;

@@ -106,4 +107,5 @@ }

context.beginPath();
var preSegment = void 0;
var preSegment;
segments = [];
for (var _i = 0; _i < path.length; _i++) {

@@ -115,2 +117,3 @@ var item = path[_i];

}
this._cfg.segments = segments;

@@ -120,3 +123,2 @@ this._cfg.hasUpdate = false;

});
module.exports = Marker;
var Util = require('../../util/index');
var vec2 = require('../../util/matrix').vec2;

@@ -12,4 +13,5 @@

function angleNearTo(angle, min, max, out) {
var v1 = void 0;
var v2 = void 0;
var v1;
var v2;
if (out) {

@@ -33,8 +35,11 @@ if (angle < min) {

var plus = 0;
if (endAngle - startAngle >= Math.PI * 2) {
plus = Math.PI * 2;
}
startAngle = Util.mod(startAngle, Math.PI * 2);
endAngle = Util.mod(endAngle, Math.PI * 2) + plus;
angle = Util.mod(angle, Math.PI * 2);
if (clockwise) {

@@ -45,9 +50,13 @@ if (startAngle >= endAngle) {

}
return angleNearTo(angle, endAngle, startAngle, true);
}
if (angle < startAngle || angle > endAngle) {
return angle;
}
return angleNearTo(angle, startAngle, endAngle);
}
if (startAngle <= endAngle) {

@@ -57,7 +66,10 @@ if (startAngle < angle && angle < endAngle) {

}
return angleNearTo(angle, startAngle, endAngle, true);
}
if (angle > startAngle || angle < endAngle) {
return angle;
}
return angleNearTo(angle, endAngle, startAngle);

@@ -72,5 +84,5 @@ }

var angle = vec2.angleTo(v1, subv);
angle = nearAngle(angle, startAngle, endAngle, clockwise);
var vpoint = [r * Math.cos(angle) + cx, r * Math.sin(angle) + cy];
if (out) {

@@ -80,2 +92,3 @@ out.x = vpoint[0];

}
var d = vec2.distance(vpoint, v);

@@ -92,2 +105,3 @@ return d;

var angle = nearAngle(angleRight, startAngle, endAngle, clockwise);
if (angle === angleRight) {

@@ -98,2 +112,3 @@ points.push(circlePoint(cx, cy, r, angleRight));

angle = nearAngle(angleBottom, startAngle, endAngle, clockwise);
if (angle === angleBottom) {

@@ -104,2 +119,3 @@ points.push(circlePoint(cx, cy, r, angleBottom));

angle = nearAngle(angleLeft, startAngle, endAngle, clockwise);
if (angle === angleLeft) {

@@ -110,2 +126,3 @@ points.push(circlePoint(cx, cy, r, angleLeft));

angle = nearAngle(angleTop, startAngle, endAngle, clockwise);
if (angle === angleTop) {

@@ -125,8 +142,11 @@ points.push(circlePoint(cx, cy, r, angleTop));

}
if (maxX < point.x) {
maxX = point.x;
}
if (minY > point.y) {
minY = point.y;
}
if (maxY < point.y) {

@@ -136,3 +156,2 @@ maxY = point.y;

});
return {

@@ -153,5 +172,4 @@ minX: minX,

},
pointDistance: arcProjectPoint,
box: arcBox
};
var Util = require('../../util/index');
var vec2 = require('../../util/matrix').vec2;

@@ -15,12 +16,14 @@

function cubicProjectPoint(x1, y1, x2, y2, x3, y3, x4, y4, x, y, out) {
var t = void 0;
var t;
var interval = 0.005;
var d = Infinity;
var _t = void 0;
var v1 = void 0;
var d1 = void 0;
var d2 = void 0;
var v2 = void 0;
var prev = void 0;
var next = void 0;
var _t;
var v1;
var d1;
var d2;
var v2;
var prev;
var next;
var EPSILON = 0.0001;

@@ -31,4 +34,4 @@ var v0 = [x, y];

v1 = [cubicAt(x1, x2, x3, x4, _t), cubicAt(y1, y2, y3, y4, _t)];
d1 = vec2.squaredDistance(v0, v1);
d1 = vec2.squaredDistance(v0, v1);
if (d1 < d) {

@@ -39,2 +42,3 @@ t = _t;

}
d = Infinity;

@@ -49,5 +53,3 @@

next = t + interval;
v1 = [cubicAt(x1, x2, x3, x4, prev), cubicAt(y1, y2, y3, y4, prev)];
d1 = vec2.squaredDistance(v0, v1);

@@ -60,3 +62,2 @@

v2 = [cubicAt(x1, x2, x3, x4, next), cubicAt(y1, y2, y3, y4, next)];
d2 = vec2.squaredDistance(v0, v2);

@@ -86,5 +87,5 @@

var extrema = [];
var t1 = void 0;
var t2 = void 0;
var discSqrt = void 0;
var t1;
var t2;
var discSqrt;

@@ -94,2 +95,3 @@ if (Util.isNumberEqual(a, 0)) {

t1 = -c / b;
if (t1 >= 0 && t1 <= 1) {

@@ -101,2 +103,3 @@ extrema.push(t1);

var disc = b * b - 4 * a * c;
if (Util.isNumberEqual(disc, 0)) {

@@ -108,5 +111,7 @@ extrema.push(-b / (2 * a));

t2 = (-b - discSqrt) / (2 * a);
if (t1 >= 0 && t1 <= 1) {
extrema.push(t1);
}
if (t2 >= 0 && t2 <= 1) {

@@ -117,2 +122,3 @@ extrema.push(t2);

}
return extrema;

@@ -131,2 +137,3 @@ }

}
z = z > 1 ? 1 : z < 0 ? 0 : z;

@@ -138,2 +145,3 @@ var z2 = z / 2;

var sum = 0;
for (var i = 0; i < n; i++) {

@@ -146,2 +154,3 @@ var ct = z2 * Tvalues[i] + z2;

}
return z2 * sum;

@@ -158,3 +167,2 @@ }

},
pointDistance: cubicProjectPoint,

@@ -161,0 +169,0 @@ extrema: cubicExtrema,

@@ -9,2 +9,3 @@ var vec2 = require('../../util/matrix').vec2;

var d = [x2 - x1, y2 - y1];
if (vec2.exactEquals(d, [0, 0])) {

@@ -25,3 +26,2 @@ return NaN;

var maxY = Math.max(y1, y2);
return {

@@ -28,0 +28,0 @@ minX: minX - halfWidth,

var Util = require('../../util/index');
var vec2 = require('../../util/matrix').vec2;

@@ -10,11 +11,13 @@

function quadraticProjectPoint(x1, y1, x2, y2, x3, y3, x, y, out) {
var t = void 0;
var t;
var interval = 0.005;
var d = Infinity;
var d1 = void 0;
var v1 = void 0;
var v2 = void 0;
var _t = void 0;
var d2 = void 0;
var i = void 0;
var d1;
var v1;
var v2;
var _t;
var d2;
var i;
var EPSILON = 0.0001;

@@ -25,4 +28,4 @@ var v0 = [x, y];

v1 = [quadraticAt(x1, x2, x3, _t), quadraticAt(y1, y2, y3, _t)];
d1 = vec2.squaredDistance(v0, v1);
d1 = vec2.squaredDistance(v0, v1);
if (d1 < d) {

@@ -33,2 +36,3 @@ t = _t;

}
d = Infinity;

@@ -43,5 +47,3 @@

var next = t + interval;
v1 = [quadraticAt(x1, x2, x3, prev), quadraticAt(y1, y2, y3, prev)];
d1 = vec2.squaredDistance(v0, v1);

@@ -54,3 +56,2 @@

v2 = [quadraticAt(x1, x2, x3, next), quadraticAt(y1, y2, y3, next)];
d2 = vec2.squaredDistance(v0, v2);

@@ -77,9 +78,13 @@

var a = p0 + p2 - 2 * p1;
if (Util.isNumberEqual(a, 0)) {
return [0.5];
}
var rst = (p0 - p1) / a;
if (rst <= 1 && rst >= 0) {
return [rst];
}
return [];

@@ -95,5 +100,4 @@ }

},
pointDistance: quadraticProjectPoint,
extrema: quadraticExtrema
};
var Util = require('../util/index');
var Shape = require('../core/shape');
var PathSegment = require('./util/path-segment');
var Format = require('../util/format');
var Arrow = require('./util/arrow');
var PathUtil = require('../util/path');
var CubicMath = require('./math/cubic');

@@ -19,5 +25,3 @@

};
Util.extend(Path, Shape);
Util.augment(Path, {

@@ -36,2 +40,3 @@ canFill: true,

var self = this;
if (Util.isNil(path)) {

@@ -42,4 +47,5 @@ self.setSilent('segments', null);

}
var pathArray = Format.parsePath(path);
var preSegment = void 0;
var preSegment;
var segments = [];

@@ -50,3 +56,5 @@

}
var count = pathArray.length;
for (var i = 0; i < pathArray.length; i++) {

@@ -57,2 +65,3 @@ var item = pathArray[i];

}
self.setSilent('segments', segments);

@@ -69,2 +78,3 @@ self.setSilent('tCache', null);

}
var lineWidth = this.getHitLineWidth();

@@ -78,2 +88,3 @@ var minX = Infinity;

var box = segment.box;
if (box) {

@@ -97,2 +108,12 @@ if (box.minX < minX) {

});
if (minX === Infinity || minY === Infinity) {
return {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
};
}
return {

@@ -109,6 +130,6 @@ minX: minX,

var tCache = [];
var segmentT = void 0;
var segmentL = void 0;
var segmentN = void 0;
var l = void 0;
var segmentT;
var segmentL;
var segmentN;
var l;
var curve = this._cfg.curve;

@@ -123,2 +144,3 @@

l = segment.length;
if (segmentN) {

@@ -128,6 +150,6 @@ totalLength += CubicMath.len(segment[l - 2], segment[l - 1], segmentN[1], segmentN[2], segmentN[3], segmentN[4], segmentN[5], segmentN[6]);

});
Util.each(curve, function (segment, i) {
segmentN = curve[i + 1];
l = segment.length;
if (segmentN) {

@@ -142,3 +164,2 @@ segmentT = [];

});
this._cfg.tCache = tCache;

@@ -154,6 +175,4 @@ },

var segments = this.get('segments');
var startPoint = void 0,
endPoint = void 0,
tangent = void 0,
result = void 0;
var startPoint, endPoint, tangent, result;
if (segments.length > 1) {

@@ -164,2 +183,3 @@ startPoint = segments[0].endPoint;

result = [];
if (Util.isFunction(tangent)) {

@@ -174,2 +194,3 @@ var v = tangent();

}
return result;

@@ -180,6 +201,4 @@ },

var segmentsLen = segments.length;
var startPoint = void 0,
endPoint = void 0,
tangent = void 0,
result = void 0;
var startPoint, endPoint, tangent, result;
if (segmentsLen > 1) {

@@ -190,2 +209,3 @@ startPoint = segments[segmentsLen - 2].endPoint;

result = [];
if (Util.isFunction(tangent)) {

@@ -200,2 +220,3 @@ var v = tangent();

}
return result;

@@ -205,8 +226,10 @@ },

var tCache = this._cfg.tCache;
var subt = void 0;
var index = void 0;
var subt;
var index;
if (!tCache) {
this._calculateCurve();
this._setTcache();
tCache = this._cfg.tCache;

@@ -224,4 +247,6 @@ }

}
return null;
}
Util.each(tCache, function (v, i) {

@@ -234,5 +259,7 @@ if (t >= v[0] && t <= v[1]) {

var seg = curve[index];
if (Util.isNil(seg) || Util.isNil(index)) {
return null;
}
var l = seg.length;

@@ -248,7 +275,8 @@ var nextSeg = curve[index + 1];

var segments = self.get('segments');
if (!Util.isArray(segments)) {
return;
}
context = context || self.get('context');
context.beginPath();

@@ -267,11 +295,15 @@ var segmentsLen = segments.length;

context = context || self.get('context');
if (!Util.isArray(segments)) {
return;
}
if (segments.length === 1) {
return;
}
if (!attrs.startArrow && !attrs.endArrow) {
return;
}
if (path[path.length - 1] === 'z' || path[path.length - 1] === 'Z' || attrs.fill) {

@@ -281,5 +313,5 @@ // 闭合路径不绘制箭头

}
var startPoints = self.getStartTangent();
Arrow.addStartArrow(context, attrs, startPoints[0][0], startPoints[0][1], startPoints[1][0], startPoints[1][1]);
var endPoints = self.getEndTangent();

@@ -289,3 +321,2 @@ Arrow.addEndArrow(context, attrs, endPoints[0][0], endPoints[0][1], endPoints[1][0], endPoints[1][1]);

});
module.exports = Path;
var Util = require('../util/index');
var Shape = require('../core/shape');

@@ -12,5 +13,3 @@

};
Util.extend(Polygon, Shape);
Util.augment(Polygon, {

@@ -30,5 +29,7 @@ canFill: true,

var lineWidth = this.getHitLineWidth();
if (!points || points.length === 0) {
return null;
}
var minX = Infinity;

@@ -38,9 +39,10 @@ var minY = Infinity;

var maxY = -Infinity;
Util.each(points, function (point) {
var x = point[0];
var y = point[1];
if (x < minX) {
minX = x;
}
if (x > maxX) {

@@ -58,3 +60,2 @@ maxX = x;

});
var halfWidth = lineWidth / 2;

@@ -72,5 +73,7 @@ return {

var points = attrs.points;
if (points.length < 2) {
return;
}
context = context || self.get('context');

@@ -88,3 +91,2 @@ context.beginPath();

});
module.exports = Polygon;
var Util = require('../util/index');
var Shape = require('../core/shape');
var Arrow = require('./util/arrow');
var LineMath = require('./math/line');

@@ -17,9 +20,8 @@

};
Util.extend(Polyline, Shape);
Util.augment(Polyline, {
canStroke: true,
type: 'polyline',
tCache: null, // 缓存各点的t
tCache: null,
// 缓存各点的t
getDefaultAttrs: function getDefaultAttrs() {

@@ -37,5 +39,7 @@ return {

var points = attrs.points;
if (!points || points.length === 0) {
return null;
}
var minX = Infinity;

@@ -45,9 +49,10 @@ var minY = Infinity;

var maxY = -Infinity;
Util.each(points, function (point) {
var x = point[0];
var y = point[1];
if (x < minX) {
minX = x;
}
if (x > maxX) {

@@ -65,3 +70,2 @@ maxX = x;

});
var halfWidth = lineWidth / 2;

@@ -82,4 +86,5 @@ return {

var tCache = [];
var segmentT = void 0;
var segmentL = void 0;
var segmentT;
var segmentL;
if (!points || points.length === 0) {

@@ -94,5 +99,7 @@ return;

});
if (totalLength <= 0) {
return;
}
Util.each(points, function (p, i) {

@@ -114,4 +121,4 @@ if (points[i + 1]) {

var points = attrs.points;
var l = void 0;
var i = void 0;
var l;
var i;

@@ -121,9 +128,11 @@ if (points.length < 2) {

}
context = context || self.get('context');
context.beginPath();
context.moveTo(points[0][0], points[0][1]);
context.moveTo(points[0][0], points[0][1]);
for (i = 1, l = points.length - 1; i < l; i++) {
context.lineTo(points[i][0], points[i][1]);
}
context.lineTo(points[l][0], points[l][1]);

@@ -156,2 +165,3 @@ },

}
if (attrs.endArrow) {

@@ -165,8 +175,11 @@ Arrow.addEndArrow(context, attrs, points[l - 1][0], points[l - 1][1], points[l][0], points[l][1]);

var tCache = this.tCache;
var subt = void 0;
var index = void 0;
var subt;
var index;
if (!tCache) {
this._setTcache();
tCache = this.tCache;
}
Util.each(tCache, function (v, i) {

@@ -184,3 +197,2 @@ if (t >= v[0] && t <= v[1]) {

});
module.exports = Polyline;

@@ -20,5 +20,3 @@ var Util = require('../util/index');

};
Util.extend(Rect, Shape);
Util.augment(Rect, {

@@ -42,3 +40,2 @@ canFill: true,

var lineWidth = this.getHitLineWidth();
var halfWidth = lineWidth / 2;

@@ -61,4 +58,4 @@ return {

context = context || self.get('context');
context.beginPath();
context.beginPath();
if (radius === 0) {

@@ -82,3 +79,2 @@ // 改成原生的rect方法

});
module.exports = Rect;
var Util = require('../util/index');
var Shape = require('../core/shape');

@@ -22,5 +23,3 @@

};
Util.extend(CText, Shape);
Util.augment(CText, {

@@ -45,2 +44,3 @@ canFill: true,

var fontSize = this._attrs.fontSize;
if (fontSize && +fontSize < 12) {

@@ -58,4 +58,6 @@ // 小于 12 像素的文本进行 scale 处理

var fontStyle = attrs.fontStyle; // self.attr('fontStyle');
var fontVariant = attrs.fontVariant; // self.attr('fontVariant');
// self.attr('font', [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' '));
attrs.font = [fontStyle, fontVariant, fontWeight, fontSize + 'px', fontFamily].join(' ');

@@ -66,3 +68,4 @@ },

var text = attrs.text;
var textArr = void 0;
var textArr = null;
if (Util.isString(text) && text.indexOf('\n') !== -1) {

@@ -72,6 +75,5 @@ textArr = text.split('\n');

attrs.lineCount = lineCount;
attrs.textArr = textArr;
}
// attrs.height = this._getTextHeight();
// attrs.width = this.measureText();
attrs.textArr = textArr;
},

@@ -82,6 +84,9 @@ _getTextHeight: function _getTextHeight() {

var fontSize = attrs.fontSize * 1;
if (lineCount > 1) {
var spaceingY = this._getSpaceingY();
return fontSize * lineCount + spaceingY * (lineCount - 1);
}
return fontSize;

@@ -96,9 +101,13 @@ },

var cfg = this._cfg;
if (!cfg.attrs || cfg.hasUpdate) {
this._assembleFont();
this._setAttrText();
}
var x = attrs.x;
var y = attrs.y;
var width = self.measureText(); // attrs.width
if (!width) {

@@ -113,3 +122,6 @@ // 如果width不存在,四点共其实点

}
var height = self._getTextHeight(); // attrs.height
var textAlign = attrs.textAlign;

@@ -158,21 +170,28 @@ var textBaseline = attrs.textBaseline;

var cfg = this._cfg;
if (!cfg.attrs || cfg.hasUpdate) {
this._assembleFont();
this._setAttrText();
}
context.font = attrs.font;
var text = attrs.text;
if (!text) {
return;
}
var textArr = attrs.textArr;
var x = attrs.x;
var y = attrs.y;
context.beginPath();
context.beginPath();
if (self.hasStroke()) {
var strokeOpacity = attrs.strokeOpacity;
if (!Util.isNil(strokeOpacity) && strokeOpacity !== 1) {
context.globalAlpha = strokeOpacity;
}
if (textArr) {

@@ -183,9 +202,13 @@ self._drawTextArr(context, false);

}
context.globalAlpha = 1;
}
if (self.hasFill()) {
var fillOpacity = attrs.fillOpacity;
if (!Util.isNil(fillOpacity) && fillOpacity !== 1) {
context.globalAlpha = fillOpacity;
}
if (textArr) {

@@ -197,2 +220,3 @@ self._drawTextArr(context, true);

}
cfg.hasUpdate = false;

@@ -204,3 +228,5 @@ },

var fontSize = this._attrs.fontSize * 1;
var spaceingY = this._getSpaceingY();
var x = this._attrs.x;

@@ -210,8 +236,9 @@ var y = this._attrs.y;

var height = box.maxY - box.minY;
var subY = void 0;
var subY;
Util.each(textArr, function (subText, index) {
subY = y + index * (spaceingY + fontSize) - height + fontSize; // bottom;
if (textBaseline === 'middle') subY += height - fontSize - (height - fontSize) / 2;
if (textBaseline === 'top') subY += height - fontSize;
if (fill) {

@@ -230,5 +257,4 @@ context.fillText(subText, x, subY);

var textArr = attrs.textArr;
var measureWidth = void 0;
var measureWidth;
var width = 0;
if (Util.isNil(text)) return undefined;

@@ -238,8 +264,11 @@ var context = document.createElement('canvas').getContext('2d');

context.font = font;
if (textArr) {
Util.each(textArr, function (subText) {
measureWidth = context.measureText(subText).width;
if (width < measureWidth) {
width = measureWidth;
}
context.restore();

@@ -251,6 +280,6 @@ });

}
return width;
}
});
module.exports = CText;

@@ -1,4 +0,3 @@

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; };
var Format = require('../../util/format');
var Format = require('../../util/format');
var PathSegment = require('../util/path-segment');

@@ -14,9 +13,9 @@

function _addArrow(ctx, attrs, x1, y1, x2, y2, isStart) {
var leftX = void 0;
var leftY = void 0;
var rightX = void 0;
var rightY = void 0;
var offsetX = void 0;
var offsetY = void 0;
var angle = void 0;
var leftX;
var leftY;
var rightX;
var rightY;
var offsetX;
var offsetY;
var angle;

@@ -28,2 +27,3 @@ if (!attrs.fill) {

// Calculate angle
angle = atan2(y1 - y2, x1 - x2);

@@ -33,25 +33,27 @@ /* // Adjust angle correctly

// Calculate offset to place arrow at edge of path
offsetX = Math.abs(attrs.lineWidth * cos(angle)) / 2;
offsetY = Math.abs(attrs.lineWidth * sin(angle)) / 2;
if (isStart) {
offsetX = -offsetX;
offsetY = -offsetY;
}
// Calculate coordinates for left half of arrow
} // Calculate coordinates for left half of arrow
leftX = x2 + arrowLength * cos(angle + arrowAngle / 2);
leftY = y2 + arrowLength * sin(angle + arrowAngle / 2);
// Calculate coordinates for right half of arrow
leftY = y2 + arrowLength * sin(angle + arrowAngle / 2); // Calculate coordinates for right half of arrow
rightX = x2 + arrowLength * cos(angle - arrowAngle / 2);
rightY = y2 + arrowLength * sin(angle - arrowAngle / 2);
ctx.beginPath();
// Draw left half of arrow
ctx.beginPath(); // Draw left half of arrow
ctx.moveTo(leftX - offsetX, leftY - offsetY);
ctx.lineTo(x2 - offsetX, y2 - offsetY);
// Draw right half of arrow
ctx.lineTo(rightX - offsetX, rightY - offsetY);
ctx.lineTo(x2 - offsetX, y2 - offsetY); // Draw right half of arrow
// Visually connect arrow to path
ctx.lineTo(rightX - offsetX, rightY - offsetY); // Visually connect arrow to path
ctx.moveTo(x2 - offsetX, y2 - offsetY);
ctx.lineTo(x2 + offsetX, y2 + offsetY);
// Move back to end of path
ctx.lineTo(x2 + offsetX, y2 + offsetY); // Move back to end of path
ctx.moveTo(x2, y2);

@@ -65,3 +67,3 @@ ctx.stroke();

var pathArray = Format.parsePath(attrs.path);
var preSegment = void 0;
var preSegment;

@@ -71,3 +73,5 @@ if (!Array.isArray(pathArray) || pathArray.length === 0 || pathArray[0][0] !== 'M' && pathArray[0][0] !== 'm') {

}
var count = pathArray.length;
for (var i = 0; i < pathArray.length; i++) {

@@ -78,2 +82,3 @@ var item = pathArray[i];

}
return segments;

@@ -89,2 +94,3 @@ }

var tan = Math.atan(x / y);
if (y === 0 && x < 0) {

@@ -101,6 +107,9 @@ deg = Math.PI;

}
var path = parsePath(shape);
if (!path) {
return;
}
if (d) {

@@ -115,2 +124,3 @@ if (isStart) {

}
ctx.save();

@@ -120,5 +130,7 @@ ctx.beginPath();

ctx.rotate(deg);
for (var i = 0; i < path.length; i++) {
path[i].draw(ctx);
}
ctx.setTransform(1, 0, 0, 1, 0, 0);

@@ -132,3 +144,3 @@ ctx.fillStyle = ctx.strokeStyle;

addStartArrow: function addStartArrow(ctx, attrs, x1, y1, x2, y2) {
if (_typeof(attrs.startArrow) === 'object') {
if (typeof attrs.startArrow === 'object') {
_addCustomizedArrow(ctx, attrs, x1, y1, x2, y2, true);

@@ -140,3 +152,3 @@ } else if (attrs.startArrow) {

addEndArrow: function addEndArrow(ctx, attrs, x1, y1, x2, y2) {
if (_typeof(attrs.endArrow) === 'object') {
if (typeof attrs.endArrow === 'object') {
_addCustomizedArrow(ctx, attrs, x1, y1, x2, y2, false);

@@ -143,0 +155,0 @@ } else if (attrs.endArrow) {

var Line = require('../math/line');
var Quadratic = require('../math/quadratic');
var Cubic = require('../math/cubic');
var Arc = require('../math/arc');

@@ -15,5 +18,7 @@

var d = Line.pointDistance(x1, y1, x2, y2, x, y);
if (isNaN(d)) {
return false;
}
return d <= lineWidth / 2;

@@ -23,5 +28,7 @@ },

var l = points.length - 1;
if (l < 1) {
return false;
}
for (var i = 0; i < l; i++) {

@@ -28,0 +35,0 @@ var x1 = points[i][0];

var Util = require('../../util/index');
var Inside = require('./inside');
var Cubic = require('../math/cubic');
var Quadratic = require('../math/quadratic');
var Ellipse = require('../math/ellipse');
var vec3 = require('../../util/matrix').vec3;
var mat3 = require('../../util/matrix').mat3;

@@ -48,2 +54,3 @@

var lambda = xp * xp / (rx * rx) + yp * yp / (ry * ry);
if (lambda > 1) {

@@ -53,2 +60,3 @@ rx *= Math.sqrt(lambda);

}
var diff = rx * rx * (yp * yp) + ry * ry * (xp * xp);

@@ -60,2 +68,3 @@ var f = Math.sqrt((rx * rx * (ry * ry) - diff) / diff);

}
if (isNaN(f)) {

@@ -67,6 +76,4 @@ f = 0;

var cyp = f * -ry * xp / rx;
var cx = (x1 + x2) / 2.0 + Math.cos(psi) * cxp - Math.sin(psi) * cyp;
var cy = (y1 + y2) / 2.0 + Math.sin(psi) * cxp + Math.cos(psi) * cyp;
var theta = vAngle([1, 0], [(xp - cxp) / rx, (yp - cyp) / ry]);

@@ -76,8 +83,11 @@ var u = [(xp - cxp) / rx, (yp - cyp) / ry];

var dTheta = vAngle(u, v);
if (fs === 0 && dTheta > 0) {
dTheta = dTheta - 2 * Math.PI;
}
if (fs === 1 && dTheta < 0) {
dTheta = dTheta + 2 * Math.PI;
}
return [point1, cx, cy, rx, ry, theta, dTheta, psi, fs];

@@ -102,15 +112,17 @@ }

var relative = ARR_CMD.indexOf(command) >= 0; // /[a-z]/.test(command);
var cmd = relative ? command.toUpperCase() : command;
var p = item;
var point1 = void 0;
var point2 = void 0;
var point3 = void 0;
var point = void 0;
var point1;
var point2;
var point3;
var point;
var preEndPoint = preSegment.endPoint;
var p1 = p[1];
var p2 = p[2];
switch (cmd) {
default:
break;
case 'M':

@@ -125,2 +137,3 @@ if (relative) {

}
this.command = 'M';

@@ -131,2 +144,3 @@ this.params = [preEndPoint, point];

break;
case 'L':

@@ -141,2 +155,3 @@ if (relative) {

}
this.command = 'L';

@@ -146,9 +161,13 @@ this.params = [preEndPoint, point];

this.endPoint = point;
this.endTangent = function () {
return [point.x - preEndPoint.x, point.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point.x, preEndPoint.y - point.y];
};
break;
case 'H':

@@ -163,2 +182,3 @@ if (relative) {

}
this.command = 'L';

@@ -168,9 +188,13 @@ this.params = [preEndPoint, point];

this.endPoint = point;
this.endTangent = function () {
return [point.x - preEndPoint.x, point.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point.x, preEndPoint.y - point.y];
};
break;
case 'V':

@@ -185,2 +209,3 @@ if (relative) {

}
this.command = 'L';

@@ -190,9 +215,13 @@ this.params = [preEndPoint, point];

this.endPoint = point;
this.endTangent = function () {
return [point.x - preEndPoint.x, point.y - preEndPoint.y];
};
this.startTangent = function () {
return [preEndPoint.x - point.x, preEndPoint.y - point.y];
};
break;
case 'Q':

@@ -212,2 +241,3 @@ if (relative) {

}
this.command = 'Q';

@@ -217,9 +247,13 @@ this.params = [preEndPoint, point1, point2];

this.endPoint = point2;
this.endTangent = function () {
return [point2.x - point1.x, point2.y - point1.y];
};
this.startTangent = function () {
return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
};
break;
case 'T':

@@ -234,2 +268,3 @@ if (relative) {

}
if (preSegment.command === 'Q') {

@@ -241,5 +276,7 @@ point1 = toSymmetry(preSegment.params[1], preEndPoint);

this.endPoint = point2;
this.endTangent = function () {
return [point2.x - point1.x, point2.y - point1.y];
};
this.startTangent = function () {

@@ -253,5 +290,7 @@ return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];

this.endPoint = point2;
this.endTangent = function () {
return [point2.x - preEndPoint.x, point2.y - preEndPoint.y];
};
this.startTangent = function () {

@@ -263,2 +302,3 @@ return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];

break;
case 'C':

@@ -283,2 +323,3 @@ if (relative) {

}
this.command = 'C';

@@ -288,9 +329,13 @@ this.params = [preEndPoint, point1, point2, point3];

this.endPoint = point3;
this.endTangent = function () {
return [point3.x - point2.x, point3.y - point2.y];
};
this.startTangent = function () {
return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];
};
break;
case 'S':

@@ -310,2 +355,3 @@ if (relative) {

}
if (preSegment.command === 'C') {

@@ -317,5 +363,7 @@ point1 = toSymmetry(preSegment.params[2], preEndPoint);

this.endPoint = point3;
this.endTangent = function () {
return [point3.x - point2.x, point3.y - point2.y];
};
this.startTangent = function () {

@@ -329,5 +377,7 @@ return [preEndPoint.x - point1.x, preEndPoint.y - point1.y];

this.endPoint = point3;
this.endTangent = function () {
return [point3.x - point2.x, point3.y - point2.y];
};
this.startTangent = function () {

@@ -337,3 +387,5 @@ return [preEndPoint.x - point2.x, preEndPoint.y - point2.y];

}
break;
case 'A':

@@ -346,2 +398,3 @@ {

var fs = p[5];
if (relative) {

@@ -363,10 +416,15 @@ point = toAbsolute(p[6], p[7], preEndPoint);

var startAngle = params[5] % (Math.PI * 2);
if (Util.isNumberEqual(startAngle, Math.PI * 2)) {
startAngle = 0;
}
var endAngle = params[6] % (Math.PI * 2);
if (Util.isNumberEqual(endAngle, Math.PI * 2)) {
endAngle = 0;
}
var d = 0.001;
this.startTangent = function () {

@@ -376,2 +434,3 @@ if (fs === 0) {

}
var dx = params[3] * Math.cos(startAngle - d) + params[1];

@@ -381,7 +440,10 @@ var dy = params[4] * Math.sin(startAngle - d) + params[2];

};
this.endTangent = function () {
var endAngle = params[6];
if (endAngle - Math.PI * 2 < 0.0001) {
endAngle = 0;
}
var dx = params[3] * Math.cos(startAngle + endAngle + d) + params[1];

@@ -391,4 +453,6 @@ var dy = params[4] * Math.sin(startAngle + endAngle - d) + params[2];

};
break;
}
case 'Z':

@@ -408,2 +472,3 @@ {

var box = self.box;
if (box) {

@@ -414,7 +479,10 @@ if (!Inside.box(box.minX, box.maxX, box.minY, box.maxY, x, y)) {

}
switch (command) {
default:
break;
case 'M':
return false;
case 'TL':

@@ -424,5 +492,7 @@ case 'L':

return Inside.line(params[0].x, params[0].y, params[1].x, params[1].y, lineWidth, x, y);
case 'SQ':
case 'Q':
return Inside.quadraticline(params[0].x, params[0].y, params[1].x, params[1].y, params[2].x, params[2].y, lineWidth, x, y);
case 'C':

@@ -432,2 +502,3 @@ {

}
case 'A':

@@ -444,7 +515,5 @@ {

var fs = p[8];
var r = rx > ry ? rx : ry;
var scaleX = rx > ry ? 1 : rx / ry;
var scaleY = rx > ry ? ry / rx : 1;
p = [x, y, 1];

@@ -459,2 +528,3 @@ var m = [1, 0, 0, 0, 1, 0, 0, 0, 1];

}
return false;

@@ -465,5 +535,5 @@ },

var params = this.params;
var point1 = void 0;
var point2 = void 0;
var point3 = void 0;
var point1;
var point2;
var point3;

@@ -473,5 +543,7 @@ switch (command) {

break;
case 'M':
context.moveTo(params[1].x, params[1].y);
break;
case 'TL':

@@ -481,2 +553,3 @@ case 'L':

break;
case 'SQ':

@@ -488,2 +561,3 @@ case 'Q':

break;
case 'C':

@@ -495,2 +569,3 @@ point1 = params[1];

break;
case 'A':

@@ -509,7 +584,5 @@ {

var fs = p[8];
var r = rx > ry ? rx : ry;
var scaleX = rx > ry ? 1 : rx / ry;
var scaleY = rx > ry ? ry / rx : 1;
context.translate(cx, cy);

@@ -524,2 +597,3 @@ context.rotate(psi);

}
case 'Z':

@@ -533,6 +607,6 @@ context.closePath();

var params = this.params;
var yDims = void 0;
var xDims = void 0;
var i = void 0;
var l = void 0;
var yDims;
var xDims;
var i;
var l;

@@ -544,2 +618,3 @@ switch (this.command) {

break;
case 'TL':

@@ -554,13 +629,18 @@ case 'L':

break;
case 'SQ':
case 'Q':
xDims = Quadratic.extrema(params[0].x, params[1].x, params[2].x);
for (i = 0, l = xDims.length; i < l; i++) {
xDims[i] = Quadratic.at(params[0].x, params[1].x, params[2].x, xDims[i]);
}
xDims.push(params[0].x, params[2].x);
yDims = Quadratic.extrema(params[0].y, params[1].y, params[2].y);
for (i = 0, l = yDims.length; i < l; i++) {
yDims[i] = Quadratic.at(params[0].y, params[1].y, params[2].y, yDims);
}
yDims.push(params[0].y, params[2].y);

@@ -574,11 +654,16 @@ this.box = {

break;
case 'C':
xDims = Cubic.extrema(params[0].x, params[1].x, params[2].x, params[3].x);
for (i = 0, l = xDims.length; i < l; i++) {
xDims[i] = Cubic.at(params[0].x, params[1].x, params[2].x, params[3].x, xDims[i]);
}
yDims = Cubic.extrema(params[0].y, params[1].y, params[2].y, params[3].y);
for (i = 0, l = yDims.length; i < l; i++) {
yDims[i] = Cubic.at(params[0].y, params[1].y, params[2].y, params[3].y, yDims[i]);
}
xDims.push(params[0].x, params[3].x);

@@ -593,2 +678,3 @@ yDims.push(params[0].y, params[3].y);

break;
case 'A':

@@ -608,3 +694,2 @@ {

var end = theta + dTheta;
var xDim = Ellipse.xExtrema(psi, rx, ry);

@@ -614,4 +699,6 @@ var minX = Infinity;

var xs = [start, end];
for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
var xAngle = xDim + i;
if (fs === 1) {

@@ -630,5 +717,7 @@ if (start < xAngle && xAngle < end) {

var x = Ellipse.xAt(psi, rx, ry, cx, xs[i]);
if (x < minX) {
minX = x;
}
if (x > maxX) {

@@ -643,4 +732,6 @@ maxX = x;

var ys = [start, end];
for (i = -Math.PI * 2; i <= Math.PI * 2; i += Math.PI) {
var yAngle = yDim + i;
if (fs === 1) {

@@ -659,5 +750,7 @@ if (start < yAngle && yAngle < end) {

var y = Ellipse.yAt(psi, rx, ry, cy, ys[i]);
if (y < minY) {
minY = y;
}
if (y > maxY) {

@@ -667,2 +760,3 @@ maxY = y;

}
this.box = {

@@ -679,3 +773,2 @@ minX: minX - halfWidth,

});
module.exports = PathSegment;

@@ -11,9 +11,13 @@ var Util = require('@antv/util/lib');

isNumber: Util.isNumber,
isEmpty: Util.isEmpty, // isBlank
isEmpty: Util.isEmpty,
// isBlank
uniqueId: Util.uniqueId,
clone: Util.clone,
deepMix: Util.deepMix,
assign: Util.mix, // simpleMix
merge: Util.deepMix, // mix
upperFirst: Util.upperFirst, // ucfirst
assign: Util.mix,
// simpleMix
merge: Util.deepMix,
// mix
upperFirst: Util.upperFirst,
// ucfirst
each: Util.each,

@@ -20,0 +24,0 @@ isEqual: Util.isEqual,

@@ -15,3 +15,2 @@ var Util = require('./common');

};
module.exports = {

@@ -30,2 +29,3 @@ getBoundingClientRect: function getBoundingClientRect(node, defaultValue) {

}
return defaultValue || null;

@@ -46,2 +46,3 @@ },

}
return dom.currentStyle[name];

@@ -52,2 +53,3 @@ } catch (e) {

}
return null;

@@ -64,2 +66,3 @@ }

}
return dom;

@@ -75,5 +78,7 @@ },

var name = FRAGMENT_REG.test(str) && RegExp.$1;
if (!(name in CONTAINERS)) {
name = '*';
}
var container = CONTAINERS[name];

@@ -98,5 +103,7 @@ str = str.replace(/(^\s*)|(\s*$)/g, '');

var width = this.getStyle(el, 'width', defaultValue);
if (width === 'auto') {
width = el.offsetWidth;
}
return parseFloat(width);

@@ -113,5 +120,7 @@ },

var height = this.getStyle(el, 'height', defaultValue);
if (height === 'auto') {
height = el.offsetHeight;
}
return parseFloat(height);

@@ -118,0 +127,0 @@ },

@@ -6,3 +6,2 @@ var Util = require('../util/index');

var numColorCache = {};
module.exports = {

@@ -14,2 +13,3 @@ parseRadius: function parseRadius(radius) {

r4 = 0;
if (Util.isArray(radius)) {

@@ -34,2 +34,3 @@ if (radius.length === 1) {

}
return {

@@ -44,2 +45,3 @@ r1: r1,

path = path || [];
if (Util.isArray(path)) {

@@ -53,2 +55,3 @@ return path;

item = item.match(regexDot);
if (item[0].length > 1) {

@@ -59,2 +62,3 @@ var tag = item[0].charAt(0);

}
Util.each(item, function (sub, i) {

@@ -73,12 +77,16 @@ if (!isNaN(sub)) {

var color = numColorCache[num];
if (!color) {
var str = num.toString(16);
for (var i = str.length; i < 6; i++) {
str = '0' + str;
}
color = '#' + str;
numColorCache[num] = color;
}
return color;
}
};
var CommonUtil = require('./common');
var DomUtil = require('./dom');
var Util = {};
CommonUtil.merge(Util, CommonUtil, DomUtil, {
mixin: function mixin(c, mixins) {
var Param = c.CFG ? 'CFG' : 'ATTRS';
if (c && mixins) {

@@ -16,2 +17,3 @@ c._mixins = mixins;

var attrs = mixin[Param];
if (attrs) {

@@ -25,3 +27,2 @@ Util.merge(temp, attrs);

});
module.exports = Util;
var CommonUtil = require('./common');
var mat3 = require('@antv/gl-matrix/lib/gl-matrix/mat3');
var vec3 = require('@antv/gl-matrix/lib/gl-matrix/vec3');
var vec2 = require('@antv/gl-matrix/lib/gl-matrix/vec2');

@@ -16,8 +19,12 @@

*/
vec2.direction = function (v1, v2) {
return v1[0] * v2[1] - v2[0] * v1[1];
};
vec2.angleTo = function (v1, v2, direct) {
var angle = vec2.angle(v1, v2);
var angleLargeThanPI = vec2.direction(v1, v2) >= 0;
if (direct) {

@@ -34,4 +41,6 @@ if (angleLargeThanPI) {

}
return Math.PI * 2 - angle;
};
vec2.vertical = function (out, v, flag) {

@@ -78,11 +87,15 @@ if (flag) {

break;
case 's':
mat3.scale(m, m, [t[1], t[2]]);
break;
case 'r':
mat3.rotate(m, m, t[1]);
break;
case 'm':
mat3.multiply(m, m, t[1]);
break;
default:

@@ -89,0 +102,0 @@ return false;

@@ -1,9 +0,7 @@

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; };
var Util = require('./common');
var Util = require('./common');
var SPACES = '\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029';
var SPACES = "\t\n\x0B\f\r \xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029";
var PATH_COMMAND = new RegExp('([a-z])[' + SPACES + ',]*((-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?[' + SPACES + ']*,?[' + SPACES + ']*)+)', 'ig');
var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig');
var PATH_VALUES = new RegExp('(-?\\d*\\.?\\d*(?:e[\\-+]?\\d+)?)[' + SPACES + ']*,?[' + SPACES + ']*', 'ig'); // Parses given path string into an array of arrays of path segments
// Parses given path string into an array of arrays of path segments
var parsePathString = function parsePathString(pathString) {

@@ -14,5 +12,6 @@ if (!pathString) {

if ((typeof pathString === 'undefined' ? 'undefined' : _typeof(pathString)) === _typeof([])) {
if (typeof pathString === typeof []) {
return pathString;
}
var paramCounts = {

@@ -34,3 +33,2 @@ a: 7,

var data = [];
String(pathString).replace(PATH_COMMAND, function (a, b, c) {

@@ -42,2 +40,3 @@ var params = [];

});
if (name === 'm' && params.length > 2) {

@@ -48,5 +47,7 @@ data.push([b].concat(params.splice(0, 2)));

}
if (name === 'o' && params.length === 1) {
data.push([b, params[0]]);
}
if (name === 'r') {

@@ -57,2 +58,3 @@ data.push([b].concat(params));

data.push([b].concat(params.splice(0, paramCounts[name])));
if (!paramCounts[name]) {

@@ -64,9 +66,9 @@ break;

});
return data;
};
}; // http://schepers.cc/getting-to-the-point
// http://schepers.cc/getting-to-the-point
var catmullRom2bezier = function catmullRom2bezier(crp, z) {
var d = [];
for (var i = 0, iLen = crp.length; iLen - 2 * !z > i; i += 2) {

@@ -86,2 +88,3 @@ var p = [{

}];
if (z) {

@@ -118,2 +121,3 @@ if (!i) {

}
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]);

@@ -127,5 +131,7 @@ }

var res = [];
if (a === null && ry === null) {
ry = rx;
}
x = +x;

@@ -135,2 +141,3 @@ y = +y;

ry = +ry;
if (a !== null) {

@@ -146,2 +153,3 @@ var rad = Math.PI / 180;

}
return res;

@@ -156,2 +164,3 @@ };

}
var res = [];

@@ -163,4 +172,5 @@ var x = 0;

var start = 0;
var pa0 = void 0;
var dots = void 0;
var pa0;
var dots;
if (pathArray[0][0] === 'M') {

@@ -174,3 +184,5 @@ x = +pathArray[0][1];

}
var crz = pathArray.length === 3 && pathArray[0][0] === 'M' && pathArray[1][0].toUpperCase() === 'R' && pathArray[2][0].toUpperCase() === 'Z';
for (var r, pa, i = start, ii = pathArray.length; i < ii; i++) {

@@ -180,4 +192,6 @@ res.push(r = []);

pa0 = pa[0];
if (pa0 !== pa0.toUpperCase()) {
r[0] = pa0.toUpperCase();
switch (r[0]) {

@@ -193,10 +207,14 @@ case 'A':

break;
case 'V':
r[1] = +pa[1] + y;
break;
case 'H':
r[1] = +pa[1] + x;
break;
case 'R':
dots = [x, y].concat(pa.slice(1));
for (var j = 2, jj = dots.length; j < jj; j++) {

@@ -206,5 +224,7 @@ dots[j] = +dots[j] + x;

}
res.pop();
res = res.concat(catmullRom2bezier(dots, crz));
break;
case 'O':

@@ -216,2 +236,3 @@ res.pop();

break;
case 'U':

@@ -222,6 +243,9 @@ res.pop();

break;
case 'M':
mx = +pa[1] + x;
my = +pa[2] + y;
break; // for lint
break;
// for lint
default:

@@ -231,2 +255,3 @@ for (var _j = 1, _jj = pa.length; _j < _jj; _j++) {

}
}

@@ -252,3 +277,5 @@ } else if (pa0 === 'R') {

}
pa0 = pa0.toUpperCase();
if (pa0 !== 'O') {

@@ -260,12 +287,17 @@ switch (r[0]) {

break;
case 'H':
x = r[1];
break;
case 'V':
y = r[1];
break;
case 'M':
mx = r[r.length - 2];
my = r[r.length - 1];
break; // for lint
break;
// for lint
default:

@@ -287,3 +319,5 @@ x = r[r.length - 2];

var _13 = 1 / 3;
var _23 = 2 / 3;
return [_13 * x1 + _23 * ax, _13 * y1 + _23 * ay, _13 * x2 + _23 * ax, _13 * y2 + _23 * ay, x2, y2];

@@ -300,9 +334,11 @@ };

var _120 = Math.PI * 120 / 180;
var rad = Math.PI / 180 * (+angle || 0);
var res = [];
var xy = void 0;
var f1 = void 0;
var f2 = void 0;
var cx = void 0;
var cy = void 0;
var xy;
var f1;
var f2;
var cx;
var cy;
var rotate = function rotate(x, y, rad) {

@@ -316,2 +352,3 @@ var X = x * Math.cos(rad) - y * Math.sin(rad);

};
if (!recursive) {

@@ -324,2 +361,3 @@ xy = rotate(x1, y1, -rad);

y2 = xy.y;
if (x1 === x2 && y1 === y2) {

@@ -329,8 +367,10 @@ // 若弧的起始点和终点重叠则错开一点

y2 += 1;
}
// const cos = Math.cos(Math.PI / 180 * angle);
} // const cos = Math.cos(Math.PI / 180 * angle);
// const sin = Math.sin(Math.PI / 180 * angle);
var x = (x1 - x2) / 2;
var y = (y1 - y2) / 2;
var h = x * x / (rx * rx) + y * y / (ry * ry);
if (h > 1) {

@@ -341,2 +381,3 @@ h = Math.sqrt(h);

}
var rx2 = rx * rx;

@@ -349,3 +390,2 @@ var ry2 = ry * ry;

f2 = Math.asin(((y2 - cy) / ry).toFixed(9));
f1 = x1 < cx ? Math.PI - f1 : f1;

@@ -355,5 +395,7 @@ f2 = x2 < cx ? Math.PI - f2 : f2;

f2 < 0 && (f2 = Math.PI * 2 + f2);
if (sweep_flag && f1 > f2) {
f1 = f1 - Math.PI * 2;
}
if (!sweep_flag && f2 > f1) {

@@ -368,3 +410,5 @@ f2 = f2 - Math.PI * 2;

}
var df = f2 - f1;
if (Math.abs(df) > _120) {

@@ -379,2 +423,3 @@ var f2old = f2;

}
df = f2 - f1;

@@ -394,10 +439,14 @@ var c1 = Math.cos(f1);

m2[1] = 2 * m1[1] - m2[1];
if (recursive) {
return [m2, m3, m4].concat(res);
}
res = [m2, m3, m4].concat(res).join().split(',');
var newres = [];
for (var i = 0, ii = res.length; i < ii; i++) {
newres[i] = i % 2 ? rotate(res[i - 1], res[i], rad).y : rotate(res[i], res[i + 1], rad).x;
}
return newres;

@@ -430,15 +479,23 @@ };

var pcoms1 = []; // path commands of original path p
var pcoms2 = []; // path commands of original path p2
var pfirst = ''; // temporary holder for original path command
var pcom = ''; // holder for previous path command of original path
var ii = void 0;
var ii;
var processPath = function processPath(path, d, pcom) {
var nx = void 0,
ny = void 0;
var nx, ny;
if (!path) {
return ['C', d.x, d.y, d.x, d.y, d.x, d.y];
}!(path[0] in {
}
!(path[0] in {
T: 1,
Q: 1
}) && (d.qx = d.qy = null);
switch (path[0]) {

@@ -449,5 +506,7 @@ case 'M':

break;
case 'A':
path = ['C'].concat(a2c.apply(0, [d.x, d.y].concat(path.slice(1))));
break;
case 'S':

@@ -457,2 +516,3 @@ if (pcom === 'C' || pcom === 'S') {

nx = d.x * 2 - d.bx; // And reflect the previous
ny = d.y * 2 - d.by; // command's control point relative to the current point.

@@ -464,4 +524,6 @@ } else {

}
path = ['C', nx, ny].concat(path.slice(1));
break;
case 'T':

@@ -471,2 +533,3 @@ if (pcom === 'Q' || pcom === 'T') {

d.qx = d.x * 2 - d.qx; // And make a reflection similar
d.qy = d.y * 2 - d.qy; // to case "S".

@@ -478,4 +541,6 @@ } else {

}
path = ['C'].concat(q2c(d.x, d.y, d.qx, d.qy, path[1], path[2]));
break;
case 'Q':

@@ -486,19 +551,26 @@ d.qx = path[1];

break;
case 'L':
path = ['C'].concat(l2c(d.x, d.y, path[1], path[2]));
break;
case 'H':
path = ['C'].concat(l2c(d.x, d.y, path[1], d.y));
break;
case 'V':
path = ['C'].concat(l2c(d.x, d.y, d.x, path[1]));
break;
case 'Z':
path = ['C'].concat(l2c(d.x, d.y, d.X, d.Y));
break;
default:
break;
}
return path;
};
var fixArc = function fixArc(pp, i) {

@@ -508,7 +580,11 @@ if (pp[i].length > 7) {

var pi = pp[i];
while (pi.length) {
pcoms1[i] = 'A'; // if created multiple C:s, their original seg is saved
p2 && (pcoms2[i] = 'A'); // the same as above
pp.splice(i++, 0, ['C'].concat(pi.splice(0, 6)));
}
pp.splice(i, 1);

@@ -518,2 +594,3 @@ ii = Math.max(p.length, p2 && p2.length || 0);

};
var fixM = function fixM(path1, path2, a1, a2, i) {

@@ -529,5 +606,6 @@ if (path1 && path2 && path1[i][0] === 'M' && path2[i][0] !== 'M') {

};
ii = Math.max(p.length, p2 && p2.length || 0);
for (var i = 0; i < ii; i++) {
p[i] && (pfirst = p[i][0]); // save current path command

@@ -538,4 +616,6 @@

pcoms1[i] = pfirst; // Save current path command
i && (pcom = pcoms1[i - 1]); // Get previous path command pcom
}
p[i] = processPath(p[i], attrs, pcom); // Previous path command is inputted to processPath

@@ -552,2 +632,3 @@

p2[i] && (pfirst = p2[i][0]);
if (pfirst !== 'C') {

@@ -557,2 +638,3 @@ pcoms2[i] = pfirst;

}
p2[i] = processPath(p2[i], attrs2, pcom);

@@ -566,2 +648,3 @@

}
fixM(p, p2, attrs, attrs2, i);

@@ -587,2 +670,3 @@ fixM(p2, p, attrs2, attrs, i);

var p2s = /,?([a-z]),?/gi;
var parsePathArray = function parsePathArray(path) {

@@ -602,2 +686,3 @@ return path.join(',').replace(p2s, '$1');

}
z = z > 1 ? 1 : z < 0 ? 0 : z;

@@ -609,2 +694,3 @@ var z2 = z / 2;

var sum = 0;
for (var i = 0; i < n; i++) {

@@ -617,2 +703,3 @@ var ct = z2 * Tvalues[i] + z2;

}
return z2 * sum;

@@ -624,6 +711,6 @@ };

var bounds = [[], []];
var a = void 0;
var b = void 0;
var c = void 0;
var t = void 0;
var a;
var b;
var c;
var t;

@@ -640,2 +727,3 @@ for (var i = 0; i < 2; ++i) {

}
if (Math.abs(a) < 1e-12) {

@@ -645,18 +733,27 @@ if (Math.abs(b) < 1e-12) {

}
t = -c / b;
if (t > 0 && t < 1) {
tvalues.push(t);
}
continue;
}
var b2ac = b * b - 4 * c * a;
var sqrtb2ac = Math.sqrt(b2ac);
if (b2ac < 0) {
continue;
}
var t1 = (-b + sqrtb2ac) / (2 * a);
if (t1 > 0 && t1 < 1) {
tvalues.push(t1);
}
var t2 = (-b - sqrtb2ac) / (2 * a);
if (t2 > 0 && t2 < 1) {

@@ -669,3 +766,4 @@ tvalues.push(t2);

var jlen = j;
var mt = void 0;
var mt;
while (j--) {

@@ -683,3 +781,2 @@ t = tvalues[j];

bounds[0].length = bounds[1].length = jlen + 2;
return {

@@ -701,2 +798,3 @@ min: {

}
var nx = (x1 * y2 - y1 * x2) * (x3 - x4) - (x1 - x2) * (x3 * y4 - y3 * x4);

@@ -709,2 +807,3 @@ var ny = (x1 * y2 - y1 * x2) * (y3 - y4) - (y1 - y2) * (x3 * y4 - y3 * x4);

}
var px = nx / denominator;

@@ -714,5 +813,7 @@ var py = ny / denominator;

var py2 = +py.toFixed(2);
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)) {
return;
}
return {

@@ -732,2 +833,3 @@ x: px,

}
var res = [['M', x, y], ['l', w, 0], ['l', 0, h], ['l', -w, 0], ['z']];

@@ -742,2 +844,3 @@ res.parsePathArray = parsePathArray;

}
if (y === null) {

@@ -749,2 +852,3 @@ y = x.y;

}
return {

@@ -779,2 +883,3 @@ x: x,

}
var bbox = curveDim.apply(null, p1x);

@@ -800,4 +905,4 @@ return box(bbox.min.x, bbox.min.y, bbox.max.x - bbox.min.x, bbox.max.y - bbox.min.y);

var cy = t1 * c2y + t * p2y;
var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI;
// (mx > nx || my < ny) && (alpha += 180);
var alpha = 90 - Math.atan2(mx - nx, my - ny) * 180 / Math.PI; // (mx > nx || my < ny) && (alpha += 180);
return {

@@ -829,5 +934,7 @@ x: x,

var bbox2 = bezierBBox(bez2);
if (!isBBoxIntersect(bbox1, bbox2)) {
return justCount ? 0 : [];
}
var l1 = bezlen.apply(0, bez1);

@@ -841,2 +948,3 @@ var l2 = bezlen.apply(0, bez2);

var res = justCount ? 0 : [];
for (var i = 0; i < n1 + 1; i++) {

@@ -850,4 +958,6 @@ var d = findDotsAtSegment.apply(0, bez1.concat(i / n1));

}
for (var _i = 0; _i < n2 + 1; _i++) {
var _d = findDotsAtSegment.apply(0, bez2.concat(_i / n2));
dots2.push({

@@ -859,2 +969,3 @@ x: _d.x,

}
for (var _i2 = 0; _i2 < n1; _i2++) {

@@ -869,2 +980,3 @@ for (var j = 0; j < n2; j++) {

var is = intersect(di.x, di.y, di1.x, di1.y, dj.x, dj.y, dj1.x, dj1.y);
if (is) {

@@ -874,5 +986,7 @@ if (xy[is.x.toFixed(4)] === is.y.toFixed(4)) {

}
xy[is.x.toFixed(4)] = is.y.toFixed(4);
var t1 = di.t + Math.abs((is[ci] - di[ci]) / (di1[ci] - di[ci])) * (di1.t - di.t);
var t2 = dj.t + Math.abs((is[cj] - dj[cj]) / (dj1[cj] - dj[cj])) * (dj1.t - dj.t);
if (t1 >= 0 && t1 <= 1 && t2 >= 0 && t2 <= 1) {

@@ -893,2 +1007,3 @@ if (justCount) {

}
return res;

@@ -900,15 +1015,17 @@ };

path2 = pathTocurve(path2);
var x1 = void 0;
var y1 = void 0;
var x2 = void 0;
var y2 = void 0;
var x1m = void 0;
var y1m = void 0;
var x2m = void 0;
var y2m = void 0;
var bez1 = void 0;
var bez2 = void 0;
var x1;
var y1;
var x2;
var y2;
var x1m;
var y1m;
var x2m;
var y2m;
var bez1;
var bez2;
var res = justCount ? 0 : [];
for (var i = 0, ii = path1.length; i < ii; i++) {
var pi = path1[i];
if (pi[0] === 'M') {

@@ -927,4 +1044,6 @@ x1 = x1m = pi[1];

}
for (var j = 0, jj = path2.length; j < jj; j++) {
var pj = path2[j];
if (pj[0] === 'M') {

@@ -943,3 +1062,5 @@ x2 = x2m = pj[1];

}
var intr = interHelper(bez1, bez2, justCount);
if (justCount) {

@@ -954,2 +1075,3 @@ res += intr;

}
res = res.concat(intr);

@@ -961,2 +1083,3 @@ }

}
return res;

@@ -979,2 +1102,3 @@ };

var middlePoints = [];
for (var i = 0; i < points.length - 1; i++) {

@@ -984,14 +1108,22 @@ if (i === 0) {

}
if (i === points.length - 2) {
right.push(points[i + 1]);
}
middlePoints[i] = [(1 - t) * points[i][0] + t * points[i + 1][0], (1 - t) * points[i][1] + t * points[i + 1][1]];
}
recurse(middlePoints, t);
}
}
if (points.length) {
recurse(points, t);
}
return { left: left, right: right.reverse() };
return {
left: left,
right: right.reverse()
};
}

@@ -1003,2 +1135,3 @@

var segments = [];
if (end[0] === 'A') {

@@ -1027,5 +1160,7 @@ points.push(end[6]);

}
segments.push(leftSegments);
var result = segments.map(function (segment) {
var cmd = [];
if (segment.length === 4) {

@@ -1035,2 +1170,3 @@ cmd.push('C');

}
if (segment.length >= 3) {

@@ -1040,7 +1176,10 @@ if (segment.length === 3) {

}
cmd = cmd.concat(segment[1]);
}
if (segment.length === 2) {
cmd.push('L');
}
cmd = cmd.concat(segment[segment.length - 1]);

@@ -1056,3 +1195,5 @@ return cmd;

}
var segments = [];
if (end[0] === 'L' || end[0] === 'C' || end[0] === 'Q') {

@@ -1062,5 +1203,7 @@ segments = segments.concat(splitCurve(start, end, count));

var temp = [].concat(start);
if (temp[0] === 'M') {
temp[0] = 'L';
}
for (var i = 0; i <= count - 1; i++) {

@@ -1070,2 +1213,3 @@ segments.push(temp);

}
return segments;

@@ -1078,2 +1222,3 @@ };

}
var sourceLen = source.length - 1;

@@ -1083,2 +1228,3 @@ var targetLen = target.length - 1;

var segmentsToFill = [];
if (source.length === 1 && source[0][0] === 'M') {

@@ -1088,4 +1234,6 @@ for (var i = 0; i < targetLen - sourceLen; i++) {

}
return source;
}
for (var _i3 = 0; _i3 < targetLen; _i3++) {

@@ -1095,2 +1243,3 @@ var index = Math.floor(ratio * _i3);

}
var filled = segmentsToFill.reduce(function (filled, count, i) {

@@ -1100,8 +1249,11 @@ if (i === sourceLen) {

}
return filled.concat(splitSegment(source[i], source[i + 1], count));
}, []);
filled.unshift(source[0]);
if (target[targetLen] === 'Z' || target[targetLen] === 'z') {
filled.push('Z');
}
return filled;

@@ -1114,2 +1266,3 @@ };

}
var result = true;

@@ -1124,5 +1277,7 @@ Util.each(obj1, function (item, i) {

};
function getMinDiff(del, add, modify) {
var type = null;
var min = modify;
if (add < min) {

@@ -1132,2 +1287,3 @@ min = add;

}
if (del < min) {

@@ -1137,2 +1293,3 @@ min = del;

}
return {

@@ -1143,3 +1300,2 @@ type: type,

}
/*

@@ -1149,18 +1305,27 @@ * https://en.wikipedia.org/wiki/Levenshtein_distance

*/
var levenshteinDistance = function levenshteinDistance(source, target) {
var sourceLen = source.length;
var targetLen = target.length;
var sourceSegment = void 0,
targetSegment = void 0;
var sourceSegment, targetSegment;
var temp = 0;
if (sourceLen === 0 || targetLen === 0) {
return null;
}
var dist = [];
for (var i = 0; i <= sourceLen; i++) {
dist[i] = [];
dist[i][0] = { min: i };
dist[i][0] = {
min: i
};
}
for (var j = 0; j <= targetLen; j++) {
dist[0][j] = { min: j };
dist[0][j] = {
min: j
};
}

@@ -1170,4 +1335,6 @@

sourceSegment = source[_i4 - 1];
for (var _j2 = 1; _j2 <= targetLen; _j2++) {
targetSegment = target[_j2 - 1];
if (isEqual(sourceSegment, targetSegment)) {

@@ -1178,2 +1345,3 @@ temp = 0;

}
var del = dist[_i4 - 1][_j2].min + 1;

@@ -1185,2 +1353,3 @@ var add = dist[_i4][_j2 - 1].min + 1;

}
return dist;

@@ -1195,4 +1364,4 @@ };

var index = 1;
var minPos = 1;
// 如果source和target不是完全不相等
var minPos = 1; // 如果source和target不是完全不相等
if (diffMatrix[sourceLen][targetLen] !== sourceLen) {

@@ -1203,2 +1372,3 @@ // 获取从source到target所需改动

minPos = i;
for (var j = index; j <= targetLen; j++) {

@@ -1210,10 +1380,17 @@ if (diffMatrix[i][j].min < min) {

}
index = minPos;
if (diffMatrix[i][index].type) {
changes.push({ index: i - 1, type: diffMatrix[i][index].type });
changes.push({
index: i - 1,
type: diffMatrix[i][index].type
});
}
}
// 对source进行增删path
} // 对source进行增删path
for (var _i5 = changes.length - 1; _i5 >= 0; _i5--) {
index = changes[_i5].index;
if (changes[_i5].type === 'add') {

@@ -1225,6 +1402,7 @@ source.splice(index, 0, [].concat(source[index]));

}
}
} // source尾部补齐
// source尾部补齐
sourceLen = source.length;
if (sourceLen < targetLen) {

@@ -1239,14 +1417,18 @@ for (var _i6 = 0; _i6 < targetLen - sourceLen; _i6++) {

}
return source;
};
}; // 将两个点均分成count个点
// 将两个点均分成count个点
function _splitPoints(points, former, count) {
var result = [].concat(points);
var index = void 0;
var index;
var t = 1 / (count + 1);
var formerEnd = _getSegmentPoints(former)[0];
for (var i = 1; i <= count; i++) {
t *= i;
index = Math.floor(points.length * t);
if (index === 0) {

@@ -1258,5 +1440,5 @@ result.unshift([formerEnd[0] * t + points[index][0] * (1 - t), formerEnd[1] * t + points[index][1] * (1 - t)]);

}
return result;
}
/*

@@ -1268,4 +1450,7 @@ * 抽取pathSegment中的关键点

*/
function _getSegmentPoints(segment) {
var points = [];
switch (segment[0]) {

@@ -1275,8 +1460,11 @@ case 'M':

break;
case 'L':
points.push([segment[1], segment[2]]);
break;
case 'A':
points.push([segment[6], segment[7]]);
break;
case 'Q':

@@ -1286,5 +1474,7 @@ points.push([segment[3], segment[4]]);

break;
case 'T':
points.push([segment[1], segment[2]]);
break;
case 'C':

@@ -1295,2 +1485,3 @@ points.push([segment[5], segment[6]]);

break;
case 'S':

@@ -1300,11 +1491,14 @@ points.push([segment[3], segment[4]]);

break;
case 'H':
points.push([segment[1], segment[1]]);
break;
case 'V':
points.push([segment[1], segment[1]]);
break;
default:
}
}
return points;

@@ -1317,3 +1511,5 @@ }

}
var points = void 0;
var points;
for (var i = 0; i < toPath.length; i++) {

@@ -1323,2 +1519,3 @@ if (fromPath[i][0] !== toPath[i][0]) {

points = _getSegmentPoints(fromPath[i]);
switch (toPath[i][0]) {

@@ -1328,5 +1525,7 @@ case 'M':

break;
case 'L':
fromPath[i] = ['L'].concat(points[0]);
break;
case 'A':

@@ -1337,2 +1536,3 @@ fromPath[i] = [].concat(toPath[i]);

break;
case 'Q':

@@ -1347,2 +1547,3 @@ if (points.length < 2) {

}
fromPath[i] = ['Q'].concat(points.reduce(function (arr, i) {

@@ -1352,5 +1553,7 @@ return arr.concat(i);

break;
case 'T':
fromPath[i] = ['T'].concat(points[0]);
break;
case 'C':

@@ -1365,2 +1568,3 @@ if (points.length < 3) {

}
fromPath[i] = ['C'].concat(points.reduce(function (arr, i) {

@@ -1370,2 +1574,3 @@ return arr.concat(i);

break;
case 'S':

@@ -1380,2 +1585,3 @@ if (points.length < 2) {

}
fromPath[i] = ['S'].concat(points.reduce(function (arr, i) {

@@ -1385,2 +1591,3 @@ return arr.concat(i);

break;
default:

@@ -1391,2 +1598,3 @@ fromPath[i] = toPath[i];

}
return fromPath;

@@ -1393,0 +1601,0 @@ };

{
"name": "@antv/g",
"version": "3.1.2",
"version": "3.1.3",
"description": "A canvas library which providing 2d draw for G2.",

@@ -23,8 +23,8 @@ "keywords": [

"devDependencies": {
"torchjs": "~2.0.4",
"babel-cli": "~6.26.0",
"@babel/cli": "^7.0.0",
"@babel/core": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"babel-eslint": "~7.2.3",
"babel-loader": "~7.1.1",
"babel-loader": "^8.0.0",
"babel-plugin-transform-remove-strict-mode": "~0.0.2",
"babel-preset-env": "~1.6.1",
"chai": "~4.0.1",

@@ -42,2 +42,3 @@ "electron": "~2.0.2",

"spm-sinon": "~1.6.0",
"torchjs": "~2.0.4",
"uglify-js": "~3.0.15",

@@ -60,3 +61,3 @@ "webpack": "~3.4.1"

"test": "torch --compile --renderer --recursive ./test/unit",
"test-live": "torch --compile --renderer --interactive --recursive ./test/unit"
"test-live": "torch --compile --renderer --interactive --recursive ./test/unit/"
},

@@ -63,0 +64,0 @@ "pre-commit": {

@@ -103,2 +103,3 @@ const Util = require('./util/index');

const shape = this.getShape(point.x, point.y, e);
const el = this.get('el');
let emitObj;

@@ -111,2 +112,3 @@ if (type === 'mousemove') {

emitObj && emitObj.emit('mouseleave', mouseleave);
el.style.cursor = 'default';
}

@@ -138,3 +140,2 @@

const el = this.get('el');
if (shape && !shape.get('destroyed')) {

@@ -141,0 +142,0 @@ el.style.cursor = shape.attr('cursor') || 'default';

@@ -26,3 +26,3 @@ module.exports = {

// version, etc.
version: '3.1.2'
version: '3.1.3'
};

@@ -73,2 +73,3 @@ const Util = require('../util/index');

let maxY = -Infinity;
Util.each(segments, function(segment) {

@@ -95,2 +96,10 @@ segment.getBBox(lineWidth);

});
if (minX === Infinity || minY === Infinity) {
return {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
};
}
return {

@@ -97,0 +106,0 @@ minX,

@@ -66,3 +66,3 @@ const Util = require('../util/index');

const text = attrs.text;
let textArr;
let textArr = null;
if (Util.isString(text) && (text.indexOf('\n') !== -1)) {

@@ -72,6 +72,4 @@ textArr = text.split('\n');

attrs.lineCount = lineCount;
attrs.textArr = textArr;
}
// attrs.height = this._getTextHeight();
// attrs.width = this.measureText();
attrs.textArr = textArr;
},

@@ -78,0 +76,0 @@ _getTextHeight() {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc