Package-level declarations

Types

Link copied to clipboard
class Circle(val center: Point, radius: Double) : Ellipse

A circle defined by a center point and radius.

Link copied to clipboard
abstract class ConvexPolygon : Polygon

A Polygon with internal angles all <= 180°

Link copied to clipboard
open class Ellipse(val center: Point, xRadius: Double, yRadius: Double) : Shape

An Ellipse centered at center, with xRadius and yRadius as its radii.

Link copied to clipboard
value class Path

Represents a path-command string as defined by: https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d#Path_commands

Link copied to clipboard
sealed interface PathBuilder

Provides a way to create Paths programmatically.

Link copied to clipboard
interface PathMetrics

Provides a mechanism to measure the size of a Path.

Link copied to clipboard
sealed interface Point : Vector3D

A two-dimensional vector with an x and y component.

Link copied to clipboard
abstract class Polygon : Shape

A Shape defined by a set of line segments that connect to enclose a region.

Link copied to clipboard
class Rectangle(val position: Point = Origin, val size: Size = Size.Empty) : ConvexPolygon

A rectangular ConvexPolygon with 4 sides at right-angles.

Link copied to clipboard
typealias SegmentBuilder = PathBuilder.(current: Point, end: Point) -> Unit

Determines how to connect current and end points in a Path

Link copied to clipboard
interface Shape

Objects implementing this interface represent shapes.

Link copied to clipboard
class Size

A width and height pair that denote a rectangular area.

Link copied to clipboard
typealias Vector2D = Point
Link copied to clipboard
sealed interface Vector3D

A three-dimensional vector with an x, y and z component.

Properties

Link copied to clipboard

Inherited properties

Link copied to clipboard

The circle's circumference (2 * PI * Circle.radius)

Link copied to clipboard

The circle's diameter (2 * Circle.radius)

Link copied to clipboard

Creates a builder that is initialized with the current path and allows further modifications. The resulting path from that builder is different from the one then was called on.

Functions

Link copied to clipboard
fun circle(center: Point, radius: Double, direction: RotationDirection): Path

Creates a circle path. The direction flag allows multiple circles to be combined to create circular holes. A ring can be created by joining an outer and inner circle with opposite directions.

Link copied to clipboard
fun lerp(first: Vector2D, second: Vector2D, fraction: Float): Vector2D

Interpolates between 2 points

fun lerp(first: Rectangle, second: Rectangle, fraction: Float): Rectangle

Interpolates between 2 Rectangles

fun lerp(first: Size, second: Size, fraction: Float): Size

Interpolates between 2 Sizes

Link copied to clipboard
fun path(from: Point): PathBuilder

Creates a Path at the given point and a builder to further define it.

fun path(data: String): Path?

Creates a Path from the path data string.

Creates a Path at the given x,y and a builder to further define it.

Link copied to clipboard
fun ring(center: Point, innerRadius: Double, outerRadius: Double): Path

Creates ring (donut) path.

Link copied to clipboard
fun ringSection(    center: Point,     innerRadius: Double,     outerRadius: Double,     start: Measure<Angle>,     end: Measure<Angle>,     startCap: SegmentBuilder = { _,_ -> },     endCap: SegmentBuilder = { _,it -> lineTo(it) }): Path

Creates a path for a section of a ring (donut) shape. The direction of sweep is controlled by the sign of end - start.

Link copied to clipboard
fun semicircle(center: Point, radius: Double, start: Measure<Angle>, end: Measure<Angle>): Path

Creates a path for a semicircle. The direction of sweep is controlled by the sign of end - start.

Link copied to clipboard
fun star(circle: Circle, points: Int = 5, rotation: Measure<Angle> = 0 * degrees, innerCircle: Circle): Polygon?
fun star(circle: Circle, points: Int = 5, rotation: Measure<Angle> = 0 * degrees, innerCircleRatio: Float = starDefaultInnerCircleRatio): Polygon?

