Canvas Block
About 1440 words
- Type ID:
2 - Type: Map
A Canvas is "one layer of one page on one screen". The Ink, Shape, Media and Clear blocks that follow it are all drawn on this Canvas until the next Canvas appears. The Canvas also stores the page's metadata: page number, background, PPT binding, and the pan and zoom state viewport.
Levels
- Core:
pageGuid,pageIndex,layerIndex,workspaceGuid,deviceGuid; for the same unique key, the last occurrence wins. - Basic:
pageNumber,background. - Standard:
viewport; for PPT,slideId,binding,pageState,pageKind. - Full: compositing of multiple layers (
layerIndex > 0),layerNumber.
Fields
| Field | Type | Requirement | Level | Description |
|---|---|---|---|---|
type | uint16 | Required | Core | Always 2 |
workspaceGuid | string(36) | Conditional | Core | Required when an explicit Workspace registry is used |
deviceGuid | string(36) | Conditional | Core | Required when an explicit Device registry is used |
pageGuid | string(36) | Required | Core | Permanent UUID of the page |
pageIndex | uint32 | Required | Core | Order of the page within the Workspace, starting at 0 |
pageNumber | uint32 | Required | Basic | Page number shown in the UI; not used for ordering |
layerIndex | uint32 | Required | Core | Layer order, starting at 0 |
layerNumber | uint32 | Required | Full | Layer number shown in the UI; not used for ordering |
viewport | Map | Optional | Standard | Pan and zoom, written on layer 0 only; see viewport |
background | Map | Optional | Basic | Page background, written on layer 0 only; see Page metadata |
pageState | int32 | Optional | Standard | Page state, written on layer 0 only |
pageKind | int32 | Optional | Standard | Page kind, written on layer 0 only |
binding | int32 | Optional | Standard | PPT binding method, written on layer 0 only |
slideId | int32 | Conditional | Standard | PowerPoint SlideID; see PPT binding |
extra | Map | Optional | — | App-private fields |
Page identity
- CANVAS-1
pageGuidis unique within the whole file and stays unchanged after pages are reordered or the file is fully saved; a copied page must get a new UUID. - CANVAS-2 Canvases of the same page on multiple Devices and multiple layers share
pageGuidandpageIndex. - CANVAS-3 In a compact file, within one Workspace
pageGuidandpageIndexcorrespond one to one, andpageIndexis contiguous starting at0. During page append there may temporarily be duplicates or gaps; readers handle them per SAVE-14. - CANVAS-4 Under each
(Workspace, Device, pageGuid),layerIndexis contiguous starting at0. Different Devices may have different numbers of layers. - CANVAS-5
(Workspace, Device, pageGuid, layerIndex)is the unique key of a Canvas. When the same key appears more than once, the later one replaces the earlier one entirely (FILE-8). - CANVAS-6
pageNumberandlayerNumberare for display only and may skip numbers or repeat. - CANVAS-7 When a page is copied, the new page inherits the original page's
viewportand page metadata.
Page metadata
Page metadata belongs to "a page on a given Device" and, like viewport, is written on layer 0 only:
- CANVAS-8
viewport,background,pageState,pageKindandbindingmay only be written on the Canvas withlayerIndex = 0; other layers inherit them from layer 0. When readers find these fields on other layers, they ignore them and report a warning.
background (Basic)
| Field | Type | Requirement | Description |
|---|---|---|---|
color | Color Map | Required | Background color |
pattern | int32 | Optional | 0 Blank (default), 1 Dots, 2 Grid (square grid); 3–127 reserved, 128+ private |
pattern: 0pattern: 1pattern: 2- CANVAS-9 The pattern's spacing and line color are up to the app. An unknown
patternis shown as Blank. - CANVAS-10 Without
background, the background is transparent (screen annotation, PPT) or up to the app (whiteboard).
pageState, pageKind, binding (Standard)
| Field | Value | Meaning |
|---|---|---|
pageState | 0 Active (default) | Normal page |
1 Retained | Retained page: its content is still saved but not shown in the normal page order. For example, annotations in PPT whose slide has been deleted | |
pageKind | 0 Normal (default) | Ordinary page |
1 EndScreen | The black screen page after a PPT slide show ends; may have no slideId | |
binding | 0 SlideId (default) | Bound to a slide by slideId |
1 PageIndex | Bound by order: page pageIndex corresponds to slide pageIndex + 1 |
- CANVAS-11 Standard readers do not put retained pages into the normal page order; they may list them separately for the user to view or rebind.
- CANVAS-12 Unknown values of
pageState,pageKindandbindingare treated as the default.
PPT binding
- CANVAS-13 When
workspaceType = 2, an ordinary page withbinding = 0(default) must writeslideId; pages withbinding = 1orpageKind = 1may omit it. - CANVAS-14 When binding by
slideId, readers locate the slide withSlides.FindBySlideID. If it cannot be found, readers must keep the Canvas, mark it as unbound and notify the user; they must not automatically reattach it bypageIndex, the current page or any other slide. After the user picks a new slide through an explicit rebind action, writers save the new binding. - CANVAS-15 When the same slide is shown on multiple Devices, the Canvases share
pageGuidandslideId, and their content is independent.
viewport
The viewport specifies which point on the Canvas maps to the Device's top-left corner and what scale factor to use.
| Field | Type | Requirement | Description |
|---|---|---|---|
x | float32 | Required | Canvas X corresponding to the Device's top-left corner; may be negative |
y | float32 | Required | Canvas Y corresponding to the Device's top-left corner; may be negative |
scale | float32 | Required | Scale factor, a finite positive number; 1 means one Canvas unit corresponds to one Device pixel |
CanvasCanvas coordinates, grid spacing 40
Device view320 × 200 pixels
viewport
{ x: 60, y: 40, scale: 1.25 }Point PCanvas
(240, 150) → Device deviceX = (240 − 60) × 1.25 = 225deviceY = (150 − 40) × 1.25 = 137.5Visible areawidth 320 / 1.25 = 256, height 200 / 1.25 = 160
Conversion between Canvas coordinates and Device coordinates:
deviceX = (canvasX − viewport.x) × viewport.scale
deviceY = (canvasY − viewport.y) × viewport.scale
canvasX = deviceX / viewport.scale + viewport.x
canvasY = deviceY / viewport.scale + viewport.y- CANVAS-16 When
viewportis missing, it is{ x: 0, y: 0, scale: 1 }. - CANVAS-17 All content blocks (Ink, Shape, Media) are mapped by the same
viewport; Ink stroke widths and Shape stroke widths are also multiplied byscale. - CANVAS-18 The Canvas range currently visible on the Device is
Device.width / scalewide andDevice.height / scalehigh. When the Device size changes, the top-left corner stays fixed and the visible range grows or shrinks toward the bottom right. - CANVAS-19
viewport.x/yare Canvas coordinates and have nothing to do with the Device's ownx/y(DEV-3). - CANVAS-20 UInk does not register viewport rotation, skew or non-uniform scaling.
- CANVAS-21 All Workspace types may use
viewport. An app may disallow user panning and zooming, but when it encounters a valid non-defaultviewportit must display it using the formulas in this section. - CANVAS-22 When
viewportis missing a field,x/yis not a finite number, orscaleis not a finite positive number, the wholeviewportis invalid and the default is used.
Other rules
- CANVAS-23 A Canvas does not store its own bounds; its display viewport always fills the Device it references (FILE-10).
- CANVAS-24 When explicit registries are used and
workspaceGuidordeviceGuidis missing or cannot be found, readers create a temporary Workspace or root Device and report a warning (FILE-23). - CANVAS-25 When
pageGuidorpageIndexis missing or invalid, readers may generate temporary pages in object stream order; whenlayerIndexis missing or invalid, they generate temporary layers under the temporary page in object stream order. Temporary results must not be written back to the file.
Example
{
"type": 2,
"workspaceGuid": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
"deviceGuid": "11111111-1111-4111-8111-111111111111",
"pageGuid": "cccccccc-cccc-4ccc-8ccc-cccccccccccc",
"pageIndex": 0,
"pageNumber": 1,
"layerIndex": 0,
"layerNumber": 0,
"viewport": { "x": -320.0, "y": 180.0, "scale": 1.5 },
"background": { "color": { "fallback": 16777215 }, "pattern": 1 } // white background with a dot pattern
}PPT end page:
{
"type": 2,
"workspaceGuid": "aaaaaaaa-aaaa-4aaa-8aaa-aaaaaaaaaaaa",
"pageGuid": "dddddddd-dddd-4ddd-8ddd-dddddddddddd",
"pageIndex": 24, "pageNumber": 25, "layerIndex": 0, "layerNumber": 0,
"pageKind": 1 // no slideId
}Fallback
| Capability the reader lacks | How it is shown |
|---|---|
background (Core) | Transparent or the app's default background |
viewport (Core, Basic) | Shown as { x: 0, y: 0, scale: 1 } |
PPT binding, pageState, pageKind (Core, Basic) | All pages are shown as ordinary pages by pageIndex, retained pages included |
| Multiple layers (below Full) | Overlaid by layerIndex from low to high and shown as one layer |