Splines

Here’s a class for drawing spline curves.

http://npryce-codea.posterous.com/splinetastic

Currently it only renders well when antialiasing is disabled. Antialiasing of lines seems not to work correctly.

So - I’m working on my image() stuff - line draw, polygon (and ngon) fill, flood fill, image load, and so on - and I’m like “I wonder if I should add some sort of curve drawing? Nah - that’s too hard to figure out right now…” AND POOF - splines!

Unless you object horribly, a mangled version of this will be included with my draw-on-an-image() library.

By the way - NICE. The demo with handles is awesome. Suggestion: Add a button in the corner somewhere where when I tap it, it print()s the parameters you’d use to make the spline programatically.

Go for it!

I plan for drawing to only be just one aspect of the spline object. I want to add features useful for animation, such as calculating the derivative w.r.t. the curve parameter, which can be used to determine the tangent, and so steer a sprite along the curve.