-
Notifications
You must be signed in to change notification settings - Fork 3
Using blend modes
vincent-petithory edited this page Sep 13, 2010
·
1 revision
To apply a shader of the Stdpx library, you must use the DisplayObject.blendShader
property of any display object.
All available blend modes are in the stdpx.blendmodes.*
package.
You have two ways to access a stdpx blend mode : (examples below assume myDisplayObject
is a DisplayObject
instance)
- by creating an instance of a blend mode class :
import stdpx.blendmodes.*;
// Applies a blend mode Saturation to myDisplayObject
myDisplayObject.blendShader = new BlendModeSaturation();
- by accessing the blend mode through the
stdpx.blendmodes.StdpxBlendMode
or thestdpx.blendmodes.FlashBlendMode
static classes.
The former wraps new blend modes that are not available natively in Flash Player.
The latter wraps existing blend modes in Flash. The FlashBlendMode class exists only for compatibility. However, they use hardware while Flash Player ones use software. Consider it when choosing between Flash Player blend modes and thoses from thestdpx.blendmodes.FlashBlendMode
class.
Class | Description |
stdpx.blendmodes.StdpxBlendMode |
New blend modes not previously in flash |
stdpx.blendmodes.FlashBlendMode |
All legacy blend modes of Flash |
import stdpx.blendmodes.StdpxBlendMode;
// Applies a blend mode Saturation to myDisplayObject
myDisplayObject.blendShader = StdpxBlendMode.SATURATION;
This way is more intuitive and faster to write, however you cannot specify parameters to the blend mode (not a bad news since there is no parameters for blend modes yet).
That’s it for blend modes with Stdpx.