UNPKG

cione-comp-lib

Version:

`$ yarn add cione-comp-lib` 或者 `$ npm i cione-comp-lib -S`

69 lines (68 loc) 1.7 kB
import { __extends } from "../../../../tslib/tslib.es6.mjs"; import Path from "../Path.mjs"; import { subPixelOptimizeLine } from "../helper/subPixelOptimize.mjs"; var subPixelOptimizeOutputShape = {}; var LineShape = function() { function LineShape2() { this.x1 = 0; this.y1 = 0; this.x2 = 0; this.y2 = 0; this.percent = 1; } return LineShape2; }(); var Line = function(_super) { __extends(Line2, _super); function Line2(opts) { return _super.call(this, opts) || this; } Line2.prototype.getDefaultStyle = function() { return { stroke: "#000", fill: null }; }; Line2.prototype.getDefaultShape = function() { return new LineShape(); }; Line2.prototype.buildPath = function(ctx, shape) { var x1; var y1; var x2; var y2; if (this.subPixelOptimize) { var optimizedShape = subPixelOptimizeLine(subPixelOptimizeOutputShape, shape, this.style); x1 = optimizedShape.x1; y1 = optimizedShape.y1; x2 = optimizedShape.x2; y2 = optimizedShape.y2; } else { x1 = shape.x1; y1 = shape.y1; x2 = shape.x2; y2 = shape.y2; } var percent = shape.percent; if (percent === 0) { return; } ctx.moveTo(x1, y1); if (percent < 1) { x2 = x1 * (1 - percent) + x2 * percent; y2 = y1 * (1 - percent) + y2 * percent; } ctx.lineTo(x2, y2); }; Line2.prototype.pointAt = function(p) { var shape = this.shape; return [ shape.x1 * (1 - p) + shape.x2 * p, shape.y1 * (1 - p) + shape.y2 * p ]; }; return Line2; }(Path); Line.prototype.type = "line"; var Line$1 = Line; export { LineShape, Line$1 as default };