| Package | org.flintparticles.twoD.renderers |
| Class | public class BitmapRenderer |
| Inheritance | BitmapRenderer SpriteRendererBase flash.display.Sprite |
| Subclasses | PixelRenderer |
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
| Property | Defined by | ||
|---|---|---|---|
| canvas : Rectangle
The canvas is the area within the renderer on which particles can be drawn.
| BitmapRenderer | ||
![]() | emitters : Array | SpriteRendererBase | |
| Property | Defined by | ||
|---|---|---|---|
| _bitmapData : BitmapData | BitmapRenderer | ||
| ZERO_POINT : Point [static]
| BitmapRenderer | ||
| Method | Defined by | ||
|---|---|---|---|
|
BitmapRenderer(canvas:Rectangle, smoothing:Boolean = false)
The constructor creates a BitmapRenderer.
| BitmapRenderer | ||
![]() |
addEmitter(emitter:Emitter):void
Adds the emitter to the renderer.
| SpriteRendererBase | |
|
addFilter(filter:BitmapFilter, postRender:Boolean = false):void
The addFilter method adds a BitmapFilter to the renderer.
| BitmapRenderer | ||
|
clearPaletteMap():void
Clears any palette map that has been set for the renderer.
| BitmapRenderer | ||
![]() |
removeEmitter(emitter:Emitter):void
Removes the emitter from the renderer.
| SpriteRendererBase | |
|
removeFilter(filter:BitmapFilter):void
Removes a BitmapFilter object from the Renderer.
| BitmapRenderer | ||
|
setPaletteMap(red:Array = null, green:Array = null, blue:Array = null, alpha:Array = null):void
Sets a palette map for the renderer.
| BitmapRenderer | ||
| Method | Defined by | ||
|---|---|---|---|
![]() |
addParticle(particle:Particle):void
The addParticle method is called when a particle is added to one of
the emitters that is being rendered by this renderer.
| SpriteRendererBase | |
|
createBitmap():void
Create the Bitmap and BitmapData objects
| BitmapRenderer | ||
|
drawParticle(particle:Particle2D):void
Used internally here and in derived classes to alter the manner of
the particle rendering.
| BitmapRenderer | ||
![]() |
removeParticle(particle:Particle):void
The removeParticle method is called when a particle is removed from one
of the emitters that is being rendered by this renderer.
| SpriteRendererBase | |
|
renderParticles(particles:Array):void
The renderParticles method is called during the render phase of
every frame if the state of one of the emitters being rendered
by this renderer has changed.
| BitmapRenderer | ||
| _bitmapData | property |
protected var _bitmapData:BitmapData
| canvas | property |
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_POINT | property |
protected static var ZERO_POINT:Point
| 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.
Parameterscanvas: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
| addFilter | () | method |
public function addFilter(filter:BitmapFilter, postRender:Boolean = false):voidThe 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.
Parametersfilter: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.
|
| clearPaletteMap | () | method |
public function clearPaletteMap():voidClears any palette map that has been set for the renderer.
| createBitmap | () | method |
protected function createBitmap():voidCreate the Bitmap and BitmapData objects
| drawParticle | () | method |
protected function drawParticle(particle:Particle2D):voidUsed internally here and in derived classes to alter the manner of the particle rendering.
Parametersparticle:Particle2D — The particle to draw on the bitmap.
|
| removeFilter | () | method |
public function removeFilter(filter:BitmapFilter):voidRemoves a BitmapFilter object from the Renderer.
Parametersfilter:BitmapFilter — The BitmapFilter to remove
|
See also
| renderParticles | () | method |
protected override function renderParticles(particles:Array):voidThe renderParticles method is called during the render phase of every frame if the state of one of the emitters being rendered by this renderer has changed.
Parametersparticles:Array — The particles being managed by all the emitters
being rendered by this renderer. The particles are in no particular
order.
|
| setPaletteMap | () | method |
public function setPaletteMap(red:Array = null, green:Array = null, blue:Array = null, alpha:Array = null):voidSets 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 will be applied to the full canvas of the renderer after all filters have been applied and the particles have been drawn.
Parametersred:Array (default = null) |
|
green:Array (default = null) |
|
blue:Array (default = null) |
|
alpha:Array (default = null) |