GeoGen Development snapshot a3
Public Member Functions

GGen_Data_2D Class Reference

List of all members.

Public Member Functions

 GGen_Data_2D (GGen_Size width, GGen_Size height, GGen_Height value)
void Abs ()
void Add (GGen_Height value)
void AddMap (GGen_Data_2D *addend)
void AddMapMasked (GGen_Data_2D *addend, GGen_Data_2D *mask, bool relative)
void AddMasked (GGen_Height value, GGen_Data_2D *mask, bool relative)
void AddTo (GGen_Data_2D *addend, GGen_CoordOffset offset_x, GGen_CoordOffset offset_y)
void Clamp (GGen_Height min, GGen_Height max)
GGen_Data_2DClone ()
void Combine (GGen_Data_2D *victim, GGen_Data_2D *mask, bool relative)
void ConvexityMap (GGen_Distance radius)
void CropValues (GGen_Height min, GGen_Height max)
void Distort (GGen_Size waveLength, GGen_Distance amplitude)
void Expand (GGen_Distance distance)
void ExpandDirection (GGen_Distance distance, GGen_Direction direction)
void Fill (GGen_Height value)
void FillMasked (GGen_Height value, GGen_Data_2D *mask, bool relative)
void FillPolygon (GGen_Path *path, GGen_Height value)
void Flip (GGen_Direction direction)
void Flood (double land_amount)
void FloodFill (GGen_Coord start_x, GGen_Coord start_y, GGen_Height fill_value, GGen_Comparison_Mode mode, GGen_Height threshold)
void FloodSelect (GGen_Coord start_x, GGen_Coord start_y, GGen_Comparison_Mode mode, GGen_Height threshold)
GGen_Size GetHeight ()
GGen_Index GetLength ()
GGen_Distance GetMaxDistance ()
GGen_Height GetMaxValueOnPath (GGen_Path *path)
GGen_Height GetMinValueOnPath (GGen_Path *path)
GGen_Height GetNormal (GGen_Coord x, GGen_Coord y)
GGen_Data_1DGetProfile (GGen_Direction direction, GGen_Coord coordinate)
GGen_Height GetValue (GGen_Coord x, GGen_Coord y)
GGen_Height GetValueInterpolated (GGen_Coord x, GGen_Coord y, GGen_Size scale_to_width, GGen_Size scale_to_height)
GGen_Size GetWidth ()
void Gradient (GGen_Coord from_x, GGen_Coord from_y, GGen_Coord to_x, GGen_Coord to_y, GGen_Height from_value, GGen_Height to_value, bool fill_outside)
void GradientFromProfile (GGen_Coord from_x, GGen_Coord from_y, GGen_Coord to_x, GGen_Coord to_y, GGen_Data_1D *profile, bool fill_outside)
void Intersection (GGen_Data_2D *victim)
void IntersectionTo (GGen_Data_2D *victim, GGen_CoordOffset offset_x, GGen_CoordOffset offset_y)
void Invert ()
GGen_Height Max ()
GGen_Height Min ()
void Monochrome (GGen_Height threshold)
void Multiply (double factor)
void MultiplyMap (GGen_Data_2D *factor)
void Noise (GGen_Size min_feature_size, GGen_Size max_feature_size, GGen_Amplitudes *amplitudes)
void NormalDifferenceMap (int32 angle)
void Normalize (GGen_Normalization_Mode mode)
void NormalizeDirection (GGen_Direction direction, GGen_Normalization_Mode mode)
void NormalMap ()
void Outline (GGen_Comparison_Mode mode, GGen_Height threshold, GGen_Outline_Mode outlineMode)
void Pattern (GGen_Data_2D *pattern)
void Project (GGen_Data_1D *profile, GGen_Direction direction)
void RadialGradient (GGen_Coord center_x, GGen_Coord center_y, GGen_Coord radius, GGen_Height from_value, GGen_Height to_value, bool fill_outside)
void RadialGradientFromProfile (GGen_Coord center_x, GGen_Coord center_y, GGen_Distance radius, GGen_Data_1D *profile, bool fill_outside)
void ReplaceValue (GGen_Height needle, GGen_Height replace)
void ResizeCanvas (GGen_Size new_width, GGen_Size new_height, GGen_CoordOffset new_zero_x, GGen_CoordOffset new_zero_y)
void ReturnAs (const GGen_String &label)
void Rotate (int32 angle, bool preserve_size)
void Scale (double ratio, bool scale_values)
void ScaleTo (GGen_Size new_width, GGen_Size new_height, bool scale_values)
void ScaleValuesTo (GGen_Height new_min, GGen_Height new_max)
void Scatter (bool relative)
void SelectValue (GGen_Height value)
void SetValue (GGen_Coord x, GGen_Coord y, GGen_Height value)
void SetValueInRect (GGen_Coord x1, GGen_Coord y1, GGen_Coord x2, GGen_Coord y2, GGen_Height value)
void Shear (int32 horizontal_shear, int32 vertical_shear, bool preserve_size)
void Shift (GGen_Data_1D *profile, GGen_Direction direction, GGen_Overflow_Mode mode)
void Shrink (GGen_Distance distance)
void ShrinkDirection (GGen_Distance distance, GGen_Direction direction)
void SlopeMap ()
void Smooth (GGen_Distance radius)
void SmoothDirection (GGen_Distance radius, GGen_Direction direction)
void StrokePath (GGen_Path *path, GGen_Data_1D *brush, GGen_Distance radius, bool fill_outside)
void Transform (double a11, double a12, double a21, double a22, bool preserve_size)
void TransformValues (GGen_Data_1D *profile, bool relative)
void Union (GGen_Data_2D *victim)
void UnionTo (GGen_Data_2D *victim, GGen_CoordOffset offset_x, GGen_CoordOffset offset_y)
void VoronoiNoise (GGen_Size cell_size, uint8 points_per_cell, GGen_Voronoi_Noise_Mode mode)

