Skip to contents

Samples points along a centreline and offsets each one perpendicular to the path by a Gaussian random amount, producing a soft-edged spray of dots with no hard outline – the airbrush / spray-can look. The dot density falls off from the centreline (the Gaussian offset), and dots near the edge are drawn smaller so the cloud feathers out. Pure number-to-number (no grid/ggplot2); deterministic apart from the seeded RNG (ADR-0004).

Usage

spray_scatter(x, y, spread = 0.04, density = 140, dot_r = 0.004, seed = NULL)

Arguments

x, y

Numeric vectors of centreline vertices (same length, any units – spread, dot_r and density are interpreted in those units).

spread

Standard deviation of the perpendicular offset (cloud half-width).

density

Mean number of dots per unit of path arc-length.

dot_r

Base dot radius. Edge dots shrink toward 0.4 * dot_r.

seed

Integer seed for the scatter (ADR-0004).

Value

A 4-column matrix with columns x, y (dot centres), r (dot radii) and a (a 0-1 weight that fades with distance from the centreline, for the caller to fold into per-dot alpha if desired). Zero rows for a degenerate path.