public final class TurbulencePatternRed extends AbstractRed
Modifier and Type | Class and Description |
---|---|
(package private) static class |
TurbulencePatternRed.StitchInfo
Inner class to store tile stitching info.
|
Modifier and Type | Field and Description |
---|---|
private double |
baseFrequencyX
x-axis base frequency for the noise function along the x-axis
|
private double |
baseFrequencyY
y-axis base frequency for the noise function along the y-axis
|
private static int |
BM |
private static int |
BSize |
private int[] |
channels
List of channels that the generator produces.
|
private double[] |
gradient |
private static java.awt.geom.AffineTransform |
IDENTITY
Identity transform, default used when null input in the constructor.
|
private boolean |
isFractalNoise
Defines whether the filter performs a fractal noise or a turbulence function
|
private int[] |
latticeSelector |
private int |
numOctaves
Number of octaves in the noise function
|
private static double |
PerlinN |
private static int |
RAND_a |
private static int |
RAND_m
Produces results in the range [1, 2**31 - 2].
|
private static int |
RAND_q |
private static int |
RAND_r |
private int |
seed
Starting number for the pseudo random number generator
|
private TurbulencePatternRed.StitchInfo |
stitchInfo
Used when stitching is on
|
private java.awt.geom.Rectangle2D |
tile
Defines the tile for the turbulence function, if non-null turns
on stitching, so frequencies are adjusted to avoid
discontinuities in case frequencies do not match tile
boundaries.
|
(package private) double[] |
tx |
private java.awt.geom.AffineTransform |
txf
Defines the tile for the turbulence function
|
(package private) double[] |
ty |
bounds, cm, minTileX, minTileY, numXTiles, numYTiles, props, sm, srcs, tileGridXOff, tileGridYOff, tileHeight, tileWidth
Constructor and Description |
---|
TurbulencePatternRed(double baseFrequencyX,
double baseFrequencyY,
int numOctaves,
int seed,
boolean isFractalNoise,
java.awt.geom.Rectangle2D tile,
java.awt.geom.AffineTransform txf,
java.awt.Rectangle devRect,
java.awt.color.ColorSpace cs,
boolean alpha) |
Modifier and Type | Method and Description |
---|---|
java.awt.image.WritableRaster |
copyData(java.awt.image.WritableRaster dest)
Generates a Perlin noise pattern into dest Raster.
|
double |
getBaseFrequencyX() |
double |
getBaseFrequencyY() |
boolean[] |
getChannels() |
int |
getNumOctaves() |
int |
getSeed() |
java.awt.geom.Rectangle2D |
getTile() |
private void |
initLattice(int seed) |
boolean |
isFractalNoise() |
private static double |
lerp(double t,
double a,
double b) |
private void |
noise2(double[] noise,
double vec0,
double vec1)
Generate a pixel of noise corresponding to the point vec0,vec1.
|
private void |
noise2Stitch(double[] noise,
double vec0,
double vec1,
TurbulencePatternRed.StitchInfo stitchInfo)
This version of the noise function implements stitching.
|
int |
random(int seed) |
private static double |
s_curve(double t) |
int |
setupSeed(int seed) |
private int |
turbulence_4(double pointX,
double pointY,
double[] fSum)
This is the heart of the turbulence calculation.
|
private void |
turbulence(int[] rgb,
double pointX,
double pointY,
double[] fSum,
double[] noise)
This is the heart of the turbulence calculation.
|
private int |
turbulenceFractal_4(double pointX,
double pointY,
double[] fSum)
This is the heart of the turbulence calculation.
|
private void |
turbulenceFractal(int[] rgb,
double pointX,
double pointY,
double[] fSum,
double[] noise)
This is the heart of the turbulence calculation.
|
private void |
turbulenceFractalStitch(int[] rgb,
double pointX,
double pointY,
double[] fSum,
double[] noise,
TurbulencePatternRed.StitchInfo stitchInfo)
This is the heart of the turbulence calculation.
|
private void |
turbulenceStitch(int[] rgb,
double pointX,
double pointY,
double[] fSum,
double[] noise,
TurbulencePatternRed.StitchInfo stitchInfo)
This is the heart of the turbulence calculation.
|
copyBand, copyToRaster, getBounds, getColorModel, getData, getData, getDependencyRegion, getDirtyRegion, getHeight, getMinTileX, getMinTileY, getMinX, getMinY, getNumXTiles, getNumYTiles, getProperty, getPropertyNames, getSampleModel, getSources, getTile, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, getWidth, getXTile, getYTile, init, init, makeTile, updateTileGridInfo
private TurbulencePatternRed.StitchInfo stitchInfo
private static final java.awt.geom.AffineTransform IDENTITY
private double baseFrequencyX
private double baseFrequencyY
private int numOctaves
private int seed
private java.awt.geom.Rectangle2D tile
private java.awt.geom.AffineTransform txf
private boolean isFractalNoise
private int[] channels
double[] tx
double[] ty
private static final int RAND_m
private static final int RAND_a
private static final int RAND_q
private static final int RAND_r
private static final int BSize
private static final int BM
private static final double PerlinN
private final int[] latticeSelector
private final double[] gradient
public TurbulencePatternRed(double baseFrequencyX, double baseFrequencyY, int numOctaves, int seed, boolean isFractalNoise, java.awt.geom.Rectangle2D tile, java.awt.geom.AffineTransform txf, java.awt.Rectangle devRect, java.awt.color.ColorSpace cs, boolean alpha)
baseFrequencyX
- x-axis base frequency for the noise
function along the x-axisbaseFrequencyY
- y-axis base frequency for the noise
function along the x-axisnumOctaves
- number of octaves in the noise
function. Positive integral value.seed
- starting number for the pseudo random number generatorisFractalNoise
- 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 double getBaseFrequencyX()
public double getBaseFrequencyY()
public int getNumOctaves()
public int getSeed()
public java.awt.geom.Rectangle2D getTile()
public boolean isFractalNoise()
public boolean[] getChannels()
public final int setupSeed(int seed)
public final int random(int seed)
private void initLattice(int seed)
private static final double s_curve(double t)
private static final double lerp(double t, double a, double b)
private final void noise2(double[] noise, double vec0, double vec1)
noise
- The place to put the generated noise.vec0
- The X coordiate to generate noise forvec1
- The Y coordiate to generate noise forprivate final void noise2Stitch(double[] noise, double vec0, double vec1, TurbulencePatternRed.StitchInfo stitchInfo)
noise
- The place to put the generated noise.vec0
- The X coordiate to generate noise forvec1
- The Y coordiate to generate noise forstitchInfo
- The stitching information for the noise function.private final int turbulence_4(double pointX, double pointY, double[] fSum)
pointX
- x coordinate of the point to process.pointY
- y coordinate of the point to process.fSum
- array used to avoid reallocating double array for each pixelprivate final void turbulence(int[] rgb, double pointX, double pointY, double[] fSum, double[] noise)
rgb
- array for the four color componentspointX
- x coordinate of the point to process.pointY
- y coordinate of the point to process.fSum
- array used to avoid reallocating double array for each pixelnoise
- array used to avoid reallocating double array for
each pixelprivate final void turbulenceStitch(int[] rgb, double pointX, double pointY, double[] fSum, double[] noise, TurbulencePatternRed.StitchInfo stitchInfo)
rgb
- array for the four color componentspointX
- x coordinate of the point to process.pointY
- y coordinate of the point to process.fSum
- array used to avoid reallocating double array for each pixelnoise
- array used to avoid reallocating double array for
each pixelstitchInfo
- The stitching information for the noise functionprivate final int turbulenceFractal_4(double pointX, double pointY, double[] fSum)
pointX
- x coordinate of the point to process.pointY
- y coordinate of the point to process.fSum
- array used to avoid reallocating double array for each pixelprivate final void turbulenceFractal(int[] rgb, double pointX, double pointY, double[] fSum, double[] noise)
rgb
- array for the four color componentspointX
- x coordinate of the point to process.pointY
- y coordinate of the point to process.fSum
- array used to avoid reallocating double array for each pixelnoise
- array used to avoid reallocating double array for
each pixelprivate final void turbulenceFractalStitch(int[] rgb, double pointX, double pointY, double[] fSum, double[] noise, TurbulencePatternRed.StitchInfo stitchInfo)
rgb
- array for the four color componentspointX
- x coordinate of the point to process.pointY
- y coordinate of the point to process.fSum
- array used to avoid reallocating double array for each pixelnoise
- array used to avoid reallocating double array for
each pixelstitchInfo
- The stitching information for the noise functionpublic java.awt.image.WritableRaster copyData(java.awt.image.WritableRaster dest)
dest
- Raster to fill with the pattern.