Detailed Description

GGen_Data_2D represents 2-dimensional array of values. Most straightforward interpretation of such array is a bitmap, where black represents some minimal value (usually 0) and white represents some maximal value (in case of 8 bit per channel bitmaps usually 255). You will probably realize many of the GGen_Data_2D functions strongly resemble functions from classical bitmap editors - adding changes brightness, multiplying changes contrast, curves... Working with multiple 2D arrays with GGen is generally very similiar to working with layer enabled bitmap editor, just without a fancy GUI.


Constructor & Destructor Documentation

GGen_Data_2D::GGen_Data_2D ( GGen_Size  width,
GGen_Size  height,
GGen_Height  value 
)

Creates new GGen_Data_2D object of given size.

Parameters:
widthWidth of the map.
heightHeight of the map.
valueDefault value for all cells.

Member Function Documentation

void GGen_Data_2D::Abs ( )

Replaces each value with its absolute value (removes all negative signs).

void GGen_Data_2D::Add ( GGen_Height  value)

Adds an integer to all values in the map.

Parameters:
valueValue to be added to values in the map.
void GGen_Data_2D::AddMap ( GGen_Data_2D addend)

Adds another map to the current map.

Parameters:
addendMap to be added. This map will be scaled to match the original map.
void GGen_Data_2D::AddMapMasked ( GGen_Data_2D addend,
GGen_Data_2D mask,
bool  relative 
)

Adds another map to the current map. The percentage of each value from the addend will depend on corresponding value from the mask.

Parameters:
addendMap to be added. This map will be scaled to match the original map.
maskMap used to mask the added value.
relativeToggles relative mode.
Note:
0 in the mask always means the original value won't be changed. In relative mode, maximum value found in the mask then means 100%, otherwise 32767 means 100%.
void GGen_Data_2D::AddMasked ( GGen_Height  value,
GGen_Data_2D mask,
bool  relative 
)

Adds a percentage of an integer to all values in the map. The percentage added will depend on corresponding value from the mask.

