org.apache.batik.ext.awt.image.rendered
Class TurbulencePatternRed
public final
class
TurbulencePatternRed
extends AbstractRed
This class creates a RenderedImage in conformance to the one
defined for the feTurbulence filter of the SVG specification. What
follows is my high-level description of how the noise is generated.
This is not contained in the SVG spec, just the algorithm for
doing it. This is provided in the hope that someone will figure
out a clever way to accelerate parts of the function.
gradient contains a long list of random unit vectors. For each
point we are to generate noise for we do two things. first we use
the latticeSelector to 'co-mingle' the integer portions of x and y
(this allows us to have a one-dimensional array of gradients that
appears 2 dimensional, by using the co-mingled index).
We do this for [x,y], [x+1,y], [x,y+1], and [x+1, y+1], this gives
us the four gradient vectors that surround the point (b00, b10, ...)
Next we construct the four vectors from the grid points (where the
gradient vectors are defined) [these are rx0, rx1, ry0, ry1].
We then take the dot product between the gradient vectors and the
grid point vectors (this gives the portion of the grid point vector
that projects along the gradient vector for each grid point).
These four dot projects are then combined with linear interpolation.
The weight factor for the linear combination is the result of applying
the 's' curve function to the fractional part of x and y (rx0, ry0).
The S curve function get's it's name because it looks a bit like as
'S' from 0->1.
Constructor Summary |
| TurbulencePatternRed(double baseFrequencyX, double baseFrequencyY, int numOctaves, int seed, boolean isFractalNoise, Rectangle2D tile, AffineTransform txf, Rectangle devRect, ColorSpace cs, boolean alpha) |
public TurbulencePatternRed(double baseFrequencyX, double baseFrequencyY, int numOctaves, int seed, boolean isFractalNoise, Rectangle2D tile, AffineTransform txf, Rectangle devRect, ColorSpace cs, boolean alpha)
Parameters: baseFrequencyX x-axis base frequency for the noise
function along the x-axis baseFrequencyY y-axis base frequency for the noise
function along the x-axis numOctaves number of octaves in the noise
function. Positive integral value. seed starting number for the pseudo random number generator isFractalNoise defines whether the filter performs a
fractal noise or a turbulence function. tile defines the tile size. May be null if stitchTiles
is false. Otherwise, should not be null. txf The affine transform from device to user space. cs The Colorspace to output. alpha True if the data should have an alpha channel.
public WritableRaster copyData(WritableRaster dest)
Generates a Perlin noise pattern into dest Raster.
Parameters: dest Raster to fill with the pattern.
public double getBaseFrequencyX()
public double getBaseFrequencyY()
public boolean[] getChannels()
public int getNumOctaves()
public int getSeed()
public Rectangle2D getTile()
public boolean isFractalNoise()
public final int random(int seed)
public final int setupSeed(int seed)
Copyright B) 2007 Apache Software Foundation. All Rights Reserved.