SplitScript reference / Duration / fromFrames

Duration.fromFrames

Function

Duration.fromFrames<T>(frames: T, framesPerSecond: T) -> Duration where T: Integer

Constructs a duration from frames.

Every integer type is accepted. The frame count and rate use the same inferred type, so ordinary integer literals adopt the counter's type. Whole seconds are converted exactly; only the subsecond remainder passes through floating point to avoid overflowing narrow and 64-bit counters.

Parameters

  • frames: The elapsed frame count.
  • framesPerSecond: The frame rate.

Effects: pure

Runtime behavior: available everywhere; synchronous

Examples

Convert frames to game time

let elapsed = Duration.fromFrames(150, 60)