Parameters:
valueValue to be added to values in the map.
maskMap used to mask the added value. This map will be scaled to match the current map.
relativeToggles relative mode.
Note:
0 in the mask always means the original value won't be changed. In relative mode, maximum value found in the mask then means 100%, otherwise 32767 means 100%.
void GGen_Data_2D::AddTo ( GGen_Data_2D addend,
GGen_CoordOffset  offset_x,
GGen_CoordOffset  offset_y 
)

Adds another map to the current map. Its coordinates will be shifted by an offset.

Parameters:
addendMap to be added. This map will NOT be scaled to match the original map.
offset_xCoordinates of the addend will be shifted by this value along the X axis.
offset_yCoordinates of the addend will be shifted by this value along the Y axis.
void GGen_Data_2D::Clamp ( GGen_Height  min,
GGen_Height  max 
)

Clamps all values to range. All values outside the given range will be set either to min or max, whichever is closer.

Parameters:
minNew minimum value.
maxNew maximum value.
GGen_Data_2D * GGen_Data_2D::Clone ( )

Creates a 1:1 copy of the current object.

Returns:
Copy of the object.
void GGen_Data_2D::Combine ( GGen_Data_2D victim,
GGen_Data_2D mask,
bool  relative 
)

Combines the current map with another map according to corresponding values in mask.

Parameters:
victimThe intersection map. This map will NOT be scaled to match the original map.
victimThe second map. This map will be scaled to match the original map.
maskThe mask used to determine value percentage from each map used. This map will NOT be scaled to match the original map.
relativeToggles relative mode.
Note:
0 in the mask means the second map value will be used. In relative mode, maximum value (32767 otherwise) found in the mask then means the current map value will be used. Other mask values will mean a combination of both map values (the higher the mask value, the more of the current array value will be used).
void GGen_Data_2D::ConvexityMap ( GGen_Distance  radius)

Replaces values in the array with information about steepness of slope (change in value) in that particular value.

Parameters:
radiusConvexity measurement radius (how big a terrain feature must be to show on the convexity map).
void GGen_Data_2D::CropValues ( GGen_Height  min,
GGen_Height  max 
)

Clamps all values to range. All values outside the given range will be set either to 0.

Parameters:
minNew minimum value.
maxNew maximum value.
void GGen_Data_2D::Distort ( GGen_Size  waveLength,
GGen_Distance  amplitude 
)

Applies a turbulence distortion filter on the height map.

Parameters:
waveLengthSize of one distortion wave.
amplitudeStrength of the distortion effect.
void GGen_Data_2D::Expand ( GGen_Distance  distance)

Fills all areas within a distance (in maximum metric) from any value greater than 0 with 1. The rest of the map will be filled with 0.

Parameters:
distanceThe distance in maximum metric.
void GGen_Data_2D::ExpandDirection ( GGen_Distance  distance,
GGen_Direction  direction 
)

Fills all areas within a distance in one direction from any value greater than 0 with 1. The rest of the map will be filled with 0.

Parameters:
distanceThe distance in maximum metric.
directionDirection of expansion.
void GGen_Data_2D::Fill ( GGen_Height  value)

Sets all values in the map.

Parameters:
valueThe fill value.
void GGen_Data_2D::FillMasked ( GGen_Height  value,
GGen_Data_2D mask,
bool  relative 
)

Sets all values in the map. The percentage of value changed in each tile will depend on corresponding values in the mask.

Parameters:
valueThe fill value.
maskMap used to mask the filled value. This map will be scaled to match the current map.
relativeToggles relative mode.
Note:
0 in the mask always means the original value won't be changed. In relative mode, maximum value found in the mask then means 100%, otherwise 32767 means 100%.
void GGen_Data_2D::FillPolygon ( GGen_Path path,
GGen_Height  value 
)

Fills a polygon defined by its outer path.

Parameters:
pathSequence of points defining the polygon's shape. The polygon is enclosed by connecting the first and last points of the sequence.
valueValue to be filled with.
Note:
Filled areas are determined by odd-even rule.
void GGen_Data_2D::Flip ( GGen_Direction  direction)

