Variable-width Bézier curves are presented as a practical way to render pressure-sensitive pen strokes, especially for digital board-work tools. The central problem is that common 2D graphics APIs can draw Bézier curves and fixed-width strokes but lack a primitive that combines a smooth curve with changing width. The author favors circular pressure offsets: pressure controls the radius of a circle swept along the stroke. Unlike calligraphic fixed-axis widths, circular offsets stay legible, and unlike widths aligned to the stroke direction, they are less vulnerable to jitter and abrupt changes in pen motion. Pressure can be mapped nonlinearly to radius, and cubic Bézier curves between tablet samples reduce the angular appearance caused by sparse or uneven input.
The main technical contribution is a comparison of ways to render these strokes. One approach constructs the outline: locate the left and right boundaries of the swept circles, trace them as segments, and join them with end caps. The boundary can be approximated with lines or represented by cubic Bézier curves, though the latter requires care when derivatives become very large. Another approach tests pixels directly: form a Bézier polynomial expressing squared distance from the curve centerline minus squared stroke radius, then determine whether it crosses zero or find its minimum. This method suits highly parallel GPU rendering but is less efficient on a CPU; its antialiasing approximation also treats pixels like circles rather than matching supersampling. The discussion supplies implementation steps and highlights the trade-offs between smoothness, robustness, efficiency, and exportability.
Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.