# Rectangle

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

Creates a new Rectangle.

Also see IntRectangle.

## Constructors

Rectangle
common
fun Rectangle(x: Double, y: Double, width: Double, height: Double = width)
Rectangle
common
fun Rectangle(corner: Vector2, width: Double, height: Double = width)

Companion
common
object Companion

## Functions

contains
common
operator fun contains(point: Vector2): Boolean

Returns true if given point is inside the Rectangle.

div
common
operator fun div(scale: Double): Rectangle
heightScaledTo
common
fun heightScaledTo(fitHeight: Double): Rectangle

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

intersects
common
fun intersects(other: Rectangle): Boolean

Tests if the areas of two rectangles intersect.

minus
common
operator fun minus(right: Rectangle): Rectangle
moved
common
fun moved(offset: Vector2): Rectangle

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

movedBy
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
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
common
fun offsetEdges(offset: Double, offsetY: Double = offset): Rectangle

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

plus
common
operator fun plus(right: Rectangle): Rectangle
position
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
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
common
fun scaled(scale: Double, scaleY: Double = scale): Rectangle
scaledBy
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
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
common
fun sub(u0: Double, v0: Double, u1: Double, v1: Double): Rectangle
times
common
operator fun times(scale: Double): Rectangle
toInt
common
fun toInt(): IntRectangle

Casts to IntRectangle.

widthScaledTo
common
fun widthScaledTo(fitWidth: Double): Rectangle

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

## Properties

area
common
val area: Double

The unitless area covered by this Rectangle.

center
common
val center: Vector2

The center of the Rectangle.

contour
common
open override val contour: ShapeContour

Returns ShapeContour representation of the Rectangle.

corner
common
val corner: Vector2
dimensions
common
val dimensions: Vector2

The dimensions of the Rectangle.

height
common
val height: Double
scale
common
open override val scale: Vector2

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

shape
common
open override val shape: Shape

Returns Shape representation of the Rectangle.

width
common
val width: Double
x