-
Notifications
You must be signed in to change notification settings - Fork 1
/
exampleStillImage.js
30 lines (26 loc) · 1.06 KB
/
exampleStillImage.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
import {FastImageSequence} from '../../src/index';
export async function initExampleStillImage(container) {
const fastImageSequence = new FastImageSequence(container, {
name: 'StillImageTest',
frames: 89,
src: {
imageURL: (i) => `${('' + (i + 1)).padStart(4, '0')}.webp`,
maxCachedImages: 1, // default 32
useWorker: true,
},
// optional arguments:
loop: true, // default false
objectFit: 'cover', // default 'cover'
fillStyle: '#00000000', // default #00000000
clearCanvas: false, // default false
showDebugInfo: true,
});
await fastImageSequence.ready();
console.log('fastImageSequence loaded');
// now the first frame is loaded (numberOfCachedImages = 1), wait for 2 seconds, and then preload the other the frames
setTimeout(() => {
fastImageSequence.src.setMaxCachedImages(89, (progress) => console.log('preload progress:', progress)).then(() => {
console.log('all frames preloaded');
});
}, 2000);
}