weaveThreads

Two sets of threads woven over and under each other, returned as a finished color.

weaveThreads(slots: {
    frame: PatternPaint
    gap: PropRef
    /** `[horizontal, vertical]` thread colors. */
    colors: [PropRef, PropRef]
}): PatternPaint

Import patterns from shaders/std and use patterns.weaveThreads.

gap 0–0.5 is the empty margin on each side of a thread, as a fraction of a cell; 0 packs them tight. colors is [horizontal, vertical]. The gaps are transparent, so this goes straight into paint:. Draw it in a 'plain' cellFrame.

Parameters

NameTypeNotes
slots`{
frame: PatternPaint
gap: PropRef
/** `[horizontal, vertical]` thread colors. */
colors: [PropRef, PropRef]

}` | |

Example

paint: weaveThreads({frame: cellFrame({cells: p('cells'), rotation: p('rotation'), convention: 'plain'}), gap: p('gap'), colors: [p('colorA'), p('colorB')]})

See also

  • cellFrame — The shared coordinate system of a tiled pattern: how many cells fit down the canvas height and how far the whole lattice is rotated.
  • gridLines — Square grid lines drawn in a cellFrame, plus a per-cell shade for the fill.
  • truchetArcs — A maze of quarter-circle arcs, two per tile, flipped at random so they join into flowing curves.

Used by

Weave