mirror of
https://github.com/thorvg/thorvg.git
synced 2025-06-28 19:02:23 +00:00
example: more precisely calculate frame numbers
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
Some checks are pending
Android / build_x86_64 (push) Waiting to run
Android / build_aarch64 (push) Waiting to run
iOS / build_x86_64 (push) Waiting to run
iOS / build_arm64 (push) Waiting to run
macOS / build (push) Waiting to run
macOS / compact_test (push) Waiting to run
macOS / unit_test (push) Waiting to run
Ubuntu / build (push) Waiting to run
Ubuntu / compact_test (push) Waiting to run
Ubuntu / unit_test (push) Waiting to run
Windows / build (push) Waiting to run
Windows / compact_test (push) Waiting to run
Windows / unit_test (push) Waiting to run
fixed a missing case of the last frame.
This commit is contained in:
parent
05e4c3e4eb
commit
43923a54d4
1 changed files with 3 additions and 3 deletions
|
@ -496,10 +496,10 @@ struct WgWindow : Window
|
||||||
float progress(uint32_t elapsed, float durationInSec, bool rewind = false)
|
float progress(uint32_t elapsed, float durationInSec, bool rewind = false)
|
||||||
{
|
{
|
||||||
auto duration = uint32_t(durationInSec * 1000.0f); //sec -> millisec.
|
auto duration = uint32_t(durationInSec * 1000.0f); //sec -> millisec.
|
||||||
if (duration == 0) return 0.0f;
|
if (elapsed == 0 || duration == 0) return 0.0f;
|
||||||
auto forward = ((elapsed / duration) % 2 == 0) ? true : false;
|
auto forward = ((elapsed / duration) % 2 == 0) ? true : false;
|
||||||
auto wrapped = elapsed % duration;
|
if (elapsed % duration == 0) return 1.0f;
|
||||||
auto progress = ((float)wrapped / (float)duration);
|
auto progress = (float(elapsed % duration) / (float)duration);
|
||||||
if (rewind) return forward ? progress : (1 - progress);
|
if (rewind) return forward ? progress : (1 - progress);
|
||||||
return progress;
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue