---
title: "weaveThreads"
description: "Two sets of threads woven over and under each other, returned as a finished color."
group: "paint"
groupTitle: "Painting"
categoryId: "patterns"
categorySlug: "patterns"
categoryTitle: "Patterns & tiling"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/patterns.ts#L768"
---

# weaveThreads

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

```ts
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

| Name | Type | Notes |
|---|---|---|
| `slots` | `{
    frame: PatternPaint
    gap: PropRef
    /** `[horizontal, vertical]` thread colors. */
    colors: [PropRef, PropRef]
}` |  |

## Example

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

## See also

- [`cellFrame`](/docs/primitives/patterns/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`](/docs/primitives/patterns/gridlines) — Square grid lines drawn in a `cellFrame`, plus a per-cell shade for the fill.
- [`truchetArcs`](/docs/primitives/patterns/truchetarcs) — A maze of quarter-circle arcs, two per tile, flipped at random so they join into flowing curves.

## Used by

[Weave](/docs/components/weave)