loom & weft
Made for Swift.

Unreleased APIs from PR #2. Not in 0.2.1. Stable 0.2.1 reference.

LOOM Unreleased (PR #2) / PLOTTING AND CALENDARS

Canvas

A clipped coordinate-space rasterizer.

It changes logical cells and performs no terminal I/O. Empty cells remain untouched. Shapes in one layer combine their dots; later strokes own cell style.

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

_ = Canvas(xBounds: CanvasBounds(min: -1, max: 1), yBounds: CanvasBounds(min: -1, max: 1)) { context in
    context.line(from: CanvasPoint(x: -1, y: 0), to: CanvasPoint(x: 1, y: 0))
}
Members on this page

Feature guides and release status

Canvas

Structure
struct Canvas

Conforms to: Widget.

A clipped coordinate-space rasterizer.

It changes logical cells and performs no terminal I/O. Empty cells remain untouched. Shapes in one layer combine their dots; later strokes own cell style.

Source · Canvas.swift:69

xBounds

Instance Property
var xBounds: CanvasBounds

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Canvas.swift:70

yBounds

Instance Property
var yBounds: CanvasBounds

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Canvas.swift:71

marker

Instance Property
var marker: CanvasMarker

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Canvas.swift:72

style

Instance Property
var style: Style

Visual attributes used when painting this value.

Source · Canvas.swift:73

paint

Instance Property
var paint: (inout CanvasContext) -> Void

A public field of this type. Its value type and mutability are shown in the declaration.

Source · Canvas.swift:74

init(xBounds:yBounds:marker:style:paint:)

Initializer
init(xBounds: CanvasBounds, yBounds: CanvasBounds, marker: CanvasMarker = .braille, style: Style = Style(), paint: @escaping (inout CanvasContext) -> Void)

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

Parameters (5)
xBounds
Argument type and any default are shown in the declaration; see the behavior notes above.
yBounds
Argument type and any default are shown in the declaration; see the behavior notes above.
marker
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
paint
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · Canvas.swift:76

render(in:buffer:)

Instance Method
func render(in area: Rect, buffer: inout Buffer)

Paints this widget into the assigned terminal-cell rectangle. Application code owns state, input routing, and terminal lifetime.

Parameters (2)
in
Argument type and any default are shown in the declaration; see the behavior notes above.
buffer
Mutable destination cell grid.
Source · Canvas.swift:87