chickadee » sdl2 » color-lerp

color-lerp color1 color2 tprocedure
color-lerp! color1 color2 t #!optional destprocedure
colour-lerp color1 color2 tprocedure
colour-lerp! color1 color2 t #!optional destprocedure

Efficient linear interpolation (or extrapolation) between color1 and color2. sdl2:color can only hold integer values, so the results will be truncated to integers. The results will be clamped to the range 0 to 255.

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

  • color-lerp and colour-lerp return a new managed sdl2:color.
  • color-lerp! and colour-lerp! modify and return dest. If dest is omitted, color1 is modified and returned.

Requires sdl2 egg 0.2.0 or higher.