Pointlist to Bezier?

-hh hh at livecode.org
Sun Dec 6 19:20:14 EST 2015


> Michael K. wrote:
> Pointlist to Bezier
> Hi there
> I wonder if any have code to take a point-list and turn it
> into a smooth-lined bezier.

A bezier curve is a mathematical model. It can only approximately be
drawn by polygons. LC's path method is as good as others, has
only (because it's not a drawing app) no enhanced antialiasing
algorithms attached which emulate "dividing" pixels or 'atomic'
printer points, tricking our eyes.

That is, one uses bezier curves to approximate 'theoretically' a list
of user-points and then use polygons (here: deCasteljau's algorithm) to approximate the bezier curves.

The main starting problem for smoothing lists of 'user-points' by
any approximating curve model is to decide

= what is a badly drawn straight line
= what is a curved piece

Now look at the HTML5 demo "(Smooth-)Draw"
http://hyperhh.org/html5/krikelKrakel-8.0.0-dp-9X.html

Check "Show Markers" and "Smoothing" and see if it's doing what you
think of. If you download the stack you can have a (close to) "live"
smoothing, the HTML5 javascript slows down by a factor of > 10.

The script is a (mathematically) rather simple approach, but suffices
for a demo. The algorithm used there is deCasteljau's, approximating
quadratic bezier curves with control points taken from user's input.
I use there also a well-known decision rule to differentiate between
curved and non-curved parts.

There is possibly already an app that is based on this approach and
has an improved handling/rescaling of the smoothed points and a better
collecting points algorithm. (The original idea had 'Mag' some time
ago in the LC-forum, I put only imperfectly, in a few hours, the "smoothing" onto that. May be he finished meanwhile his project).

HTH, Hermann



More information about the use-livecode mailing list