Hacker News new | ask | show | jobs
by dahart 1604 days ago
You can use the very close relative of the Bezier, the uniform B-spline, for drawing curves, it’s a more natural fit. Yes, this way you can collect a sequence of mouse events and use them as-is as the control points of a curve. Depending on how you render your curve, in 2d, you might want a “normal” for the curve in order to rasterize a thick and/or textured stroke. You can do it easily and unambiguously by rotating the tangent (derivative) of the curve by 90 degrees. In 3d, it’s harder.

The B-spline is just a math name for a connected sequence of curve segments, setup so that the segments join nicely and so that there is a continuous “parameter” along the entire curve.

For a sketch interface, I personally prefer the quadratic B-spline to the cubic (but you can use any degree you want). The background for curves in general isn’t easy to pick up and understand quickly, but you might check out the “Chaikin” subdivision which is super simple math and equivalent to a quadratic curve.