Packagestarling.display
Classpublic class BlendMode
InheritanceBlendMode Inheritance Object

A class that provides constant values for visual blend mode effects.

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

flash.display3D.Context3DBlendFactor


Public Properties
 PropertyDefined 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
Public Methods
 MethodDefined 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
  
get(modeName:String):BlendMode
[static] Returns the blend mode with the given name.
BlendMode
  
register(name:String, srcFactor:String, dstFactor:String):BlendMode
[static] Registers a blending mode under a certain name.
BlendMode
  
toString():String
Returns the name of the blend mode.
BlendMode
Public Constants
 ConstantDefined 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
Property Detail
destinationFactorproperty
destinationFactor:String  [read-only]

The destination blend factor of this blend mode.


Implementation
    public function get destinationFactor():String
nameproperty 
name:String  [read-only]

Returns the name of the blend mode.


Implementation
    public function get name():String
sourceFactorproperty 
sourceFactor:String  [read-only]

The source blend factor of this blend mode.


Implementation
    public function get sourceFactor():String
Constructor Detail
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.

Parameters
name:String
 
sourceFactor:String
 
destinationFactor:String
Method Detail
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

Returns
BlendMode
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

Returns
BlendMode
toString()method 
public function toString():String

Returns the name of the blend mode.

Returns
String
Constant Detail
ADDConstant
public static const ADD:String = add

Adds the values of the colors of the display object to the colors of its background.

AUTOConstant 
public static const AUTO:String = auto

Inherits the blend mode from this display object's parent.

BELOWConstant 
public static const BELOW:String = below

Draws under/below existing objects; useful especially on RenderTextures.

ERASEConstant 
public static const ERASE:String = erase

Erases the background when drawn on a RenderTexture.

MASKConstant 
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.

MULTIPLYConstant 
public static const MULTIPLY:String = multiply

Multiplies the values of the display object colors with the the background color.

NONEConstant 
public static const NONE:String = none

Deactivates blending, i.e. disabling any transparency.

NORMALConstant 
public static const NORMAL:String = normal

The display object appears in front of the background.

SCREENConstant 
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.