From cd99f8fd0be5352a6afc20de6c26ae9ffbaa1857 Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Wed, 30 Jul 2014 12:33:45 +0100 Subject: [PATCH] Gone back (hopefully temporarily) to using collage load-image function while I try to sort out the resources issue. This isn't very satisfactory, as the collage distribution is compiled using Java 7, which is going to break for some people, and because I'm bloating my code with two separate image libraries. --- buildall.sh | 2 +- project.clj | 3 ++- src/mw_engine/heightmap.clj | 16 ++++++++++------ test/mw_engine/heightmap_test.clj | 3 ++- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/buildall.sh b/buildall.sh index 7f72cde..a68de45 100755 --- a/buildall.sh +++ b/buildall.sh @@ -251,7 +251,7 @@ do fi # if nothing broke so far, clean up... - # rm -rf "${tmp}" + rm -rf "${tmp}" popd done diff --git a/project.clj b/project.clj index 8c2ae67..f777a2e 100644 --- a/project.clj +++ b/project.clj @@ -15,4 +15,5 @@ :dependencies [[org.clojure/clojure "1.5.1"] [org.clojure/math.combinatorics "0.0.7"] [org.clojure/tools.trace "0.7.8"] - [net.mikera/imagez "0.3.1"]]) + [net.mikera/imagez "0.3.1"] + [fivetonine/collage "0.2.0"]]) diff --git a/src/mw_engine/heightmap.clj b/src/mw_engine/heightmap.clj index 98d540d..b31008e 100644 --- a/src/mw_engine/heightmap.clj +++ b/src/mw_engine/heightmap.clj @@ -6,10 +6,10 @@ (ns mw-engine.heightmap (:import [java.awt.image BufferedImage]) (:use mw-engine.utils - mw-engine.world - [mikera.image.core :only [load-image filter-image get-pixels]] - [mikera.image.filters] - )) + mw-engine.world) + (:require [fivetonine.collage.util :as collage] + [mikera.image.core :as imagez :only [filter-image get-pixels]] + [mikera.image.filters :as filters])) (defn- abs "Surprisingly, Clojure doesn't seem to have an abs function, or else I've @@ -70,12 +70,16 @@ a world the size of the heightmap will be created. * `imagepath` a file path or URL which indicates an image file." ([world imagepath] - (let [heightmap (filter-image (grayscale)(load-image imagepath))] + (let [heightmap (imagez/filter-image + (filters/grayscale) + (collage/load-image imagepath))] (map-world (map-world world tag-altitude (list heightmap)) tag-gradient))) ([imagepath] - (let [heightmap (filter-image (grayscale)(load-image imagepath)) + (let [heightmap (imagez/filter-image + (filters/grayscale) + (collage/load-image imagepath)) world (make-world (.getWidth heightmap) (.getHeight heightmap))] (map-world (map-world world tag-altitude (list heightmap)) diff --git a/test/mw_engine/heightmap_test.clj b/test/mw_engine/heightmap_test.clj index 2925b5f..eb10b64 100644 --- a/test/mw_engine/heightmap_test.clj +++ b/test/mw_engine/heightmap_test.clj @@ -1,11 +1,12 @@ (ns mw-engine.heightmap-test + (:use clojure.java.io) (:require [clojure.test :refer :all] [mw-engine.heightmap :refer :all] [clojure.math.combinatorics :as combo])) (deftest apply-heightmap-test (testing "Heightmap functionality" - (let [world (apply-heightmap "heightmaps/test9x9.png") + (let [world (apply-heightmap (as-file "resources/heightmaps/test9x9.png")) altitudes (map #(:altitude %) (flatten world)) gradients (map #(:gradient %) (flatten world))] (is (= (count world) 9) "World should be 9x9")