forked from mifi/editly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customFabric.js
36 lines (29 loc) · 845 Bytes
/
customFabric.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
const editly = require('..');
/* eslint-disable spaced-comment,no-param-reassign */
async function func({ width, height, fabric }) {
async function onRender(progress, canvas) {
canvas.backgroundColor = 'hsl(33, 100%, 50%)';
const text = new fabric.Text(`PROGRESS\n${Math.floor(progress * 100)}%`, {
originX: 'center',
originY: 'center',
left: width / 2,
top: (height / 2) * (1 + (progress * 0.1 - 0.05)),
fontSize: 20,
textAlign: 'center',
fill: 'white',
});
canvas.add(text);
}
function onClose() {
// Cleanup if you initialized anything
}
return { onRender, onClose };
}
editly({
// fast: true,
outPath: './customFabric.gif',
// outPath: './customFabric.mp4',
clips: [
{ duration: 2, layers: [{ type: 'fabric', func }] },
],
}).catch(console.error);