loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / RENDERING AND LAYOUT

Color

RGB and indexed channels are UInt8 values. terminalDefault follows the emulator theme. RGB blending is available only between explicit RGB triples. CellDiff converts RGB to the configured output color depth; monochrome suppresses color sequences while retaining text attributes.

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 amber = Color.rgb(237, 166, 98)
let highlight = amber.blended(toward: .rgb(255, 255, 255), amount: 0.4)
_ = highlight
Members on this page

Feature guides and release status

Color

Enumeration
enum Color

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

A terminal-native color or an indexed palette entry.

Source · Style.swift:4

terminalDefault

Case
case terminalDefault

Uses the terminal’s configured foreground or background color.

Source · Style.swift:5

indexed(_:)

Case
case indexed(UInt8)

An indexed terminal palette color, from 0 through 255.

Source · Style.swift:6

rgb(_:_:_:)

Case
case rgb(UInt8, UInt8, UInt8)

Explicit red, green, and blue channels, each from 0 through 255.

Source · Style.swift:7

blended(toward:amount:)

Instance Method
func blended(toward other: Color, amount: Double) -> Color?

Linear blend from this RGB color toward other.

Amounts outside 0...1 are clamped. Non-finite amounts stay on this color. Returns nil when either color is not an explicit RGB triple, because indexed and default colors depend on the terminal.

Parameters (2)
toward
Argument type and any default are shown in the declaration; see the behavior notes above.
amount
Amount to blend or inset, as described by this method.

Returns Color?.

Source · Style.swift:14