Packageorg.flintparticles.twoD.zones
Classpublic class GreyscaleZone
InheritanceGreyscaleZone Inheritance Object
Implements Zone2D

The Greyscale zone defines a shaped zone based on a BitmapData object. The zone contains all pixels in the bitmap that are not black, with a weighting such that lighter pixels are more likely to be selected than darker pixels when creating particles inside the zone.



Public Properties
 PropertyDefined By
  bitmapData : BitmapData
The bitmapData object that defines the zone.
GreyscaleZone
  offsetX : Number
A horizontal offset to apply to the pixels in the BitmapData object to reposition the zone
GreyscaleZone
  offsetY : Number
A vertical offset to apply to the pixels in the BitmapData object to reposition the zone
GreyscaleZone
  scaleX : Number
A scale factor to stretch the bitmap horizontally
GreyscaleZone
  scaleY : Number
A scale factor to stretch the bitmap vertically
GreyscaleZone
Public Methods
 MethodDefined By
  
GreyscaleZone(bitmapData:BitmapData = null, offsetX:Number = 0, offsetY:Number = 0, scaleX:Number = 1, scaleY:Number = 1)
The constructor creates a GreyscaleZone object.
GreyscaleZone
  
collideParticle(particle:Particle2D, bounce:Number = 1):Boolean
Manages collisions between a particle and the zone.
GreyscaleZone
  
contains(x:Number, y:Number):Boolean
The contains method determines whether a point is inside the zone.
GreyscaleZone
  
getArea():Number
The getArea method returns the size of the zone.
GreyscaleZone
  
getLocation():Point
The getLocation method returns a random point inside the zone.
GreyscaleZone
  
invalidate():void
This method forces the zone to revaluate itself.
GreyscaleZone
Property Detail
bitmapDataproperty
bitmapData:BitmapData

The bitmapData object that defines the zone.


Implementation
    public function get bitmapData():BitmapData
    public function set bitmapData(value:BitmapData):void
offsetXproperty 
offsetX:Number

A horizontal offset to apply to the pixels in the BitmapData object to reposition the zone


Implementation
    public function get offsetX():Number
    public function set offsetX(value:Number):void
offsetYproperty 
offsetY:Number

A vertical offset to apply to the pixels in the BitmapData object to reposition the zone


Implementation
    public function get offsetY():Number
    public function set offsetY(value:Number):void
scaleXproperty 
scaleX:Number

A scale factor to stretch the bitmap horizontally


Implementation
    public function get scaleX():Number
    public function set scaleX(value:Number):void
scaleYproperty 
scaleY:Number

A scale factor to stretch the bitmap vertically


Implementation
    public function get scaleY():Number
    public function set scaleY(value:Number):void
Constructor Detail
GreyscaleZone()Constructor
public function GreyscaleZone(bitmapData:BitmapData = null, offsetX:Number = 0, offsetY:Number = 0, scaleX:Number = 1, scaleY:Number = 1)

The constructor creates a GreyscaleZone object.

Parameters
bitmapData:BitmapData (default = null) — The bitmapData object that defines the zone.
 
offsetX:Number (default = 0) — A horizontal offset to apply to the pixels in the BitmapData object to reposition the zone
 
offsetY:Number (default = 0) — A vertical offset to apply to the pixels in the BitmapData object to reposition the zone
 
scaleX:Number (default = 1)
 
scaleY:Number (default = 1)
Method Detail
collideParticle()method
public function collideParticle(particle:Particle2D, bounce:Number = 1):Boolean

Manages collisions between a particle and the zone. The particle will collide with the edges of the zone, from the inside or outside. In the interests of speed, these collisions do not take account of the collisionRadius of the particle and they do not calculate an accurate bounce direction from the shape of the zone. Priority is placed on keeping particles inside or outside the zone.

Parameters

particle:Particle2D — The particle to be tested for collision with the zone.
 
bounce:Number (default = 1) — The coefficient of restitution for the collision.

Returns
Boolean — Whether a collision occured.
contains()method 
public function contains(x:Number, y:Number):Boolean

The contains method determines whether a point is inside the zone.

Parameters

x:Number — The location to test for.
 
y:Number

Returns
Boolean — true if point is inside the zone, false if it is outside.
getArea()method 
public function getArea():Number

The getArea method returns the size of the zone. It's used by the MultiZone class to manage the balancing between the different zones.

Returns
Number — the size of the zone.
getLocation()method 
public function getLocation():Point

The getLocation method returns a random point inside the zone.

Returns
Point — a random point inside the zone.
invalidate()method 
public function invalidate():void

This method forces the zone to revaluate itself. It should be called whenever the contents of the BitmapData object change. However, it is an intensive method and calling it frequently will likely slow your application down.