# Rectangle

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

Creates a new axis-aligned Rectangle.

Rectangle is only a data structure with no visible representation, although it can be drawn by calling org.openrndr.draw.Drawer.rectangle.

Also see IntRectangle.

## Constructors

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

object Companion

## Functions

operator fun contains(point: Vector2): Boolean

Returns true if given point is inside the Rectangle.

operator fun div(scale: Double): Rectangle
fun flippedHorizontally(u: Double = 0.5): Rectangle

Creates a Rectangle mirrored around a vertical axis. u specifies the axis position. Defaults to 0.5 (center). Left edge = 0.0, right edge = 1.0. Frequently used for mirroring images or video.

fun flippedVertically(v: Double = 0.5): Rectangle

Creates a Rectangle mirrored around a horizontal axis. v specifies the axis position. Defaults to 0.5 (center). Top edge = 0.0, bottom edge = 1.0. Frequently used for mirroring images or video.

fun heightScaledTo(fitHeight: Double): Rectangle

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

fun horizontal(v: Double = 0.5): LineSegment

Returns a horizontal LineSegment specified by v. Top edge v = 0.0, bottom edge v = 1.0.

fun intersects(other: Rectangle): Boolean

Tests if the areas of two rectangles intersect.

operator fun minus(right: Rectangle): Rectangle
open override fun movedBy(offset: Vector2): Rectangle

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

open override fun movedTo(position: Vector2): Rectangle

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

fun offsetEdges(offset: Double, offsetY: Double = offset): Rectangle

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

operator fun plus(right: Rectangle): Rectangle
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.

open override fun scaledBy(    scale: Double,     uAnchor: Double,     vAnchor: Double): Rectangle

Creates a new shape with dimensions scaled by scale.

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

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

open override fun scaledTo(size: Double): Rectangle

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

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

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

fun sub(    u0: Double,     v0: Double,     u1: Double,     v1: Double): Rectangle
operator fun times(scale: Double): Rectangle
fun toInt(): IntRectangle

Casts to IntRectangle.

fun vertical(u: Double = 0.5): LineSegment

Returns a vertical LineSegment specified by u. Left edge u = 0.0, right edge u = 1.0.

fun widthScaledTo(fitWidth: Double): Rectangle

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

## Properties

val area: Double

The unitless area covered by this Rectangle.

val center: Vector2

The center of the Rectangle.

open override val contour: ShapeContour

Returns ShapeContour representation of the Rectangle.

val corner: Vector2
val dimensions: Vector2

The dimensions of the Rectangle.

val height: Double
open override val scale: Vector2

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

open override val shape: Shape

Returns Shape representation of the Rectangle.

val width: Double