withWhite method

Color withWhite (
  1. int add
)

Color.withWhite(int add)

brightens Color's RGB values by add (result <= 255)

Implementation

Color withWhite(int add) {
  int red = this.red ?? 0;
  int green = this.green ?? 0;
  int blue = this.blue ?? 0;

  if (red + add > 255)
    red = 255;
  else
    red += add;
  if (green + add > 255)
    green = 255;
  else
    green += add;
  if (blue + add > 255)
    blue = 255;
  else
    blue += add;

  return this.withRed(red).withGreen(green).withBlue(blue);
}