Skip to component
Modulo

Interactive art

A growing lotus garden with flexible stems, a day and night cycle, and PNG layer exports.

Preview

Lotus garden

Day 0:16

Controls

Live preview

Hover over a flower, or hold and pull it. The stem returns when you let go.

3x

Export artwork

Installation

bunx shadcn@latest add @modulo/interactive-art

Requires 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 video

API

Pass scene options to GardenCanvas. Use the controller from onReady for live changes.

PropTypeDefault
initialTimeScene age in seconds.number16
timeScaleGrowth and lighting speed. Physics keeps its own clock.number1
seedRepeatable scene composition.number1486
cycleSecondsLength of a complete day and night cycle.number120
windStrength of the wind.number1
plantsPositions, growth, and flower colors.readonly PlantDefinition[]DEFAULT_PLANTS
pausedInitial pause state.booleanfalse
fallbackYour own still image URL, displayed behind the canvas.stringOptional
classNameClass names for the scene container.string""
onReadyController on mount, null on cleanup. Keep callbacks stable.(garden | null) => voidOptional
onFrameScene status after a rendered frame.(FrameState) => voidOptional
onErrorCanvas initialization failure.(Error) => voidOptional
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...