---
url: /en-us/standard/blocks/ink.md
---
* Type ID: `3`
* Type: Map

**An Ink is one complete stroke**: the series of points from pen-down to pen-up, each with a width. Pen, highlighter and eraser are all represented as Ink, distinguished by `inkType`.

::: tip Levels

* **Core**: Pen point coordinates, per-point widths and the `fallback` color; may ignore opacity; all ends are drawn as round caps.
* **Basic**: block-level `opacity`, Highlighter, the nib description `nib`, the cap `cap`.
* **Full**: per-point styles of Advanced Highlighter, `texture`, `renderOnlyWhenLatest`.
* **Inkeys extension**: Erase Ink and eraser nib shapes.
  :::

## When to use

* Every stroke the user writes with a pen or highlighter.
* The path swept by the eraser in the Inkeys extension (Erase Ink).
* Editable shapes such as lines and rectangles use [Shape](shape), not Ink.

## Fields

The "Level" column states from which level a reader must understand the field. Fields marked Required must always be written, whatever level the writer claims.

| Field | Type | Requirement | Level | Description |
| --- | --- | --- | --- | --- |
| `type` | uint16 | Required | Core | Always `3` |
| `contentId` | uint32 | Required | Core | Content sequence number within the Canvas, see INK-2 |
| `undoId` | uint32 | Required | Standard | Undo group number, see INK-3 |
| `inkType` | int32 | Required | Core | Kind of pen, see the table below |
| `color` | [Color Map](../common/color) | Required | Core | Block-level color; Core uses only `fallback` |
| `opacity` | float32 | Required | Basic | Block-level opacity, `0`–`1` |
| `texture` | int32 | Required | Full | Texture number: `0` is the default, `1`–`127` reserved, `128`+ private |
| `points` | `Array<Map>` | Required | Core | At least one point, see [Stroke points](#stroke-points) |
| `nib` | Map | Optional | Basic | Nib description, see [Nibs and Caps](../common/nib) |
| `cap` | int32 | Optional | Basic | Cap; applies to circle nibs only, defaults to Round; ignored for rectangle nibs (NIB-3). See [Nibs and Caps](../common/nib) |
| `renderOnlyWhenLatest` | bool | Optional | Full | Defaults to `false`, see INK-15 |
| `extra` | Map | Optional | — | App-private fields |

### `inkType`

| Value | Name | Level | Meaning |
| --- | --- | --- | --- |
| `0` | Erase | Inkeys | Erase path |
| `1` | Pen | Core | Ordinary pen |
| `2` | Highlighter | Basic | Highlighter |
| `3` | Advanced Highlighter | Full | Highlighter whose points may carry color and opacity anchors |
| `4`–`127` | Reserved | — | Reserved for future versions |
| `128`+ | Private | — | App-defined |

### Stroke points

| Field | Type | Requirement | Level | Description |
| --- | --- | --- | --- | --- |
| `x` | float32 | Required | Core | Absolute coordinate for the first point; displacement from the previous point afterwards |
| `y` | float32 | Required | Core | Same as above |
| `width` | float32 | Required | Core | Stroke width at this point; must be greater than `0` |
| `color` | Color Map | Conditional | Full | Per-point color of Advanced Highlighter; appears paired with `opacity` |
| `opacity` | float32 | Conditional | Full | Per-point opacity of Advanced Highlighter; appears paired with `color` |

## Rules

### Numbering and undo

* **INK-1** The `type` of Ink is always `3`. The kind of pen is determined only by `inkType`.
* **INK-2** `contentId` is shared within one Canvas by Ink, Shape, Media and Clear: it starts at `0` and increases contiguously in object stream order. It is valid only within the current version of the file and is renumbered after a full save, so it cannot be used as a stable object identity.
* **INK-3** `undoId` starts at `0` and never decreases. Contiguous content blocks in the object stream with the same `undoId` form one undo group, and a single undo reverts them together.

### Geometry

* **INK-4** `points` has at least one point. The first point is an absolute Canvas coordinate; each following point stores the displacement from the previous point. Readers should accumulate displacements in float64 to avoid accumulated error on long strokes.
* **INK-5** `width` must be greater than `0`. With a circle nib (including no `nib`), `width` is the stroke's diameter at that point; with a rectangle nib, `width` is the nib height. See [Nib size](../common/nib#nib-size).
* **INK-6** Coordinates and widths are in Device pixels. Zoom is expressed by the Canvas `viewport.scale`, and widths scale with it when rendering.
* **INK-7** Readers must preserve the order, positions and width meaning of the points. Curve interpolation between points, outline generation and anti-aliasing are up to the app; a single-point Ink is drawn as a dot with the same nib.
* **INK-8** Readers must ignore unknown point keys. 1.1 does not register input channels such as pressure, tilt or time; tapering effects should be expressed directly in each point's `width`.

### Drawing

* **INK-9** Pen is drawn with the block-level `color` and `opacity`. Core readers may ignore `opacity` and draw it opaque.
* **INK-10** Highlighter must first generate the complete coverage area of the whole stroke, then composite it onto the canvas as a single unit with alpha source-over; it must not be composited segment by segment, so that overlaps do not darken.
* **INK-11** Erase belongs to the Inkeys extension. **Readers that do not implement the Inkeys extension must skip Ink with `inkType = 0` and must not draw it as an ordinary pen.** Readers that implement this level apply Erase, in object stream order, to the Ink and Shape before it in the same Canvas; Erase does not affect Media. The exact erase effect (clipping, transparency) is up to the app.
* **INK-12** The per-point `color` and `opacity` of Advanced Highlighter must appear in pairs, forming style anchors. Before the first anchor, the first anchor's style is used; after the last anchor, the last anchor's style is used; between anchors the style transitions smoothly (the interpolation method is up to the app). With no anchors at all, the block-level style is used. Compositing is the same as INK-10.
* **INK-13** When readers encounter an unknown or unsupported `inkType` (other than `0`), they must keep the geometry and draw it as Pen.
* **INK-14** If the `texture` value is unknown, readers must draw the Ink using texture `0` and must not discard it.

### Trailing latest group (Full)

* **INK-15** `renderOnlyWhenLatest` is used for "shape correction": the original stroke is saved first and marked `true`, then the corrected shape is saved; while the correction exists the original is hidden, and after the correction is undone the original reappears. Full readers do the following for each Canvas:

  1. Scan backward starting from the last content block.
  2. Pass over Media.
  3. Stop at a Clear.
  4. When an Ink or Shape marked `true` is found, add it to the trailing latest group and continue backward.
  5. Stop at the first unmarked Ink or Shape.
  6. The trailing latest group and all unmarked content are shown normally; the remaining content marked `true` is hidden.

  This rule affects display only and does not change `undoId`; the hidden original is still valid content and must be kept on a full save. Lower-level readers ignore this field.

### Saving

* **INK-16** An ordinary eraser that cuts existing strokes must write the erase result as the remaining complete pieces and perform a full save; the pieces produced by the same erase may share one `undoId`. Appending must not be used in a way that leaves the old stroke and the new pieces both present.
* **INK-17** An Erase Ink is a new complete Ink and may be appended directly to the end of the file.

### Error tolerance

* **INK-18** A finite but out-of-range `opacity` is clamped to `0`–`1`; NaN and Infinity make the field invalid.
* **INK-19** For an Ink with no points, a corrupt point structure or missing required fields, readers skip it, report a warning and continue reading the following content.

## Example

All of the following are readable pseudo-JSON of MessagePack Maps.

::: tabs

@tab Pen (Core)

```jsonc
{
  "type": 3,
  "contentId": 0,
  "undoId": 0,
  "inkType": 1,
  "color": { "fallback": 255 },        // 0x0000FF, blue
  "opacity": 1.0,
  "texture": 0,
  "points": [
    { "x": 120.0, "y": 240.0, "width": 6.0 },  // first point: absolute coordinate
    { "x": 4.5, "y": 1.0, "width": 6.2 }       // displacement from the previous point
  ]
}
```

@tab Highlighter (Basic)

```jsonc
{
  "type": 3,
  "contentId": 1,
  "undoId": 1,
  "inkType": 2,
  "color": { "fallback": 16776960 },   // 0xFFFF00, yellow
  "opacity": 0.4,
  "texture": 0,
  "nib": { "shape": 1, "aspect": 0.125, "orientation": 0 },
  "points": [
    { "x": 100.0, "y": 300.0, "width": 24.0 },  // width is the nib height
    { "x": 180.0, "y": 0.0, "width": 24.0 }
  ]
}
```

@tab Rectangle eraser (Inkeys extension)

```jsonc
{
  "type": 3,
  "contentId": 2,
  "undoId": 2,
  "inkType": 0,
  "color": { "fallback": 0 },
  "opacity": 1.0,
  "texture": 0,
  "nib": { "shape": 1, "aspect": 0.6666667, "orientation": 0 },
  "points": [
    { "x": 320.0, "y": 180.0, "width": 24.0 },  // width is the nib height: 16 × 24
    { "x": 8.0, "y": -2.0, "width": 24.0 }
  ]
}
```

:::

## Fallback

| Capability the reader lacks | How it is shown |
| --- | --- |
| Block-level `opacity` (Core) | Drawn opaque |
| Highlighter (Core) | Drawn as Pen; the meaning of width is unchanged |
| `nib`, `cap` (Core) | Circle nib, round cap; `width` treated as the diameter |
| Advanced Highlighter per-point styles (Basic, Standard) | Drawn as Highlighter with the block-level style |
| `texture` (below Full) | Drawn with the default texture |
| `renderOnlyWhenLatest` (below Full) | Marker ignored; everything shown |
| Erase Ink (Inkeys extension not implemented) | Skipped, not shown (INK-11) |

For how to handle Erase Ink and `renderOnlyWhenLatest` when exporting to a lower level, see [Compatible export](../compatibility#compatible-export).

## Related

* [Nibs and Caps](../common/nib)
* [Color Map](../common/color)
* [Shape Block](shape)
* [Clear Block](clear)
* [Canvas Block](canvas)
* [Saving, Appending and Recovery](../incremental)
