-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerator.js
41 lines (37 loc) · 1.24 KB
/
generator.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import Generator from './src/generator';
import Renderer from './src/renderer/canvas-2d';
import wasmBinary from './src/wasm-binary';
import videoData from './video-data';
window.addEventListener('load', async () => {
const wrapHeight = window.innerHeight;
const wrapWidth = Math.floor(window.innerHeight / videoData.height * videoData.width);
const wrap = {
height: wrapHeight,
width: wrapWidth,
top: 0,
left: -(wrapWidth - window.innerWidth) / 2 | 0,
};
const wrapDom = document.querySelector('.canvas-wrap');
wrapDom.style.width = wrap.width + 'px';
wrapDom.style.height = wrap.height + 'px';
wrapDom.style.top = wrap.top + 'px';
wrapDom.style.left = wrap.left + 'px';
const canvas = document.querySelector('#video-content');
canvas.width = wrapWidth;
canvas.height = wrapHeight;
const renderer = new Renderer({ canvas });
const generator = new Generator({
url: videoData.url,
renderer,
wasmBinary,
loop: true,
progressive: true,
disableWebAssembly: true,
});
generator.init().then(() => {
setInterval(() => {
generator.update();
}, 20)
});
window.generator = generator;
}, false);