cione-comp-lib
Version:
`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`
67 lines (66 loc) • 2.1 kB
JavaScript
import { __extends } from "../../../../tslib/tslib.es6.mjs";
import { normalize } from "../../../../zrender/lib/core/vector.mjs";
import Line from "../../../../zrender/lib/graphic/shape/Line.mjs";
import BezierCurve from "../../../../zrender/lib/graphic/shape/BezierCurve.mjs";
import Path from "../../../../zrender/lib/graphic/Path.mjs";
var straightLineProto = Line.prototype;
var bezierCurveProto = BezierCurve.prototype;
var StraightLineShape = function() {
function StraightLineShape2() {
this.x1 = 0;
this.y1 = 0;
this.x2 = 0;
this.y2 = 0;
this.percent = 1;
}
return StraightLineShape2;
}();
(function(_super) {
__extends(CurveShape, _super);
function CurveShape() {
return _super !== null && _super.apply(this, arguments) || this;
}
return CurveShape;
})(StraightLineShape);
function isStraightLine(shape) {
return isNaN(+shape.cpx1) || isNaN(+shape.cpy1);
}
var ECLinePath = function(_super) {
__extends(ECLinePath2, _super);
function ECLinePath2(opts) {
var _this = _super.call(this, opts) || this;
_this.type = "ec-line";
return _this;
}
ECLinePath2.prototype.getDefaultStyle = function() {
return {
stroke: "#000",
fill: null
};
};
ECLinePath2.prototype.getDefaultShape = function() {
return new StraightLineShape();
};
ECLinePath2.prototype.buildPath = function(ctx, shape) {
if (isStraightLine(shape)) {
straightLineProto.buildPath.call(this, ctx, shape);
} else {
bezierCurveProto.buildPath.call(this, ctx, shape);
}
};
ECLinePath2.prototype.pointAt = function(t) {
if (isStraightLine(this.shape)) {
return straightLineProto.pointAt.call(this, t);
} else {
return bezierCurveProto.pointAt.call(this, t);
}
};
ECLinePath2.prototype.tangentAt = function(t) {
var shape = this.shape;
var p = isStraightLine(shape) ? [shape.x2 - shape.x1, shape.y2 - shape.y1] : bezierCurveProto.tangentAt.call(this, t);
return normalize(p, p);
};
return ECLinePath2;
}(Path);
var ECLinePath$1 = ECLinePath;
export { ECLinePath$1 as default };