Strokes
Stroke approaches
A drawing tool must turn the pointer's path into a mark. Several established methods do this, each with its own advantages and disadvantages (See also: Codifying materials).
Stamping: Most raster paint programs stamp a brush tip (a small textured shape) at short intervals along the path, then blend the overlapping stamps. These dabs build up the mark.
Simulation: Engines model the medium itself (the flow of ink or water, the bend of the bristles, the diffusion of pigment) and let the mark emerge from those interactions. This approach is the most physically faithful and generally the most computationally expensive.
Geometry: A geometry-based approach builds the mark's shape directly based on the drawn line, then fills or shades it.
We use the geometry-based approach. Each stroke or fill is built in a single pass as a mesh generated from the path, then shaded by a fragment shader. No per-dab compositing loop or simulation timestep is needed, so the stroke can be drawn immediately. This approach is lightweight, keeps each mark as data, and makes animation easy.
Demo
open full size ↗A stroke begins with a spine traced from the pointer's path. We smooth the spine based on the tool type and stroke width. A thin pencil stroke should follow the user's input precisely, while a thick brush stroke can be less sensitive to hand movement and often looks better with smoother lines. See the Stroke processing page for smoothing methods.
Draw on the canvas to see the raw pointer path in black, the smoothed spine in blue, and the filled shape of the stroke around it.