Skip to content

Sprite Swarm

Sprite Swarm gives Sprite an ember renderer: a breathing ring that rests, and performs Agent-written scenes of shapes, paths and labels as a swarm.

  • @fungi.computer/sprite-swarm
  • v0.0.0
  • MIT

Fastest path

  1. Install

    Add it to your project with npm, pnpm, Yarn or Bun.

    TERMINAL
    npm install @fungi.computer/sprite-swarm
  2. Perform a scene

    Decodes a one-beat scene, encodes it once and builds the performance a Sprite host passes to the ember character. No canvas or WebGL needed.

    home.ts
    import { createSprite } from "@fungi.computer/sprite";
    import emberCharacter from "@fungi.computer/sprite-swarm/ember";
    import renderSwarm, { builtinCharacters } from "@fungi.computer/sprite-swarm";
    import { decodeScene, performanceOf } from "@fungi.computer/sprite-swarm/scene";
    import * as Result from "effect/Result";
    const scene = decodeScene({
    beats: [
    {
    duration: 2,
    caption: "A dot",
    elements: [{ kind: "shape", name: "dot", primitive: "sphere" }],
    },
    ],
    });
    if (Result.isFailure(scene)) throw new Error("the scene is invalid");
    const service = createSprite({ characters: builtinCharacters });
    const performance = performanceOf(
    1,
    scene.success,
    {
    beat: 0,
    playing: true,
    },
    {},
    );
    void service;
    void performance;
    void renderSwarm;
    void emberCharacter;