openrndr / org.openrndr.shape / Rectangle

Rectangle

data class Rectangle (source)

Rectangle with double precision

Constructors

<init>

Rectangle(x: Double, y: Double, width: Double, height: Double = width)

Rectangle with double precision

Rectangle(corner: Vector2, width: Double, height: Double = width)

Properties

area

the unitless area covered by this rectangle

val area: Double

center

the center of the rectangle

val center: Vector2

contour

ShapeContour representation of the rectangle

val contour: ShapeContour

corner

val corner: Vector2

dimensions

the dimensions of the rectangle

val dimensions: Vector2

height

val height: Double

shape

Shape representation of the rectangle

val shape: Shape

width

val width: Double

x

x-coordinate of the top-left corner

val x: Double

y

y-coordinate of the top-left corner

val y: Double

Functions

contains

check if point is contained by Rectangle

operator fun contains(point: Vector2): Boolean

div

operator fun div(scale: Double): Rectangle

heightScaledTo

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

fun heightScaledTo(fitHeight: Double): Rectangle

minus

operator fun minus(right: Rectangle): Rectangle

moved

creates a new Rectangle with its position offset by offset

fun moved(offset: Vector2): Rectangle

offsetEdges

create a new Rectangle instance with offset edges

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

plus

operator fun plus(right: Rectangle): Rectangle

position

returns a position for parameterized coordinates u and v between 0 and 1

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

scaled

create a new Rectangle with dimensions scaled by scale and scaleY

fun scaled(scale: Double, scaleY: Double = scale): Rectangle

sub

fun sub(u0: Double, v0: Double, u1: Double, v1: Double): Rectangle

times

operator fun times(scale: Double): Rectangle

toInt

convert to IntRectangle

fun toInt(): IntRectangle

widthScaledTo

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

fun widthScaledTo(fitWidth: Double): Rectangle

Companion Object Properties

EMPTY

val EMPTY: Rectangle

Companion Object Functions

fromCenter

creates a Rectangle around center with dimensions width and height

fun fromCenter(center: Vector2, width: Double, height: Double = width): Rectangle