Home›Journal›This post

Lenia Canvas: Continuous Cellular Art

Implement Lenia's normalized kernel, growth rule, clipped fixed-step update, and an iridescent Canvas edition with a replayable state receipt.

JP
JP Casabianca
AI Engineer and Product Designer · full-stack delivery · Bogotá

Lenia Canvas art turns continuous cellular rules into forms that glide, pulse, decay, and bloom. This tutorial builds a seeded fixed-step simulation, directs its iridescent visual language, and exports enough state to replay the edition without calling it biology.

Lenia Canvas turns rules into continuous material

Lenia Canvas art begins with a field of continuous values rather than a grid of binary alive-or-dead cells. Each update measures a neighborhood through a smooth kernel, maps that potential through a growth function, and advances the field by a fixed amount. The result can pulse, glide, dissolve, or bloom with an uncanny material quality.

This Lenia simulation tutorial builds one bounded, reproducible simulation and treats its visual direction as a separate authored layer. It does not claim that a compelling form is alive or biologically realistic. The work is artificial life art and Canvas generative art: a numerical system staged through palette, scale, crop, rhythm, and negative space.

The lab keeps the grid at or below 96 squared, uses deterministic seeded initialization, and exports the state needed for replay. Direct convolution is intentionally understandable rather than maximally fast. A stable edition depends on the rule, boundary, initial field, time step, and renderer all being named.

For a contrasting discrete practice, cellular automata woven patterns turns finite state transitions into textile rhythm. Lenia Canvas replaces those steps with continuous neighborhoods and values, creating softer visual causality without removing the need for an exact contract.

Lenia continuous cellular update pipelineA toroidal field passes through a normalized radial kernel and convolution, then a bell growth function and fixed clipped update produce the next field.ONE FIXED STEP, FULLY NAMEDTOROIDALFIELD ANORMALIZEDKERNEL KCONVOLVEU = K * AGROWTHG(U)CLIPA + dt·Ggrid · boundary · kernel digest · μ · σ · dt · step · field digestRendering changes presentation, never the field state.
Continuous rule pipeline. The visual organism is downstream of a finite numerical contract.
  1. Read the toroidal continuous field.
  2. Convolve with a normalized radial kernel.
  3. Map neighborhood potential through bell growth.
  4. Add one fixed-time update and clip to zero through one.
  5. Record rule and state digests before rendering.

Reading rule: labels, order, values, shapes, and line styles carry the conclusion; color is supplementary.

Freeze the field, boundary, and clock

Lenia Canvas represents continuous cellular automata as a width-by-height array whose cells stay in the closed interval from zero to one. Choose a logical grid size independent of CSS pixels. The Canvas can resize and redraw that field, but a layout change must never create a new initial condition or advance time.

This edition uses a toroidal boundary: coordinates leaving one edge wrap to the opposite edge. The choice avoids hard walls and gives drifting structures continuous space, but it also means opposite edges are neighbors. State that visibly so a viewer does not mistake seam crossing for teleportation.

Advance time with a fixed simulation step. Animation frames may request several steps or none, yet every update uses the same delta. A frame-rate delta makes the numerical trajectory dependent on device speed and background throttling. Start, pause, single-step, and reset must operate on the same clock state.

The original Lenia paper describes a continuous cellular automaton family with continuous space, state, and time formulations. A browser grid is a finite approximation. Naming its resolution and integration rule keeps the artwork honest about that boundary.

Build and normalize a radial kernel

A Lenia neighborhood kernel assigns weight by distance from the center. Create a radial profile over a finite radius, often using one or more smooth rings. Sample that profile onto grid offsets, then divide every weight by their total. Normalization makes the convolution interpretable across radius and resolution changes.

Record the discrete weight sum before and after normalization. A zero or non-finite sum is a hard failure. Because the center and rings are sampled onto a square lattice, two seemingly identical continuous profiles can differ at small grid sizes. The receipt should contain the realized kernel dimensions and a digest of its weights.

The visual figure shows rings, but color is not the proof. A semantic table lists radius bands, sample weights, and the normalized sum. That equivalence matters for readers who cannot perceive the hue ramp and for anyone auditing the rule from text.

Kernel design sets the scale of interaction. A narrow ring favors local surface changes; broader or multiple rings can couple interior and exterior regions. Change one aspect at a time, keep the initial field fixed, and distinguish a genuine rule response from an accidental normalization error.

Bound convolution before optimizing it

For each cell, convolution multiplies neighboring field values by kernel weights and adds the results. A direct nested loop is simple and serves as an oracle, but work grows with grid area and kernel area. The lab caps the grid at 96 by 96 and kernel radius at a declared maximum so a local page remains responsive.

Wrap coordinates with modular arithmetic that handles negative offsets. Precompute only nonzero kernel taps as offset-weight triples. Then each cell walks the same ordered tap list. This makes behavior deterministic and avoids rebuilding geometry every frame.

Faster editions may use separable approximations, FFT convolution, WebGL, or WebGPU. The reaction-diffusion WebGPU art tutorial shows how a field simulation can move to the GPU while preserving a numerical receipt. Optimize only after comparing several steps against the direct oracle and defining an acceptable error.

Bound total steps during export and testing as well. A beautiful attractor that requires an unbounded search is not a reliable interactive artifact. Presets should declare whether they are expected to stabilize, decay, or saturate within a finite observation window.

