API Reference › Tween › Tween.round
method

Tween.round

Tween.round(from, to, t) -> int

Interpolates two int endpoints by amount t and rounds to the nearest integer (half up): from + round((to - from) * t). The go-to for tweening a pixel position, a channel byte, or any integer field. Combine with Tween.ease for shaped motion.

Parameters

fromthe value at t = 0 (an int)
tothe value at t = 1 (an int)
tthe blend amount (a fixed, usually 0..1)

Example

program Demo {
  property Slide { timer: fixed = 0.0 }
  model Card { Slide }
  handler Run phase Update {
    Slide.timer = Slide.timer + Time.delta()
    let t = Tween.progress(Slide.timer, fixed(1))
    let x = Tween.round(0, 320, Tween.ease(t, 2))
    print(x)
  }
}
← All symbols