Smooth & Straighten

Skip to first unread message

Erik Sombroek

May 21, 2024, 8:20:01 AMMay 21
to skia-discuss

I would like to create the 2 functions that Adobe Animate has to optimise pencil paths. They have the Smooth function and the Straighten function.

I think for the straightening they use the RDP algorithm (Ramer–Douglas–Peucker algorithm) and for the Smoothening they probable do a moving average and curve fitting.
Any input or ideas on this would be welcome!

Additionally I was wondering if there is a "simplify" function, or how to implement it. The simplify would transform e.g. a polygon path of points to a combination of curves and lines trying to maintain the integrity of the shape.

Thanks for any input / suggestions!



Peter Nelson

Jul 11, 2024, 11:51:58 PM (3 days ago) Jul 11
to skia-discuss

I don't know if you found a solution for the simplify function that you were looking for, but the CloneWithTransform method found here: might be what you are looking for. I created a function based on it that just simplifies that path without doing any transform, and it works well and seems reasonably fast, at least for what I've needed to use it for.

Reply all
Reply to author
0 new messages