svg-engine
Version:
Create SVG files in Node.js
53 lines • 2.1 kB
JavaScript
import { SVGInstance } from "../../browser/instance/SVGInstance.js";
import { SVGTSpanInstance } from "./SVGTSpanInstance.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";
// Attributes
import { XYPositioning } from "../mixins/attributes/xyPositioning.js";
import { WidthHeight } from "../mixins/attributes/widthHeight.js";
import { TextAttributes } from "../mixins/attributes/text.js";
// Style attributes
import { Font } from "../mixins/style-attributes/font.js";
//-- Class
export class SVGTextInstance extends SVGInstance {
constructor(_parent) {
super("text", _parent);
}
addTSpan(xOrTextOrUndefined, yOrUndefined, textOrUndefined) {
const text = new SVGTSpanInstance(this);
if (typeof xOrTextOrUndefined === "string" && typeof yOrUndefined === "undefined") {
text.text(xOrTextOrUndefined);
}
else if ((typeof xOrTextOrUndefined === "string" || typeof xOrTextOrUndefined === "number") && (typeof yOrUndefined === "string" || typeof yOrUndefined === "number")) {
text.attr("x", xOrTextOrUndefined);
text.attr("y", yOrUndefined);
if (typeof textOrUndefined === "string") {
text.text(textOrUndefined);
}
}
this.appendInstance(text);
return text;
}
}
applyMixins(SVGTextInstance, [
Color,
Display,
Fill,
Opacity,
Stroke,
VectorEffect,
Visibility,
XYPositioning,
WidthHeight,
TextAttributes,
Font
]);
//# sourceMappingURL=SVGTextInstance.js.map