1function SkottieExample(CanvasKit, surface, jsonStr, bounds) { 2 if (!CanvasKit || !jsonStr) { 3 return; 4 } 5 const animation = CanvasKit.MakeAnimation(jsonStr); 6 const duration = animation.duration() * 1000; 7 8 const firstFrame = performance.now(); 9 10 function drawFrame(skcanvas) { 11 const now = performance.now(); 12 const seek = ((now - firstFrame) / duration) % 1.0; 13 14 animation.seek(seek); 15 animation.render(skcanvas, [0, 0, 500, 500]); 16 17 surface.requestAnimationFrame(drawFrame); 18 } 19 surface.requestAnimationFrame(drawFrame); 20}