views:

181

answers:

2

I need to draw a shape whose boundaries are parts of parabola (that is quadratic bezier curves) using iText. I have found only method for drawing cubic bezier curves in PdfContentByte class.

So how do I draw quadratic bezier curves using iText ? One way would be to use method for cubic bezier curves. Is it possible to draw quadratic bezier curves as a cubic bezier curves (with 2 control points). I gues it is but I cannot make up the formula. If somebody states the formula tu "translate" cubic bezier curves to quadratic that would solve the problem. Any other ways to draw quadratic bezier(parts of parabola) curves in iText (and filled shapes made of them) is also the solution.

Thanks

A: 

For those interested in answer the formula for control points C1 and C2 of cubic bezier curve that is equal to quadratic bezier curve with control point C is:

C1 = 2/3*C + 1/3*P1
C2 = 2/3*C + 1/3*P2

where P1, P2 are beginning and end points of both original quadratic curve and corresponding cubic curve. More about the topic is here (under the title: Transforming a quadratic Bezier in a cubic Bezier).

There is also a direct way to draw quadratic bezier curves using iText using this method. I just did not see it at first...

drasto
A: 

drasto,

You have no idea, how useful are for me these two formulae. I am using an export tool to convert Flash into XAML (silverlight) and finally draw the result with GDI+, and guess what - Flash works with quadratic beziers and GDI+ - with cubic. Your posting saved me lots of time of figuring how to port one into the other :)

Thanks, Daniel

Daniel
I'm glad I helped somebody but what you posted is not an answer, it is a comment. You should delete it and comment on my answer instead please. If you like my answer feel free to vote up for it. That will be the best thanks :).
drasto