Learn R Programming

ggsketch (version 2.0.0)

spray_scatter: Scatter a cloud of dots along a path (airbrush / spray)

Description

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)

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.

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).

See Also

Other sketch-core: arrowhead(), curve_fill(), engrave_fill(), engrave_ladder(), hachure_fill(), hachure_fill_multi(), leader_path(), repel_layout(), rough_arc(), rough_bezier(), rough_ellipse(), roughen_polyline(), sketch_arrowheads(), sketch_fill(), sketch_fill_multi(), stroke_profile(), stroke_ribbon(), treemap_layout(), wash_bleed(), watercolor_wash(), watercolor_wash_multi()