Skip to content
Snippets Groups Projects
Unverified Commit d295b91c authored by Jerome Humbert's avatar Jerome Humbert Committed by GitHub
Browse files

Add elapsed API (#67)

Add two new methods to the `Tweenable<T>` trait:
- `set_elapsed(Duration)` sets the elapsed time of the tweenable. This
  is equivalent to `set_progress(duration().mul_f32(progress))`, with
  the added benefit of avoiding floating-point conversions and potential
  rounding errors resulting from it. `set_progress()` is now largely
  implemented in terms of and as a convenience wrapper to calling
  `set_elapsed()`.
- `elapsed()` which queries the elapsed time of the tweenable. This is
  equivalent to `duration().mul_f32(progress())`, again with better
  precision.

The elapsed API is the recommended way going forward to manipulate a
tweenable's time outside of the normal `tick()` flow. It supersedes the
progress API.

This change purposedly skips any discussion about what happens to
completion events when `set_progress()` or now `set_elpased()` is called
with a lower value than the current one to seek time back. This design
issue is logged as #60 and is still pending. The change also partially
addresses #31, but without removing any existing API or feature.
parent dd6ac741
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment