Published release 0.2.1. Unreleased PR #2 reference.
LOOM 0.2.1 / 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
struct CanvasConforms 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:58xBounds
var xBounds: CanvasBoundsA public field of this type. Its value type and mutability are shown in the declaration.
Source · Canvas.swift:59yBounds
var yBounds: CanvasBoundsA public field of this type. Its value type and mutability are shown in the declaration.
Source · Canvas.swift:60marker
var marker: CanvasMarkerA public field of this type. Its value type and mutability are shown in the declaration.
Source · Canvas.swift:61style
var style: StyleVisual attributes used when painting this value.
Source · Canvas.swift:62paint
var paint: (inout CanvasContext) -> VoidA public field of this type. Its value type and mutability are shown in the declaration.
Source · Canvas.swift:63init(xBounds:yBounds:marker:style:paint:)
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.
render(in:buffer:)
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.