Preparation to work client-side.
This commit is contained in:
parent
6237eab0cd
commit
b9ee9d138a
5 changed files with 29 additions and 19 deletions
|
|
@ -56,8 +56,10 @@
|
|||
"Apply a single `rule` to a `cell`. What this is about is that I want to be able,
|
||||
for debugging purposes, to tag a cell with the rule text of the rule which
|
||||
fired (and especially so when an exception is thrown. So a rule may be either
|
||||
an ifn, or a list (ifn source-text). This function deals with despatching
|
||||
on those two possibilities. `world` is also passed in in order to be able
|
||||
an ifn, a list (ifn source-text), or a list (ifn {:rule source-text :clojure
|
||||
generated-function}.
|
||||
This function deals with despatching on those three possibilities. `world`
|
||||
is also passed in in order to be able
|
||||
to access neighbours."
|
||||
([world cell rule]
|
||||
(cond
|
||||
|
|
@ -66,6 +68,7 @@
|
|||
([world cell rule source]
|
||||
(let [result (apply rule (list cell world))]
|
||||
(cond
|
||||
(and result source (map? source)) (merge result source)
|
||||
(and result source) (merge result {:rule source})
|
||||
true result))))
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,7 @@
|
|||
:author "Simon Brooke"}
|
||||
microworld.engine.heightmap
|
||||
(:import [java.awt.image BufferedImage])
|
||||
(:require [fivetonine.collage.util :as collage :only [load-image]]
|
||||
[mikera.image.core :as imagez :only [filter-image get-pixels]]
|
||||
(:require [mikera.image.core :as imagez :only [filter-image get-pixels]]
|
||||
[mikera.image.filters :as filters]
|
||||
[microworld.engine.utils :refer [abs get-int get-neighbours map-world]]
|
||||
[microworld.engine.world :refer [make-world]]))
|
||||
|
|
@ -107,15 +106,15 @@
|
|||
* `imagepath` a file path or URL which indicates an (ideally greyscale) image file."
|
||||
([world imagepath]
|
||||
(let [heightmap (imagez/filter-image
|
||||
(filters/grayscale)
|
||||
(collage/load-image imagepath))]
|
||||
(imagez/load-image-resource imagepath)
|
||||
(filters/grayscale))]
|
||||
(map-world
|
||||
(map-world world tag-altitude (list heightmap))
|
||||
tag-gradient)))
|
||||
([imagepath]
|
||||
(let [heightmap (imagez/filter-image
|
||||
(filters/grayscale)
|
||||
(collage/load-image imagepath))
|
||||
(imagez/load-image-resource imagepath)
|
||||
(filters/grayscale))
|
||||
world (make-world (.getWidth heightmap) (.getHeight heightmap))]
|
||||
(map-world
|
||||
(map-world world tag-altitude (list heightmap))
|
||||
|
|
@ -132,6 +131,6 @@
|
|||
intensity of the corresponding cell of the image."
|
||||
[world imagepath property]
|
||||
(let [heightmap (imagez/filter-image
|
||||
(filters/grayscale)
|
||||
(collage/load-image imagepath))]
|
||||
(imagez/load-image-resource imagepath)
|
||||
(filters/grayscale))]
|
||||
(map-world world tag-property (list property heightmap))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue