Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/maps/random/rmgen/painter/PerlinPainter.js
- This file was added.
/** | |||||
* Perlin noise painter. | |||||
* @param {number} iterations - Must be > 0. The higher the more detailed the noise. | |||||
* @param {number} scale - A value > 1 zooms in and < 1 zooms out the noise. | |||||
FeXoR: Specify that the is an array of Vector2D objects representing tiles. | |||||
Done Inline ActionsMust* Krinkle: Must* | |||||
* @param {number} multiplier - Range (0,1). Frequency reduction after each iteration. | |||||
* @param {boolean} type - ELEVATION_MODIFY or ELEVATION_SET. | |||||
* @param {number} verticalScale - Vertical scale of the values height. | |||||
* @param {number} positive - If true height will be posititve, if false can be both. | |||||
* @param {number} baseHeight - Initial height if type == ELEVATION_SET. | |||||
*/ | |||||
function PerlinPainter(iterations = 3, scale = 5, multiplier = 0.75, type = ELEVATION_MODIFY, verticalScale = 1, positive = true, baseHeight = 0) | |||||
Done Inline ActionsI think there are no caps https://jsdoc.app/tags-returns.html for js doc Stan: I think there are no caps https://jsdoc.app/tags-returns.html for js doc
also if it's an array… | |||||
{ | |||||
this.iterations = iterations; | |||||
this.scale = scale; | |||||
this.multiplier = multiplier; | |||||
this.type = type; | |||||
this.positive = positive; | |||||
this.verticalScale = verticalScale; | |||||
this.positive = positive; | |||||
this.baseHeight = baseHeight; | |||||
} | |||||
PerlinPainter.prototype.paint = function (area) | |||||
{ | |||||
for (let point of area.getPoints()) | |||||
{ | |||||
let height = perlinNoise(point, this.iterations, this.scale, this.multiplier); | |||||
if (this.positive) | |||||
height = height / 2 + 0.5; | |||||
height *= this.verticalScale; | |||||
if (this.type == ELEVATION_SET) | |||||
height += this.baseHeight; | |||||
else | |||||
height += g_Map.getHeight(point); | |||||
g_Map.setHeight(point, height); | |||||
}; | |||||
} |
Wildfire Games · Phabricator
Specify that the is an array of Vector2D objects representing tiles.