| Package | org.flintparticles.renderers |
| Class | public class BitmapRenderer |
| Inheritance | BitmapRenderer flash.display.Sprite |
| Implements | Renderer |
| Subclasses | FullStageBitmapRenderer, 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 | ||
| Property | Defined by | ||
|---|---|---|---|
| ZERO_POINT : Point [static]
| BitmapRenderer | ||
| Method | Defined 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 | ||
|
clearPaletteMap():void
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 | ||
| Method | Defined 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 | ||
| 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.
|
| addParticle | () | method |
public function addParticle(particle:Particle):voidThe addParticle method is called when a particle is added to the emitter that this renderer is assigned to.
Parametersparticle:Particle — The particle.
|
| 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
| dispose | () | method |
public function dispose():voidWhen 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):voidUsed internally here and in derived classes to alter the manner of the particle rendering.
Parametersparticle:Particle — 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
| removeParticle | () | method |
public function removeParticle(particle:Particle):voidThe removeParticle method is called when a particle is removed from the emitter that this renderer is assigned to.
Parametersparticle:Particle — The particle.
|
| renderParticles | () | method |
public function renderParticles(particles:Array):voidThe renderParticles method is called every frame so the renderer can draw the particles that are in the emitter that this renderer is assigned to.
Parametersparticles:Array — The particles to draw.
|
| 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 is 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) |