withBlack method
- int subtract
⬛
Color.withBlack(int subtract)
darkens Color
's RGB values by subtract
(result >= 0)
Implementation
Color withBlack(int subtract) {
int red = this.red ?? 0;
int green = this.green ?? 0;
int blue = this.blue ?? 0;
if (red - subtract < 0)
red = 0;
else
red -= subtract;
if (green - subtract < 0)
green = 0;
else
green -= subtract;
if (blue - subtract < 0)
blue = 0;
else
blue -= subtract;
return this.withRed(red).withGreen(green).withBlue(blue);
}