Returns an entity based on ShapeRenderer. You may pass in a type (see shape-type) or an existing shape entity that you want to modify.
A shape can draw multiple sub-shapes internally, allowing you to create more complicated shapes. If you use assoc to set the overall :x and :y of the shape, each sub-shape's x and y position will be relative to it.
; create a green and red rectangle
(shape :filled
:set-color (color :green)
:rect 0 0 10 30
:set-color (color :red)
:rect 10 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)
; create a green rectangle at 10,10 and rotate it 45 degrees
(assoc (shape :filled
:set-color (color :green)
:rect 0 0 10 30)
:x 10
:y 10
:angle 45)
Options
:arc^float x, ^float y, ^float radius, ^float start, ^float degrees
Calls {@link #arc(float, float, float, float, float, int)} by estimating the number of segments needed for a smooth arc.
:arc^float x, ^float y, ^float radius, ^float start, ^float degrees, ^int segments
Draws an arc using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:begin
Begins a new batch without specifying a shape type.
:begin^ShapeRenderer.ShapeType type
Starts a new batch of shapes. Shapes drawn within the batch will attempt to use the type specified. The call to this method
must be paired with a call to {@link #end()}.
:box^float x, ^float y, ^float z, ^float width, ^float height, ^float depth
Draws a cube using {@link ShapeType#Line} or {@link ShapeType#Filled}. The x, y and z specify the bottom, left, front corner
of the rectangle.
:circle^float x, ^float y, ^float radius
Calls {@link #circle(float, float, float, int)} by estimating the number of segments needed for a smooth circle.
:circle^float x, ^float y, ^float radius, ^int segments
Draws a circle using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:cone^float x, ^float y, ^float z, ^float radius, ^float height
Calls {@link #cone(float, float, float, float, float, int)} by estimating the number of segments needed for a smooth
circular base.
:cone^float x, ^float y, ^float z, ^float radius, ^float height, ^int segments
Draws a cone using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:curve^float x1, ^float y1, ^float cx1, ^float cy1, ^float cx2, ^float cy2, ^float x2, ^float y2, ^int segments
Draws a curve using {@link ShapeType#Line}.
:dispose
:ellipse^float x, ^float y, ^float width, ^float height
Calls {@link #ellipse(float, float, float, float, int)} by estimating the number of segments needed for a smooth ellipse.
:ellipse^float x, ^float y, ^float width, ^float height, ^int segments
Draws an ellipse using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:ellipse^float x, ^float y, ^float width, ^float height, ^float rotation
Calls {@link #ellipse(float, float, float, float, float, int)} by estimating the number of segments needed for a smooth ellipse.
:ellipse^float x, ^float y, ^float width, ^float height, ^float rotation, ^int segments
Draws an ellipse using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:end
Finishes the batch of shapes and ensures they get rendered.
:flush
:get-color
:get-current-type
Returns the current shape type.
:get-projection-matrix
If the matrix is modified, {@link #updateMatrices()} must be called.
:get-renderer
:get-transform-matrix
If the matrix is modified, {@link #updateMatrices()} must be called.
:identity
Sets the transformation matrix to identity.
:is-drawing
:line^float x, ^float y, ^float z, ^float x2, ^float y2, ^float z2
Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:line^Vector3 v0, ^Vector3 v1
:line^float x, ^float y, ^float x2, ^float y2
:line^Vector2 v0, ^Vector2 v1
:line^float x, ^float y, ^float x2, ^float y2, ^Color c1, ^Color c2
:line^float x, ^float y, ^float z, ^float x2, ^float y2, ^float z2, ^Color c1, ^Color c2
Draws a line using {@link ShapeType#Line} or {@link ShapeType#Filled}. The line is drawn with two colors interpolated
between the start and end points.
:point^float x, ^float y, ^float z
Draws a point using {@link ShapeType#Point}, {@link ShapeType#Line} or {@link ShapeType#Filled}.
:polygon^float[] vertices, ^int offset, ^int count
Draws a polygon in the x/y plane using {@link ShapeType#Line}. The vertices must contain at least 3 points (6 floats x,y).
:polygon^float[] vertices
:polyline^float[] vertices, ^int offset, ^int count
Draws a polyline in the x/y plane using {@link ShapeType#Line}. The vertices must contain at least 2 points (4 floats x,y).
:polyline^float[] vertices
:rect^float x, ^float y, ^float width, ^float height
Draws a rectangle in the x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:rect^float x, ^float y, ^float width, ^float height, ^Color col1, ^Color col2, ^Color col3, ^Color col4
Draws a rectangle in the x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}. The x and y specify the lower
left corner.
:rect^float x, ^float y, ^float origin-x, ^float origin-y, ^float width, ^float height, ^float scale-x, ^float scale-y, ^float degrees
Draws a rectangle in the x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}. The x and y specify the lower
left corner. The originX and originY specify the point about which to rotate the rectangle.
:rect^float x, ^float y, ^float origin-x, ^float origin-y, ^float width, ^float height, ^float scale-x, ^float scale-y, ^float degrees, ^Color col1, ^Color col2, ^Color col3, ^Color col4
Draws a rectangle in the x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}. The x and y specify the lower
left corner. The originX and originY specify the point about which to rotate the rectangle.
:rect-line^float x1, ^float y1, ^float x2, ^float y2, ^float width
Draws a line using a rotated rectangle, where with one edge is centered at x1, y1 and the opposite edge centered at x2, y2.
:rect-line^Vector2 p1, ^Vector2 p2, ^float width
:rotate^float axis-x, ^float axis-y, ^float axis-z, ^float degrees
Multiplies the current transformation matrix by a rotation matrix.
:scale^float scale-x, ^float scale-y, ^float scale-z
Multiplies the current transformation matrix by a scale matrix.
:set^ShapeRenderer.ShapeType type
:set-auto-shape-type^boolean auto-shape-type
If true, when drawing a shape cannot be performed with the current shape type, the batch is flushed and the shape type is
changed automatically. This can increase the number of batch flushes if care is not taken to draw the same type of shapes
together. Default is false.
:set-color^Color color
Sets the color to be used by the next shapes drawn.
:set-color^float r, ^float g, ^float b, ^float a
Sets the color to be used by the next shapes drawn.
:set-projection-matrix^Matrix4 matrix
Sets the projection matrix to be used for rendering. Usually this will be set to {@link Camera#combined}.
:set-transform-matrix^Matrix4 matrix
:translate^float x, ^float y, ^float z
Multiplies the current transformation matrix by a translation matrix.
:triangle^float x1, ^float y1, ^float x2, ^float y2, ^float x3, ^float y3
Draws a triangle in x/y plane using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:triangle^float x1, ^float y1, ^float x2, ^float y2, ^float x3, ^float y3, ^Color col1, ^Color col2, ^Color col3
Draws a triangle in x/y plane with colored corners using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:update-matrices
:x^float x, ^float y, ^float size
Draws two crossed lines using {@link ShapeType#Line} or {@link ShapeType#Filled}.
:x^Vector2 p, ^float size
Source
(defn shape*
([]
(ShapeEntity. (ShapeRenderer.)))
([max-vertices]
(ShapeEntity. (ShapeRenderer. max-vertices))))(defmacro shape
[type & options]
(assert (empty? (clojure.set/intersection #{:begin :end} (set options)))
"No need to call :begin or :end, because it's done for you.")
`(let [entity# ~(if (keyword? type)
`(assoc (shape*) :type (shape-type ~type))
type)
^ShapeRenderer object# (u/get-obj entity# :object)]
(assoc entity# :draw! (fn [] (u/calls! object# ~@options)))))