[cairo] Getting Bezier Control Points from a Smoothing Function

cecashon at aol.com cecashon at aol.com
Mon Jun 19 18:50:00 UTC 2017


Hi everyone,

I have been testing some different methods for drawing ring gradients with Cairo. I came across the following

https://medium.com/@ramshandilya/draw-smooth-curves-through-a-set-of-points-in-ios-34f6d73c8f9

and decided to give it a try. I don't have an Apple computer so I translated the Swift code over to C and put together some test code to look at a few drawings using Cairo.

https://github.com/cecashon/OrderedSetVelociRaptor/blob/master/Misc/cairo_drawings/squiggles1.c

Ramsundar's code works very well for getting Bezier control points from a set of points. Smoothing is often done in graphing or a graphics program but it is very useful for the programmer drawing with Cairo. For a circle the smoothing function can get it very close with 24 points. This might be faster for drawing ring gradients than using trapezoids, rotated bezier curves or rotating lines from a linear gradient. Haven't got the testing that far yet though.

Besides ring gradients, getting control points from a set of points is very useful in general. My thinking is that it would be very good to have a function like this as part of Cairo?

Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.cairographics.org/archives/cairo/attachments/20170619/3366ac58/attachment.html>


More information about the cairo mailing list