| Package | org.flintparticles.twoD.renderers |
| Class | public class BitmapRenderer |
| Inheritance | BitmapRenderer SpriteRendererBase flash.display.Sprite |
| Subclasses | BitmapLineRenderer, 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. You can also disable the clearing of the particles by setting the clearBetweenFrames property to false.
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.
| Property | Defined By | ||
|---|---|---|---|
| bitmapData : BitmapData [read-only]
The bitmap data of the renderer. | BitmapRenderer | ||
| canvas : Rectangle
The canvas is the area within the renderer on which particles can be drawn. | BitmapRenderer | ||
| clearBetweenFrames : Boolean
Controls whether the display is cleared between each render frame. | BitmapRenderer | ||
![]() | emitters : Vector.<Emitter>
The array of all emitters being rendered by this renderer. | SpriteRendererBase | |
| postFilters : Array
The array of all filters being applied before rendering. | BitmapRenderer | ||
| preFilters : Array
The array of all filters being applied before rendering. | BitmapRenderer | ||
| smoothing : Boolean | BitmapRenderer | ||
| Property | Defined By | ||
|---|---|---|---|
| _bitmapData : BitmapData | BitmapRenderer | ||
![]() | _particles : Array | SpriteRendererBase | |
| 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 | ||
![]() | emitterUpdated(ev:EmitterEvent):void | SpriteRendererBase | |
![]() | 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 [override]
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 | ||
![]() | updateParticles(ev:Event):void | SpriteRendererBase | |
| _bitmapData | property |
protected var _bitmapData:BitmapData| bitmapData | property |
bitmapData:BitmapData [read-only] The bitmap data of the renderer.
public function get bitmapData():BitmapData| canvas | property |
canvas:RectangleThe canvas is the area within the renderer on which particles can be drawn. Particles outside this area will not be drawn.
public function get canvas():Rectangle public function set canvas(value:Rectangle):void| clearBetweenFrames | property |
clearBetweenFrames:BooleanControls whether the display is cleared between each render frame. If you use pre-render filters, this value is ignored and the display is not cleared. If you use no filters or only post-render filters, this value governs whether the screen is cleared.
For BitmapRenderer and PixelRenderer, this value defaults to true. For BitmapLineRenderer it defaults to false.
public function get clearBetweenFrames():Boolean public function set clearBetweenFrames(value:Boolean):void| postFilters | property |
postFilters:ArrayThe array of all filters being applied before rendering.
public function get postFilters():Array public function set postFilters(value:Array):void| preFilters | property |
preFilters:ArrayThe array of all filters being applied before rendering.
public function get preFilters():Array public function set preFilters(value:Array):void| smoothing | property |
smoothing:Boolean public function get smoothing():Boolean public function set smoothing(value:Boolean):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.
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.
|
| 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.
Parameters
particle:Particle2D — The particle to draw on the bitmap.
|
| removeFilter | () | method |
public function removeFilter(filter:BitmapFilter):voidRemoves a BitmapFilter object from the Renderer.
Parameters
filter:BitmapFilter — The BitmapFilter to remove
|
See also
| renderParticles | () | method |
override protected 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.
Parameters
particles: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.
Parameters
red:Array (default = null) | |
green:Array (default = null) | |
blue:Array (default = null) | |
alpha:Array (default = null) |