|

Strokes

On this page, we build the stroke class that turns a path and a width into drawable geometry, and the renderers that shade it.

Every demo below draws the same path at the same three positions, so the only change between them is the renderer. Each row is rounded, square, and ragged from top to bottom.

The classes are documented on Stroke Definition and Renderers.

Common to every demo

Depth ordering, sampling, and color selection are shared across every demo on this page. Each demo section covers only what its renderer adds.

Details

Depth: Strokes are 2D: they move in X and Y, and their Z sits just above the paper. Z slightly elevates along the stroke to avoid z-fighting.

Sampling: Sample count (number of vertices) is derived from measured arc length, not from how many control points the path was authored with.

Color: Every demo draws its colors from one generated Palette.

Basic strokes

open full size ↗

A flat ribbon along the path, filled with one color and closed at both ends by a cap. This is the shape every other renderer starts from.

Details

Cap styles: All three strokes share one renderer class, with the cap as an option. Square adds no geometry: the ribbon stops at its last sample. Rounded sweeps a triangle fan from the left edge, through the outward tangent, to the right edge. Ragged pushes a strip of spikes past the end at varying depths.

Rounded cap: Radius interpolates from the left width to the right width across the sweep, so an asymmetric stroke ends in a half-ellipse that meets both edges. Resolution scales with radius.

Ragged cap: Spike depths come from two sine samples offset by the stroke's seed, so the same seed always tears the same way.

Brush strokes

open full size ↗

The same ribbon, shaded per pixel as bristles rather than filled. Each stroke carries two pigments instead of one.

Details

Shading: The ribbon is handed to a fragment shader that computes a color per pixel, so the texture follows the mark instead of repeating on top of it.

Bristle noise: One noise field draws the bristle lanes, erodes the edge, and decides which pigment shows at each point.

Two pigments: The stroke mixes two colors along the bristle noise, with a slow drift along the mark. The two come from different hues of one palette.

Shadow strokes

open full size ↗

Effects around the mark: a drop shadow, a debossed bevel, and a glow from top to bottom.

Details

Drop shadow: A blurred silhouette of the stroke, offset and drawn beneath, so the mark reads as floating.

Deboss: A band inside the boundary darkens where its outward direction faces a fixed light, the shadow a cutout's lit rim casts onto its floor. There is no highlight, so the stroke reads as cut out of the paper.

Glow: The same silhouette blurred wider, in the most saturated bright color of the palette.

The shadow and the glow are one class, StrokeHalo. It renders the stroke into a private low-resolution target and blurs there, so the softness cannot fold with the path.

Try drawing

open full size ↗

Draw with the strokes on this page, in the drawing tool: the settings panel picks the tool, its colors, and its parameters exactly, the floating dials reroll the palette, set the width, and walk a trail of rolled tools, and Clear, Replay, and recording work as on the Drawing Tool Demo page. A turn sharper than a threshold splits the drawn line, so a fast zigzag bakes as separate strokes; each piece appears once its direction settles, and the wider the stroke, the harder its turns smooth. With a pen tablet, pressure scales the stroke around the set width, light thinner and heavy wider, each tool by its own amount; a mouse draws at the set width.