rive-app/rive-ios

Render animation at arbitrary time

Opened this issue · 2 comments

I am trying to live render a Rive animation onto a video using RiveRenderer and a custom AVComposition. This will be displayed in a player that has scrubbing and rewind, so I need to be able to get an animation frame given a time. I am only seeing an advance(by: seconds) method on Artboard, is it possible to pass an arbitrary time? Could animation setTime do this?

I'm also struggling to understand the relationship between artboard + animation, following Example-iOS/CustomRenderer it seems like to do this I would want to setTime on animation, apply animation to artboard, and render artboard using RiveRenderer, but it seems like animation.apply(to: Artboard) is no longer an API.

If you just need to do this with a LinearAnimation you can directly apply it at a specific time.

You can do this by getting a raw LinearAnimation (not an instance) from the artboard:
https://github.com/rive-app/rive-cpp/blob/142d059a87deac3cf02198e96550eaad43edfceb/include/rive/artboard.hpp#L149-L151

And then applying it to an Artboard or ArtboardInstance with a given time:
https://github.com/rive-app/rive-cpp/blob/142d059a87deac3cf02198e96550eaad43edfceb/include/rive/animation/linear_animation.hpp#L24C27-L24C27

I'm not sure if there's a good way to access this from the higher level iOS runtime but in theory everything should be available. I'll ping @mjtalbot to see if he has ideas.