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.
You can add your own blend modes via BlendMode.register
.
To get the math right, remember that all colors in Starling use premultiplied alpha (PMA),
which means that their RGB values were multiplied with the alpha value.
See also
Property | Defined By | ||
---|---|---|---|
destinationFactor : String [read-only] The destination blend factor of this blend mode. | BlendMode | ||
name : String [read-only] Returns the name of the blend mode. | BlendMode | ||
sourceFactor : String [read-only] The source blend factor of this blend mode. | BlendMode |
Method | Defined By | ||
---|---|---|---|
BlendMode(name:String, sourceFactor:String, destinationFactor:String) Creates a new BlendMode instance. | BlendMode | ||
activate():void Sets the appropriate blend factors for source and destination on the current context. | BlendMode | ||
[static] Returns the blend mode with the given name. | BlendMode | ||
getAll(out:Array = null):Array [static] Returns an array with all currently registered blend modes. | BlendMode | ||
isRegistered(modeName:String):Boolean [static] Returns true if a blend mode with the given name is available. | BlendMode | ||
[static] Registers a blending mode under a certain name. | BlendMode | ||
toString():String Returns the name of the blend mode. | 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 |
destinationFactor | property |
destinationFactor:String
[read-only] The destination blend factor of this blend mode.
public function get destinationFactor():String
name | property |
name:String
[read-only] Returns the name of the blend mode.
public function get name():String
sourceFactor | property |
sourceFactor:String
[read-only] The source blend factor of this blend mode.
public function get sourceFactor():String
BlendMode | () | Constructor |
public function BlendMode(name:String, sourceFactor:String, destinationFactor:String)
Creates a new BlendMode instance. Don't call this method directly; instead,
register a new blend mode using BlendMode.register
.
name:String | |
sourceFactor:String | |
destinationFactor:String |
activate | () | method |
public function activate():void
Sets the appropriate blend factors for source and destination on the current context.
get | () | method |
public static function get(modeName:String):BlendMode
Returns the blend mode with the given name. Throws an ArgumentError if the mode does not exist.
Parameters
modeName:String |
BlendMode |
getAll | () | method |
public static function getAll(out:Array = null):Array
Returns an array with all currently registered blend modes.
Parameters
out:Array (default = null )
|
Array |
isRegistered | () | method |
public static function isRegistered(modeName:String):Boolean
Returns true if a blend mode with the given name is available.
Parameters
modeName:String |
Boolean |
register | () | method |
public static function register(name:String, srcFactor:String, dstFactor:String):BlendMode
Registers a blending mode under a certain name.
Parameters
name:String | |
srcFactor:String | |
dstFactor:String |
BlendMode |
toString | () | method |
public function toString():String
Returns the name of the blend mode.
ReturnsString |
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.