svg-engine
Version:
Create SVG files in Node.js
98 lines • 3.52 kB
JavaScript
import { SVGInstance } from "../../browser/instance/SVGInstance.js";
//-- Mixins
import { applyMixins } from "../mixins/index.js";
// Presentation attributes
import { Color } from "../mixins/presentation-attributes/color.js";
import { Display } from "../mixins/presentation-attributes/display.js";
import { Fill } from "../mixins/presentation-attributes/fill.js";
import { Opacity } from "../mixins/presentation-attributes/opacity.js";
import { Stroke } from "../mixins/presentation-attributes/stroke.js";
import { VectorEffect } from "../mixins/presentation-attributes/vectorEffect.js";
import { Visibility } from "../mixins/presentation-attributes/visibility.js";
//-- Class
export class SVGPathInstance extends SVGInstance {
constructor(_parent) {
super("path", _parent);
}
lineTo(x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " L " : " l ");
d += ` ${x}, ${y} `;
this.attr("d", d);
return this;
}
moveTo(x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " M " : " m ");
d += ` ${x}, ${y} `;
this.attr("d", d);
return this;
}
cubicBezierCurveTo(p1x, p1y, p2x, p2y, x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " C " : " c ");
d += ` ${p1x} ${p1y}, ${p2x} ${p2y}, ${x} ${y} `;
this.attr("d", d);
return this;
}
smoothBezierCurveTo(x2, y2, x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " S " : " s ");
d += ` ${x2}, ${y2} ${x}, ${y} `;
this.attr("d", d);
return this;
}
quadraticBezierCurveTo(p1x, p1y, x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " Q " : " q ");
d += ` ${p1x} ${p1y}, ${x} ${y} `;
this.attr("d", d);
return this;
}
smoothQuadraticBezierCurveTo(x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " T " : " t ");
d += ` ${x}, ${y} `;
this.attr("d", d);
return this;
}
ellipticalArcCurveTo(rx, ry, xRot, largeArc, sweep, x, y, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " A " : " a ");
d += ` ${rx}, ${ry} ${xRot} ${largeArc ? 1 : 0} ${sweep ? 1 : 0} ${x} ${y} `;
this.attr("d", d);
return this;
}
curveTo(x, y, x1, y1, relative = false) {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += (relative === false ? " S " : " s ");
d += ` ${x}, ${y} ${x1}, ${y1} `;
this.attr("d", d);
return this;
}
close() {
var _a;
let d = (_a = this.attr("d")) !== null && _a !== void 0 ? _a : "";
d += " Z";
this.attr("d", d);
return this;
}
}
applyMixins(SVGPathInstance, [
Color,
Display,
Fill,
Opacity,
Stroke,
VectorEffect,
Visibility
]);
//# sourceMappingURL=SVGPathInstance.js.map