From 33367be7aaa02d5ca0463772cf4caedb839e8b05 Mon Sep 17 00:00:00 2001 From: oakes Date: Fri, 3 Jan 2014 10:14:39 -0500 Subject: [PATCH] Add mutations to the image function --- src/play_clj/core_2d.clj | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/play_clj/core_2d.clj b/src/play_clj/core_2d.clj index ca0b255..7943fb9 100644 --- a/src/play_clj/core_2d.clj +++ b/src/play_clj/core_2d.clj @@ -33,22 +33,25 @@ ; textures (defn image - [val] - (if (string? val) - (-> ^String val Texture. TextureRegion.) - (TextureRegion. ^TextureRegion val))) + [val & {:keys [] :as options}] + (let [^TextureRegion + img (if (string? val) + (-> ^String val Texture. TextureRegion.) + (TextureRegion. ^TextureRegion val))] + (doseq [[k v] options] + (case k + :width (.setRegionWidth img v) + :height (.setRegionHeight img v) + nil)) + img)) (defn image-width - ([^TextureRegion img] - (.getRegionWidth img)) - ([img val] - (doto ^TextureRegion (image img) (.setRegionWidth val)))) + [^TextureRegion img] + (.getRegionWidth img)) (defn image-height - ([^TextureRegion img] - (.getRegionHeight img)) - ([img val] - (doto ^TextureRegion (image img) (.setRegionHeight val)))) + [^TextureRegion img] + (.getRegionHeight img)) (defn split-image ([val size]