---
title: "vary"
description: "A color lightened or darkened per cell by a shade factor, alpha untouched."
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#L119"
---

# vary

A color lightened or darkened per cell by a shade factor, alpha untouched.

```ts
vary(color: PaintSlot, factor: PaintSlot): PatternPaint
```

Import `patterns` from `shaders/std` and use `patterns.vary`.

`factor` is the `shade` output of a lattice word: 1 keeps the color, above 1 brightens, below 1 darkens. Use it on the cell fill so every tile reads slightly different.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `color` | `PaintSlot` |  |
| `factor` | `PaintSlot` |  |

## Example

```ts
paint: strokeOver({fill: vary(p('cellColor'), field.shade), stroke: p('color'), mask: field.lines, space: p('colorSpace')})
```

## See also

- [`gridLines`](/docs/primitives/patterns/gridlines) — Square grid lines drawn in a `cellFrame`, plus a per-cell shade for the fill.
- [`hexLines`](/docs/primitives/patterns/hexlines) — Honeycomb lines (pointy-top hexagons) drawn in a `cellFrame`, plus a per-cell shade.
- [`brickCourses`](/docs/primitives/patterns/brickcourses) — A brick wall: staggered rows with mortar gaps, optional rotation and per-row drift.
- [`strokeOver`](/docs/primitives/patterns/strokeover) — Two colors mixed through a mask: `fill` where the mask is 0, `stroke` where it is 1.

## Used by

[BrickPattern](/docs/components/brickpattern), [Grid](/docs/components/grid), [HexGrid](/docs/components/hexgrid), [TriangularGrid](/docs/components/triangulargrid)