Packagede.popforge.imageprocessing.filters.noise
Classpublic final class PerlinNoise
ImplementsIFilter

The PerlinNoise filter is an implementation of the native BitmapData.perlinNoise() function.

In addition to the native function this filter caches the result. To force the re-creation of the noise for one execution you may use perlinNoise.cache = false;.

Supported formats:


Example
  
  var filter: PerlinNoise = new PerlinNoise( 25, 25, 10 );
  
  var video: WebCam = new WebCam( 160, 120 );
  var image: Image = new Image( 160, 120, ImageFormat.RGB );
  
  image.loadBitmapData( video.getCurrentFrame(), true );
  
  filter.apply( image );
  

See also

flash.display.BitmapData.perlinNoise()


Public Properties
 PropertyDefined by
  baseX : int
Frequency to use in the x direction.
PerlinNoise
  baseY : int
Frequency to use in the y direction.
PerlinNoise
  cache : Boolean
Setting cache to false forces the filter to generate a new noise on next execution.
PerlinNoise
  channelOptions : int
A number that can be a combination of any of the color channel values (PerlinNoise.CHANNEL_GRAY, PerlinNoise.CHANNEL_RED, PerlinNoise.CHANNEL_GREEN, PerlinNoise.CHANNEL_BLUE, PerlinNoise.CHANNEL_ALPHA).
PerlinNoise
  fractalNoise : Boolean
If the value is true, the method generates fractal noise; otherwise, it generates turbulence.
PerlinNoise
  numOctaves : int
Number of octaves or individual noise functions to combine to create this noise.
PerlinNoise
  offsets : Array
An array of points that correspond to x and y offsets for each octave.
PerlinNoise
  randomSeed : int
The random seed number to use.
PerlinNoise
  stitch : Boolean
If the value is true, the method attempts to smooth the transition edges of the image to create seamless textures for tiling as a bitmap fill.
PerlinNoise
Public Methods
 MethodDefined by
  
PerlinNoise(baseX:int = 0, baseY:int = 0, numOctaves:uint = 1, randomSeed:int = -1, stitch:Boolean = false, fractalNoise:Boolean = false, channelOptions:int = 1, offsets:Array = null)
Creates a new PerlinNoise object.
PerlinNoise
  
apply(image:Image):void
Applies the filter to the given Image object.
PerlinNoise
  
toString():String
Builds and returns a string containing the name of the class.
PerlinNoise
Public Constants
 ConstantDefined by
  CHANNEL_ALPHA : int = 8
[static] Alpha channel constant for the Perlin noise.
PerlinNoise
  CHANNEL_BLUE : int = 4
[static] Blue channel constant for the Perlin noise.
PerlinNoise
  CHANNEL_GRAY : int = 1
[static] Gray channel constant for the Perlin noise.
PerlinNoise
  CHANNEL_GREEN : int = 2
[static] Green channel constant for the Perlin noise.
PerlinNoise
  CHANNEL_RED : int = 1
[static] Red channel constant for the Perlin noise.
PerlinNoise
Property detail
baseXproperty
baseX:int  [read-write]

Frequency to use in the x direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 64 for the baseX value.

Implementation
    public function get baseX():int
    public function set baseX(value:int):void
baseYproperty 
baseY:int  [read-write]

Frequency to use in the y direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 128 for the baseY value

Implementation
    public function get baseY():int
    public function set baseY(value:int):void
cacheproperty 
cache:Boolean  [read-write]

Setting cache to false forces the filter to generate a new noise on next execution.

Implementation
    public function get cache():Boolean
    public function set cache(value:Boolean):void
channelOptionsproperty 
channelOptions:int  [read-write]

A number that can be a combination of any of the color channel values (PerlinNoise.CHANNEL_GRAY, PerlinNoise.CHANNEL_RED, PerlinNoise.CHANNEL_GREEN, PerlinNoise.CHANNEL_BLUE, PerlinNoise.CHANNEL_ALPHA). You can use the logical OR operator (|) to combine channel values.

Implementation
    public function get channelOptions():int
    public function set channelOptions(value:int):void
fractalNoiseproperty 
fractalNoise:Boolean  [read-write]

If the value is true, the method generates fractal noise; otherwise, it generates turbulence. An image with turbulence has visible discontinuities in the gradient that can make it better approximate sharper visual effects like flames and ocean waves.

