---
title: "cycle"
description: "A repeating cycle as two numbers: `progress` (0..1 through the current cycle) and `index` (which cycle this is)."
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#L54"
---

# cycle

A repeating cycle as two numbers: `progress` (0..1 through the current cycle) and `index` (which cycle this is).

```ts
cycle(t: Expr, period: Expr | number): {progress: Expr; index: Expr}
```

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

`period` is the cycle length in seconds. The "every N seconds" word: fade something in with `progress`, and feed `index` to `cycleSeed` when each pass should look different.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `t` | `Expr` |  |
| `period` | `Expr \| number` |  |

## Example

```ts
const {progress, index} = motion.cycle(animatedTime(params), 2) // a new pass every 2 s
```

## See also

- [`cycleSeed`](/docs/primitives/motion/cycleseed) — A random but stable number, 0..1, for each cycle index.
- [`phase`](/docs/primitives/motion/phase) — How far through a repeating cycle the clock is, 0..1.
- [`pulseTrain`](/docs/primitives/motion/pulsetrain) — An on/off rhythm: 1 for the first part of each cycle, 0 for the rest.