chickadee » sdl2 » color-sub!

color-sub! color1 color2 #!optional destprocedure
colour-sub! color1 color2 #!optional destprocedure

Efficiently subtract-blend color1 by color2. This is equivalent to the "subtract" blend mode of image editors, where color1 is the bottom layer and color2 is the top layer.

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

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

The results are clamped to the range [0, 255]. sdl2:color can only hold integer values, so the results will be truncated to integers.

This operation only affects the R, G, and B values. The result's A value will always be the same as color1's A value.

color2's A value controls the strength of the effect. E.g. 255 means full strength, 127 means half strength, 0 means no effect (the result will have the same values as color1).