Allow creating textures from pixmaps
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
(ns play-clj.g2d
|
(ns play-clj.g2d
|
||||||
(:require [play-clj.utils :as u])
|
(:require [play-clj.utils :as u])
|
||||||
(:import [com.badlogic.gdx.graphics Texture]
|
(:import [com.badlogic.gdx.graphics Pixmap Texture]
|
||||||
[com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch
|
[com.badlogic.gdx.graphics.g2d Animation BitmapFont NinePatch
|
||||||
ParticleEffect TextureAtlas TextureRegion]
|
ParticleEffect TextureAtlas TextureRegion]
|
||||||
[play_clj.entities TextureEntity NinePatchEntity
|
[play_clj.entities TextureEntity NinePatchEntity
|
||||||
@@ -22,6 +22,8 @@
|
|||||||
(cond
|
(cond
|
||||||
(string? arg)
|
(string? arg)
|
||||||
(-> ^String arg Texture. TextureRegion.)
|
(-> ^String arg Texture. TextureRegion.)
|
||||||
|
(isa? (type arg) Pixmap)
|
||||||
|
(-> ^Pixmap arg Texture. TextureRegion.)
|
||||||
(:object arg)
|
(:object arg)
|
||||||
(TextureRegion. ^TextureRegion (:object arg))
|
(TextureRegion. ^TextureRegion (:object arg))
|
||||||
:else
|
:else
|
||||||
@@ -31,10 +33,10 @@
|
|||||||
"Returns an entity based on [TextureRegion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureRegion.html).
|
"Returns an entity based on [TextureRegion](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/g2d/TextureRegion.html).
|
||||||
|
|
||||||
(texture \"image.png\")
|
(texture \"image.png\")
|
||||||
(texture \"image.png\" :flip true false)
|
|
||||||
(texture \"image.png\"
|
(texture \"image.png\"
|
||||||
:flip true false
|
:flip true false
|
||||||
:set-region 0 0 100 100)"
|
:set-region 0 0 100 100)
|
||||||
|
(texture (texture \"image.png\"))"
|
||||||
[arg & options]
|
[arg & options]
|
||||||
`(let [entity# (texture* ~arg)]
|
`(let [entity# (texture* ~arg)]
|
||||||
(u/calls! ^TextureRegion (u/get-obj entity# :object) ~@options)
|
(u/calls! ^TextureRegion (u/get-obj entity# :object) ~@options)
|
||||||
|
|||||||
Reference in New Issue
Block a user