Rectangle

data class Rectangle(corner: Vector2, width: Double, height: Double) : Movable, Scalable2D, ShapeProvider, ShapeContourProvider

Creates a new Rectangle.

Also see IntRectangle.

Constructors

Rectangle
Link copied to clipboard
common
fun Rectangle(x: Double, y: Double, width: Double, height: Double = width)
Rectangle
Link copied to clipboard
common
fun Rectangle(corner: Vector2, width: Double, height: Double = width)

Types

Companion
Link copied to clipboard
common
object Companion

Functions

contains
Link copied to clipboard
common
operator fun contains(point: Vector2): Boolean

Returns true if given point is inside the Rectangle.

div
Link copied to clipboard
common
operator fun div(scale: Double): Rectangle
heightScaledTo
Link copied to clipboard
common
fun heightScaledTo(fitHeight: Double): Rectangle

Creates a new Rectangle with height set to fitHeight and width scaled proportionally.

intersects
Link copied to clipboard
common
fun intersects(other: Rectangle): Boolean

Tests if the areas of two rectangles intersect.

minus
Link copied to clipboard
common
operator fun minus(right: Rectangle): Rectangle
moved
Link copied to clipboard
common
fun moved(offset: Vector2): Rectangle

Creates a new Rectangle with the same size but the current position offset by offset amount.

movedBy
Link copied to clipboard
common
open override fun movedBy(offset: Vector2): Movable

Creates a new shape with the same size but the current position offset by the given amount.

movedTo
Link copied to clipboard
common
open override fun movedTo(position: Vector2): Movable

Creates a new shape with the same size but the current position is set to position.

offsetEdges
Link copied to clipboard
common
fun offsetEdges(offset: Double, offsetY: Double = offset): Rectangle

Creates a new Rectangle with sides offset both horizontally and vertically by specified amount.

plus
Link copied to clipboard
common
operator fun plus(right: Rectangle): Rectangle
position
Link copied to clipboard
common
open fun position(uv: Vector2): Vector2

Returns a position in the bounding box for a parameterized uv value between (0.0, 0.0) and (1.0, 1.0) where (0.5, 0.5) is the center of the bounding box.

open override fun position(u: Double, v: Double): Vector2

Returns a position in the bounding box for parameterized values u and v between 0.0 and 1.0 where (0.5, 0.5) is the center of the bounding box.

scale
Link copied to clipboard
common
fun scale(scale: Double, scaleY: Double = scale, anchorU: Double = 0.5, anchorV: Double = 0.5): Rectangle

Creates a new Rectangle with dimensions scaled by scale and scaleY.

scaled
Link copied to clipboard
common
fun scaled(scale: Double, scaleY: Double = scale): Rectangle
scaledBy
Link copied to clipboard
common
open override fun scaledBy(scale: Double, uAnchor: Double, vAnchor: Double): Scalable1D

Creates a new shape with dimensions scaled by scale.

open override fun scaledBy(xScale: Double, yScale: Double, uAnchor: Double, vAnchor: Double): Scalable2D

Creates a new shape with dimensions scaled by xScale and yScale.

scaledTo
Link copied to clipboard
common
open override fun scaledTo(size: Double): Scalable1D

Creates a new shape at the same position with the given dimension, scaled uniformly.

open override fun scaledTo(width: Double, height: Double): Scalable2D

Creates a new shape at the same position with the given dimensions.

sub
Link copied to clipboard
common
fun sub(u0: Double, v0: Double, u1: Double, v1: Double): Rectangle
times
Link copied to clipboard
common
operator fun times(scale: Double): Rectangle
toInt
Link copied to clipboard
common
fun toInt(): IntRectangle

Casts to IntRectangle.

widthScaledTo
Link copied to clipboard
common
fun widthScaledTo(fitWidth: Double): Rectangle

Creates a new Rectangle with width set to fitWidth and height scaled proportionally.

Properties

area
Link copied to clipboard
common
val area: Double

The unitless area covered by this Rectangle.

center
Link copied to clipboard
common
val center: Vector2

The center of the Rectangle.

contour
Link copied to clipboard
common
open override val contour: ShapeContour

Returns ShapeContour representation of the Rectangle.

corner
Link copied to clipboard
common
val corner: Vector2
dimensions
Link copied to clipboard
common
val dimensions: Vector2

The dimensions of the Rectangle.

height
Link copied to clipboard
common
val height: Double
scale
Link copied to clipboard
common
open override val scale: Vector2

Current scale of this shape. Generally equivalent to its dimensions.

shape
Link copied to clipboard
common
open override val shape: Shape

Returns Shape representation of the Rectangle.

width
Link copied to clipboard
common
val width: Double
x
Link copied to clipboard
common
val x: Double

The x-coordinate of the top-left corner.

y
Link copied to clipboard
common
val y: Double

The y-coordinate of the top-left corner.