Packageorg.zozuar.volumetrics
Classpublic class VolumetricPointLight
InheritanceVolumetricPointLight Inheritance EffectContainer Inheritance flash.display.Sprite

VolumetricPointLight creates a simple effect container with a gradient emission pattern. The gradient's center is automatically moved to the (srcX, srcY) coordinates and it's radius is adjusted to the length of the viewport's diagonal, so if you set srcX and srcY to the viewport's center then only half of the gradient colors will be used.

This should also perform a little better than EffectContainer.



Public Properties
 PropertyDefined By
 Inheritedblur : Boolean = false
When true a blur filter is applied to the final effect bitmap (can help when colorIntegrity == true).
EffectContainer
 InheritedcolorIntegrity : Boolean = false
Selects rendering method; when set to true colors won't be distorted and performance will be a little worse.
EffectContainer
 Inheritedintensity : Number = 4
Light intensity.
EffectContainer
 Inheritedpasses : uint = 6
Number of passes applied to buffer.
EffectContainer
 InheritedrasterQuality : String = null
Set this to one of the StageQuality constants to use this quality level when drawing bitmaps, or to null to use the current stage quality.
EffectContainer
 Inheritedscale : Number = 2
Final scale of emission.
EffectContainer
 Inheritedsmoothing : Boolean = true
Smooth scaling of the effect's final output bitmap.
EffectContainer
 InheritedsrcX : Number
Light source x.
EffectContainer
 InheritedsrcY : Number
Light source y.
EffectContainer
Protected Properties
 PropertyDefined By
  _alphas : Array
VolumetricPointLight
 Inherited_baseBmd : BitmapData
EffectContainer
 Inherited_blurFilter : BlurFilter
EffectContainer
 Inherited_bufferBmd : BitmapData
EffectContainer
 Inherited_bufferRect : Rectangle
EffectContainer
 Inherited_bufferSize : uint = 0x8000
EffectContainer
  _colors : Array
VolumetricPointLight
 Inherited_ct : ColorTransform
EffectContainer
 Inherited_emission : DisplayObject
EffectContainer
  _gradient : Shape
VolumetricPointLight
  _gradientBmp : Bitmap
VolumetricPointLight
  _gradientLoResBmd : BitmapData
VolumetricPointLight
  _gradientLoResDirty : Boolean = true
VolumetricPointLight
  _gradientMtx : Matrix
VolumetricPointLight
 Inherited_halve : ColorTransform
EffectContainer
  _lastColorIntegrity : Boolean = false
VolumetricPointLight
  _lastIntensity : Number
VolumetricPointLight
  _lastSrcX : Number
VolumetricPointLight
  _lastSrcY : Number
VolumetricPointLight
 Inherited_lightBmp : Bitmap
EffectContainer
 Inherited_mtx : Matrix
EffectContainer
 Inherited_occlusion : DisplayObject
EffectContainer
 Inherited_occlusionLoResBmd : BitmapData
EffectContainer
 Inherited_occlusionLoResBmp : Bitmap
EffectContainer
  _ratios : Array
VolumetricPointLight
 Inherited_viewportHeight : uint
EffectContainer
 Inherited_viewportWidth : uint
EffectContainer
 Inherited_zero : Point
EffectContainer
Public Methods
 MethodDefined By
  
VolumetricPointLight(width:uint, height:uint, occlusion:DisplayObject, colorOrGradient:*, alphas:Array = null, ratios:Array = null)
Creates a new effect container, with an emission created from the supplied color or gradient.
VolumetricPointLight
  
dispose():void
[override] Dispose of all intermediate buffers.
VolumetricPointLight
  
render(e:Event = null):void
[override] Render a single frame.
VolumetricPointLight
 Inherited
setBufferSize(size:uint):void
Sets the approximate size (in pixels) of the effect's internal buffers.
EffectContainer
  
setViewportSize(width:uint, height:uint):void
[override] Sets the container's size.
VolumetricPointLight
 Inherited
Render the effect on every frame until stopRendering is called.
EffectContainer
 Inherited
Stop rendering on every frame.
EffectContainer
Protected Methods
 MethodDefined By
 Inherited
_applyEffect(bmd:BitmapData, rect:Rectangle, buffer:BitmapData, mtx:Matrix, passes:uint):void
Low-level workhorse, applies the lighting effect to a bitmap.
EffectContainer
 Inherited
_copyMatrix(src:Matrix, dst:Matrix):void
EffectContainer
  
VolumetricPointLight
  
[override] Updates the lo-res gradient bitmap if neccesary and copies it to _baseBmd.
VolumetricPointLight
 Inherited
Draws a scaled-down occlusion on _occlusionLoResBmd and erases it from _baseBmd.
EffectContainer
  
[override]
VolumetricPointLight
Property Detail
_alphasproperty
protected var _alphas:Array

_colorsproperty 
protected var _colors:Array

_gradientproperty 
protected var _gradient:Shape

_gradientBmpproperty 
protected var _gradientBmp:Bitmap

_gradientLoResBmdproperty 
protected var _gradientLoResBmd:BitmapData

_gradientLoResDirtyproperty 
protected var _gradientLoResDirty:Boolean = true

_gradientMtxproperty 
protected var _gradientMtx:Matrix

_lastColorIntegrityproperty 
protected var _lastColorIntegrity:Boolean = false

_lastIntensityproperty 
protected var _lastIntensity:Number

_lastSrcXproperty 
protected var _lastSrcX:Number

_lastSrcYproperty 
protected var _lastSrcY:Number

_ratiosproperty 
protected var _ratios:Array

Constructor Detail
VolumetricPointLight()Constructor
public function VolumetricPointLight(width:uint, height:uint, occlusion:DisplayObject, colorOrGradient:*, alphas:Array = null, ratios:Array = null)

Creates a new effect container, with an emission created from the supplied color or gradient. The constructor lets you use a shortcut syntax for creating simple single-color gradients.

Parameters
width:uint — Viewport width in pixels.
 
height:uint — Viewport height in pixels.
 
occlusion:DisplayObject — An occlusion object, will be overlayed above the lighting gradient and under the light effect bitmap.
 
colorOrGradient:* — Either a gradient colors array, or a uint color value.
 
alphas:Array (default = null) — Will only be used if colorOrGradient is an array. This will be passed to beginGradientFill. If not provided alphas will all be 1.
 
ratios:Array (default = null) — Will only be used if colorOrGradient is an array. This will be passed to beginGradientFill. If colorOrGradient is an Array and ratios aren't provided default ones will be created automatically.

Example
The shortcut syntax:
new VolumetricPointLight(800, 600, occlusion, 0xc08040);
is equivalent to:
new VolumetricPointLight(800, 600, occlusion, [0xc08040, 0], [1, 1], [0, 255]);
Method Detail
_drawGradient()method
protected function _drawGradient():void

_drawLoResEmission()method 
override protected function _drawLoResEmission():void

Updates the lo-res gradient bitmap if neccesary and copies it to _baseBmd.

_updateBuffers()method 
override protected function _updateBuffers():void

dispose()method 
override public function dispose():void

Dispose of all intermediate buffers. After calling this the EffectContainer object will be unusable.

render()method 
override public function render(e:Event = null):void

Render a single frame.

Parameters

e:Event (default = null) — In case you want to make this an event listener.

setViewportSize()method 
override public function setViewportSize(width:uint, height:uint):void

Sets the container's size. This method recreates internal buffers (slow), do not call this on every frame.

Parameters

width:uint — Viewport width in pixels
 
height:uint — Viewport height in pixels