Live data from Hacker News

Animated Bézier Curves

jasondavies.com

1–10 of 21 posts

Re: Animated Bézier Curves

#9
The same simple explanation in the animation leads to a nice simple Haskell implementation.

Assuming you already have a parametric line function `line p q t` that interpolates between two points p and q on t in [0,1], you can recursively implement parametric Bézier on a list of control points as:

  bezier [p] t = p
  bezier ps  t = line (bezier (init ps) t)
                      (bezier (tail ps) t)
                      t
It's exponential in the number of points though ;)

(Full source at https://github.com/hrldcpr/Bezier.hs/blob/master/Bezier.hs)

Post reply on HN