Flips the map along one coordinate axis.

Parameters:
directionThe axis, along which the map will be flipped.
void GGen_Data_2D::Flood ( double  land_amount)

Changes the values so only given percentage of values is higher than 0.

Parameters:
land_amountThe percentage of values to be higher than 0. 0 means no "land", 1.0 means no "water".
void GGen_Data_2D::FloodFill ( GGen_Coord  start_x,
GGen_Coord  start_y,
GGen_Height  fill_value,
GGen_Comparison_Mode  mode,
GGen_Height  threshold 
)

Fills uniform area matching a simple arithmetic condition (all tiles matching the condition reachable from the starting point through tiles matching the condition are filled with value).

Parameters:
start_xX coordinate of the starting point.
start_yY coordinate of the starting point.
fill_valueThe value the matching area is filled with.
modeArithmetic operator to be used in the condition.
thresholdValue to be compared against.
Note:
If the starting point doesn't match the condition, no tiles are changed.
The filling is 4-directional (the spread is only along the main two axes).
void GGen_Data_2D::FloodSelect ( GGen_Coord  start_x,
GGen_Coord  start_y,
GGen_Comparison_Mode  mode,
GGen_Height  threshold 
)

Replaces all values in an uniform area matching a simple arithmetic condition with 1 (all tiles matching the condition reachable from the starting point through tiles matching the condition are filled with 1). All other areas are filled with 0.

Parameters:
start_xX coordinate of the starting point.
start_yY coordinate of the starting point.
modeArithmetic operator to be used in the condition.
thresholdValue to be compared against.
Note:
If the starting point doesn't match the condition, all tiles will be filed with 0.
The filling is 4-directional (the spread is only along the main two axes).
GGen_Size GGen_Data_2D::GetHeight ( )

Returns height of the map.

Returns:
height of the map.
GGen_Index GGen_Data_2D::GetLength ( )

Returns length of the map.

Returns:
Length of the map.
Note:
Length is total number of tiles in the map (= width * height)
GGen_Distance GGen_Data_2D::GetMaxDistance ( )

Returns maximum possible distance between two cells within the map.

Returns:
Maximum distance within the map.
GGen_Height GGen_Data_2D::GetMaxValueOnPath ( GGen_Path path)

Returns the highest value found in tiles touching a path.

Parameters:
pathSequence of points defining the path.
Returns:
The maximum value found on the path.
GGen_Height GGen_Data_2D::GetMinValueOnPath ( GGen_Path path)

Returns the lowest value found in tiles touching a path.

Parameters:
pathSequence of points defining the path.
Returns:
The minimum value found on the path.
GGen_Height GGen_Data_2D::GetNormal ( GGen_Coord  x,
GGen_Coord  y 
)

Returns surface normal angle in a tile. Angle 0° (eastern slope) is represented by value 0, angles in range (0°, 180°) are represented by negative values in range (GGEN_MIN_HEIGHT, 0) and angles in range (180°, 360°) are represented by positive values in range (0, GGEN_MAX_HEIGHT).

Parameters:
xX coordinate of the tile.
yY coordinate of the tile.
Returns:
Surface normal angle.
GGen_Data_1D * GGen_Data_2D::GetProfile ( GGen_Direction  direction,
GGen_Coord  coordinate 
)

Extracts a one-dimensional slice from the map.

Parameters:
directionDetermines if a row (GGEN_HORIZONTAL) or column will be extracted.
coordinateCoordinate of the row/column.
GGen_Height GGen_Data_2D::GetValue ( GGen_Coord  x,
GGen_Coord  y 
)

Returns one value from the array.

Parameters:
xX coordinate of the tile.
yY coordinate of the tile.
Returns:
Value in the tile.
GGen_Height GGen_Data_2D::GetValueInterpolated ( GGen_Coord  x,
GGen_Coord  y,
GGen_Size  scale_to_width,
GGen_Size  scale_to_height 
)

Return one value from the array interpolated to a different map size.

