GeoGen Script reference
Contructors | Member Functions
HeightMap Class Reference

Two-dimensional height map. More...

Contructors

static HeightMap CellNoise (Number meanCellSize, Number seed)
 Creates a map filled with cell (Worley) noise. More...
 
static HeightMap Clone (HeightMap heightMap)
 Creates a deep copy of another height map. More...
 
static HeightMap ConvexityMap (HeightMap heightMap, Number radius)
 Creates a map representing convexity of local areas (with radius) in another height map. More...
 
static HeightMap DistanceMap (HeightMap heightMap, Number maximumDistance)
 Creates a map representing euclidean distance of each pixel of a height map to the closest pixel with height 0 or less. More...
 
static HeightMap Flat (Number height)
 Creates a height map with constant height. More...
 
static HeightMap Gradient (Point sourcePoint, Point destinationPoint, Number sourceHeight, Number destinationHeight)
 Creates a linear height gradient going from sourceHeight at sourcePoint to destinationHeight at destinationPoint. More...
 
static HeightMap Noise (Array layerDefinitions, Number seed)
 Creates a height map filled with random perlin noise. More...
 
static HeightMap Pattern (HeightMap pattern, Point firstRectanglePoint, Point secondRectanglePoint)
 Creates a height map with a rectangular area of pattern repeating infinitely in all directions. More...
 
static HeightMap Projection (HeightProfile profile, Direction direction)
 Creates a height map with a profile projected along direction. More...
 
static HeightMap RadialGradient (Point center, Number radius, Number centerHeight, Number rimHeight)
 Creates a radial height gradient centered at center with radius. More...
 
static HeightMap RidgedNoise (Array layerDefinitions, Number seed)
 Creates a height map filled with random perlin noise with pronounced ridges. More...
 

Member Functions

HeightMap Abs ()
 Replaces height in each pixel with its absolute value (makes negative heights positive). More...
 
HeightMap Add (Number/HeightMap addend, HeightMap mask)
 Adds a number or a corresponding pixel from another height map to each pixel in the height map. More...
 
HeightMap Blur (Number radius)
 Blurs the height map with box blur algorithm with kernel of given radius. More...
 
HeightMap ClampHeights (Number min, Number max)
 Replaces heights greater than max with max and less than min with min. More...
 
HeightMap Combine (HeightMap other, HeightMap mask)
 Replaces heights in each pixel with a height blended from that height and corresponding height from another height map. More...
 
HeightMap Crop (Point firstRectanglePoint, Point secondRectanglePoint, Number replace)
 Replaces all heights outside of an rectangle with replace. More...
 
HeightMap CropHeights (Number min, Number max, Number replace)
 Replaces heights greater than max or less than min with replace. More...
 
HeightMap Distort (Number perturbationSize, Number maximumDistance, Number seed)
 Distorts the map with random perturbations. More...
 
HeightMap DrawLine (Point start, Point end, Number height)
 Draws a 1 pixel wide line from start to end. More...
 
HeightMap Fill (Number height)
 Replaces each pixel with height. More...
 
HeightMap FillRectangle (Point firstRectanglePoint, Point secondRectanglePoint, Number height)
 Replaces each pixel in a rectangle with height. More...
 
HeightMap Flip (Direction direction)
 Flips the map horizontally of vertically. More...
 
HeightMap Glaciate (Number strength, bool includeNegative)
 Exaggerates lower altitudes, making valley bases wider and peaks sharper. More...
 
HeightMap Intersect (HeightMap other)
 Sets each pixel in the to the less of the two corresponding heights in the current map and the other map. More...
 
HeightMap Invert ()
 Flips sign of each height in the map. More...
 
HeightMap Move (Point offset)
 Moves the height map by offset. More...
 
HeightMap Multiply (Number/HeightMap factor)
 Multiplies the height in each pixel by a number or a corresponding pixel from another height map. More...
 
HeightMap Rescale (Number horizontalScale, Number verticalScale)
 Enlarges (with scale > 1) or shrinks (with scale < 1) the entire map. More...
 
HeightMap Rotate (Number angle)
 Rotates the height map by angle in radians clockwise. More...
 