Finite Lenia mu and sigma outcome atlasA three-by-three grid marks observed decay, sustained motion, and saturation for one fixed seed, kernel, grid, and time step.OBSERVED HERE · NOT UNIVERSAL CLASSIFICATIONDECAYDECAYPULSEDRIFTSUSTAINOSCILLATESATURATESATURATEUNSTABLEμ increases →σ increases →seed = aurora-18 · 64² · torus · fixed dt · 240 steps
Mu and sigma outcome atlas. Parameter labels describe one seed and implementation, avoiding claims that an outcome region is universal or biological.
Atlas interpretation
Observed outcomeFinite meaning
DecayMass approaches zero in the recorded window
Sustain or driftStructure retains bounded mass and changes position or shape
SaturateMany cells clip near one
UnstableLarge oscillation; inspect timestep and parameters

Reading rule: labels, order, values, shapes, and line styles carry the conclusion; color is supplementary.

Apply the growth function and clipped update

Convolution produces a neighborhood potential. A bell-shaped growth function maps that value into a negative-to-positive rate centered at mu with width sigma. One common form is twice a Gaussian minus one. The field update adds delta-time times growth, then clips every cell back into zero through one.

Mu and sigma are sensitive controls, not decorative sliders. A small shift can move a preset from sustained motion to decay or saturation. Publish the exact values and avoid labeling regions as universally alive, dead, or chaotic. The same parameters can behave differently with another kernel, grid, seed, or integration step.

The expanded-universe research on Lenia parameter families motivates exploring a broader rule space while also showing why named parameters matter. Our atlas reports observed outcomes for one finite implementation, not universal classes.

Test three honest outcomes: a stable or oscillatory preset that retains mass, a decaying case whose mass approaches zero, and an exploding case that clips toward saturation. These are safety rails for implementation errors. They do not decide whether an edition is aesthetically successful.

Art-direct the Lenia Canvas edition

Rendering translates cell values into a material. Use a perceptually ordered palette so low, middle, and high values remain distinguishable in grayscale. This edition places iridescent organisms on a midnight field, with a quiet warm halo at active edges. The kernel and state stay unchanged when the palette changes.

Interpolate a short palette table rather than mapping hue through a full rainbow. Add only subtle bloom in a second pass; too much blur hides the cellular boundary and makes every preset look alike. A contour at a fixed field value can reveal structure without suggesting a biological membrane.

Composition also comes from initialization. Seed several bounded Gaussian deposits using a deterministic generator. Their positions, radii, and amplitudes belong in the replay receipt. Keep enough negative space for drift, and avoid reseeding when the browser resizes.

The principle from seeded randomness for generative art applies directly: randomness becomes a design material when the seed is visible and portable. Curation can remain subjective while construction stays reproducible.

Lenia frame budget and reconstructive edition receiptA fixed-step queue feeds rendering on the left while a receipt on the right lists seed, grid, boundary, kernel, growth, time, and field digest.ANIMATION SCHEDULEaccumulate wall timerun N fixed dt stepsrender current fieldLENIA EDITION L-84C1seedaurora-18grid / boundary64² / toruskernel digest29af…d142μ / σ / dt.15 / .017 / .1step240field digest84c1…09ba
Frame budget and edition receipt. A responsive animation can vary its display cadence while preserving one replayable simulation history.
Simulation
Advances only in fixed steps, independent of frame rate.
Rendering
Resizes and redraws without mutating state.
Receipt
Stores seed, grid, boundary, kernel, growth, time, and quantized field.
Identity
Uses the field digest; PNG pixels remain presentation.

Reading rule: labels, order, values, shapes, and line styles carry the conclusion; color is supplementary.

Make responsive Canvas accessible

Separate the drawing buffer from logical simulation space. Measure the displayed Canvas, cap device-pixel ratio, resize the bitmap, and render the existing field into the new buffer. The simulation array and clock remain untouched. This prevents a mobile rotation or panel resize from creating a different edition.

Canvas pixels need a semantic companion. Expose the preset, seed, grid, step count, total mass, minimum, maximum, kernel sum, and observed state in text. Label every control, keep targets at least 44 pixels high, support keyboard operation, and never rely on color alone. A concise method description explains what the image cannot.

Respect reduced motion by loading paused and allowing single-step. Forced-colors mode should preserve controls and the receipt even if the artwork palette is remapped. At 200 percent zoom, controls may stack but must not overlap or create horizontal page overflow.

The browser Lenia reference implementation offers rich context for the system's history and variants. This lab deliberately remains dependency-free and small enough to inspect as one file.

Export, replay, and test the edition

Export a PNG of the curated surface and JSON plus CSV receipts. The JSON includes schema version, seed, preset, grid, boundary, fixed delta, kernel specification and digest, growth parameters, step count, palette, field digest, and the quantized field. CSV provides one row for cataloging editions. Neither format sends data to a server.

Replay means more than matching the visible card. Reset from the receipt, reconstruct the initial field, advance the recorded number of fixed steps, and compare the field digest. Rendered pixels can vary slightly across browsers, so the state digest is the stronger identity; the PNG remains the exhibition surface.

Mutation tests should reject an unnormalized kernel, frame-rate-dependent delta, unseeded initialization, resize-triggered simulation changes, an incomplete receipt, and an oversized grid. Run the same seed twice and a different seed once. Pause, step, reset, and export through browser automation.

This makes Lenia Canvas a complete creative-coding artifact: numerical contract, expressive direction, accessible explanation, and reconstructive evidence. The neighboring diffusion-limited aggregation Canvas tutorial uses random walkers instead of a continuous field, offering a useful comparison between contact-grown branches and continuously coupled material.

Runnable local artifact — The lab is a finite generative-art implementation inspired by Lenia; it is not a validated biological model and does not promise identical raster pixels across browsers.

Plain text1 line
Choose a seeded preset; start, pause, step, or reset the bounded simulation; inspect state and kernel metrics; export PNG, JSON, or CSV.