Skip to content

Paint reaction diffusion

Read as Markdown

Mount an interactive reaction-diffusion layer with a typed brush.

Plain source. Run as a browser module after the document body exists. TSX uses jsx: "react-jsx" and jsxImportSource: "@pibbl/core".

/** @jsxImportSource @pibbl/core */
import { pibblSync } from '@pibbl/core/sync';
import {
ReactionDiffusion,
texturePalettes,
type ReactionDiffusionProps,
type TextureBrush,
} from "@pibbl/core/textures";
const canvas = document.createElement("canvas");
canvas.width = 320;
canvas.height = 200;
document.body.append(canvas);
const brush: TextureBrush = { radius: 6, strength: 0.8 };
const props: ReactionDiffusionProps = {
seed: 7,
preset: "spots",
palette: texturePalettes.ember,
resolution: { width: 128, height: 80 },
brush,
};
const controller = pibblSync(
canvas,
<ReactionDiffusion {...props} style={{ width: 320, height: 200 }} />,
);
window.addEventListener("pagehide", () => controller.dispose(), { once: true });
  • The layer owns its simulation until the Pibbl controller is disposed.

Documentation built with @pibbl/core 0.0.2, revision a1dcf8e. ALPHA — NOT FOR PRODUCTION USE.