amenui
en·中 github ↗ v0.0.1
01docs 02components 03lab 04works
en·中github ↗
×

docs / lab / contours docs / lab /

Contours

On this page ▾
  1. Formula
  2. Parameters
  3. How it is made
drawn by amenuiopen ↗

Iso-lines of a field: drifting noise plus a bump under the pointer, sampled on a 61 × 46 grid and traced by marching squares into polylines, drawn as strokes.

Formula

text
f(x, y) = n(x/s, y/s, t) + a · e^(−|p − m|²/r²)

Parameters

Every number is a number control under the cell (type, arrow keys, drag sideways); none is a slider.

namedefaultrangewhat it is
s52 px12–120noise feature size
a0.700–2bump height
r30 px6–90bump radius
n92–16number of levels

How it is made

The field is the sum of two parts: field::Noise, which drifts slowly with time, and field::Bump, a Gaussian under the pointer whose height fades in and out as the pointer arrives and leaves. field::Grid::sample samples it at every node; Grid::contours runs marching squares at each of the n levels and joins the segments into polylines, and Drawing::contours turns them into strokes.

Where the bump bends a line, the line takes the accent, so the pointer's effect stays visible against the drifting noise. A small s gives tight, busy lines; a large one gives a few broad ones. The code is examples/lab/contours.rs.