Parameters:
xX coordinate of the tile (in the interpolated map).
yY coordinate of the tile (in the interpolated map).
scale_to_widthInterpolated array width.
scale_to_heightInterpolated array height.
Returns:
Interpolated value in the tile.
Note:
If the interpolated size is larger than the original, interpolated values will be calculated using the linear interpolation algorithm. Otherwise, interpolated values will be chosen using the nearest neighbor algorithm.
GGen_Size GGen_Data_2D::GetWidth ( )

Returns width of the map.

Returns:
Width of the map.
void GGen_Data_2D::Gradient ( GGen_Coord  from_x,
GGen_Coord  from_y,
GGen_Coord  to_x,
GGen_Coord  to_y,
GGen_Height  from_value,
GGen_Height  to_value,
bool  fill_outside 
)

Creates a smooth gradient between two coords. The values will make transition between two values.

Parameters:
from_xThe starting point X coordinate.
from_yThe starting point Y coordinate.
to_xThe ending point X coordinate.
to_yThe starting point Y coordinate.
from_valueThe starting transition base.
to_valueThe ending transition base.
fill_outsideShould the values outside gradient area be filled as well?
Note:
If fill_flat is set to true, values outside the gradient strip will be filled with flat color. Tiles closer to the starting point will be filled with from_value and tiles closer to the ending point will be filled with to_value.
void GGen_Data_2D::GradientFromProfile ( GGen_Coord  from_x,
GGen_Coord  from_y,
GGen_Coord  to_x,
GGen_Coord  to_y,
GGen_Data_1D profile,
bool  fill_outside 
)

Creates a smooth gradient between two coords. The values will be picked from the gradient profile according to the point's position on the gradient.

Parameters:
from_xThe starting point X coordinate.
from_yThe starting point Y coordinate.
to_xThe ending point X coordinate.
to_yThe starting point Y coordinate.
profileThe gradient profile.
fill_outsideShould the values outside gradient area be filled as well?
Note:
If fill_flat is set to true, values outside the gradient strip will be filled with flat color. Tiles closer to the starting point will be filled with the left-most value from the profile and tiles closer to the ending point will be filled with the right-most value from the profile.
void GGen_Data_2D::Intersection ( GGen_Data_2D victim)

Performs a set intersection of the map graphs (higher of two respective values is applied).

Parameters:
victimThe intersection map. This map will be scaled to match the original map.
void GGen_Data_2D::IntersectionTo ( GGen_Data_2D victim,
GGen_CoordOffset  offset_x,
GGen_CoordOffset  offset_y 
)

Performs a set intersection of the map graphs (higher of two respective values is applied). The intersection map coordinates will be shifted by an offset.

Parameters:
victimThe intersection map. This map will NOT be scaled to match the original map.
offset_xCoordinates of the intersection map will be shifted by this value along the X axis.
offset_yCoordinates of the intersection map will be shifted by this value along the Y axis.
void GGen_Data_2D::Invert ( )

Flips sign of all values in the map.

GGen_Height GGen_Data_2D::Max ( )

Returns the maximum of all values in the map.

Returns:
The maximum.
GGen_Height GGen_Data_2D::Min ( )

Returns the minimum of all values in the map.

Returns:
The minimum.
void GGen_Data_2D::Monochrome ( GGen_Height  threshold)

Replaces each value with 0 if it is less than equal than the threshold or 1 otherwise.

Parameters:
thresholdValues above threshold will be 1, otherwise 0.
void GGen_Data_2D::Multiply ( double  factor)

Multiplies each value in the map by a real number.

Parameters:
factorReal number to multiply all values in the map.
void GGen_Data_2D::MultiplyMap ( GGen_Data_2D factor)

Multiplies each value in the map by a corresponding value from factor.

Parameters:
factorArray to be multiplied by. This map will be scaled to match the original map.
void GGen_Data_2D::Noise ( GGen_Size  min_feature_size,
GGen_Size  max_feature_size,
GGen_Amplitudes amplitudes 
)

Fills the array with random fractal noise.

