Turn any Pencil.js scene into an animated GIF.
npm install @pencil.js/gif
You can download this directly from a CDN.
<script type="module">
import gif from "https://unpkg.com/@pencil.js/gif/dist/gif.esm.js";
gif();
</script>
<script src="https://unpkg.com/@pencil.js/gif"></script>
<!-- or -->
<script src="https://cdn.jsdelivr.net/npm/@pencil.js/gif"></script>
<script>
gif();
</script>
import gif from "@pencil.js/gif";
gif(<OffscreenCanvas>, <nbFrames>, <options>);
Check out the examples directory.
Turn any Pencil.js scene into an animated GIF.
Name | Type | Default | Comment |
---|---|---|---|
offscreenCanvas | OffscreenCanvas |
required | OffscreenCanvas or Scene coming from Pencil.js to be draw onto the GIF |
nbFrames | Number |
1 |
Number of frames to draw |
options | GIFOptions |
(see below) | Some options |
You can also use all canvas-gif-encoder
's options.
Name | Type | Default | Comment |
---|---|---|---|
speed | Number |
1 |
Rendering speed ratio (1 means ~60fps, 0.5 means ~30fps ...) |
This package is using Worker
to offload the computation to a separate thread and not lock the browser.
When using a web bundler like Webpack or Rollup,
you should use a worker-loader plugin like webpack worker-loader
or
rollup worker-loader
.