HeightMap Shear (Number shearFactor, Direction direction)
 Shears the height map by shearFactor in direction. More...
 
HeightMap Shift (HeightProfile profile, Coordinate maximumDistance, Direction direction)
 Shifts each row (if direction is vertical) or column (if direction is horizontal) by distance determined by the corresponding height in the profile (1 in profile means the pixels will be shifted by maximumDistance, -1 means the pixels will be shifted by -maximumDistance). More...
 
HeightMap Stratify (Number numberOfStrata, Number steepness, Number smoothness, Boolean includeNegative)
 Distributes the heights among a specified number of strata, creating a terraced terrain. More...
 
HeightMap Transform (Number a11, Number a12, Number a21, Number a22)
 Applies a linear transformation on the height map - each pixel pixel's position vector will be be multiplied by the transformation matrix composed from cells a11, a12, a21 and a22. More...
 
HeightMap TransformHeights (HeightProfile profile, Coordinate startingCoordinate, Coordinate endingCoordinate, Number minHeight, Number maxHeight)
 Maps the height in each pixel from the height map to another height, using a height profile as a transformation function. More...
 
HeightMap Unify (HeightMap other)
 Sets each pixel in the to the greater of the two corresponding heights in the current map and the other map. More...
 

Detailed Description

Two-dimensional height map.

X coordinates go from left (negative) to right (positive) in the horizontal direction and Y coordinates go from top (negative) to bottom (positive) in the vertical direction.

Examples:
conflux.ggs, dunesea.ggs, marshlands.ggs, ouroboros.ggs, and tepui.ggs.

Member Function Documentation

HeightMap HeightMap.Abs ( )

Replaces height in each pixel with its absolute value (makes negative heights positive).

Example:

yield HeightMap.Noise().Abs();
std_2d_abs.png
Returns
The height map itself (for call chaining).
Examples:
marshlands.ggs.
HeightMap HeightMap.Add ( Number/HeightMap  addend,
HeightMap  mask 
)

Adds a number or a corresponding pixel from another height map to each pixel in the height map.

If mask is provided, the addition in each pixel will be modulated by the mask. Heights less than 0 from the mask are considered to be 0.

Example with a numeric addend without a mask (forcing the heights at the tip of the cone to overflow):

yield HeightMap.RadialGradient([500, 500], 400, 1, -1).Add(0.5);
std_2d_add_number.png

Example with map addend:

var rectangle = HeightMap.Flat().FillRectangle([600, 400], [200, 200], 0.5);
yield HeightMap.RadialGradient([500, 500], 400, 0.7, -1).Add(rectangle);
std_2d_add_map.png

Example with map addend and a mask:

var main = HeightMap.RadialGradient([500, 500], 450, -0.5, 0.75);
var noise = HeightMap.Noise();
var mask = HeightMap.Clone(main).ClampHeights(0.1, 1);
yield main.Add(noise, mask); // Less of the noise will be added in the center, where there are lower heights in the mask
std_2d_add_map_mask.png
Parameters
addendThe addend.
mask(Optional) The mask.
Returns
The height map itself (for call chaining).
Examples:
conflux.ggs, dunesea.ggs, marshlands.ggs, ouroboros.ggs, and tepui.ggs.
HeightMap HeightMap.Blur ( Number  radius)

Blurs the height map with box blur algorithm with kernel of given radius.

Example:

var main = HeightMap.RadialGradient([500, 500], 450, 1, -1);
main.Unify(HeightMap.Gradient([0, 0], [1000, 0], -1, 1));
yield main.Blur(50);
std_2d_blur.png
See also
Box blur on Wikipedia
Parameters
radiusThe blur kernel size.
Returns
The height map itself (for call chaining).
Examples:
conflux.ggs, marshlands.ggs, ouroboros.ggs, and tepui.ggs.
static HeightMap HeightMap.CellNoise ( Number  meanCellSize,
Number  seed 
)
static

Creates a map filled with cell (Worley) noise.

Example:

var main = HeightMap.CellNoise(200);
yield main;
std_2d_cellnoise.png
See also
Worley noise
Parameters
meanCellSizeMean width/height of each cell. Must be greater than 0.
seed(Optional) Random seed. If not provided, 0 is used. This seed is always combined with the main script seed provided in script arguments to the script.
Returns
The height map.
HeightMap HeightMap.ClampHeights ( Number  min,
Number  max 
)

Replaces heights greater than max with max and less than min with min.

Example:

yield HeightMap.Noise().ClampHeights(-0.3, 0.3);
std_2d_clampheights.png
Parameters
minThe minimum height.
maxThe maximum height.
Returns
The height map itself (for call chaining).
Examples:
ouroboros.ggs.
static HeightMap HeightMap.Clone ( HeightMap  heightMap)
static

Creates a deep copy of another height map.

Example:

var main = HeightMap.RadialGradient([400, 500], 500, 1, 0);
var copy = HeightMap.Clone(main);
copy.Move([200, 0]);
yield main.Unify(copy);
std_2d_clone.png
Parameters
heightMapThe map to copy.
Returns
The height map.
Examples:
dunesea.ggs, and ouroboros.ggs.
HeightMap HeightMap.Combine ( HeightMap  other,
HeightMap  mask 
)

Replaces heights in each pixel with a height blended from that height and corresponding height from another height map.

The blending will be done according to the height in the mask - 1 will mean 100% of the current height map's height will be used, 0 will mean 100% of the height from the other height map will be used. Any heights in between will cause the two heights to be blended linearly. Heights less than 0 from the mask are considered to be 0.

Example:

var roughNoise = HeightMap.Noise();
var smoothNoise = HeightMap.Noise({256: 0.9}, 1); // Use different seed.
var mask = HeightMap.Gradient([300, 0], [700, 0], 0, 1).Blur(20); // Blur to remove hard edges on ends of the gradient
yield roughNoise.Combine(smoothNoise, mask);
std_2d_combine.png
Parameters
otherThe other map.
maskThe mask.
Returns
The height map itself (for call chaining).
Examples:
tepui.ggs.
static HeightMap HeightMap.ConvexityMap ( HeightMap  heightMap,
Number  radius 
)
static

Creates a map representing convexity of local areas (with radius) in another height map.

Positive heights in the convexity map indicate convex areas and negative heights indicate concave areas.

Example:

var main = HeightMap.Noise();
yield HeightMap.ConvexityMap(main, 50) as "ConvexityMap";
yield main;
std_2d_convexitymap.png
Parameters
heightMapThe height map.
radiusThe radius. Must be greater than 0.
Returns
The convexity map.
HeightMap HeightMap.Crop ( Point  firstRectanglePoint,
Point  secondRectanglePoint,
Number  replace 
)

Replaces all heights outside of an rectangle with replace.

Example:

yield HeightMap.RadialGradient([500, 500], 400, 1, 0).Crop([350, 250], [650, 750]);
std_2d_crop.png
Parameters
firstRectanglePointFirst point defining the rectangle.
secondRectanglePointSecond point defining the rectangle.
replace(Optional) The replacement height. 0 is used if not provided.
Returns
The height map.
HeightMap HeightMap.CropHeights ( Number  min,
Number  max,
Number  replace 
)

Replaces heights greater than max or less than min with replace.

Example:

yield HeightMap.Noise().ClampHeights(-0.3, 0.3);
std_2d_cropheights.png
Parameters
minThe minimum height.
maxThe maximum height.
replace(Optional) The replacement height. 0 is used if not provided.
Returns
The height map itself (for call chaining).
Examples:
tepui.ggs.
static HeightMap HeightMap.DistanceMap ( HeightMap  heightMap,
Number  maximumDistance 
)
static

Creates a map representing euclidean distance of each pixel of a height map to the closest pixel with height 0 or less.

The distance is capped at maximumDistance. Each pixel will have height proportional to its distance to the closest pixel with height 0 or less. Pixels with distance maximumDistance or greater will have height 1.

Example:

var noise = HeightMap.Noise(CreateNoiseLayers(64, 256));
yield HeightMap.DistanceMap(noise, 250);
std_2d_distancemap.png
See also
Distance transform on Wikipedia
Parameters
heightMapThe height map.
maximumDistanceThe maximum distance considered. Must be greater than 0.
Returns
The distance map.
Examples:
conflux.ggs.
HeightMap HeightMap.Distort ( Number  perturbationSize,
Number  maximumDistance,
Number  seed 
)

Distorts the map with random perturbations.

Example:

var profile = HeightProfile.Noise();
var main = HeightMap.Projection(profile, Direction.Vertical);
main.Rotate(DegToRad(30));
main.Distort(20, 64);
yield main;
std_2d_distort.png
Parameters
perturbationSizeWave length of the perturbation distance.
maximumDistanceMaximum distance by which a pixel can be moved.
seed(Optional) Random seed. If not provided, 0 is used. This seed is always combined with the main script seed provided in script arguments to the script.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.DrawLine ( Point  start,
Point  end,
Number  height 
)

Draws a 1 pixel wide line from start to end.

Example:

var main = HeightMap.Flat(1);
// Draw the star from lines
var angleStep = 360 / 16;
for(var angle = 0; angle < 360; angle += angleStep)
{
var point = [
500 + Cos(DegToRad(angle)) * 390,
500 + Sin(DegToRad(angle)) * 390];
main.DrawLine([500, 500], point, 0);
}
// Stroke the star
yield HeightMap.DistanceMap(main, 100);
std_2d_drawline.png
Parameters
startOne of the ending points.
endThe other ending point.
heightThe height.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.Fill ( Number  height)

Replaces each pixel with height.

Example:

yield HeightMap.Noise().Fill(0.5);
std_2d_fill.png
Parameters
heightThe height.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.FillRectangle ( Point  firstRectanglePoint,
Point  secondRectanglePoint,
Number  height 
)

Replaces each pixel in a rectangle with height.

Example:

yield HeightMap.Noise().FillRectangle([200, 200], [600, 800], 0.5);
std_2d_fillrectangle.png
Parameters
firstRectanglePointFirst point defining the rectangle.
secondRectanglePointSecond point defining the rectangle.
heightThe height.
Returns
The height map itself (for call chaining).
static HeightMap HeightMap.Flat ( Number  height)
static

Creates a height map with constant height.

Parameters
height(Optional) The height. If not provided, 0 is used.
Returns
The height map.
Examples:
conflux.ggs, and ouroboros.ggs.
HeightMap HeightMap.Flip ( Direction  direction)

Flips the map horizontally of vertically.

The transformation origin is [0, 0].

Example:

// Create the main ridge around row 0, because flip origin is [0, 0]
var main = HeightMap.Gradient([0, -300], [0, 300], 0, 1);
var profile = HeightProfile.Noise({64: 0.9 });
main.Shift(profile, 150, Direction.Vertical);
var flipped = HeightMap.Clone(main).Flip(Direction.Vertical);
main.Intersect(flipped);
main.Move([0,0500]);
yield main;
std_2d_flip.png
Parameters
directionThe direction.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.Glaciate ( Number  strength,
bool  includeNegative 
)

Exaggerates lower altitudes, making valley bases wider and peaks sharper.

Example:

var main = HeightMap.Noise();
yield main.Multiply(1.45).Glaciate(0.25, true);
std_2d_glaciate_25.png

The same height map with strength 1 and includeNegative set to false.

std_2d_glaciate_100.png
Parameters
strengthStrength of the effect. Must be greater than or equal to 0 and less than or equal to 1.
includeNegativeTrue if the effect is to be applied on negative heights. If false, negative heights will be ignored. The effect is mirrored on negative heights.
Returns
The height map itself (for call chaining).
Examples:
conflux.ggs.
static HeightMap HeightMap.Gradient ( Point  sourcePoint,
Point  destinationPoint,
Number  sourceHeight,
Number  destinationHeight 
)
static

Creates a linear height gradient going from sourceHeight at sourcePoint to destinationHeight at destinationPoint.

Pixels outside of the gradient strip are filled with height of source or destination, whichever is closer.

Example:

yield HeightMap.Gradient([200, 200], [700, 700], -1, 1);
std_2d_gradient.png
Parameters
sourcePointThe source point.
destinationPointThe destination point.
sourceHeightHeight at the source.
destinationHeightHeight at the destination.
Returns
The height map.
HeightMap HeightMap.Intersect ( HeightMap  other)

Sets each pixel in the to the less of the two corresponding heights in the current map and the other map.

Example:

var main = HeightMap.Gradient([0, 0], [1000, 0], 0, 1);
var other = HeightMap.Gradient([0, 0], [0, 1000], 0, 1);
yield main.Intersect(other);
std_2d_intersect.png
Parameters
otherThe other map.
Returns
The height map itself (for call chaining).
Examples:
dunesea.ggs, and marshlands.ggs.
HeightMap HeightMap.Invert ( )

Flips sign of each height in the map.

Example:

// Transforms absolute value noise into ridges
yield HeightMap.Noise().Abs().Invert().Add(1);
std_2d_invert.png
Returns
The height map itself (for call chaining).
Examples:
ouroboros.ggs.
HeightMap HeightMap.Move ( Point  offset)

Moves the height map by offset.

Example:

var main = HeightMap.Noise({256:1});
var copy = HeightMap.Clone(main).Move([150, 100]);
yield main.Unify(copy);
std_2d_move.png
Parameters
offsetThe offset. The map is moved by both of the offset's component coordinates in the respective direction.
Returns
The height map itself (for call chaining).
Examples:
ouroboros.ggs.
HeightMap HeightMap.Multiply ( Number/HeightMap  factor)

Multiplies the height in each pixel by a number or a corresponding pixel from another height map.

Example with a numeric factor:

yield HeightMap.Noise().Multiply(0.2);
std_2d_multiply_number.png

Example with map factor:

var main = HeightMap.Noise();
var multiplier = HeightMap.RadialGradient([500, 500], 400, 1, 0.2);
yield main.Multiply(multiplier);
std_2d_multiply_map.png
Parameters
factorThe factor.
Returns
A HeightMap.
Examples:
conflux.ggs, marshlands.ggs, ouroboros.ggs, and tepui.ggs.
static HeightMap HeightMap.Noise ( Array  layerDefinitions,
Number  seed 
)
static

Creates a height map filled with random perlin noise.

The layer definitions are an array of pairs wave length: amplitude. Wave length and amplitude must be greater than 0. Example:

yield HeightMap.Noise({1: 0.1, 8: 0.3, 512: 0.6 });
std_2d_noise_custom.png

The default value for layerDefinitions parameter is:

{
{1: 0.001953125},
{2: 0.00390625},
{4: 0.0078125},
{8: 0.015625},
{16: 0.03125},
{32: 0.0625},
{64: 0.125},
{128: 0.25},
{256: 0.5}
}

Which produces noise like this:

std_2d_noise_standard.png

TODO: Overshoots.

See also
Perlin noise
Parameters
layerDefinitions(Optional) Array defining layers of the noise. If not provided, a default array is used. This array can be created using CreateNoiseLayers.
seed(Optional) Random seed. If not provided, 0 is used. This seed is always combined with the main script seed provided in script arguments to the script.
Returns
The height map.
Examples:
conflux.ggs, dunesea.ggs, marshlands.ggs, ouroboros.ggs, and tepui.ggs.
static HeightMap HeightMap.Pattern ( HeightMap  pattern,
Point  firstRectanglePoint,
Point  secondRectanglePoint 
)
static

Creates a height map with a rectangular area of pattern repeating infinitely in all directions.

The repeating pattern will start at point [0, 0].

Example:

var pattern = HeightMap.RadialGradient([100, 100], 200, 1, -1);
yield HeightMap.Pattern(pattern, [0, 0], [200, 200]);
std_2d_pattern.png
Parameters
patternThe height map from which the pattern is copied.
firstRectanglePointFirst point defining the pattern rectangle.
secondRectanglePointSecond point defining the pattern rectangle.
Returns
The height map.
static HeightMap HeightMap.Projection ( HeightProfile  profile,
Direction  direction 
)
static

