forked from mifi/editly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
customCanvas.js
37 lines (32 loc) · 874 Bytes
/
customCanvas.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
import editly from '..';
async function func({ canvas }) {
async function onRender(progress) {
const context = canvas.getContext('2d');
const centerX = canvas.width / 2;
const centerY = canvas.height / 2;
const radius = 40 * (1 + progress * 0.5);
context.beginPath();
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
context.fillStyle = 'hsl(350, 100%, 37%)';
context.fill();
context.lineWidth = 5;
context.strokeStyle = '#ffffff';
context.stroke();
}
function onClose() {
// Cleanup if you initialized anything
}
return { onRender, onClose };
}
editly({
// fast: true,
// outPath: './customCanvas.mp4',
outPath: './customCanvas.gif',
clips: [
{ duration: 2,
layers: [
{ type: 'rainbow-colors' },
{ type: 'canvas', func },
] },
],
}).catch(console.error);