2020-07-21 21:46:58 +00:00
|
|
|
function SkottieExample(CanvasKit, surface, jsonStr, bounds) {
|
|
|
|
if (!CanvasKit || !jsonStr) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
const animation = CanvasKit.MakeAnimation(jsonStr);
|
|
|
|
const duration = animation.duration() * 1000;
|
|
|
|
|
|
|
|
const firstFrame = performance.now();
|
|
|
|
|
|
|
|
function drawFrame(skcanvas) {
|
|
|
|
const now = performance.now();
|
|
|
|
const seek = ((now - firstFrame) / duration) % 1.0;
|
|
|
|
|
|
|
|
animation.seek(seek);
|
2021-02-17 16:23:57 +00:00
|
|
|
animation.render(skcanvas, [0, 0, 500, 500]);
|
2020-07-21 21:46:58 +00:00
|
|
|
|
|
|
|
surface.requestAnimationFrame(drawFrame);
|
|
|
|
}
|
|
|
|
surface.requestAnimationFrame(drawFrame);
|
|
|
|
}
|