# How to author a board

Write a `.draw` file. Have the user import the file. Do not write an SVG and expect Draw to turn the SVG into shapes. The Pictures and SVG page describes picture files. When you drop or insert a PNG or an SVG, you see the picture on the board in Chrome.

## Save the file

Save the text below as a file whose name ends in `.draw`. A raw JSON file works when the first byte is `{`. A zip works when the zip contains `draw.json` and any `assets/` bytes.

```json
{
  "format": "draw",
  "version": 1,
  "kind": "board",
  "exportedAt": 1,
  "projects": [
    {
      "name": "Project name",
      "boards": [
        {
          "name": "Board name",
          "background": "blank",
          "shapes": []
        }
      ]
    }
  ],
  "assets": [],
  "layouts": []
}
```

## Set the background and the export time

`background` is `blank`, `dots`, or `grid`. A bad value becomes `dots`. `exportedAt` is a number. In the checked example, `exportedAt` is `1`.

## Give every shape an id and a place

Each shape needs `id`, `type`, `x`, `y`, and `index`.

- `id` is any non-empty string. Draw's own ids are 16 characters. A shorter id also imports.
- `x` and `y` are CSS pixels. For a rectangle, a text shape, a sticky note, or a focus area, `x` and `y` are the top left.
- `index` is a fractional key. In the checked example, `index` runs `a0`, then `a1`, through `a7`, back to front.
- `rotation` defaults to 0 and is in radians. `parentId` defaults to null. `locked` defaults to false. `opacity` defaults to 1 and must be from 0 to 1.

Missing props are filled from the shape defaults. A prop that fails its schema drops the whole shape.

## Write the text blocks

`text` on a shape is rich text. The value is a list of blocks. A block `type` is `paragraph`, `bullet`, `number`, or `check`. A check may set `checked` to true or false. `spans` is a list of `{ "text": "..." }` with optional `"bold": true`.

## Set the shared style

Set each field to one of these values.

- Colors are `black`, `grey`, `red`, `orange`, `yellow`, `green`, `teal`, `blue`, `violet`, and `pink`.
- Fill is `none`, `semi`, `solid`, or `hachure`. Dash is `solid`, `dashed`, or `dotted`.
- Size is `s`, `m`, `l`, or `xl`.
- Font is `hand`, `sans`, or `mono`. The style panel calls those **Hand-drawn**, **Sans**, and **Mono**.
- Align is `start`, `middle`, or `end`. The panel calls those **Left**, **Centre**, and **Right**.
- Sketch is `rough` or `clean`. The panel calls those **Hand-drawn** and **Clean**.

`hand` uses Shantell Sans, then Segoe Print, Comic Sans MS, and cursive. `sans` uses Inter, then system-ui. `mono` uses JetBrains Mono, then ui-monospace. The font files on the page are Latin subsets.

Size `s` uses a 2 pixel stroke and 16 pixel text. Size `m` uses a 3 pixel stroke and 22 pixel text. Size `l` uses a 5 pixel stroke and 32 pixel text. Size `xl` uses an 8 pixel stroke and 46 pixel text. A sticky note uses 15, 19, 26, and 36 for `s`, `m`, `l`, and `xl`. A widget label uses the text size times 0.78, rounded. A table cell uses the text size times 0.72, rounded.

## Add a focus area

A focus area has type `frame`. Set `w`, `h`, and `name`. A click in the tool drops a focus area at 720 by 460. The checked example uses 960 by 540. There is no paper size and no required slide size. To put the focus area behind the shapes, give the focus area the lowest `index`.

## Add a rectangle

A rectangle has type `geo`. Set `geo` to `rectangle`, `ellipse`, `diamond`, `triangle`, `hexagon`, or `star`. The tool default is 180 by 120. Also set `color`, `fill`, `dash`, `size`, `font`, `align`, `sketch`, `text`, and `seed`. `seed` is an integer. Draw uses `seed` to keep a hand-drawn stroke stable. Any integer is accepted. Clean strokes still store a `seed`.

## Add text

A text shape has type `text`. Set `text`, `color`, `size`, `font`, `align`, `autoSize`, `w`, and `h`. With `autoSize` true, the words can paint wider than `w`. The export box still uses `w` and `h`. If you want the export to keep the words, make `w` and `h` at least as large as the words. A smaller box can clip the words in the export.

At zoom 1 in Chrome, the bold sans title Quarter plan at size `xl` measured 281 by 63. The grey sans line Three things to show at size `m` measured 219 by 30. The example stored larger boxes, 400 by 70 and 360 by 40, so the words fit.

## Add a sticky note

A sticky note has type `note`. The default box is 220 by 220. Set `w`, `h`, `text`, `color`, `size`, `font`, and `align`.

## Add an arrow

An arrow has type `arrow`. `x` and `y` are the page position of the start. `start` and `end` are offsets from that point. Each offset is `{ "x", "y", "binding" }`. Use `"binding": null` for a free end. A binding is `{ "shapeId", "anchor" }`. The anchor `x` and `y` run from 0 to 1 across the target box. `bend` is a number. `arrowheadStart` and `arrowheadEnd` are `none`, `arrow`, `triangle`, `dot`, or `bar`. A line is an arrow with both heads set to `none`.

The checked example connected two rectangles. After Draw resolved the ends, the stored arrow was at x 343 y 330, with end offset x 50 y 0. Copy coordinates from a board you have opened, or copy them from the checked example. The line paints the stored offsets. Draw drops a binding when the target id is missing.

## Add a widget

A widget has type `widget`. Set `kind` to one of the names below. The default box follows the kind name.

- `button` is 150 by 48.
- `input` is 260 by 48.
- `menu` is 200 by 176.
- `switch` is 170 by 40.
- `checkbox` is 180 by 36.
- `phone` is 300 by 600.
- `computer` is 800 by 500.
- `server` is 140 by 150.
- `database` is 140 by 160.
- `queue` is 220 by 96.
- `cloud` is 210 by 120.
- `user` is 110 by 150.

Set `label`, `checked`, `color`, `fill`, `size`, `font`, `sketch`, and `seed`. A menu label uses a newline between rows.

## Add a table

A table has type `table`. `cols` and `rows` are lists of positive widths and heights. `cells` is a list of lists of strings. `header` is true or false. The default is three columns of 140 and three rows of 44, with a header.

## Add a link

A link has type `link`. Set `w`, `h`, `url`, `title`, and `color`. The default box is 300 by 76. The open button accepts only `http`, `https`, or `mailto`.

## Add a group

A group has type `group` and empty props. Point children at the group with `parentId`. If a delete leaves the group with fewer than two children, the group dissolves.

## Add a pen mark

A pen mark has type `pen`. `points` is a flat list of x, y, and pressure in local coordinates. Prefer rectangles, text, and arrows when an AI writes the file. A pen path was not part of the checked example.

## Leave pictures out

Do not put an `image` shape or a `file` shape in a presentation file unless you also zip the bytes. Importing a `.draw` zip that includes an image asset is not checked. See Pictures and SVG.
