---
title: "wrapRamp"
description: "Runs a palette value back and forth `cycles` times so a ramp repeats without a seam."
group: "paint"
groupTitle: "Painting"
categoryId: "paint"
categorySlug: "paint"
categoryTitle: "Fields, palettes & ramps"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/fields.ts#L728"
---

# wrapRamp

Runs a palette value back and forth `cycles` times so a ramp repeats without a seam.

```ts
wrapRamp(opts: {t: Expr; cycles: Expr | number}): Expr
```

Import `paint` from `shaders/std` and use `paint.wrapRamp`.

At `cycles` 1 the value passes through unchanged. Where the bands get thinner than a pixel they fade to the palette's middle instead of flickering. Use it on the value before the palette lookup, in a `paint:` function.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `opts` | `{t: Expr; cycles: Expr \| number}` |  |

## Example

```ts
return standardPalette(wrapRamp({t: field, cycles: math.add(1, math.mul(uniformOf(p('wrapping'), params), 6))}), params)
```

> **Tip.** Not for use inside a `guarded` branch. Reach for `foldRamp` there.

## See also

- [`foldRamp`](/docs/primitives/paint/foldramp) — Folds any number into 0–1 as a seamless zigzag: up from 0 to 1, back down, every 2 units.
- [`scatterField`](/docs/primitives/paint/scatterfield) — A mesh-gradient field: up to 8 drifting points scattered across the canvas, blended by nearness.

## Used by

[MeshGradient](/docs/components/meshgradient)