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

CanvasContext

Drawing commands for a Canvas.

Coordinates are independent of terminal cell dimensions.

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.

Members on this page

Feature guides and release status

CanvasContext

Structure
struct CanvasContext

Drawing commands for a Canvas.

Coordinates are independent of terminal cell dimensions.

Source · Canvas.swift:109

point(at:style:)

Instance Method
mutating func point(at point: CanvasPoint, style: Style? = nil)

Adds a dot if the finite coordinate lies inside the canvas.

Parameters (2)
at
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Canvas.swift:141

points(_:style:)

Instance Method
mutating func points(_ points: [CanvasPoint], style: Style? = nil)

Plots the supplied finite coordinates into the current layer, clipping to the visible raster.

Parameters (2)
points
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Canvas.swift:149

line(from:to:style:)

Instance Method
mutating func line(from start: CanvasPoint, to end: CanvasPoint, style: Style? = nil)

Clips crossing segments before rasterization, even when both endpoints are outside the bounds.

Parameters (3)
from
Argument type and any default are shown in the declaration; see the behavior notes above.
to
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Canvas.swift:154

filledLine(from:to:baseline:style:)

Instance Method
mutating func filledLine(from start: CanvasPoint, to end: CanvasPoint, baseline: Double, style: Style? = nil)

Fills vertical raster columns between a segment and an explicit horizontal baseline.

Non-finite inputs paint nothing. Work is bounded by the visible raster, even for offscreen endpoints; vertical and zero-length segments fill their baseline column.

Parameters (4)
from
Argument type and any default are shown in the declaration; see the behavior notes above.
to
Argument type and any default are shown in the declaration; see the behavior notes above.
baseline
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Canvas.swift:191

rectangle(origin:width:height:style:filled:)

Instance Method
mutating func rectangle(origin: CanvasPoint, width: Double, height: Double, style: Style? = nil, filled: Bool = false)

Draws an outline or filled rectangle.

Negative sizes are accepted; zero sizes produce a line or point.

Parameters (5)
origin
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.
style
Text/cell appearance.
filled
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · Canvas.swift:245

circle(center:radius:style:)

Instance Method
mutating func circle(center: CanvasPoint, radius: Double, style: Style? = nil)

Draws a circle outline, sampling in proportion to the visible raster size.

Parameters (3)
center
Argument type and any default are shown in the declaration; see the behavior notes above.
radius
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Canvas.swift:282

print(_:at:style:)

Instance Method
mutating func print(_ text: String, at point: CanvasPoint, style: Style? = nil)

Flushes the current raster layer, then writes Unicode text anchored at its top-left cell.

Whole graphemes crossing the canvas or enclosing buffer clip are omitted.

Parameters (3)
text
Source text.
at
Argument type and any default are shown in the declaration; see the behavior notes above.
style
Text/cell appearance.
Source · Canvas.swift:302

newLayer()

Instance Method
mutating func newLayer()

Commits accumulated dots.

The next layer may replace glyphs and styles in the same cells.

Source · Canvas.swift:322

draw(_:)

Instance Method
mutating func draw<S>(_ shape: S) where S : CanvasShape

Draws a custom shape into the current layer.

Parameters (1)
shape
Argument type and any default are shown in the declaration; see the behavior notes above.
Source · Canvas.swift:450