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.

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

flash.display3D.Context3DBlendFactor


Public Methods
 MethodDefined 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
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
Method Detail
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)

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

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.