Parameters:
min_feature_sizeMinimum wave length for amplitude to be used.
max_feature_sizeMaximum wave length for amplitude to be used.
amplitudesGGen_Amplitudes object.
void GGen_Data_2D::NormalDifferenceMap ( int32  angle)

Replaces all values with values representing angle difference between surface normal in the tile and given angle. Angle difference of 0° is represented by value 0, angle difference of 180° is represented by GGEN_MAX_HEIGHT.

Parameters:
angleThe angle in degrees.
Note:
Flat areas (with normal pointing directly upward) are replaced with value GGEN_INVALID_HEIGHT.
void GGen_Data_2D::Normalize ( GGen_Normalization_Mode  mode)

Makes sure that there are no slopes steeper than 45° in the map. Steeper slopes will be dealt with according to mode.

Parameters:
modeThe normalization mode (see GGen_Normalization_Mode).
void GGen_Data_2D::NormalizeDirection ( GGen_Direction  direction,
GGen_Normalization_Mode  mode 
)

Makes sure that there are no slopes steeper than 45° in either horizontal or vertical direction. Steeper slopes will be dealt with according to mode.

Parameters:
directionDirection of the normalization.
modeThe normalization mode (see GGen_Normalization_Mode).
void GGen_Data_2D::NormalMap ( )

Replaces all values with values representing horizontal angle of surface normal in the tile. Angle 0° (eastern slope) is represented by value 0, angles in range (0°, 180°) are represented by negative values in range (GGEN_MIN_HEIGHT, 0) and angles in range (180°, 360°) are represented by positive values in range (0, GGEN_MAX_HEIGHT).

Note:
Flat areas (with normal pointing directly upward) are replaced with value GGEN_INVALID_HEIGHT.
void GGen_Data_2D::Outline ( GGen_Comparison_Mode  mode,
GGen_Height  threshold,
GGen_Outline_Mode  outlineMode 
)

Draws a border (made of value 1) around an area matching a condition. The non-border areas are filled with 0.

Parameters:
modeCondition operator.
thresholdCondition value.
outlineModeInside or outside border.
void GGen_Data_2D::Pattern ( GGen_Data_2D pattern)

Fills the current map with repeating pattern.

Parameters:
patternThe pattern.
void GGen_Data_2D::Project ( GGen_Data_1D profile,
GGen_Direction  direction 
)

Extrudes one-dimensional profile towards a direction.

Parameters:
profileThe profile to be projected.
directionThe extrusion direction.
void GGen_Data_2D::RadialGradient ( GGen_Coord  center_x,
GGen_Coord  center_y,
GGen_Coord  radius,
GGen_Height  from_value,
GGen_Height  to_value,
bool  fill_outside 
)

Creates a radial gradient. The values will make a smooth transition between the center and the outer rim.

Parameters:
center_xX coordinate of the gradient center.
center_yY coordinate of the gradient center.
radiusThe gradient radius.
from_valueValue in the center.
to_valueValue on the outer rim.
fill_outsideShould the values outside gradient area be filled as well?
Note:
If fill_flat is set to true, values beyond the outer rim will be filled with to_value.
void GGen_Data_2D::RadialGradientFromProfile ( GGen_Coord  center_x,
GGen_Coord  center_y,
GGen_Distance  radius,
GGen_Data_1D profile,
bool  fill_outside 
)

Creates a radial gradient. The values will be picked from the gradient profile according to the point's position on the gradient.

Parameters:
center_xX coordinate of the gradient center.
center_yY coordinate of the gradient center.
radiusThe gradient radius.
profileThe gradient profile.
fill_outsideShould the values outside gradient area be filled as well?
Note:
If fill_flat is set to true, values beyond the outer rim will be filled with the right-most value from the profile.
void GGen_Data_2D::ReplaceValue ( GGen_Height  needle,
GGen_Height  replace 
)

Replaces all occurrences of a value with a different value.

Parameters:
needleThe replaced value.
replaceThe new value.
void GGen_Data_2D::ResizeCanvas ( GGen_Size  new_width,
GGen_Size  new_height,
GGen_CoordOffset  new_zero_x,
GGen_CoordOffset  new_zero_y 
)

