Mat
Mat

Reputation: 481

return bounding box of transformed text element using SVG.js?

I am using SVG.js and trying to fetch the bounding box of a transformed text. I made a small example of my use case:

    this.draw.attr({ width: 200, height: 200 });

        const text = this.draw
            .text("some text is here")
            .attr({ x: 50, y: 50, transform: "rotate(45) scale(1.1 1.1)" });

        const textbbox = text.rbox();
        const textBorder = this.draw
            .rect(textbbox.w, textbbox.h)
            .attr({ fill: "none", "stroke-width": 1, stroke: "black" })
            .move(textbbox.x, textbbox.y);
        return this.draw;

Whenever I am trying to use rbox(), it returns the following error: enter image description here

Thanks,

Mat

Upvotes: 0

Views: 42

Answers (0)

Related Questions