---
title: "oscillate"
description: "A smooth back-and-forth between `min` and `max`."
group: "space"
groupTitle: "Shapes, frames & warps"
categoryId: "motion"
categorySlug: "motion"
categoryTitle: "Motion & timing"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/motion.ts#L109"
---

# oscillate

A smooth back-and-forth between `min` and `max`.

```ts
oscillate(
  t: Expr,
  opts: {rate?: number; min?: Expr | number; max?: Expr | number; offset?: number},
): Expr
```

Import `motion` from `shaders/std` and use `motion.oscillate`.

`rate` is cycles per second, default 1. `min` and `max` default to 0 and 1. `offset` shifts the starting point, in radians, so two oscillations can run out of step.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `t` | `Expr` |  |
| `opts` | `{rate?: number; min?: Expr \| number; max?: Expr \| number; offset?: number}` |  |

## Example

```ts
const breathe = motion.oscillate(animatedTime(params), {rate: 0.5, min: 0.6, max: 1})
```

## See also

- [`oscillating`](/docs/primitives/motion/oscillating) — A knob that sweeps between `min` and `max` on its own, for any slot that takes a prop.
- [`pulseTrain`](/docs/primitives/motion/pulsetrain) — An on/off rhythm: 1 for the first part of each cycle, 0 for the rest.
- [`phase`](/docs/primitives/motion/phase) — How far through a repeating cycle the clock is, 0..1.