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:
Simon Brooke 2014-07-17 09:50:22 +01:00
parent 601c7d74a6
commit 6ac4f55ed5
2 changed files with 15 additions and 4 deletions

View file

@ -6,6 +6,7 @@
(ns mw-engine.heightmap
(:import [java.awt.image BufferedImage])
(:use mw-engine.utils
mw-engine.world
;; interestingly the imagez load-image is failing for me, while the
;; collage version is problem free.
[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
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."
[world imagepath]
([world imagepath]
;; bizarrely, the collage load-util is working for me, but the imagez version isn't.
(let [heightmap (filter-image (grayscale)(load-image imagepath))]
(apply vector (map #(apply-heightmap-row % heightmap) world))))
(let [heightmap (filter-image (grayscale)(load-image imagepath))]
(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)))))

View file

@ -1,4 +1,9 @@
;; 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
(:use mw-engine.utils