Ink Block
About 1644 words
- 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.
Levels
- Core: Pen point coordinates, per-point widths and the
fallbackcolor; may ignore opacity; all ends are drawn as round caps. - Basic: block-level
opacity, Highlighter, the nib descriptionnib, the capcap. - 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, 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 | 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 |
nib | Map | Optional | Basic | Nib description, see Nibs and Caps |
cap | int32 | Optional | Basic | Cap; applies to circle nibs only, defaults to Round; ignored for rectangle nibs (NIB-3). See Nibs and Caps |
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 |
x, y in filewidthAbsoluteP0 is absolute; from P1 on, each offset is added to the previous point (INK-4). Without nib, width is the stroke diameter at that point (NIB-1).
Rules
Numbering and undo
- INK-1 The
typeof Ink is always3. The kind of pen is determined only byinkType. - INK-2
contentIdis shared within one Canvas by Ink, Shape, Media and Clear: it starts at0and 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
undoIdstarts at0and never decreases. Contiguous content blocks in the object stream with the sameundoIdform one undo group, and a single undo reverts them together.
Geometry
- INK-4
pointshas 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
widthmust be greater than0. With a circle nib (including nonib),widthis the stroke's diameter at that point; with a rectangle nib,widthis the nib height. See 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
colorandopacity. Core readers may ignoreopacityand 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 = 0and 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
colorandopacityof 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 than0), they must keep the geometry and draw it as Pen. - INK-14 If the
texturevalue is unknown, readers must draw the Ink using texture0and must not discard it.
- 1Stroke A
inkType 1Before Erase: erased through - 2Erase
inkType 0Affects only earlier content - 3Stroke B
inkType 1After Erase: unaffected
Gray area: where Erase swept (illustration only; not displayed)
Trailing latest group (Full)
INK-15
renderOnlyWhenLatestis used for "shape correction": the original stroke is saved first and markedtrue, 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:- Scan backward starting from the last content block.
- Pass over Media.
- Stop at a Clear.
- When an Ink or Shape marked
trueis found, add it to the trailing latest group and continue backward. - Stop at the first unmarked Ink or Shape.
- The trailing latest group and all unmarked content are shown normally; the remaining content marked
trueis 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.
- Existing strokesInkNo
renderOnlyWhenLatestUnmarked: shown normally - Hand-drawn originalInk
renderOnlyWhenLatest: trueIn the trailing latest group: shown
1. Draw the originalThe hand-drawn circle is saved as Ink marked renderOnlyWhenLatest: true. Scanning backward from the end, it is the last block, so it joins the trailing latest group and is shown normally.
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
opacityis clamped to0–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.
{
"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
]
}{
"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 }
]
}{
"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.