dom-vcr
v1.0.1
Published
Generates an video or GIF from a DOM node using HTML5 canvas and SVG
Downloads
107
Maintainers
Readme
📦 Install
npm i dom-vcr
# optional deps
npm i modern-gif # by export GIF
npm i modern-mp4 # by export MP4
npm i mp4box
<script src="https://unpkg.com/dom-vcr"></script>
🦄 Usage
import { createVcr } from 'dom-vcr'
const dom = document.querySelector('#app')
const vcr = createVcr(dom, {
type: 'webm',
interval: 1000,
})
async function generate() {
dom.style.backgroundColor = 'red'
await vcr.addFrame()
dom.style.backgroundColor = 'yellow'
await vcr.addFrame()
dom.style.backgroundColor = 'green'
await vcr.addFrame()
const blob = await vcr.render()
window.open(URL.createObjectURL(blob))
}
generate()
Need install
mp4box
、modern-mp4
import { createVcr } from 'dom-vcr'
const dom = document.querySelector('#app')
const vcr = createVcr(dom, {
type: 'mp4',
interval: 1000,
})
async function generate() {
dom.style.backgroundColor = 'red'
await vcr.addFrame()
dom.style.backgroundColor = 'yellow'
await vcr.addFrame()
dom.style.backgroundColor = 'green'
await vcr.addFrame()
const blob = await vcr.render()
window.open(URL.createObjectURL(blob))
}
generate()
Need install
modern-gif
import { createVcr } from 'dom-vcr'
const dom = document.querySelector('#app')
const vcr = createVcr(dom, {
type: 'gif',
interval: 1000,
})
async function generate() {
dom.style.backgroundColor = 'red'
await vcr.addFrame()
dom.style.backgroundColor = 'yellow'
await vcr.addFrame()
dom.style.backgroundColor = 'green'
await vcr.addFrame()
const blob = await vcr.render()
window.open(URL.createObjectURL(blob))
}
generate()