mw-engine.heightmap
Functions to apply a heightmap to a world.
Heightmaps are considered only as greyscale images, so colour is redundent (will be ignored). Darker shades are higher.
apply-heightmap
(apply-heightmap world imagepath)
(apply-heightmap imagepath)
Apply the image file loaded from this path to this world, and return a world whose altitudes are modified (added to) by the altitudes in the heightmap. It is assumed that the heightmap is at least as large in x and y dimensions as the world. Note that, in addition to setting the :altitude
of each cell, this function also sets the :gradient
.
world
a world, as defined inworld.clj
, q.v.; if world is not supplied, a world the size of the heightmap will be created;imagepath
a file path or URL which indicates an (ideally greyscale) image file.
apply-valuemap
(apply-valuemap world imagepath property)
Generalised from apply-heightmap, set an arbitrary property on each cell of this world
from the values in this (ideally greyscale) heightmap.
world
a world, as defined inworld.clj
, q.v.;imagepath
a file path or URL which indicates an (ideally greyscale) image file;property
the property of each cell whose value should be added to from the intensity of the corresponding cell of the image.
tag-altitude
(tag-altitude _ cell heightmap)
(tag-altitude cell heightmap)
Set the altitude of this cell from the corresponding pixel of this heightmap. If the heightmap you supply is smaller than the world, this will break.
world
not actually used, but present to enable this function to be passed as an argument tomw-engine.utils/map-world
, q.v.;cell
a cell, as discussed in world.clj, q.v. Alternatively, a map;heightmap
an (ideally) greyscale image, whose x and y dimensions should exceed those of the world of which thecell
forms part.
tag-gradient
(tag-gradient world cell)
Set the gradient
property of this cell
of this world
to the difference in altitude between its highest and lowest neghbours.
tag-gradients
(tag-gradients world)
Set the gradient
property of each cell in this world
to the difference in altitude between its highest and lowest neghbours.
tag-property
(tag-property _ cell property heightmap)
(tag-property cell property heightmap)
Set the value of this property
of this cell from the corresponding pixel of this heightmap
. If the heightmap you supply is smaller than the world, this will break.
world
not actually used, but present to enable this function to be passed as an argument tomw-engine.utils/map-world
, q.v.cell
a cell, as discussed in world.clj, q.v. Alternatively, a map;property
the property (normally a keyword) whose value will be set on the cell.heightmap
an (ideally) greyscale image, whose x and y dimensions should exceed those of the world of which thecell
forms part.