Implementation
    public function get fractalNoise():Boolean
    public function set fractalNoise(value:Boolean):void
numOctavesproperty 
numOctaves:int  [read-write]

Number of octaves or individual noise functions to combine to create this noise. Larger numbers of octaves create images with greater detail. Larger numbers of octaves also require more processing time.

Implementation
    public function get numOctaves():int
    public function set numOctaves(value:int):void
offsetsproperty 
offsets:Array  [read-write]

An array of points that correspond to x and y offsets for each octave. By manipulating the offset values you can smoothly scroll the layers of a perlinNoise image. Each point in the offset array affects a specific octave noise function.

Implementation
    public function get offsets():Array
    public function set offsets(value:Array):void
randomSeedproperty 
randomSeed:int  [read-write]

The random seed number to use. If you keep all other parameters the same, you can generate different pseudo-random results by varying the random seed value. The Perlin noise function is a mapping function, not a true random-number generation function, so it creates the same results each time from the same random seed.

Implementation
    public function get randomSeed():int
    public function set randomSeed(value:int):void
stitchproperty 
stitch:Boolean  [read-write]

If the value is true, the method attempts to smooth the transition edges of the image to create seamless textures for tiling as a bitmap fill.

Implementation
    public function get stitch():Boolean
    public function set stitch(value:Boolean):void
Constructor detail
PerlinNoise()constructor
public function PerlinNoise(baseX:int = 0, baseY:int = 0, numOctaves:uint = 1, randomSeed:int = -1, stitch:Boolean = false, fractalNoise:Boolean = false, channelOptions:int = 1, offsets:Array = null)

Creates a new PerlinNoise object.

Parameters
baseX:int (default = 0) — Frequency to use in the x direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 64 for the baseX value.
 
baseY:int (default = 0) — Frequency to use in the y direction. For example, to generate a noise that is sized for a 64 x 128 image, pass 128 for the baseY value
 
numOctaves:uint (default = 1) — Number of octaves or individual noise functions to combine to create this noise. Larger numbers of octaves create images with greater detail. Larger numbers of octaves also require more processing time.
 
randomSeed:int (default = -1) — The random seed number to use. If you keep all other parameters the same, you can generate different pseudo-random results by varying the random seed value. The Perlin noise function is a mapping function, not a true random-number generation function, so it creates the same results each time from the same random seed.
 
stitch:Boolean (default = false) — A Boolean value. If the value is true, the method attempts to smooth the transition edges of the image to create seamless textures for tiling as a bitmap fill.
 
fractalNoise:Boolean (default = false) — A Boolean value. If the value is true, the method generates fractal noise; otherwise, it generates turbulence. An image with turbulence has visible discontinuities in the gradient that can make it better approximate sharper visual effects like flames and ocean waves.
 
channelOptions:int (default = 1) — A number that can be a combination of any of the color channel values (PerlinNoise.CHANNEL_GRAY, PerlinNoise.CHANNEL_RED, PerlinNoise.CHANNEL_GREEN, PerlinNoise.CHANNEL_BLUE, PerlinNoise.CHANNEL_ALPHA). You can use the logical OR operator (|) to combine channel values.
 
offsets:Array (default = null) — An array of points that correspond to x and y offsets for each octave. By manipulating the offset values you can smoothly scroll the layers of a perlinNoise image. Each point in the offset array affects a specific octave noise function.
Method detail
apply()method
public function apply(image:Image):void

Applies the filter to the given Image object.

Parameters
image:Image — The image that will be manipulated.
toString()method 
public function toString():String

Builds and returns a string containing the name of the class.

Returns
String — A string containing the name of the class.
Constant detail
CHANNEL_ALPHAconstant
public static const CHANNEL_ALPHA:int = 8

Alpha channel constant for the Perlin noise.

CHANNEL_BLUEconstant 
public static const CHANNEL_BLUE:int = 4

Blue channel constant for the Perlin noise.

CHANNEL_GRAYconstant 
public static const CHANNEL_GRAY:int = 1

Gray channel constant for the Perlin noise.

CHANNEL_GREENconstant 
public static const CHANNEL_GREEN:int = 2

Green channel constant for the Perlin noise.

CHANNEL_REDconstant 
public static const CHANNEL_RED:int = 1

Red channel constant for the Perlin noise.