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 | ||
BELOW : String = below [static] Draws under/below existing objects; useful especially on RenderTextures. | BlendMode | ||
ERASE : String = erase [static] Erases the background when drawn on a RenderTexture. | BlendMode | ||
MASK : String = mask [static] When used on a RenderTexture, the drawn object will act as a mask for the current
content, i.e. | 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):Array
Returns 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):void
Registeres 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 = add
Adds the values of the colors of the display object to the colors of its background.
AUTO | Constant |
public static const AUTO:String = auto
Inherits the blend mode from this display object's parent.
BELOW | Constant |
public static const BELOW:String = below
Draws under/below existing objects; useful especially on RenderTextures.
ERASE | Constant |
public static const ERASE:String = erase
Erases the background when drawn on a RenderTexture.
MASK | Constant |
public static const MASK:String = mask
When used on a RenderTexture, the drawn object will act as a mask for the current content, i.e. the source alpha overwrites the destination alpha.
MULTIPLY | Constant |
public static const MULTIPLY:String = multiply
Multiplies the values of the display object colors with the the background color.
NONE | Constant |
public static const NONE:String = none
Deactivates blending, i.e. disabling any transparency.
NORMAL | Constant |
public static const NORMAL:String = normal
The display object appears in front of the background.
SCREEN | Constant |
public static const SCREEN:String = screen
Multiplies the complement (inverse) of the display object color with the complement of the background color, resulting in a bleaching effect.