Added functionality to heightmap to allow a word to be created the size of
the supplied heightmap - after all, that's what we will normally want.
This commit is contained in:
parent
601c7d74a6
commit
6ac4f55ed5
|
@ -6,6 +6,7 @@
|
||||||
(ns mw-engine.heightmap
|
(ns mw-engine.heightmap
|
||||||
(:import [java.awt.image BufferedImage])
|
(:import [java.awt.image BufferedImage])
|
||||||
(:use mw-engine.utils
|
(:use mw-engine.utils
|
||||||
|
mw-engine.world
|
||||||
;; interestingly the imagez load-image is failing for me, while the
|
;; interestingly the imagez load-image is failing for me, while the
|
||||||
;; collage version is problem free.
|
;; collage version is problem free.
|
||||||
[mikera.image.core :only [filter-image get-pixels]]
|
[mikera.image.core :only [filter-image get-pixels]]
|
||||||
|
@ -58,9 +59,14 @@
|
||||||
altitudes are modified (added to) by the altitudes in the heightmap. It is assumed that
|
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.
|
the heightmap is at least as large in x and y dimensions as the world.
|
||||||
|
|
||||||
* `world` a world, as defined in `world.clj`, q.v.;
|
* `world` a world, as defined in `world.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 image file."
|
* `imagepath` a file path or URL which indicates an image file."
|
||||||
[world imagepath]
|
([world imagepath]
|
||||||
;; bizarrely, the collage load-util is working for me, but the imagez version isn't.
|
;; bizarrely, the collage load-util is working for me, but the imagez version isn't.
|
||||||
(let [heightmap (filter-image (grayscale)(load-image imagepath))]
|
(let [heightmap (filter-image (grayscale)(load-image imagepath))]
|
||||||
(apply vector (map #(apply-heightmap-row % heightmap) world))))
|
(apply vector (map #(apply-heightmap-row % heightmap) world))))
|
||||||
|
([imagepath]
|
||||||
|
(let [heightmap (filter-image (grayscale)(load-image imagepath))
|
||||||
|
world (make-world (.getWidth heightmap) (.getHeight heightmap))]
|
||||||
|
(apply vector (map #(apply-heightmap-row % heightmap) world)))))
|
|
@ -1,4 +1,9 @@
|
||||||
;; A set of MicroWorld rules describing a simplified natural ecosystem.
|
;; A set of MicroWorld rules describing a simplified natural ecosystem.
|
||||||
|
;;
|
||||||
|
;; Since the completion of the rule language this is more or less obsolete -
|
||||||
|
;; there are still a few things that you can do with rules written in Clojure
|
||||||
|
;; that you can't do in the rule language, but not many and I doubt they're
|
||||||
|
;; important.
|
||||||
|
|
||||||
(ns mw-engine.natural-rules
|
(ns mw-engine.natural-rules
|
||||||
(:use mw-engine.utils
|
(:use mw-engine.utils
|
||||||
|
|
Loading…
Reference in a new issue