Class BlendMode
- java.lang.Object
-
- ca.cgjennings.graphics.composites.AbstractARGBComposite
-
- ca.cgjennings.graphics.composites.BlendMode
-
- All Implemented Interfaces:
java.awt.Composite
- Direct Known Subclasses:
MaskComposite
public abstract class BlendMode extends AbstractARGBComposite
Composites that have similar effects to the layer blending modes in popular paint programs. This class itself is an abstract superclass of such composites; it provides concrete implementations for several common modes as immutable static members.Note: Because this extends
AbstractARGBComposite
, it only supports 32-bit integer (A)RGB colour models. To avoid potential problems, do not apply this composite directly to a screen, printer, or other arbitrary graphics context. Instead, create a temporary image inTYPE_INT_RGB
orTYPE_INT_ARGB
mode, composite into this image, and then draw the image to the destination.- Author:
- Chris Jennings
-
-
Field Summary
Fields Modifier and Type Field Description static BlendMode
Add
For each channel,Add
takes the sum of the of the source and destination values.static BlendMode
Burn
For each channel,Burn
decreases the brightness of the destination relative to the brightness of the source.static BlendMode
Color
Color
mixes the hue and saturation of the source pixel but keeps the brightness of the destination.static BlendMode
ColorBurn
For each channel,ColorBurn
decreases the contrast of the destination relative to the brightness of the source.static BlendMode
ColorDodge
For each channel,ColorDodge
brightens the destination by decreasing the contrast relative to the source.static BlendMode
Darken
For each channel,Darken
chooses the darker of the source and destination values.static BlendMode
Difference
For each channel,Difference
takes the absolute value of the difference of the source and destination values.static BlendMode
Dodge
For each channel,Dodge
increases the brightness of the destination relative to the brightness of the source.static BlendMode
Exclusion
Exclusion
produces an effect similar toDifference
, but lower in contrast.static BlendMode
Glow
Glow
has the same effect asReflect
, but is used when the source and destination are reversed.static BlendMode
HardLight
For each channel,HardLight
either multiplies or screens the values, depending on the source value.static BlendMode
HardMix
For each channel,HardMix
drives the value to either be fully off or fully on depending on the sum of the source and destination values.static BlendMode
Hue
Hue
mixes the hue of the source pixel but keeps the saturation and brightness of the destination.static BlendMode
Lighten
For each channel,Lighten
chooses the lighter of the source and destination values.static BlendMode
LinearBurn
For each channel,LinearBurn
darkens the destination by increasing the contrast relative to the source.static BlendMode
LinearDodge
LinearDodge
is the same asAdd
.static BlendMode
LinearLight
For each channel,LinearLight
either dodges or burns the values by adjusting brightness, depending on the source value.static BlendMode
Luminosity
Luminosity
mixes the brightness of the source pixel but keeps the hue and saturation of the destination.static BlendMode
Multiply
For each channel,Multiply
takes the product of the of the source and destination values.static BlendMode
Negation
Negation
produces a similar effect toDifference
, but the values are inverted so that the destination becomes lighter rather than darker.static java.awt.AlphaComposite
Normal
Normal
mixes the source and destination using the weighted averagesource/alpha + destination/(1-alpha)
.static BlendMode
Overlay
For each channel,Overlay
either multiplies or screens the values, depending on the destination.static BlendMode
PinLight
For each channel,PinLight
may replace the destination value with the source value.static BlendMode
Reflect
Reflect
lightens the destination based on the source using a non-linear function.static BlendMode
Saturation
Saturation
mixes the saturation of the source pixel but keeps the hue and brightness of the destination.static BlendMode
Screen
For each channel,Screen
takes the inverse product of the source and destination values.static BlendMode
SoftLight
For each channel,SoftLight
either dodges or burns the values, depending on the source value.static BlendMode
Subtract
For each channel,Subtract
subtracts the source value from the destination value.static BlendMode
VividLight
For each channel,VividLight
either dodges or burns the values by adjusting contrast, depending on the source value.-
Fields inherited from class ca.cgjennings.graphics.composites.AbstractARGBComposite
alpha
-
-
Method Summary
-
Methods inherited from class ca.cgjennings.graphics.composites.AbstractARGBComposite
compose, createContext, derive, getAlpha
-
-
-
-
Field Detail
-
Normal
public static final java.awt.AlphaComposite Normal
Normal
mixes the source and destination using the weighted averagesource/alpha + destination/(1-alpha)
.Normal
is identical to theAlphaComposite.SrcOver
composite. It is included here for completeness.
-
Lighten
public static final BlendMode Lighten
For each channel,Lighten
chooses the lighter of the source and destination values.
-
Darken
public static final BlendMode Darken
For each channel,Darken
chooses the darker of the source and destination values.
-
Add
public static final BlendMode Add
For each channel,Add
takes the sum of the of the source and destination values. The result is always lighter unless the destination is white or the source is black.Add
is sometimes called Linear Dodge.
-
Subtract
public static final BlendMode Subtract
For each channel,Subtract
subtracts the source value from the destination value.
-
Difference
public static final BlendMode Difference
For each channel,Difference
takes the absolute value of the difference of the source and destination values.
-
Exclusion
public static final BlendMode Exclusion
Exclusion
produces an effect similar toDifference
, but lower in contrast.
-
Negation
public static final BlendMode Negation
Negation
produces a similar effect toDifference
, but the values are inverted so that the destination becomes lighter rather than darker.
-
Multiply
public static final BlendMode Multiply
For each channel,Multiply
takes the product of the of the source and destination values. The result is always darker unless the destination is black.
-
Screen
public static final BlendMode Screen
For each channel,Screen
takes the inverse product of the source and destination values. The result is always lighter unless the destination is white. Visually, the effect is comparable to projecting one photographic slide over another.
-
Burn
public static final BlendMode Burn
For each channel,Burn
decreases the brightness of the destination relative to the brightness of the source.
-
ColorBurn
public static final BlendMode ColorBurn
For each channel,ColorBurn
decreases the contrast of the destination relative to the brightness of the source.
-
LinearBurn
public static final BlendMode LinearBurn
For each channel,LinearBurn
darkens the destination by increasing the contrast relative to the source.
-
Dodge
public static final BlendMode Dodge
For each channel,Dodge
increases the brightness of the destination relative to the brightness of the source.
-
ColorDodge
public static final BlendMode ColorDodge
For each channel,ColorDodge
brightens the destination by decreasing the contrast relative to the source.
-
Overlay
public static final BlendMode Overlay
For each channel,Overlay
either multiplies or screens the values, depending on the destination. The effect is to retain shadows from the destination while taking on colour from the source.
-
HardLight
public static final BlendMode HardLight
For each channel,HardLight
either multiplies or screens the values, depending on the source value. Visually, the effect is similar to shining a hard spotlight over the destination.
-
SoftLight
public static final BlendMode SoftLight
For each channel,SoftLight
either dodges or burns the values, depending on the source value. Visually, the effect is similar to shining a diffuse spotlight over the destination.
-
LinearLight
public static final BlendMode LinearLight
For each channel,LinearLight
either dodges or burns the values by adjusting brightness, depending on the source value. Visually, the effect is similar to shining a diffuse spotlight over the destination.
-
PinLight
public static final BlendMode PinLight
For each channel,PinLight
may replace the destination value with the source value. When the source value is light, the darker of the source and destination is selected. When the source value is dark, the lighter of the source and destination is selected.
-
VividLight
public static final BlendMode VividLight
For each channel,VividLight
either dodges or burns the values by adjusting contrast, depending on the source value. Visually, the effect is similar to shining a diffuse spotlight over the destination.
-
HardMix
public static final BlendMode HardMix
For each channel,HardMix
drives the value to either be fully off or fully on depending on the sum of the source and destination values. Thus, each pixel will be one of black, red, green, blue, yellow, cyan, magenta, or white.
-
Reflect
public static final BlendMode Reflect
Reflect
lightens the destination based on the source using a non-linear function. It is useful for adding shine or highlights to the destination.
-
Glow
public static final BlendMode Glow
Glow
has the same effect asReflect
, but is used when the source and destination are reversed.
-
Hue
public static final BlendMode Hue
Hue
mixes the hue of the source pixel but keeps the saturation and brightness of the destination.
-
Saturation
public static final BlendMode Saturation
Saturation
mixes the saturation of the source pixel but keeps the hue and brightness of the destination.
-
Color
public static final BlendMode Color
Color
mixes the hue and saturation of the source pixel but keeps the brightness of the destination.
-
Luminosity
public static final BlendMode Luminosity
Luminosity
mixes the brightness of the source pixel but keeps the hue and saturation of the destination.
-
-