Creates a height map with a profile projected along direction.

Example:

var profile = HeightProfile.Noise();
std_2d_projection.png
Parameters
profileThe height profile.
directionThe projection direction.
Returns
The height map.
Examples:
marshlands.ggs.
static HeightMap HeightMap.RadialGradient ( Point  center,
Number  radius,
Number  centerHeight,
Number  rimHeight 
)
static

Creates a radial height gradient centered at center with radius.

It goes from centerHeight to rimHeight. Any pixels outside of the gradient will be filled with rimHeight.

Example:

yield HeightMap.RadialGradient([400, 400], 500, 1, 0);
std_2d_radial_gradient.png

RadialGradient can be combined with Multiply to create a cone with flat top:

yield HeightMap.RadialGradient([500, 500], 250, 1, -1).Multiply(3);
std_2d_radialgradient_cone.png
Parameters
centerThe source point.
radiusThe radius. Must not be negative.
centerHeightHeight at the source.
rimHeightHeight at the destination.
Returns
The height map.
Examples:
conflux.ggs, ouroboros.ggs, and tepui.ggs.
HeightMap HeightMap.Rescale ( Number  horizontalScale,
Number  verticalScale 
)

Enlarges (with scale > 1) or shrinks (with scale < 1) the entire map.

The scaling transformation has origin at [0, 0]. Uses linear interpolation.

Example:

// Create the template cone at [0, 0], otherwise its position would be scaled along with its size
var template = HeightMap.RadialGradient([0, 0], 300, 1, 0);
var main = HeightMap.Flat();
var cone = HeightMap.Clone(template).Move([200, 500]);
main.Unify(cone);
cone = HeightMap.Clone(template).Rescale(0.80).Multiply(0.80).Move([400, 500]);
main.Unify(cone);
cone = HeightMap.Clone(template).Rescale(0.60).Multiply(0.60).Move([600, 500]);
main.Unify(cone);
cone = HeightMap.Clone(template).Rescale(0.40).Multiply(0.40).Move([800, 500]);
main.Unify(cone);
yield main;
std_2d_rescale.png
Parameters
horizontalScaleThe horizontal scale ratio. Must be greater than 0.1 and less than 10.
verticalScale(Optional) The vertical scale ratio. If not provided, it will be the same as horizontalScale. Must be greater than 0.1 and less than 10.
Returns
The height map itself (for call chaining).
Examples:
ouroboros.ggs.
static HeightMap HeightMap.RidgedNoise ( Array  layerDefinitions,
Number  seed 
)
static

Creates a height map filled with random perlin noise with pronounced ridges.

See HeightMap.Noise for detailed description of the layerDefinitions.

Simple usage:

std_2d_ridgednoise.png
Parameters
layerDefinitions(Optional) Array defining layers of the noise. If not provided, a default array is used. This array can be created using CreateNoiseLayers.
seed(Optional) Random seed. If not provided, 0 is used. This seed is always combined with the main script seed provided in script arguments to the script.
Returns
The height map.
Examples:
conflux.ggs.
HeightMap HeightMap.Rotate ( Number  angle)

Rotates the height map by angle in radians clockwise.

The rotation origin is at [0, 0].

Example:

var main = HeightMap.Flat();
// Make the rectangle centered at [0, 0], because that point is the rotation origin.
main.FillRectangle([-300, -100], [600, 200], 1);
main.Rotate(DegToRad(45));
main.Move([500, 500]);
yield main;
std_2d_rotate.png
Parameters
angleThe angle in radians.
Returns
The height map itself (for call chaining).
Examples:
ouroboros.ggs.
HeightMap HeightMap.Shear ( Number  shearFactor,
Direction  direction 
)

Shears the height map by shearFactor in direction.

Example:

var main = HeightMap.Flat();
main.FillRectangle([200, 400], [600, 200], 1);
yield main;
std_2d_shear.png
See also
Shear mapping on Wikipedia
Parameters
shearFactorThe shear factor.
directionThe direction.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.Shift ( HeightProfile  profile,
Coordinate  maximumDistance,
Direction  direction 
)

