Showcase panel 09:noise, signed_noise, seeds, gaussians. Showcase panel 10:map, clamp, lerp, wrap, normalize and more.
Try it live: run uv run python examples/showcase.py, then hover panels 09 and 10, or see the showcase.
Random numbers make a sketch lively. Noise makes it feel alive: smooth, drifting, natural. This page goes from one to the other.
Random scatter
kiln.random(max) gives a number from 0 up to max, and kiln.random(min, max) gives one between the two. random_seed makes the sequence repeatable, so a sketch you like keeps looking the same.
import kilnkiln.random_seed(3)dots = [(kiln.random(400), kiln.random(300), kiln.random(3, 14)) for _ inrange(160)]def draw(): kiln.background(18, 20, 32)for x, y, r in dots: kiln.fill(255, 190+ kiln.random(60), 90, 170) kiln.circle(x, y, r)show(draw)
Every dot is independent of its neighbours, which is why it looks like static.
Noise is random with a memory
kiln.noise(x) returns a value between 0 and 1, and nearby inputs give nearby outputs. Multiply your coordinates by a small number to choose how big the features are: 0.01 gives hills about a hundred pixels wide. Give it two numbers for 2D noise, three for 3D, four for 4D. signed_noise is the same thing in the range -1 to 1.
A grid of circles whose size and colour come from a 2D noise field. The noise call takes numpy arrays, so the whole grid is computed at once.
kiln.map(value, in_min, in_max, out_min, out_max) is how you turn a noise value into whatever range you need, and kiln.lerp blends between two numbers.
Flow through time
A third noise coordinate makes the field move. Feed in a slowly growing time as the third argument and the whole landscape drifts smoothly.
Noise can steer motion, not just size. Each dot here walks along a direction read from 3D noise (position and time), so the swarm streams like a current.