chickadee » sdl2 » rect-lerp

rect-lerp rect1 rect2 tprocedure
rect-lerp! rect1 rect2 t #!optional destprocedure

Efficient linear interpolation (or extrapolation) between rect1 and rect2. sdl2:rect can only hold integer values, so the results will be truncated to integers. The results will be clamped to the range -2147483648 to 2147483647.

These procedures affect all values of the rect: X, Y, W, and H. If you only want to interpolate the rect's position (X and Y), use rect-lerp-xy instead.

t is the interpolation factor (a float). Values of t between 0 and 1 will interpolate between rect1 and rect2. Values of t less that 0 will extrapolate beyond rect1 (moving away from rect2). Values greater that 1 will extrapolate beyond rect2 (moving away from rect1).

  • rect-lerp returns a new managed sdl2:rect.
  • rect-lerp! modifies and returns dest. If dest is omitted, rect1 is modified and returned.

These procedures are available in sdl2 egg version 0.2.0 and higher.