Shifts each row (if direction is vertical) or column (if direction is horizontal) by distance determined by the corresponding height in the profile (1 in profile means the pixels will be shifted by maximumDistance, -1 means the pixels will be shifted by -maximumDistance).

Example:

var main = HeightMap.Gradient([200, 0], [800, 0], 0, 1);
var profile = HeightProfile.Noise({256: 0.7, 168: 0.3 });
main.Shift(profile, 300, Direction.Horizontal);
yield main;
std_2d_shift.png
Parameters
profileThe shift profile.
maximumDistanceThe maximum shift distance.
directionThe direction.
Returns
The height map itself (for call chaining).
Examples:
marshlands.ggs.
HeightMap HeightMap.Stratify ( Number  numberOfStrata,
Number  steepness,
Number  smoothness,
Boolean  includeNegative 
)

Distributes the heights among a specified number of strata, creating a terraced terrain.

Example:

yield HeightMap.Noise().Stratify(12, 0.5, 0.5, true);
std_2d_stratify.png
Parameters
numberOfStrataNumber of strata. Must be greater than or equal to 1 and less than or equal to 100.
steepness(Optional) Steepness of the cliffs. Must be greater than or equal to 0 and less than or equal to 1. Greater value means the cliffs are closer to vertical and the flat surfaces are flatter. 0.5 is used if not specified.
smoothness(Optional) Smoothness of edges of the cliffs. Must be greater than or equal to 0 and less than or equal to 1. 0.5 is used if not specified.
includeNegative(Optional) True if the effect is to be applied on negative heights. If false, negative heights will be ignored. true is used if not specified.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.Transform ( Number  a11,
Number  a12,
Number  a21,
Number  a22 
)

Applies a linear transformation on the height map - each pixel pixel's position vector will be be multiplied by the transformation matrix composed from cells a11, a12, a21 and a22.

The transformation matrix must be invertible.

Example:

var main = HeightMap.Flat();
main.FillRectangle([-300, -100], [600, 200], 1);
// The matrix combine 45 degree rotation, 0.4 horizontal shear and 0.5 vertical shear.
main.Transform(1.06066, 0.989949, -0.207183, 0.717005);
main.Move([500, 500]);
yield main;
std_2d_transform.png
Parameters
a11The top-left cell of the transformation matrix.
a12The top-right cell of the transformation matrix.
a21The bottom-left cell of the transformation matrix.
a22The bottom-right cell of the transformation matrix.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.TransformHeights ( HeightProfile  profile,
Coordinate  startingCoordinate,
Coordinate  endingCoordinate,
Number  minHeight,
Number  maxHeight 
)

Maps the height in each pixel from the height map to another height, using a height profile as a transformation function.

Height minHeight will map to height in profile at coordinate starting coordinate and height maxHeight will map to height at coordinate endingCordinate. Any heights in between will map to height at appropriate coordinate in between.

Example:

var main = HeightMap.RadialGradient([500, 500], 800, 1, 0);
main.TransformHeights(HeightProfile.Noise({64: 0.9}), 0, 1000);
yield main;
std_2d_transformheights.png
Parameters
profileThe transformation profile.
startingCoordinate(Optional) Starting coordinate of the interval of the transformation function used for mapping. If not provided, 0 is used.
endingCoordinate(Optional) Ending coordinate of the interval of the transformation function used for mapping. If not provided, 1000 is used.
minHeight(Optional) Minimum height affected by the transformation. If not provided, 0 is used.
maxHeight(Optional) Maximum height affected by the transformation. If not provided, 1 is used.
Returns
The height map itself (for call chaining).
HeightMap HeightMap.Unify ( HeightMap  other)

Sets each pixel in the to the greater of the two corresponding heights in the current map and the other map.

Example:

var main = HeightMap.Gradient([0, 0], [1000, 0], 0, 1);
var other = HeightMap.Gradient([0, 0], [0, 1000], 0, 1);
yield main.Unify(other);
std_2d_unify.png
Parameters
otherThe other map.
Returns
The height map itself (for call chaining).
Examples:
marshlands.ggs, and ouroboros.ggs.