classPiiCloudFractalGenerator
#include <PiiCloudFractalGenerator.h>
A class that generates two-dimensional cloud-like fractal pictures.
Description
This class works with integer-valued matrices (int, char, etc.) and produces gray-scale clouds that can also be used as height maps.
Constructors and destructor
|
(
Create a new fractal generator. |
Public member functions
|
template<class T>
void
|
(
Generate a non-square fractal. |
|
template<class T>
void
|
Generate a square piece of fractal into the given buffer. |
|
template<class T>
PiiMatrix< T >
|
(
Generate a size-by-size cloud fractal with the given initial corner values and rougness. |
|
int
|
( )
Get the maximum possible value. |
|
int
|
( )
Get the minimum possible value. |
|
float
|
( )
Get the rouhgness scaling factor. |
|
double
|
(
The magic equation of roughness scaling. |
|
void
|
(
Set the maximum possible value for the generated fractals. |
|
void
|
(
Set the minimum possible value for the generated fractals. |
|
void
|
(
Set the rougness scaling factor. |
|
void
|
(
Set the mean level the fractal generator will try to achieve. |
|
int
|
( )
Get the target mean value. |
Function details
-
PiiCloudFractalGenerator
(- float roughnessScale = 0.5
- int minimum = 0
- int maximum = 255
[inline]Create a new fractal generator.
Parameters
- roughnessScale
- minimum
-
the minimum allowed value for the generated fractal.
- maximum
-
the maximum allowed value for the generated fractal.
-
template<class T>
void generateFractal
(- PiiMatrix< T > & buffer
- int row
- int col
- int rows
- int cols
- int c0
- int c1
- int c2
- int c3
- double roughnessX
- double roughnessY = 0
Generate a non-square fractal.
This function splits the area into square blocks and recursively calls generateSquareFractal(). It is possible to give a roughness value for x and y direction separately, but it is usually wise to let the program decide the correct value for
roughnessY. -
template<class T>
void generateSquareFractal
Generate a square piece of fractal into the given buffer.
It the buffer already has data in it, the fractal will be seamlessly connected to it from its left and top side.
Parameters
- buffer
-
generate the fractal to this matrix
- row
-
the starting row
- col
-
the starting column
- size
-
the size of the fractal. This value must be a power of two. You may experiment with other values, but the result will not look like a cloud. The fractal image will always be square.
- c0
-
initial value for the upper left corner
- c1
-
initial value for the upper right corner
- c2
-
initial value for the lower left corner
- c3
-
initial value for the lower right corner
- roughness
-
the scale of random variations in the fractal. This value determines how large changes are allowed on the large scale. Usually, a value between minimum and maximum is used. Use setRoughnessScale to control how rapidly the roughness dies out.
-
template<class T>
PiiMatrix< T > generateSquareFractal
(- int size
- int c0
- int c1
- int c2
- int c3
- int roughness
Generate a size-by-size cloud fractal with the given initial corner values and rougness.
Return a new image.
-
int maximum
()[inline]Get the maximum possible value.
-
int minimum
()[inline]Get the minimum possible value.
-
float roughnessScale
()[inline]Get the rouhgness scaling factor.
-
double scaleRoughness
(- int a
- int b
[inline]The magic equation of roughness scaling.
Halving the size of generated fractal in the recursive algorithm scales roughness down by _fRoughnessScale. Here's what you get if you scale to an arbitrary factor a/b. Assume your initial roughness for a 100-by-100 fractal is 100. Comparable roughness for a 200-by-200 fractal is obtained with scaleRoughness(200,100)*100.
-
void setMaximum
(- int maximum
[inline]Set the maximum possible value for the generated fractals.
-
void setMinimum
(- int minimum
[inline]Set the minimum possible value for the generated fractals.
-
void setRoughnessScale
(- float roughnessScale
[inline]Set the rougness scaling factor.
This value controls how quickly the initial roughness of the fractal dies out. 0 means immediately and 1 means not at all.
-
void setTargetMean
(- int targetMean
[inline]Set the mean level the fractal generator will try to achieve.
This value is useful in large non-rectangular fractals. The generator will always drive the random variations slightly towards the target mean. If the value is less than minimum, it will not be used.
-
int targetMean
()[inline]Get the target mean value.
Add a note
Not a single note added yet. Be the first, add yours.