Clear Block
About 833 words
- Type ID:
6 - Type: Map
A Clear is an undoable "clear canvas". Everything drawn on the same Canvas before it disappears, and content after it starts drawing from blank; but the earlier content stays in the file and can be restored by undoing the Clear.
Levels
Inkeys extension. Readers that do not implement this level handle it per CLEAR-7; when exporting to other apps, writers remove the Clear and the content before it (see Compatible export).
Fields
| Field | Type | Requirement | Description |
|---|---|---|---|
type | uint16 | Required | Always 6 |
contentId | uint32 | Required | Content sequence number shared with Ink, Shape and Media (INK-2) |
undoId | uint32 | Required | Undo group number; a Clear has a group to itself |
extra | Map | Optional | App-private fields |
A Clear has no range, geometry or type filter: it always clears all visible content of the entire Canvas.
Rules
Display
- A
undoId 0Hidden by Clear - Clear1
undoId 1In effect - B
undoId 2Hidden by Clear - Clear2
undoId 3In effect - C
undoId 4Shown
- C
- empty
- B
- empty
- A
- empty
Everything is in effect; showing C.
- CLEAR-1 Readers composite a Canvas in object stream order: on encountering a Clear, they reset all visible results formed so far to transparent; content after the Clear continues compositing from transparent.
- CLEAR-2 A Clear affects only the Canvas it is in. It does not affect other Devices of the same page, other layers, other pages or other Workspaces, and does not change the Canvas's page identity,
viewportor layer order. - CLEAR-3 A Clear clears all earlier visible content, including Media. It neither modifies nor deletes earlier blocks.
Undo
- CLEAR-4 A Clear must have an undo group to itself: its
undoIdmust be greater than that of the previous content block; when the Clear is the first content of the Canvas,undoId = 0; theundoIdof the first content block after the Clear must be greater than the Clear's. - CLEAR-5 For the content stream
A, Clear1, B, Clear2, C, C is currently shown. Undoing group by group from the end: after undoing C the canvas is empty; after undoing Clear2, B is shown; continuing to undo B and Clear1 gives empty, then A. When the current interval has already been undone to empty, an app may present "undo Clear" as a single restore, but the order in the file does not change. - CLEAR-6 On a full save, trailing content and Clears that have already been undone may be removed; earlier intervals that can still be restored by undo must be kept. When an app explicitly discards the Clear history, it may delete the last effective Clear and all content before it, making the current interval the start of the Canvas.
Fallback
- CLEAR-7 When readers that do not implement the Inkeys extension encounter a Clear, they should show only the content after the last Clear of that Canvas (this only requires finding the last Clear before drawing). If they cannot, they must tell the user "The display of this page may include content that has been cleared".
Writing
- CLEAR-8 Writers must not simulate Clear with a new Canvas, a new layer, a full-screen Erase Ink or private fields.
- CLEAR-9 The specification does not limit the number of Clears in a Canvas. Inkeys keeps at most one Clear per page and supports undoing only to the previous interval; earlier content is discarded on save.
- CLEAR-10 A complete Clear may be appended to the last Canvas (SAVE-8); when undoing or redoing a Clear, modifying an earlier interval, or compacting the Clear history, append a new version of the whole page or perform a full save.
- CLEAR-11 Writers should avoid writing Clears that have no effect (a Clear on an empty Canvas, a Clear immediately following another Clear); readers handle them as usual when encountered, and the result is empty.
Error tolerance
- CLEAR-12 A Clear that is missing
type,contentIdorundoId, has fields of the wrong type, or shares anundoIdwith adjacent content is invalid; a warning is reported. - CLEAR-13 Ignoring an invalid Clear changes what is shown, so a file containing an invalid Clear must not be saved over directly; by default it is recovered read-only or saved as a new file.
Example
{ "type": 6, "contentId": 2, "undoId": 2 }This Clear clears the picture formed by the content with contentId 0 and 1; from contentId = 3 on, drawing starts from a blank canvas.
Fallback
| Reader | How it is shown |
|---|---|
| Implements the Inkeys extension | Displayed and undone per CLEAR-1 to CLEAR-5 |
| Does not implement the Inkeys extension | Shows only the content after the last Clear; if it cannot, notifies the user (CLEAR-7) |
When exporting to other apps, remove the Clear and the content before it. See Compatible export.