---
title: "fitIsoGrid"
description: "A W×H grid of square cells holding about `count` agents at the canvas `aspect`, each side clamped to `[min, max]`."
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#L209"
---

# fitIsoGrid

A W×H grid of square cells holding about `count` agents at the canvas `aspect`, each side clamped to `[min, max]`.

```ts
fitIsoGrid(
  count: number,
  aspect: number,
  min: number,
  max: number,
): { w: number; h: number; }
```

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

## Parameters

| Name | Type | Notes |
|---|---|---|
| `count` | `number` |  |
| `aspect` | `number` |  |
| `min` | `number` |  |
| `max` | `number` |  |

## Example

```ts
const {w, h} = agentFrame.fitIsoGrid(count, aspect, 8, 160)
```

## See also

- [`fitJitteredGrid`](/docs/primitives/sim-agentframe/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.