Packagestarling.filters
Classpublic class DisplacementMapFilter
InheritanceDisplacementMapFilter Inheritance FragmentFilter Inheritance EventDispatcher Inheritance Object

The DisplacementMapFilter class uses the pixel values from the specified texture (called the map texture) to perform a displacement of an object. You can use this filter to apply a warped or mottled effect to any object that inherits from the DisplayObject class.

The filter uses the following formula:

dstPixel[x, y] = srcPixel[x + ((componentX(x, y) - 128) * scaleX) / 256,
                          y + ((componentY(x, y) - 128) * scaleY) / 256]
      

Where componentX(x, y) gets the componentX property color value from the map texture at (x - mapPoint.x, y - mapPoint.y).



Public Properties
 PropertyDefined By
 InheritedalwaysDrawToBackBuffer : Boolean
Indicates if the last filter pass is always drawn directly to the back buffer.
FragmentFilter
  componentX : uint
Describes which color channel to use in the map image to displace the x result.
DisplacementMapFilter
  componentY : uint
Describes which color channel to use in the map image to displace the y result.
DisplacementMapFilter
 InheritedisCached : Boolean
[read-only] Indicates if the filter is cached (via the cache method).
FragmentFilter
  mapRepeat : Boolean
Indicates how the pixels of the map texture will be wrapped at the edge.
DisplacementMapFilter
  mapTexture : Texture
The texture that will be used to calculate displacement.
DisplacementMapFilter
  mapX : Number
The horizontal offset of the map texture relative to the origin.
DisplacementMapFilter
  mapY : Number
The vertical offset of the map texture relative to the origin.
DisplacementMapFilter
 InheritednumPasses : int
[read-only] Indicates the number of rendering passes required for this filter.
FragmentFilter
 Inheritedpadding : Padding
Padding can extend the size of the filter texture in all directions.
FragmentFilter
 Inheritedresolution : Number
The resolution of the filter texture.
FragmentFilter
  scaleX : Number
The multiplier used to scale the x displacement result from the map calculation.
DisplacementMapFilter
  scaleY : Number
The multiplier used to scale the y displacement result from the map calculation.
DisplacementMapFilter
 InheritedtextureFormat : String
The format of the filter texture.
FragmentFilter
 InheritedtextureSmoothing : String
The smoothing mode of the filter texture.
FragmentFilter
Protected Properties
 PropertyDefined By
 Inheritedeffect : FilterEffect
[read-only] The effect instance returning the FilterEffect created via createEffect.
FragmentFilter
 InheritedindexData : IndexData
[read-only] The IndexData used to process the effect.
FragmentFilter
 InheritedvertexData : VertexData
[read-only] The VertexData used to process the effect.
FragmentFilter
Public Methods
 MethodDefined By
  
DisplacementMapFilter(mapTexture:Texture, componentX:uint = 0, componentY:uint = 0, scaleX:Number = 0.0, scaleY:Number = 0.0)
Creates a new displacement map filter that uses the provided map texture.
DisplacementMapFilter
 Inherited
addEventListener(type:String, listener:Function):void
Registers an event listener at a certain object.
EventDispatcher
 Inherited
cache():void
Caches the filter output into a texture.
FragmentFilter
 Inherited
clearCache():void
Clears the cached output of the filter.
FragmentFilter
 Inherited
dispatchEvent(event:Event):void
Dispatches an event to all objects that have registered listeners for its type.
EventDispatcher
 Inherited
dispatchEventWith(type:String, bubbles:Boolean = false, data:Object = null):void
Dispatches an event with the given parameters to all objects that have registered listeners for the given type.
EventDispatcher
 Inherited
dispose():void
Disposes all resources that have been created by the filter.
FragmentFilter
 Inherited
hasEventListener(type:String, listener:Function = null):Boolean
If called with one argument, figures out if there are any listeners registered for the given event type.
EventDispatcher
 Inherited
process(painter:Painter, helper:IFilterHelper, input0:Texture = null, input1:Texture = null, input2:Texture = null, input3:Texture = null):Texture
Does the actual filter processing.
FragmentFilter
 Inherited
removeEventListener(type:String, listener:Function):void
Removes an event listener from the object.
EventDispatcher
 Inherited
removeEventListeners(type:String = null):void
Removes all event listeners with a certain type, or all of them if type is null.
EventDispatcher
 Inherited
render(painter:Painter):void
Renders the filtered target object.
FragmentFilter
Protected Methods
 MethodDefined By
 Inherited
Creates the effect that does the actual, low-level rendering.
FragmentFilter
 Inherited
Called when assigning a target display object.
FragmentFilter
 Inherited
Call this method when any of the filter's properties changes.
FragmentFilter
Events
 Event Summary Defined By
 InheritedDispatched when the settings change in a way that requires a redraw.FragmentFilter
 InheritedDispatched every frame on filters assigned to display objects connected to the stage.FragmentFilter
Property Detail
componentXproperty
componentX:uint

Describes which color channel to use in the map image to displace the x result. Possible values are constants from the BitmapDataChannel class.


Implementation
    public function get componentX():uint
    public function set componentX(value:uint):void
componentYproperty 
componentY:uint

Describes which color channel to use in the map image to displace the y result. Possible values are constants from the BitmapDataChannel class.


Implementation
    public function get componentY():uint
    public function set componentY(value:uint):void
mapRepeatproperty 
mapRepeat:Boolean

Indicates how the pixels of the map texture will be wrapped at the edge.


Implementation
    public function get mapRepeat():Boolean
    public function set mapRepeat(value:Boolean):void
mapTextureproperty 
mapTexture:Texture

The texture that will be used to calculate displacement.


Implementation
    public function get mapTexture():Texture
    public function set mapTexture(value:Texture):void
mapXproperty 
mapX:Number

The horizontal offset of the map texture relative to the origin.

The default value is 0.


Implementation
    public function get mapX():Number
    public function set mapX(value:Number):void
mapYproperty 
mapY:Number

The vertical offset of the map texture relative to the origin.

The default value is 0.


Implementation
    public function get mapY():Number
    public function set mapY(value:Number):void
scaleXproperty 
scaleX:Number

The multiplier used to scale the x displacement result from the map calculation.


Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number

The multiplier used to scale the y displacement result from the map calculation.


Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
Constructor Detail
DisplacementMapFilter()Constructor
public function DisplacementMapFilter(mapTexture:Texture, componentX:uint = 0, componentY:uint = 0, scaleX:Number = 0.0, scaleY:Number = 0.0)

Creates a new displacement map filter that uses the provided map texture.

Parameters
mapTexture:Texture
 
componentX:uint (default = 0)
 
componentY:uint (default = 0)
 
scaleX:Number (default = 0.0)
 
scaleY:Number (default = 0.0)