Liking cljdoc? Tell your friends :D

clunk.util


all-earsclj

(all-ears points)

Return all the ears of a polygon

Return all the ears of a polygon
raw docstring

bezier-curveclj

(bezier-curve start c1 c2 end & {:keys [samples] :or {samples 32}})

Generate a collection of [x y] points which describe a Bezier curve.

Generate a collection of `[x y]` points which describe a Bezier
curve.
raw docstring

bezier-pointclj

(bezier-point start c1 c2 end t)

Calculate a point on a Bezier curve using De Casteljau's algorithm via successive lerps.

start and end are the beginning and end of the line, c1 and c2 are the control points.

Calculate a point on a Bezier curve using De Casteljau's algorithm
via successive lerps.

`start` and `end` are the beginning and end of the line, `c1` and
`c2` are the control points.
raw docstring

centerclj

(center window)

The [x y] position vector at the center of the screen.

The `[x y]` position vector at the center of the screen.
raw docstring

centreclj


convex?clj

(convex? poly)

Are all the corners of the polygon turning in the same direction?

Are all the corners of the polygon turning in the same direction?
raw docstring

crossclj

(cross [ax ay az] [bx by bz])

Calculate the cross product of two vectors.

Calculate the cross product of two vectors.
raw docstring

direction-vectorclj

(direction-vector r)

Calculate the unit direction vector based on the rotation angle.

Calculate the unit direction vector based on the rotation angle.
raw docstring

ellipse-pointsclj

(ellipse-points [w h] & {:keys [num-points] :or {num-points 32}})

Generate a collection of [x y] points in CCW order around an ellipse with dimensions [w h].

The points are all in the [+x +y] quadrant so the clunk.sprite/pos-offsets function works by default.

Generate a collection of `[x y]` points in CCW order around an
ellipse with dimensions `[w h]`.

The points are all in the `[+x +y]` quadrant so the
`clunk.sprite/pos-offsets` function works by default.
raw docstring

invertclj

(invert v)

Multiply each component of the vector by -1.

Represents a rotation of 180 degrees.

Multiply each component of the vector by -1.

Represents a rotation of 180 degrees.
raw docstring

left-turn?clj

(left-turn? [ax ay] [bx by] [cx cy])

Is the corner from A->B->C a left turn?

Is the corner from A->B->C a left turn?
raw docstring

magnitudeclj

(magnitude v)

Calculate the length of a vector.

Calculate the length of a vector.
raw docstring

memo-triangulateclj


mouse-posclj

(mouse-pos window)

Get the current [x y] position of the mouse cursor.

Get the current `[x y]` position of the mouse cursor.
raw docstring

normalizeclj

(normalize v)

Calculate the unit vector of a given vector.

We calculate the reciprocal of the magnitude of the vector and multiply the components by this factor to avoid multiple division operations.

Calculate the unit vector of a given vector.

We calculate the reciprocal of the magnitude of the vector and
multiply the components by this factor to avoid multiple division
operations.
raw docstring

orthogonalsclj

(orthogonals [x y])

Calculate the two orthogonal vectors to a given 2D vector.

Y axis is inverted so this returns [90-degrees-right-vector 90-degrees-left-vector]

Calculate the two orthogonal vectors to a given 2D vector.

Y axis is inverted so this returns [90-degrees-right-vector
                                    90-degrees-left-vector]
raw docstring

other-pointsclj

(other-points i points)

Return the points which are not in the ear starting at index i

Return the points which are not in the ear starting at index `i`
raw docstring

poly-linesclj

(poly-lines poly)

Construct the lines that make up a polygon from its points.

Construct the lines that make up a polygon from its points.
raw docstring

pos-in-tri?clj

(pos-in-tri? pos [a b c])

Is the position pos inside the triangle ABC?

Is the position `pos` inside the triangle ABC?
raw docstring

remove-nthclj

(remove-nth n xs)

Remove the nth element from a collection.

Remove the nth element from a collection.
raw docstring

resource->direct-bytebufferclj

(resource->direct-bytebuffer resource-path)

rotate-vectorclj

(rotate-vector [x y :as v] r)

Rotate a vector about the origin by r degrees.

Checks first for r representing an integer number of rotations, in with case the vector will be unchanged.

Rotate a vector about the origin by `r` degrees.

Checks first for `r` representing an integer number of rotations, in
with case the vector will be unchanged.
raw docstring

rotation-angleclj

(rotation-angle [x y])

Calculate the rotation angle of a vector.

Calculate the rotation angle of a vector.
raw docstring

rounded-rect-pointsclj

(rounded-rect-points [w h] & {:keys [radius] :or {radius 60}})

Generate a collection of [x y] points in CCW order tracing a rectangle with rounded corners.

The points are all in the [+x +y] quadrant so the clunk.sprite/pos-offsets function works by default.

Generate a collection of `[x y]` points in CCW order tracing a
rectangle with rounded corners.

The points are all in the `[+x +y]` quadrant so the
`clunk.sprite/pos-offsets` function works by default.
raw docstring

split-byclj

(split-by pred coll)

Split a collection using a predicate.

Returns [things-that-were-true things-that-were-false].

Split a collection using a predicate.

Returns `[things-that-were-true things-that-were-false]`.
raw docstring

squared-magnitudeclj

(squared-magnitude [x y z])

Sum the squares of the components of a vector.

The if check on z is a lot faster than doing an apply or reduce across the vector.

Sum the squares of the components of a vector.

The `if` check on `z` is a lot faster than doing an `apply` or
`reduce` across the vector.
raw docstring

triangulateclj

(triangulate poly)

Split a concave polygon with no holes or overlapping edges into a collection of triangles which can be drawn.

Split a concave polygon with no holes or overlapping edges into a
collection of triangles which can be drawn.
raw docstring

unit-vectorclj

(unit-vector v)

Calculate the unit vector of a given vector.

Calculate the unit vector of a given vector.
raw docstring

v<clj

(v< a b)

Determine if the magnitude of a vector a is less than the magnitude of vector b.

We can just compare the component squares to avoid the costly sqrt operations.

Determine if the magnitude of a vector `a` is less than the magnitude
of vector `b`.

We can just compare the component squares to avoid the costly `sqrt`
operations.
raw docstring

v<=clj

(v<= a b)

Determine if the magnitude of a vector a is less than or equal to the magnitude of vector b.

We can just compare the component squares to avoid the costly sqrt operations.

Determine if the magnitude of a vector `a` is less than or equal to
the magnitude of vector `b`.

We can just compare the component squares to avoid the costly `sqrt`
operations.
raw docstring

window-posclj

(window-pos window [x-factor y-factor])

Create an [x y] position vector at the specified ratio coordinates.

Create an `[x y]` position vector at the specified ratio
coordinates.
raw docstring

window-sizeclj

(window-size window)

zero-vector?clj

(zero-vector? v)

Predicate to check if a vector has length 0.

Predicate to check if a vector has length 0.
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close