GODPAPER | All Packages | All Classes | Index | Frames No Frames |
BlurFilter

Package | starling.filters
Class | public class BlurFilter
Inheritance | BlurFilter FragmentFilter Object

The BlurFilter applies a Gaussian blur to an object. The strength of the blur can be set for x- and y-axis separately (always relative to the stage). A blur filter can also be set up as a drop shadow or glow filter. Use the respective static methods to create such a filter.

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | blurX : Number The blur factor in x-direction (stage coordinates). | BlurFilter
|  | blurY : Number The blur factor in y-direction (stage coordinates). | BlurFilter
|  | isCached : Boolean [read-only] Indicates if the filter is cached (via the "cache" method). | FragmentFilter
|  | mode : String The filter mode, which is one of the constants defined in the "FragmentFilterMode" class. | FragmentFilter
|  | offsetX : Number Use the x-offset to move the filter output to the right or left. | FragmentFilter
|  | offsetY : Number Use the y-offset to move the filter output to the top or bottom. | FragmentFilter
|  | resolution : Number The resolution of the filter texture. | FragmentFilter

Protected Properties
Hide Inherited Protected Properties
Show Inherited Protected Properties

| Property | Defined By
--- | --- | ---
|  | baseTextureID : int The ID (sampler) of the input texture (containing the output of the previous pass). | FragmentFilter
|  | marginX : Number The x-margin will extend the size of the filter texture along the x-axis. | FragmentFilter
|  | marginY : Number The y-margin will extend the size of the filter texture along the y-axis. | FragmentFilter
|  | mvpConstantID : int The ID of the first register of the modelview-projection constant (a 4x4 matrix). | FragmentFilter
|  | numPasses : int The number of passes the filter is applied. | FragmentFilter
|  | texCoordsAtID : int The ID of the vertex buffer attribute that stores the texture coordinates. | FragmentFilter
|  | vertexPosAtID : int The ID of the vertex buffer attribute that stores the vertex position. | FragmentFilter

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | BlurFilter(blurX:Number = 1, blurY:Number = 1, resolution:Number = 1) Create a new BlurFilter. | BlurFilter
|  | cache():void Caches the filter output into a texture. | FragmentFilter
|  | clearCache():void Clears the cached output of the filter. | FragmentFilter
|  | createDropShadow(distance:Number = 4.0, angle:Number = 0.785, color:uint = 0x0, alpha:Number = 0.5, blur:Number = 1.0, resolution:Number = 0.5):BlurFilter [static] Creates a blur filter that is set up for a drop shadow effect. | BlurFilter
|  | createGlow(color:uint = 0xffff00, alpha:Number = 1.0, blur:Number = 1.0, resolution:Number = 0.5):BlurFilter [static] Creates a blur filter that is set up for a glow effect. | BlurFilter
|  | dispose():void [override] Disposes the filter (programs, buffers, textures). | BlurFilter
|  | render(object:DisplayObject, support:RenderSupport, parentAlpha:Number):void Applies the filter on a certain display object, rendering the output into the current render target. | FragmentFilter
|  | setUniformColor(enable:Boolean, color:uint = 0x0, alpha:Number = 1.0):void A uniform color will replace the RGB values of the input color, while the alpha value will be multiplied with the given factor. | BlurFilter

Protected Methods
Show Inherited Protected Methods
Show Inherited Protected Methods

| Method | Defined By
--- | --- | ---
|  | activate(pass:int, context:Context3D, texture:Texture):void Subclasses must override this method and use it to activate their fragment- and to vertext-programs. | FragmentFilter
|  | assembleAgal(fragmentShader:String = null, vertexShader:String = null):Program3D Assembles fragment- and vertex-shaders, passed as Strings, to a Program3D. | FragmentFilter
|  | createPrograms():void Subclasses must override this method and use it to create their fragment- and vertex-programs. | FragmentFilter
|  | deactivate(pass:int, context:Context3D, texture:Texture):void This method is called directly after 'context.drawTriangles'. | FragmentFilter

Protected Constants
Hide Inherited Protected Constants
Show Inherited Protected Constants

| Constant | Defined By
--- | --- | ---
|  | PMA : Boolean = true All filter processing is expected to be done with premultiplied alpha. | FragmentFilter
|  | STD_FRAGMENT_SHADER : String = tex oc, v0, fs0 <2d, clamp, linear, mipnone> The standard fragment shader code. | FragmentFilter
|  | STD_VERTEX_SHADER : String The standard vertex shader code. | FragmentFilter

Property Detail

blurX | property

`blurX:Number`

The blur factor in x-direction (stage coordinates). The number of required passes will be `Math.ceil(value)`.

Implementation
`public function get blurX():Number`
`public function set blurX(value:Number):void`

blurY | property |

`blurY:Number`

The blur factor in y-direction (stage coordinates). The number of required passes will be `Math.ceil(value)`.

Implementation
`public function get blurY():Number`
`public function set blurY(value:Number):void`
Constructor Detail

BlurFilter | () | Constructor

`public function BlurFilter(blurX:Number = 1, blurY:Number = 1, resolution:Number = 1)`

Create a new BlurFilter. For each blur direction, the number of required passes is `Math.ceil(blur)`.

- blur = 0.5: 1 pass
- blur = 1.0: 1 pass
- blur = 1.5: 2 passes
- blur = 2.0: 2 passes
- etc.

Instead of raising the number of passes, you should consider lowering the resolution. A lower resolution will result in a blurrier image, while reducing the rendering cost.

Parameters

| `blurX:Number` (default = `1`)``
| `blurY:Number` (default = `1`)``
| `resolution:Number` (default = `1`)``

Method Detail

createDropShadow | () | method

`public static function createDropShadow(distance:Number = 4.0, angle:Number = 0.785, color:uint = 0x0, alpha:Number = 0.5, blur:Number = 1.0, resolution:Number = 0.5):BlurFilter`

Creates a blur filter that is set up for a drop shadow effect.

Parameters

| `distance:Number` (default = `4.0`)``
| `angle:Number` (default = `0.785`)``
| `color:uint` (default = `0x0`)``
| `alpha:Number` (default = `0.5`)``
| `blur:Number` (default = `1.0`)``
| `resolution:Number` (default = `0.5`)``

Returns

| `BlurFilter`

createGlow | () | method |

`public static function createGlow(color:uint = 0xffff00, alpha:Number = 1.0, blur:Number = 1.0, resolution:Number = 0.5):BlurFilter`

Creates a blur filter that is set up for a glow effect.

Parameters

| `color:uint` (default = `0xffff00`)``
| `alpha:Number` (default = `1.0`)``
| `blur:Number` (default = `1.0`)``
| `resolution:Number` (default = `0.5`)``

Returns

| `BlurFilter`

dispose | () | method |

`override public function dispose():void`

Disposes the filter (programs, buffers, textures).

setUniformColor | () | method |

`public function setUniformColor(enable:Boolean, color:uint = 0x0, alpha:Number = 1.0):void`

A uniform color will replace the RGB values of the input color, while the alpha value will be multiplied with the given factor. Pass `false` as the first parameter to deactivate the uniform color.

Parameters

| `enable:Boolean`
| `color:uint` (default = `0x0`)``
| `alpha:Number` (default = `1.0`)``

Thu Jan 16 2014, 01:11 PM +08:00