loom & weft
Made for Swift.

Published release 0.2.1. Unreleased PR #2 reference.

LOOM 0.2.1 / ANIMATION

DiagonalShine

A caller-driven diagonal brightness sample. Sample at the suggested 12 Hz cadence; opacity is a clamped 0…1 amount for blending resting and highlight colors. Coordinates run from lower left (0) to upper right (1). Non-finite/negative time starts at zero.

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 amount = DiagonalShine.opacity(diagonal: 0.5, seconds: 1.0)
_ = Color.rgb(237, 166, 98).blended(toward: .rgb(255, 255, 255), amount: amount)
_ = DiagonalShine.delayUntilNextFrame(after: 1.0)
Members on this page

Feature guides and release status

DiagonalShine

Enumeration
enum DiagonalShine

A slow diagonal sheen for a braille mark.

Opacity is 0 at the resting color and 1 at the highlight. A raised-cosine band travels from the lower left to the upper right, then rests off the mark. A shallow pulse remains during that rest. The phase is wall-clock time, so the speed does not follow the redraw rate. framesPerSecond is only the cadence at which a caller needs to sample it.

Source · DiagonalShine.swift:10

framesPerSecond

Type Property
static let framesPerSecond: Double

Suggested sampling cadence.

Source · DiagonalShine.swift:11

frame(at:)

Type Method
static func frame(at seconds: Double) -> Int

Returns the quantized sample index at framesPerSecond × nonnegative finite seconds.

Parameters (1)
at
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Int.

Source · DiagonalShine.swift:13

delayUntilNextFrame(after:)

Type Method
static func delayUntilNextFrame(after seconds: Double) -> Double

Seconds until the next quantized sample.

Callers sleep this long instead of redrawing continuously.

Parameters (1)
after
Argument type and any default are shown in the declaration; see the behavior notes above.

Returns Double.

Source · DiagonalShine.swift:21

opacity(diagonal:seconds:)

Type Method
static func opacity(diagonal: Double, seconds: Double) -> Double

diagonal is 0 at the lower left and 1 at the upper right.

Parameters (2)
diagonal
Normalized position: lower left 0, upper right 1.
seconds
Elapsed time in seconds.

Returns Double.

Source · DiagonalShine.swift:29