Creates a Star with n points that is described by an outer and inner Circle, which its concave and convex points respectively.

fun star(circle: Circle, points: Int = 5, rotation: Measure<Angle> = 0 * degrees, innerCircle: Circle, pointRoundness: Float): Path?
fun star(    circle: Circle,     points: Int = 5,     rotation: Measure<Angle> = 0 * degrees,     innerCircleRatio: Float = starDefaultInnerCircleRatio,     pointRoundness: Float): Path?

Creates a rounded star.

Inherited functions

Link copied to clipboard
fun Circle.at(point: Point): Circle
Link copied to clipboard
Link copied to clipboard

Returns a new Rectangle with the same size as this, but with its center moved to at.

Link copied to clipboard
fun Size.coerceIn(min: Size, max: Size): Size
Link copied to clipboard
operator fun Size.div(value: Double): Size
operator fun Size.div(value: Float): Size

operator fun Size.div(value: Int): Size

Returns a Size with width / value and height / value

Link copied to clipboard
fun Ellipse.inscribed(sides: Int, rotation: Measure<Angle> = 0 * degrees): ConvexPolygon?

Creates a Regular polygon by inscribing it within the ellipse.

Link copied to clipboard

Creates a Circle that is inscribed within the rectangle

Link copied to clipboard

Creates an Ellipse that is inscribed within the rectangle

Link copied to clipboard
fun Circle.inset(inset: Double): Circle
fun Ellipse.inset(insetX: Double, insetY: Double = insetX): Ellipse

fun Rectangle.inset(top: Double = 0.0, left: Double = 0.0, right: Double = 0.0, bottom: Double = 0.0): Rectangle

Rectangle that has been adjusted as follows [x + left, y + top, w - (left + right), h - (top + bottom)].

Link copied to clipboard

Calculate the interior angle between 2 vectors =>angle := cos(α) = a·b / (|a|·|b|).

Link copied to clipboard

Draws a line from the current point to this one.

Link copied to clipboard
fun ConvexPolygon.map(transform: (Point) -> Point): ConvexPolygon

Create a new ConvexPolygon with each point transformed by transform.

Link copied to clipboard

Moves from the current point to this one.

Link copied to clipboard

Create a new ConvexPolygon with the same points, but in reversed order.

Link copied to clipboard
fun Polygon.rounded(config: (index: Int, Point) -> Double): Path
fun Polygon.rounded(radius: Double, filter: (index: Int, Point) -> Boolean = { _,_ -> true }): Path

Creates a rounded shape from a Polygon. The resulting shape is essentially a polygon with the vertices rounded using a semicircular curve.

Link copied to clipboard
operator fun Size.times(value: Double): Size
operator fun Size.times(value: Float): Size
operator fun Double.times(value: Vector2D): Vector2D
operator fun Double.times(value: Vector3D): Vector3D
operator fun Float.times(value: Vector2D): Vector2D
operator fun Float.times(value: Vector3D): Vector3D
operator fun Int.times(value: Vector2D): Vector2D
operator fun Int.times(value: Vector3D): Vector3D

operator fun Size.times(value: Int): Size

Returns a Size with width * value and height * value

Link copied to clipboard

Converts an Ellipse to a Path.

Converts a Polygon to a Path.

fun Rectangle.toPath(radius: Double): Path

Converts Rectangle with radius to Path.

fun Rectangle.toPath(    topLeftRadius: Double = 0.0,     topRightRadius: Double = 0.0,     bottomRightRadius: Double = 0.0,     bottomLeftRadius: Double = 0.0): Path

Converts Rectangle with radii to Path.

Link copied to clipboard

Returns a new Rectangle with the specified size, and all the other dimensions from this one.

fun Rectangle.with(width: Double = this.width, height: Double = this.height): Rectangle

Returns a new Rectangle with the specified width, height, and all the other dimensions from this one.

Link copied to clipboard