Skip to content

RectGeometry

Rectangle geometry structure

Rect represents a rectangle with position and size, used for drawing operations.

Use Rect to define:

Examples

javascript
let rect = new Rect(10, 20, 100, 50);
console.log(rect.x, rect.y, rect.width, rect.height);
javascript
let rect = new Rect(10, 20, 100, 50);
console.log(rect.minX, rect.minY); // 10, 20
console.log(rect.maxX, rect.maxY); // 110, 70

Properties

x

  • Type: CGFloat

X coordinate of the rectangle origin

javascript
rect.x

y

  • Type: CGFloat

Y coordinate of the rectangle origin

javascript
rect.y

width

  • Type: CGFloat

Width of the rectangle

javascript
rect.width

height

  • Type: CGFloat

Height of the rectangle

javascript
rect.height

minX

  • Type: CGFloat

Minimum X coordinate (same as x)

javascript
rect.minX

minY

  • Type: CGFloat

Minimum Y coordinate (same as y)

javascript
rect.minY

maxX

  • Type: CGFloat

Maximum X coordinate (x + width)

javascript
rect.maxX

maxY

  • Type: CGFloat

Maximum Y coordinate (y + height)

javascript
rect.maxY

origin

  • Type: [String: CGFloat]

Origin point as dictionary

javascript
rect.origin returns {x, y}

size

  • Type: [String: CGFloat]

Size as dictionary

javascript
rect.size returns {width, height}