Packageorg.flintparticles.renderers
Classpublic class BitmapRenderer
InheritanceBitmapRenderer Inheritance flash.display.Sprite
ImplementsRenderer
SubclassesFullStageBitmapRenderer, PixelRenderer

The BitmapRenderer draws particles onto a single Bitmap display object. The region of the particle system covered by this bitmap object must be defined in the canvas property of the BitmapRenderer. Particles outside this region are not drawn.

The image to be used for each particle is the particle's image property. This is a DisplayObject, but this DisplayObject is not used directly. Instead it is copied into the bitmap with the various properties of the particle applied. Consequently each particle may be represented by the same DisplayObject instance and the SharedImage initializer can be used with this renderer.

The BitmapRenderer allows the use of BitmapFilters to modify the appearance of the bitmap. Every frame, under normal circumstances, the Bitmap used to display the particles is wiped clean before all the particles are redrawn. However, if one or more filters are added to the renderer, the filters are applied to the bitmap instead of wiping it clean. This enables various trail effects by using blur and other filters.

The BitmapRenderer has mouse events disabled for itself and any display objects in its display list. To enable mouse events for the renderer or its children set the mouseEnabled or mouseChildren properties to true.

This class has been modified in version 1.0.1 of Flint to fix various limitations in the previous version. Specifically, the canvas for drawing the particles on must now be specified by the developer (it previously defaulted to the size and position of the stage).

The previous behaviour, while still flawed, has been improved and given its own renderer, the FullStageBitmapRenderer. To retain the previous behaviour, please use the FullStageBitmapRenderer.

See also

org.flintparticles.renderers.FullStageBitmapRenderer


Public Properties
 PropertyDefined by
  canvas : Rectangle
The canvas is the area within the renderer on which particles can be drawn.
BitmapRenderer
Protected Properties
 PropertyDefined by
  ZERO_POINT : Point
[static]
BitmapRenderer
Public Methods
 MethodDefined by
  
BitmapRenderer(canvas:Rectangle, smoothing:Boolean = false)
The constructor creates a BitmapRenderer.
BitmapRenderer
  
addFilter(filter:BitmapFilter, postRender:Boolean = false):void
The addFilter method adds a BitmapFilter to the renderer.
BitmapRenderer
  
addParticle(particle:Particle):void
The addParticle method is called when a particle is added to the emitter that this renderer is assigned to.
BitmapRenderer
  
Clears any palette map that has been set for the renderer.
BitmapRenderer
  
dispose():void
When the renderer is no longer required, this method must be called by the user to free up memory used by the renderer.
BitmapRenderer
  
removeFilter(filter:BitmapFilter):void
Removes a BitmapFilter object from the Renderer.
BitmapRenderer
  
removeParticle(particle:Particle):void
The removeParticle method is called when a particle is removed from the emitter that this renderer is assigned to.
BitmapRenderer
  
renderParticles(particles:Array):void
The renderParticles method is called every frame so the renderer can draw the particles that are in the emitter that this renderer is assigned to.
BitmapRenderer
  
setPaletteMap(red:Array = null, green:Array = null, blue:Array = null, alpha:Array = null):void
Sets a palette map for the renderer.
BitmapRenderer
Protected Methods
 MethodDefined by
  
createBitmap():void
Create the Bitmap and BitmapData objects
BitmapRenderer
  
drawParticle(particle:Particle):void
Used internally here and in derived classes to alter the manner of the particle rendering.
BitmapRenderer
Property detail
canvasproperty
canvas:Rectangle  [read-write]

The canvas is the area within the renderer on which particles can be drawn. Particles outside this area will not be drawn.

Implementation
    public function get canvas():Rectangle
    public function set canvas(value:Rectangle):void
ZERO_POINTproperty 
protected static var ZERO_POINT:Point
Constructor detail
BitmapRenderer()constructor
public function BitmapRenderer(canvas:Rectangle, smoothing:Boolean = false)

The constructor creates a BitmapRenderer. After creation it should be added to the display list of a DisplayObjectContainer to place it on the stage and should be applied to an Emitter using the Emitter's renderer property.

Parameters
canvas:Rectangle — The area within the renderer on which particles can be drawn. Particles outside this area will not be drawn.
 
smoothing:Boolean (default = false) — Whether to use smoothing when scaling the Bitmap and, if the particles are represented by bitmaps, when drawing the particles. Smoothing removes pixelation when images are scaled and rotated, but it takes longer so it may slow down your particle system.

See also

Method detail
addFilter()method
public function addFilter(filter:BitmapFilter, postRender:Boolean = false):void

The addFilter method adds a BitmapFilter to the renderer. These filters are applied each frame, before or after the new particle positions are drawn, instead of wiping the display clear. Use of a blur filter, for example, will produce a trail behind each particle as the previous images blur and fade more each frame.

Parameters
filter:BitmapFilter — The filter to apply
 
postRender:Boolean (default = false) — If false, the filter is applied before drawing the particles in their new positions. If true the filter is applied after drawing the particles.
addParticle()method 
public function addParticle(particle:Particle):void

The addParticle method is called when a particle is added to the emitter that this renderer is assigned to.

Parameters
particle:Particle — The particle.
clearPaletteMap()method 
public function clearPaletteMap():void

Clears any palette map that has been set for the renderer.

createBitmap()method 
protected function createBitmap():void

Create the Bitmap and BitmapData objects

dispose()method 
public function dispose():void

When the renderer is no longer required, this method must be called by the user to free up memory used by the renderer. If you don't call this method then the renderer's bitmap data will remain in memory.

drawParticle()method 
protected function drawParticle(particle:Particle):void

Used internally here and in derived classes to alter the manner of the particle rendering.

Parameters
particle:Particle — The particle to draw on the bitmap.
removeFilter()method 
public function removeFilter(filter:BitmapFilter):void

Removes a BitmapFilter object from the Renderer.

Parameters
filter:BitmapFilter — The BitmapFilter to remove

See also

addFilter()
removeParticle()method 
public function removeParticle(particle:Particle):void

The removeParticle method is called when a particle is removed from the emitter that this renderer is assigned to.

Parameters
particle:Particle — The particle.
renderParticles()method 
public function renderParticles(particles:Array):void

The renderParticles method is called every frame so the renderer can draw the particles that are in the emitter that this renderer is assigned to.

Parameters
particles:Array — The particles to draw.
setPaletteMap()method 
public function setPaletteMap(red:Array = null, green:Array = null, blue:Array = null, alpha:Array = null):void

Sets a palette map for the renderer. See the paletteMap method in flash's BitmapData object for information about how palette maps work. The palette map is applied to the full canvas of the renderer after all filters have been applied and the particles have been drawn.

Parameters
red:Array (default = null)
 
green:Array (default = null)
 
blue:Array (default = null)
 
alpha:Array (default = null)