UNPKG

@liammartens/svg-path-properties

Version:

Calculate the length for an SVG path, to use it with node or a Canvas element

23 lines (22 loc) 1.1 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.svgPathProperties = void 0; const svg_path_properties_1 = __importDefault(require("./svg-path-properties")); //https://stackoverflow.com/a/48362715/1086633 class _svgPathProperties { constructor(svgPath) { this.getTotalLength = () => this.inst.getTotalLength(); this.getPointAtLength = (fractionLength) => this.inst.getPointAtLength(fractionLength); this.getTangentAtLength = (fractionLength) => this.inst.getTangentAtLength(fractionLength); this.getPropertiesAtLength = (fractionLength) => this.inst.getPropertiesAtLength(fractionLength); this.getParts = () => this.inst.getParts(); this.inst = new svg_path_properties_1.default(svgPath); if (!(this instanceof exports.svgPathProperties)) { return new exports.svgPathProperties(svgPath); } } } exports.svgPathProperties = _svgPathProperties;