Crops or expands the array without changing its values.

Parameters:
new_widthNew array width.
new_heightNew array height.
new_zero_xX coordinate of new origin relative to the original zero.
new_zero_yY coordinate of new origin relative to the original zero.
Note:
All values outside the new map area will be discarded. Newly created values will be set to 0.
void GGen_Data_2D::ReturnAs ( const GGen_String &  label)

Calls the API return handler.

Parameters:
labelLabel identifying the returned map.
void GGen_Data_2D::Rotate ( int32  angle,
bool  preserve_size 
)

Rotates the map by an angle counter-clockwise.

Parameters:
angleThe angle in degrees.
preserve_sizeIf set to true, the result will be cropped to match its original boundaries.
void GGen_Data_2D::Scale ( double  ratio,
bool  scale_values 
)

Scales size of the map by a real number.

Parameters:
ratioScaling ratio (0.5 = 50%, 2.0 = 200%).
scale_valuesMultiply the values by the ratio as well?
Note:
If the new size is larger than the original, the new values will be calculated using the linear interpolation algorithm. Otherwise, the new values will be chosen using the nearest neighbor algorithm.
void GGen_Data_2D::ScaleTo ( GGen_Size  new_width,
GGen_Size  new_height,
bool  scale_values 
)

Scales size of the map to new size.

Parameters:
new_widthTarget array width.
new_heightTarget array height.
scale_valuesScale the values correspondingly as well?
Note:
If the new size is larger than the original, the new values will be calculated using the linear interpolation algorithm. Otherwise, the new values will be chosen using the nearest neighbor algorithm.
void GGen_Data_2D::ScaleValuesTo ( GGen_Height  new_min,
GGen_Height  new_max 
)

Scales values in the map to fit a new value range.

Parameters:
new_minNew minimum value.
new_maxNew maximum value.
void GGen_Data_2D::Scatter ( bool  relative)

Replaces each value with 1 with a probability defined by its value, all other values will be replaced with 1.

Parameters:
relativeToggles relative mode.
Note:
Value 0 means 0% probability to create a 1. In relative mode, maximum value (32767 otherwise) found in the map then means 100% probability to create a 1.
void GGen_Data_2D::SelectValue ( GGen_Height  value)

Replaces all occurrences of a value with 1, all other values will be replaced with 0.

Parameters:
valueThe selected value.
void GGen_Data_2D::SetValue ( GGen_Coord  x,
GGen_Coord  y,
GGen_Height  value 
)

Sets value in one tile.

Parameters:
xX coordinate of the tile.
yY coordinate of the tile.
valueValue to use.
void GGen_Data_2D::SetValueInRect ( GGen_Coord  x1,
GGen_Coord  y1,
GGen_Coord  x2,
GGen_Coord  y2,
GGen_Height  value 
)

Sets value in all tiles inside a rectangle (bounds are included).

Parameters:
x1X coordinate of the left border
y1Y coordinate of the top borer.
x2X coordinate of the right border.
y2Y coordinate of the bottom border.
valueValue to use.
void GGen_Data_2D::Shear ( int32  horizontal_shear,
int32  vertical_shear,
bool  preserve_size 
)

Shears the map vertically and/or horizontally.

Parameters:
horizontal_shearHorizontal shear factor (0 means no horizontal shearing).
vertical_shearHorizontal shear factor (1 means no horizontal shearing).
preserve_sizeIf set to true, the result will be cropped to match its original boundaries.
Precondition:
horizontal_shear != 1 or vertical_shear != 1.
void GGen_Data_2D::Shift ( GGen_Data_1D profile,
GGen_Direction  direction,
GGen_Overflow_Mode  mode 
)

Shifts all values in the array towards a direction by a corresponding value from profile.

Parameters:
profileThe shift profile.
directionDirection towards which will the shiting be done.
modeThe overflow mode (see GGen_Overflow_Mode).
void GGen_Data_2D::Shrink ( GGen_Distance  distance)

