Companion

Makes shapes.

Properties

Link copied to clipboard
const val MAX_VERTICES: Int = 16

Most points a polygon may have.

Functions

Link copied to clipboard
fun box(width: Float, height: Float, x: Float = 0.0f, y: Float = 0.0f, angle: Float = 0.0f): Shape

Returns a box width by height centred on (x, y), turned by angle radians.

Link copied to clipboard
fun capsule(length: Float, radius: Float, x: Float = 0.0f, y: Float = 0.0f, angle: Float = 0.0f): Shape

Returns a pill length long between its two caps' centres, and radius round, centred on (x, y) and lying along x, turned by angle radians. End to end it is length + 2 · radius.

Link copied to clipboard
fun circle(radius: Float, x: Float = 0.0f, y: Float = 0.0f): Shape

Returns a circle of radius centred on (x, y).

Link copied to clipboard
fun polygon(points: List<Vec2>): Shape

Returns a convex polygon through points, which may go round either way: polygon(listOf(Vec2(0f, 0f), Vec2(20f, 0f), Vec2(10f, 15f))) is a triangle. A dent, a crossing, or points in a line are refused: a concave shape is made of several convex ones, as a compound body.