Improve shape documentation

This commit is contained in:
oakes
2014-04-04 03:06:49 -04:00
parent 3d00c2d16a
commit 52ef5b9a38
2 changed files with 12 additions and 9 deletions

View File

@@ -175,9 +175,8 @@
"SelectBox" {"select-box" :methods
"select-box!" :methods}
"SelectBox.SelectBoxStyle" {"style :select-box" :constructors}
"ShapeRenderer" {"shape!" :methods
"render-shapes!" :methods}
"ShapeRenderer.ShapeType" {"shape-type" :static-fields}
"ShapeRenderer" {"shape" :methods
"shape!" :methods}
"Skin" {"skin" :methods
"skin!" :methods}
"SkinLoader" {"loader :skin" :methods

View File

@@ -14,10 +14,7 @@
[object k & options]
`(u/call! ^Pixmap ~object ~k ~@options))
(defmacro shape-type
"Returns a static field from [ShapeRenderer.ShapeType](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.ShapeType.html).
(shape-type :filled)"
(defmacro shape-type*
[k]
`~(u/gdx-field :graphics :glutils "ShapeRenderer$ShapeType" (u/key->pascal k)))
@@ -30,14 +27,21 @@
(defmacro shape
"Returns an entity based on [ShapeRenderer](http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/graphics/glutils/ShapeRenderer.html).
(shape :filled)"
; create a red rectangle
(shape :filled
:set-color (color :red)
:rect 0 0 10 30)
; create an empty shape, then set it to a green rectangle
(shape (shape :filled)
:set-color (color :green)
:rect 0 0 10 30)"
[type & options]
(when (seq (clojure.set/intersection #{:begin :end} (set options)))
(-> "No need to call :begin or :end, because it's done for you."
Throwable.
throw))
`(let [entity# ~(if (keyword? type)
`(assoc (shape*) :type (shape-type ~type))
`(assoc (shape*) :type (shape-type* ~type))
type)
^ShapeRenderer object# (u/get-obj entity# :object)]
(assoc entity# :draw! (fn [] (u/calls! object# ~@options)))))