0.4.2 • Published 2 years ago

@netless/white-snapshot v0.4.2

Weekly downloads
3
License
MIT
Repository
github
Last release
2 years ago

@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.

OptionTypeDefaultDescription
scenePathstringcurrent sceneDefault is displayer.state.sceneState.scenePath.
paddingnumber5Pixels to the border of canvas.
backgroundstringBackground color.
cropRectanglenullApply crop on the snapshot. Note that the snapshot includes padding.
crossoriginbooleanfalseApply 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

0.4.2

2 years ago

0.4.1

2 years ago

0.3.0

2 years ago

0.4.0

2 years ago

0.3.1

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.2.2

2 years ago

0.1.2

5 years ago

0.1.1

5 years ago

0.1.0

5 years ago