Color Blending Functions
These operations are similar (though not necessarily identical) to the blend modes found in image editors like Photoshop, Fireworks, or GIMP, so you can use them to make your CSS colors match your images.
Example:
#
multiplyMultiply two colors. Corresponding RGB channels from each of the two colors are multiplied together then divided by 255. The result is a darker color.
Parameters:
color1
: A color object.color2
: A color object.
Returns: color
Examples:
#
screenDo the opposite of
multiply
. The result is a brighter color.
Parameters:
color1
: A color object.color2
: A color object.
Returns: color
Example:
#
overlayCombines the effects of both
multiply
andscreen
. Conditionally make light channels lighter and dark channels darker. Note: The results of the conditions are determined by the first color parameter.
Parameters:
color1
: A base color object. Also the determinant color to make the result lighter or darker.color2
: A color object to overlay.
Returns: color
Example:
#
softlightSimilar to
overlay
but avoids pure black resulting in pure black, and pure white resulting in pure white.
Parameters:
color1
: A color object to soft light another.color2
: A color object to be soft lighten.
Returns: color
Example:
#
hardlightThe same as
overlay
but with the color roles reversed.
Parameters:
color1
: A color object to overlay.color2
: A base color object. Also the determinant color to make the result lighter or darker.
Returns: color
Example:
#
differenceSubtracts the second color from the first color on a channel-by-channel basis. Negative values are inverted. Subtracting black results in no change; subtracting white results in color inversion.
Parameters:
color1
: A color object to act as the minuend.color2
: A color object to act as the subtrahend.
Returns: color
Example:
#
exclusionA similar effect to
difference
with lower contrast.
Parameters:
color1
: A color object to act as the minuend.color2
: A color object to act as the subtrahend.
Returns: color
Example:
#
averageCompute the average of two colors on a per-channel (RGB) basis.
Parameters:
color1
: A color object.color2
: A color object.
Returns: color
Example:
#
negationDo the opposite effect to
difference
.
The result is a brighter color. Note: The opposite effect doesn't mean the inverted effect as resulting from an addition operation.
Parameters:
color1
: A color object to act as the minuend.color2
: A color object to act as the subtrahend.
Returns: color
Example: