---
title: "scatterPoints"
description: "The scattered points of the four grid cells nearest the pixel, so anything drawn up to half a cell from its point shows whole, never clipped at a cell edge."
group: "paint"
groupTitle: "Painting"
categoryId: "patterns"
categorySlug: "patterns"
categoryTitle: "Patterns & tiling"
kind: "function"
sourceUrl: "https://github.com/shader-effects-inc/shaders/blob/main/packages/core/src/std/paint/patterns.ts#L226"
---

# scatterPoints

The scattered points of the four grid cells nearest the pixel, so anything drawn up to half a cell from its point shows whole, never clipped at a cell edge.

```ts
scatterPoints(coord: Expr, opts: ScatterOptions): ScatteredPoint[]
```

Import `patterns` from `shaders/std` and use `patterns.scatterPoints`.

Same options and same points as `scatterPoint` (one random point per cell); returns four of them instead of one. Draw something around each and add the results. Costs four times `scatterPoint`.

## Parameters

| Name | Type | Notes |
|---|---|---|
| `coord` | `Expr` |  |
| `opts` | `ScatterOptions` |  |

## Example

```ts
const glints = scatterPoints(px, {cellSize: 60, jitter: 0.6, seed: params.uniforms.seed})
    .map(({offset}) => starGlint(offset, {core: 0.9, rayLength: 0.1, rayWidth: 1.6, rays: 0.25, reach: 30}))
```

> **Tip.** Pair with `starGlint`'s `reach` set to half the cell size, so a glint has faded out
before it could reach a cell this pixel doesn't look at.

## See also

- [`scatterPoint`](/docs/primitives/patterns/scatterpoint) — One random point in each cell of a square grid: the classic scatter for glitter, stars, dust and sparkles.
- [`starGlint`](/docs/primitives/light/starglint) — A four-point star of light: a round core with a thin ray along each axis, like a glint off glitter or a star in a photograph.

## Used by

[Sparkle](/docs/components/sparkle)