Fills all areas within a distance (in maximum metric) from any negative value with 0. The rest of the map will be filled with 1.

Parameters:
distanceThe distance in maximum metric.
void GGen_Data_2D::ShrinkDirection ( GGen_Distance  distance,
GGen_Direction  direction 
)

Fills all areas within a distance (in maximum metric) from any negative value with 0. The rest of the map will be filled with 1.

Parameters:
distanceThe distance in maximum metric.
directionDirection of shrinking.
void GGen_Data_2D::SlopeMap ( )

Replaces values in the array with information about steepness of slope (change in value) in that particular value.

void GGen_Data_2D::Smooth ( GGen_Distance  radius)

Blurs the map. Uses linear smoothing algorithm.

Parameters:
radiusThe smoothing kernel radius.
void GGen_Data_2D::SmoothDirection ( GGen_Distance  radius,
GGen_Direction  direction 
)

Blurs the map in one direction. Uses linear smoothing algorithm.

Parameters:
radiusThe smoothing kernel radius.
directionDirection in which is the smoothing done.
void GGen_Data_2D::StrokePath ( GGen_Path path,
GGen_Data_1D brush,
GGen_Distance  radius,
bool  fill_outside 
)

Paints a path with one-dimensional brush onto the map.

Parameters:
pathThe path to be stroked.
brushBrush used. Value with index 0 will be the closest to the path itself.
radiusResulting size of the stroke.
fill_outsideFill the area outside the brush stroke?
Note:
Computational complexity of this function directly depends on number of segments in the path.
void GGen_Data_2D::Transform ( double  a11,
double  a12,
double  a21,
double  a22,
bool  preserve_size 
)

Applies a linear transformation matrix onto the map.

Parameters:
a11Matrix element (1,1).
a12Matrix element (1,2).
a21Matrix element (2,1).
a22Matrix element (2,2).
Precondition:
The matrix must be invertible (a11 * a22 - a12 * a21 != 0).
Parameters:
preserve_sizeIf set to true, the result will be cropped/expanded to match its original boundaries.
Note:
Do not use this function to scale the map, it uses a low-quality nearest neighbor interpolation.
void GGen_Data_2D::TransformValues ( GGen_Data_1D profile,
bool  relative 
)

Replaces each value with a corresponding value from profile. Coordinate of the corresponding value is determined by the original value - the higher the value, the higher the coordinate in profile is.

Parameters:
profileThe transformation profile.
relativeToggles relative mode.
Note:
Only values higher than zero are affected.
If relative is false, then maximum value corresponds to the rightmost coordinate (0 always corresponds to 0), else the values are used in range 0-32767 only.
The input profile will be internally smoothed to prevent sharp steps on the transformed terrain.
void GGen_Data_2D::Union ( GGen_Data_2D victim)

Performs a set union of the map graphs (higher of two respective values is applied).

Parameters:
victimThe union map. This map will be scaled to match the original map.
void GGen_Data_2D::UnionTo ( GGen_Data_2D victim,
GGen_CoordOffset  offset_x,
GGen_CoordOffset  offset_y 
)

Performs a set union of the map graphs (higher of two respective values is applied). The union map coordinates will be shifted by an offset.

Parameters:
victimThe union map. This map will NOT be scaled to match the original map.
offset_xCoordinates of the intersection map will be shifted by this value along the X axis.
offset_yCoordinates of the intersection map will be shifted by this value along the Y axis.
void GGen_Data_2D::VoronoiNoise ( GGen_Size  cell_size,
uint8  points_per_cell,
GGen_Voronoi_Noise_Mode  mode 
)

Fills the array with random voronoi noise.

Parameters:
cell_sizeSize of one cell (cells are considered to be squares).
points_per_cellNumber of points randomly placed in each cell.
modeThe noise mode (see GGen_Voronoi_Noise_Mode).
Note:
Computational complexity steeply rises with points_per_cell.
Ratio of the points_per_cell and cell_size determines randomness and density of the noise.

The documentation for this class was generated from the following files: