| Package | starling.display |
| Class | public class BlendMode |
| Inheritance | BlendMode Object |
A blend mode is always defined by two 'Context3DBlendFactor' values. A blend factor represents a particular four-value vector that is multiplied with the source or destination color in the blending formula. The blending formula is:
result = source × sourceFactor + destination × destinationFactor
In the formula, the source color is the output color of the pixel shader program. The destination color is the color that currently exists in the color buffer, as set by previous clear and draw operations.
Beware that blending factors produce different output depending on the texture type. Textures may contain 'premultiplied alpha' (pma), which means that their RGB values were multiplied with their alpha value (to save processing time). Textures based on 'BitmapData' objects have premultiplied alpha values, while ATF textures haven't. For this reason, a blending mode may have different factors depending on the pma value.
See also
| Method | Defined By | ||
|---|---|---|---|
getBlendFactors(mode:String, premultipliedAlpha:Boolean = true):Array [static] Returns the blend factors that correspond with a certain mode and premultiplied alpha
value. | BlendMode | ||
register(name:String, sourceFactor:String, destFactor:String, premultipliedAlpha:Boolean = true):void [static] Registeres a blending mode under a certain name and for a certain premultiplied alpha
(pma) value. | BlendMode | ||
| Constant | Defined By | ||
|---|---|---|---|
| ADD : String = add [static] Adds the values of the colors of the display object to the colors of its background. | BlendMode | ||
| AUTO : String = auto [static] Inherits the blend mode from this display object's parent. | BlendMode | ||
| ERASE : String = erase [static] Erases the background when drawn on a RenderTexture. | BlendMode | ||
| MULTIPLY : String = multiply [static] Multiplies the values of the display object colors with the the background color. | BlendMode | ||
| NONE : String = none [static] Deactivates blending, i.e. | BlendMode | ||
| NORMAL : String = normal [static] The display object appears in front of the background. | BlendMode | ||
| SCREEN : String = screen [static] Multiplies the complement (inverse) of the display object color with the complement of
the background color, resulting in a bleaching effect. | BlendMode | ||
| getBlendFactors | () | method |
public static function getBlendFactors(mode:String, premultipliedAlpha:Boolean = true):ArrayReturns the blend factors that correspond with a certain mode and premultiplied alpha value. Throws an ArgumentError if the mode does not exist.
Parameters
mode:String | |
premultipliedAlpha:Boolean (default = true) |
Array |
| register | () | method |
public static function register(name:String, sourceFactor:String, destFactor:String, premultipliedAlpha:Boolean = true):voidRegisteres a blending mode under a certain name and for a certain premultiplied alpha (pma) value. If the mode for the other pma value was not yet registered, the factors are used for both pma settings.
Parameters
name:String | |
sourceFactor:String | |
destFactor:String | |
premultipliedAlpha:Boolean (default = true) |
| ADD | Constant |
public static const ADD:String = addAdds the values of the colors of the display object to the colors of its background.
| AUTO | Constant |
public static const AUTO:String = autoInherits the blend mode from this display object's parent.
| ERASE | Constant |
public static const ERASE:String = eraseErases the background when drawn on a RenderTexture.
| MULTIPLY | Constant |
public static const MULTIPLY:String = multiplyMultiplies the values of the display object colors with the the background color.
| NONE | Constant |
public static const NONE:String = noneDeactivates blending, i.e. disabling any transparency.
| NORMAL | Constant |
public static const NORMAL:String = normalThe display object appears in front of the background.
| SCREEN | Constant |
public static const SCREEN:String = screenMultiplies the complement (inverse) of the display object color with the complement of the background color, resulting in a bleaching effect.