borbulon
borbulon

Reputation: 1411

get actual height of svg bezier curved path

This is more of a bezier question than an SVG question, but here goes...

given the following code:

<svg xmlns="http://www.w3.org/2000/svg" baseProfile="full" viewBox="0 0 400 400" baseProfile="full">
    <path d="M0,0 C20,400 30,200 50,100" fill="#FF0000" stroke="#000000"/>
</svg>

Using [path].getBBox() returns me a height of 400, since the 1st control point of the curve is at 400 y, and this makes sense(ish).

But what I really need is the actual height of the object as rendered, not the box that contains all points used in its drawing.

I'm assuming I'm just going to have to figure it out myself? And if that's the case, does anybody have any suggestions for where to go to find such mathy things? I did some googling, but I'm not really coming up with anything (it's very possible I'm not phrasing the question correctly, some help in that regard would be super nice as well).

Upvotes: 0

Views: 181

Answers (1)

Carlo Cannas
Carlo Cannas

Reputation: 3262

You are doing it right, it's a WebKit bug. If you try getBBox on Firefox or even Internet Explorer, it's fine.

If you need a workaround, give a look at the implementation done for SVG-edit.

Upvotes: 1

Related Questions