-
Notifications
You must be signed in to change notification settings - Fork 3
Using filters
vincent-petithory edited this page Sep 13, 2010
·
1 revision
The filters created using Pixel Pender have to use the flash.filters.ShaderFilter
base class.
In the stdpx library, every filter extends the ShaderFilter
class. This way, you may use any filter in the usual way :
import stdpx.filters.*;
// Applies a HSVColorFilter filter to myDisplayObject.
// All previous filters are removed.
myDisplayObject.filters = [new HSVColorFilter()];
When possible, each filter can be configured when calling its constructor.
// Applies a HSVColorFilter filter to myDisplayObject.
// Its hue is rotated by +30°, its saturation is decreased by 10,
// and its value increased by 5.
myDisplayObject.filters = [new HSVColorFilter(30,-10,5)];
Like all other elements of the stdpx library, every filter implements the stdpx.types.IMetadataAttachedShader
interface in order to access the shader metadata.
The stdpx.util.FilterUtil
class allows you to manipulate filters applied to any DisplayObject
. The available methods are shortcuts of the following common tasks :
- Adding a filter at the beginning of the filter chain. This filter will be applied before all other filters will be applied.
- Adding a filter at the end of the filter chain. This filter will be applied after all other filters have been applied.
- Removing duplicate filters in a filter chain. Two filters are considered duplicates if they are instances of the same class. This method does not process filters extending the `flash.filters.ShaderFilter` class. Indeed, Flash Player does not keep the real type of the shader filters ; they are all considered to extend `flash.filters.ShaderFilter` after having been applied.