Add mutations to the image function

This commit is contained in:
oakes
2014-01-03 10:14:39 -05:00
parent 77081f74f9
commit 33367be7aa

View File

@@ -33,22 +33,25 @@
; textures ; textures
(defn image (defn image
[val] [val & {:keys [] :as options}]
(if (string? val) (let [^TextureRegion
(-> ^String val Texture. TextureRegion.) img (if (string? val)
(TextureRegion. ^TextureRegion 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 (defn image-width
([^TextureRegion img] [^TextureRegion img]
(.getRegionWidth img)) (.getRegionWidth img))
([img val]
(doto ^TextureRegion (image img) (.setRegionWidth val))))
(defn image-height (defn image-height
([^TextureRegion img] [^TextureRegion img]
(.getRegionHeight img)) (.getRegionHeight img))
([img val]
(doto ^TextureRegion (image img) (.setRegionHeight val))))
(defn split-image (defn split-image
([val size] ([val size]