# DrawState

Everything the draw tool knows. Shapes, the selection and the history live
in one value, so undo covers every edit, including deleting a shape.

This is an interface exported by `@mapcairn/core`, checked against version 0.2.0.

## Signature

```ts
import type { DrawState } from "@mapcairn/core";
 
interface DrawState
```

## Properties

### coalesce

```ts
readonly coalesce: string | null;
```

The key of the last coalescing edit. An edit with the same key joins the
undo step of the one before, so a drag, or a run of arrow key presses, is
one step.

### future

```ts
readonly future: readonly DrawHistoryEntry[];
```

The steps undone, which redo reapplies, most recently undone last.

### lastEvent

```ts
readonly lastEvent: DrawEvent | null;
```

What the last action did, for announcements. Null before any action.

### mode

```ts
readonly mode: DrawKind;
```

The kind of shape the next tap starts.

### nextId

```ts
readonly nextId: number;
```

The number the next shape's id gets. Never goes back, so ids stay unique after an undo.

### past

```ts
readonly past: readonly DrawHistoryEntry[];
```

The undo steps, oldest first.

### selection

```ts
readonly selection: DrawSelection | null;
```

The selected shape and vertex, or null.

### serials

```ts
readonly serials: Readonly<Record<DrawKind, number>>;
```

How many shapes of each kind have been named, for labels such as "Polygon 2".

### shapes

```ts
readonly shapes: readonly DrawShape[];
```

Every shape in the order drawn. At most one, the last, is unfinished.

## See also

- [`DrawHistoryEntry`](https://docs.mapcairn.com/api/core/DrawHistoryEntry.md)
- [`DrawEvent`](https://docs.mapcairn.com/api/core/DrawEvent.md)
- [`DrawKind`](https://docs.mapcairn.com/api/core/DrawKind.md)
- [`DrawSelection`](https://docs.mapcairn.com/api/core/DrawSelection.md)
- [`DrawShape`](https://docs.mapcairn.com/api/core/DrawShape.md)

Source: [packages/core/src/draw/reducer.ts:83](https://github.com/MapCairn/mapcairn/blob/main/packages/core/src/draw/reducer.ts#L83)
