---
title: "fitJitteredGrid"
description: "A grid of about `count` roughly square cells over the canvas plus an `overscan` border on every side, for agents that rest on a jittered grid."
group: "simulation"
groupTitle: "Simulation"
categoryId: "sim.agentFrame"
categorySlug: "sim-agentframe"
categoryTitle: "Agent frame"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/sim/agentFrame.ts#L191"
---

# fitJitteredGrid

A grid of about `count` roughly square cells over the canvas plus an `overscan` border on every side, for agents that rest on a jittered grid.

```ts
fitJitteredGrid(
  count: number,
  domainX: number,
  overscan: number,
): { cols: number; cellW: number; cellH: number; }
```

Import `sim` from `shaders/std` and use `sim.agentFrame.fitJitteredGrid`.

`domainX` is the canvas width in heights (the aspect).

Returns the column count and the cell size, which `field.jitteredGridHome` reads.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `count` | `number` |  |
| `domainX` | `number` |  |
| `overscan` | `number` |  |

## Example

```ts
const {cols, cellW, cellH} = agentFrame.fitJitteredGrid(count, domainX, 0.1)
```

## See also

- [`fitIsoGrid`](/docs/primitives/sim-agentframe/fitisogrid) — A W×H grid of square cells holding about `count` agents at the canvas `aspect`, each side clamped to `[min, max]`.
- [`field`](/docs/primitives/sim-agentforces/field) — What a turning agent samples at its position: the magnetic field at the cursor, and its resting place on a jittered grid.