Nebulous Puffy Marshmallows

    @netless/white-snapshot
    TypeScript icon, indicating that this package has built-in type declarations

    0.4.1 • Public • Published

    @netless/white-snapshot

    Take a snapshot of a white-web-sdk scene.

    Requires white-web-sdk ≥ 2.16.20.

    Usage

    import { snapshot } from "@netless/white-snapshot";
    // room = await sdk.joinRoom(...)
    snapshot(room).then(canvas => {
      document.body.append(canvas);
    });

    Options

    snapshot(room, {
      scenePath: "/init",
      padding: 5,
      background: 'transparent',
      crop: null,
      crossorigin: false,
      src2dataurl: undefined,
    }): Promise<HTMLCanvasElement | null>;

    Returns null if failed.

    Option Type Default Description
    scenePath string current scene Default is displayer.state.sceneState.scenePath.
    padding number 5 Pixels to the border of canvas.
    background string Background color.
    crop Rectangle null Apply crop on the snapshot. Note that the snapshot includes padding.
    crossorigin boolean false Apply hack to document.createElement('img') to enable crossorigin images.
    src2dataurl (src: string) ⇒ Promise<string> Due to a limitation in html2canvas, we must convert images to dataurl before feeding them to it.

    Develop

    pnpm dev

    Changelog

    License

    MIT @ netless

    Install

    npm i @netless/white-snapshot

    DownloadsWeekly Downloads

    130

    Version

    0.4.1

    License

    MIT

    Unpacked Size

    52.3 kB

    Total Files

    8

    Last publish

    Collaborators

    • vince-hz
    • alic_zhang
    • straybugs
    • moskize
    • netless-rick
    • yleaf
    • herewhite
    • black_hole
    • cheerchen
    • l1shen
    • hyrious
    • huaguzheng