core-ktx / androidx.graphics / android.graphics.Color / plus

plus

operator fun Color.plus(c: Color): Color

Composites two translucent colors together. More specifically, adds two colors using the source over blending mode. The colors must not be pre-multiplied and the result is a non pre-multiplied color.

If the two colors have different color spaces, the color in the right-hand part of the expression is converted to the color space of the color in left-hand part of the expression.

The following example creates a purple color by blending opaque blue with semi-translucent red:

val purple = Color.valueOf(0f, 0f, 1f) + Color.valueOf(1f, 0f, 0f, 0.5f)

Exceptions

IllegalArgumentException - if the color models of the colors do not match