Smooth & Straighten

32 views
Skip to first unread message

Erik Sombroek

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

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!

Best,

Erik

Peter Nelson

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

I don't know if you found a solution for the simplify function that you were looking for, but the CloneWithTransform method found here: https://learn.microsoft.com/en-us/previous-versions/xamarin/xamarin-forms/user-interface/graphics/skiasharp/curves/information 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
Forward
0 new messages