Interactive art
A growing lotus garden with flexible stems, a day and night cycle, and PNG layer exports.
Preview
Lotus garden
Day 0:16Controls
Live previewHover over a flower, or hold and pull it. The stem returns when you let go.
Export artwork
Installation
bunx shadcn@latest add @modulo/interactive-artRequires an active Modulo key and a project configured for shadcn.
Registry setup
Set MODULO_REGISTRY_KEY to your key. Add this registry entry to components.json.
{
"registries": {
"@modulo": {
"url": "<registry-url>/r/{name}.json",
"headers": {
"Authorization": "Bearer ${MODULO_REGISTRY_KEY}"
}
}
}
}Usage
import { GardenCanvas } from "@/components/interactive-art/examples/GardenCanvas";
export default function Example() {
return <GardenCanvas initialTime={16} timeScale={3} />;
}React and Canvas 2D. No animation package required.
Registry JSONDownload still fallbackDownload thumbnailDownload preview GIFDownload preview videoAPI
Pass scene options to GardenCanvas. Use the controller from onReady for live changes.
| Prop | Type | Default |
|---|---|---|
initialTimeScene age in seconds. | number | 16 |
timeScaleGrowth and lighting speed. Physics keeps its own clock. | number | 1 |
seedRepeatable scene composition. | number | 1486 |
cycleSecondsLength of a complete day and night cycle. | number | 120 |
windStrength of the wind. | number | 1 |
plantsPositions, growth, and flower colors. | readonly PlantDefinition[] | DEFAULT_PLANTS |
pausedInitial pause state. | boolean | false |
fallbackYour own still image URL, displayed behind the canvas. | string | Optional |
classNameClass names for the scene container. | string | "" |
onReadyController on mount, null on cleanup. Keep callbacks stable. | (garden | null) => void | Optional |
onFrameScene status after a rendered frame. | (FrameState) => void | Optional |
onErrorCanvas initialization failure. | (Error) => void | Optional |
Controller methods
pause(), resume(), seek(seconds), setTimeScale(value), and bend(id, direction) control the scene.
snapshot() and saveState() return scene state. exportPNG(options) saves the whole scene or selected layers. The React component calls destroy() on unmount.
Source
Checking source access...
