GeoGen Development snapshot a3
|
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.
GGen_Data_2D::GGen_Data_2D | ( | GGen_Size | width, |
GGen_Size | height, | ||
GGen_Height | value | ||
) |
Creates new GGen_Data_2D object of given size.
width | Width of the map. |
height | Height of the map. |
value | Default value for all cells. |
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.
value | Value to be added to values in the map. |
void GGen_Data_2D::AddMap | ( | GGen_Data_2D * | addend | ) |
Adds another map to the current map.
addend | Map 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.
addend | Map to be added. This map will be scaled to match the original map. |
mask | Map used to mask the added value. |
relative | Toggles relative mode. |
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.
value | Value to be added to values in the map. |
mask | Map used to mask the added value. This map will be scaled to match the current map. |
relative | Toggles relative mode. |
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.
addend | Map to be added. This map will NOT be scaled to match the original map. |
offset_x | Coordinates of the addend will be shifted by this value along the X axis. |
offset_y | Coordinates 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.
min | New minimum value. |
max | New maximum value. |
GGen_Data_2D * GGen_Data_2D::Clone | ( | ) |
Creates a 1:1 copy of the current 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.
victim | The intersection map. This map will NOT be scaled to match the original map. |
victim | The second map. This map will be scaled to match the original map. |
mask | The mask used to determine value percentage from each map used. This map will NOT be scaled to match the original map. |
relative | Toggles relative mode. |
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.
radius | Convexity 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.
min | New minimum value. |
max | New maximum value. |
void GGen_Data_2D::Distort | ( | GGen_Size | waveLength, |
GGen_Distance | amplitude | ||
) |
Applies a turbulence distortion filter on the height map.
waveLength | Size of one distortion wave. |
amplitude | Strength 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.
distance | The 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.
distance | The distance in maximum metric. |
direction | Direction of expansion. |
void GGen_Data_2D::Fill | ( | GGen_Height | value | ) |
Sets all values in the map.
value | The 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.
value | The fill value. |
mask | Map used to mask the filled value. This map will be scaled to match the current map. |
relative | Toggles relative mode. |
void GGen_Data_2D::FillPolygon | ( | GGen_Path * | path, |
GGen_Height | value | ||
) |
Fills a polygon defined by its outer path.
path | Sequence of points defining the polygon's shape. The polygon is enclosed by connecting the first and last points of the sequence. |
value | Value to be filled with. |
void GGen_Data_2D::Flip | ( | GGen_Direction | direction | ) |
Flips the map along one coordinate axis.
direction | The 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.
land_amount | The 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).
start_x | X coordinate of the starting point. |
start_y | Y coordinate of the starting point. |
fill_value | The value the matching area is filled with. |
mode | Arithmetic operator to be used in the condition. |
threshold | Value to be compared against. |
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.
start_x | X coordinate of the starting point. |
start_y | Y coordinate of the starting point. |
mode | Arithmetic operator to be used in the condition. |
threshold | Value to be compared against. |
GGen_Size GGen_Data_2D::GetHeight | ( | ) |
Returns height of the map.
GGen_Index GGen_Data_2D::GetLength | ( | ) |
Returns length of the map.
GGen_Distance GGen_Data_2D::GetMaxDistance | ( | ) |
Returns maximum possible distance between two cells within the map.
GGen_Height GGen_Data_2D::GetMaxValueOnPath | ( | GGen_Path * | path | ) |
Returns the highest value found in tiles touching a path.
path | Sequence of points defining the path. |
GGen_Height GGen_Data_2D::GetMinValueOnPath | ( | GGen_Path * | path | ) |
Returns the lowest value found in tiles touching a path.
path | Sequence of points defining 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).
x | X coordinate of the tile. |
y | Y coordinate of the tile. |
GGen_Data_1D * GGen_Data_2D::GetProfile | ( | GGen_Direction | direction, |
GGen_Coord | coordinate | ||
) |
Extracts a one-dimensional slice from the map.
direction | Determines if a row (GGEN_HORIZONTAL) or column will be extracted. |
coordinate | Coordinate of the row/column. |
GGen_Height GGen_Data_2D::GetValue | ( | GGen_Coord | x, |
GGen_Coord | y | ||
) |
Returns one value from the array.
x | X coordinate of the tile. |
y | Y coordinate of 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.
x | X coordinate of the tile (in the interpolated map). |
y | Y coordinate of the tile (in the interpolated map). |
scale_to_width | Interpolated array width. |
scale_to_height | Interpolated array height. |
GGen_Size GGen_Data_2D::GetWidth | ( | ) |
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.
from_x | The starting point X coordinate. |
from_y | The starting point Y coordinate. |
to_x | The ending point X coordinate. |
to_y | The starting point Y coordinate. |
from_value | The starting transition base. |
to_value | The ending transition base. |
fill_outside | Should the values outside gradient area be filled as well? |
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.
from_x | The starting point X coordinate. |
from_y | The starting point Y coordinate. |
to_x | The ending point X coordinate. |
to_y | The starting point Y coordinate. |
profile | The gradient profile. |
fill_outside | Should the values outside gradient area be filled as well? |
void GGen_Data_2D::Intersection | ( | GGen_Data_2D * | victim | ) |
Performs a set intersection of the map graphs (higher of two respective values is applied).
victim | The 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.
victim | The intersection map. This map will NOT be scaled to match the original map. |
offset_x | Coordinates of the intersection map will be shifted by this value along the X axis. |
offset_y | Coordinates 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.
GGen_Height GGen_Data_2D::Min | ( | ) |
Returns the minimum of all values in the map.
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.
threshold | Values above threshold will be 1, otherwise 0. |
void GGen_Data_2D::Multiply | ( | double | factor | ) |
Multiplies each value in the map by a real number.
factor | Real 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.
factor | Array 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.
min_feature_size | Minimum wave length for amplitude to be used. |
max_feature_size | Maximum wave length for amplitude to be used. |
amplitudes | GGen_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.
angle | The angle in degrees. |
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.
mode | The 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.
direction | Direction of the normalization. |
mode | The 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).
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.
mode | Condition operator. |
threshold | Condition value. |
outlineMode | Inside or outside border. |
void GGen_Data_2D::Pattern | ( | GGen_Data_2D * | pattern | ) |
Fills the current map with repeating pattern.
pattern | The pattern. |
void GGen_Data_2D::Project | ( | GGen_Data_1D * | profile, |
GGen_Direction | direction | ||
) |
Extrudes one-dimensional profile towards a direction.
profile | The profile to be projected. |
direction | The 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.
center_x | X coordinate of the gradient center. |
center_y | Y coordinate of the gradient center. |
radius | The gradient radius. |
from_value | Value in the center. |
to_value | Value on the outer rim. |
fill_outside | Should the values outside gradient area be filled as well? |
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.
center_x | X coordinate of the gradient center. |
center_y | Y coordinate of the gradient center. |
radius | The gradient radius. |
profile | The gradient profile. |
fill_outside | Should the values outside gradient area be filled as well? |
void GGen_Data_2D::ReplaceValue | ( | GGen_Height | needle, |
GGen_Height | replace | ||
) |
Replaces all occurrences of a value with a different value.
needle | The replaced value. |
replace | The 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.
new_width | New array width. |
new_height | New array height. |
new_zero_x | X coordinate of new origin relative to the original zero. |
new_zero_y | Y coordinate of new origin relative to the original zero. |
void GGen_Data_2D::ReturnAs | ( | const GGen_String & | label | ) |
Calls the API return handler.
label | Label identifying the returned map. |
void GGen_Data_2D::Rotate | ( | int32 | angle, |
bool | preserve_size | ||
) |
Rotates the map by an angle counter-clockwise.
angle | The angle in degrees. |
preserve_size | If 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.
ratio | Scaling ratio (0.5 = 50%, 2.0 = 200%). |
scale_values | Multiply the values by the ratio as well? |
Scales size of the map to new size.
new_width | Target array width. |
new_height | Target array height. |
scale_values | Scale the values correspondingly as well? |
void GGen_Data_2D::ScaleValuesTo | ( | GGen_Height | new_min, |
GGen_Height | new_max | ||
) |
Scales values in the map to fit a new value range.
new_min | New minimum value. |
new_max | New 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.
relative | Toggles relative mode. |
void GGen_Data_2D::SelectValue | ( | GGen_Height | value | ) |
Replaces all occurrences of a value with 1, all other values will be replaced with 0.
value | The selected value. |
void GGen_Data_2D::SetValue | ( | GGen_Coord | x, |
GGen_Coord | y, | ||
GGen_Height | value | ||
) |
Sets value in one tile.
x | X coordinate of the tile. |
y | Y coordinate of the tile. |
value | Value 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).
x1 | X coordinate of the left border |
y1 | Y coordinate of the top borer. |
x2 | X coordinate of the right border. |
y2 | Y coordinate of the bottom border. |
value | Value to use. |
void GGen_Data_2D::Shear | ( | int32 | horizontal_shear, |
int32 | vertical_shear, | ||
bool | preserve_size | ||
) |
Shears the map vertically and/or horizontally.
horizontal_shear | Horizontal shear factor (0 means no horizontal shearing). |
vertical_shear | Horizontal shear factor (1 means no horizontal shearing). |
preserve_size | If set to true, the result will be cropped to match its original boundaries. |
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.
profile | The shift profile. |
direction | Direction towards which will the shiting be done. |
mode | The 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.
distance | The 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.
distance | The distance in maximum metric. |
direction | Direction 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.
radius | The smoothing kernel radius. |
void GGen_Data_2D::SmoothDirection | ( | GGen_Distance | radius, |
GGen_Direction | direction | ||
) |
Blurs the map in one direction. Uses linear smoothing algorithm.
radius | The smoothing kernel radius. |
direction | Direction 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.
path | The path to be stroked. |
brush | Brush used. Value with index 0 will be the closest to the path itself. |
radius | Resulting size of the stroke. |
fill_outside | Fill the area outside the brush stroke? |
void GGen_Data_2D::Transform | ( | double | a11, |
double | a12, | ||
double | a21, | ||
double | a22, | ||
bool | preserve_size | ||
) |
Applies a linear transformation matrix onto the map.
a11 | Matrix element (1,1). |
a12 | Matrix element (1,2). |
a21 | Matrix element (2,1). |
a22 | Matrix element (2,2). |
preserve_size | If set to true, the result will be cropped/expanded to match its original boundaries. |
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.
profile | The transformation profile. |
relative | Toggles relative mode. |
void GGen_Data_2D::Union | ( | GGen_Data_2D * | victim | ) |
Performs a set union of the map graphs (higher of two respective values is applied).
victim | The 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.
victim | The union map. This map will NOT be scaled to match the original map. |
offset_x | Coordinates of the intersection map will be shifted by this value along the X axis. |
offset_y | Coordinates 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.
cell_size | Size of one cell (cells are considered to be squares). |
points_per_cell | Number of points randomly placed in each cell. |
mode | The noise mode (see GGen_Voronoi_Noise_Mode). |