loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / TERMINAL ALIASES FROM WEFT

Rect

A half-open rectangle: x..<maxX and y..<maxY. The initializer clamps dimensions to zero or greater; its mutable fields still require sensible values and representable coordinate arithmetic. inset uses equal cell padding on all four sides.

loom.Rect is an alias for weft.Rect. It is available through import loom. The underlying type’s members are documented here.

Standard inherited Swift protocol operations such as synthesized equality and OptionSet set operations are not repeated. The public declarations below are extracted from the exact source revision listed in the coverage manifest.

Example

let area = Rect(x: 2, y: 1, width: 40, height: 8)
_ = area.inset(1)
_ = area.contains(Point(x: 3, y: 2))
Members on this page

Feature guides and release status

Rect

Type Alias
typealias Rect = weft.weft.Rect

A half-open rectangle: x..<maxX and y..<maxY. The initializer clamps dimensions to zero or greater; its mutable fields still require sensible values and representable coordinate arithmetic. inset uses equal cell padding on all four sides.

Source · TerminalExports.swift:5

Underlying weft API

Rect

Structure
struct Rect

Conforms to: Swift.Equatable, Swift.Sendable, Swift.SendableMetatype.

A rectangular region measured in terminal cells.

Source · Rect.swift:2

x

Instance Property
var x: Int

Zero-based column in terminal cells.

Source · Rect.swift:3

y

Instance Property
var y: Int

Zero-based row in terminal cells.

Source · Rect.swift:4

width

Instance Property
var width: Int

Width in terminal cells.

Source · Rect.swift:5

height

Instance Property
var height: Int

Height in terminal cells.

Source · Rect.swift:6

init(x:y:width:height:)

Initializer
init(x: Int = 0, y: Int = 0, width: Int, height: Int)

Creates a value with the supplied arguments. Default arguments are shown in the declaration.

Parameters (4)
x
Argument type and any default are shown in the declaration; see the behavior notes above.
y
Argument type and any default are shown in the declaration; see the behavior notes above.
width
Available columns in terminal cells.
height
Available rows in terminal cells.
Source · Rect.swift:8

maxX

Instance Property
var maxX: Int { get }

The column immediately after the rectangle's right edge.

Source · Rect.swift:16

maxY

Instance Property
var maxY: Int { get }

The row immediately after the rectangle's bottom edge.

Source · Rect.swift:21

contains(_:)

Instance Method
func contains(_ point: Point) -> Bool

Tests the half-open bounds: left/top edges are included, right/bottom edges excluded.

Parameters (1)
point
Zero-based terminal-cell position.

Returns Bool.

Source · Rect.swift:25

inset(_:)

Instance Method
func inset(_ amount: Int = 1) -> Rect

Insets all four edges by the same number of cells.

Parameters (1)
amount
Amount to blend or inset, as described by this method.

Returns Rect.

Source · Rect.swift:30