Rectangle

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

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

Link copied to clipboard
constructor(corner: Vector2, width: Double, height: Double = width)

Types

Link copied to clipboard
object Companion

Functions

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

Returns true if given point is inside the Rectangle.

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

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.

Link copied to clipboard

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.

Link copied to clipboard

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

Link copied to clipboard

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

Link copied to clipboard

Tests if the areas of two rectangles intersect.

Link copied to clipboard
operator fun minus(right: Rectangle): Rectangle
Link copied to clipboard
open override fun movedBy(offset: Vector2): Rectangle

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

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

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

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

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

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

Link copied to clipboard
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.

Link copied to clipboard
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.

Link copied to clipboard
fun sub(u0: Double, v0: Double, u1: Double, v1: Double): Rectangle
Link copied to clipboard
operator fun times(scale: Double): Rectangle
Link copied to clipboard
Link copied to clipboard
fun vertical(u: Double = 0.5): LineSegment

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

Link copied to clipboard

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

Properties

Link copied to clipboard

The unitless area covered by this Rectangle.

Link copied to clipboard

The center of the Rectangle.

Link copied to clipboard
open override val contour: ShapeContour

Returns ShapeContour representation of the Rectangle.

Link copied to clipboard
Link copied to clipboard

The dimensions of the Rectangle.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
open override val scale: Vector2

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

Link copied to clipboard
open override val shape: Shape

Returns Shape representation of the Rectangle.

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

The x-coordinate of the top-left corner.

Link copied to clipboard
val y: Double

The y-coordinate of the top-left corner.