setChannel function

int setChannel (
  1. int color,
  2. Channel channel,
  3. int value
)

Returns a new color, where the given color's channel has been replaced with the given value.

Implementation

int setChannel(int color, Channel channel, int value) =>
    channel == Channel.red ? setRed(color, value)
    : channel == Channel.green ? setGreen(color, value)
    : channel == Channel.blue ? setBlue(color, value)
    : channel == Channel.alpha ? setAlpha(color, value)
    : color;