---
url: /en-us/standard/appendix/shape-presets.md
---
**This appendix registers the shape presets of UInk 1.1**: each preset's name, its `construction` parameters, and how parts are generated from those parameters. Full editors use it to rebuild shapes, so users can keep dragging vertices or changing the number of sides or the height in another app.

::: tip Levels
Full. Lower-level readers display the parts in the file directly and do not need to read this appendix (SHAPE-12, SHAPE-15).
:::

## General conventions

* **PRESET-1** Display always follows the parts in the file. Parts that an editor rebuilds from `construction` may differ slightly from the parts in the file (floating-point error, number of sample points); this is not an error. After the user edits, all parts are replaced by the rebuilt result.
* **PRESET-2** Coordinates in `construction` are all **local coordinates** of the object (before `transform`), with the y axis pointing down and the same units as the Canvas. Final parts = the local geometry transformed by the object's `transform`.
* **PRESET-3** Points are written as `{ x: float32, y: float32 }`, consistent with Shape geometry.
* **PRESET-4** `construction` writes only the keys meaningful for that preset; readers ignore unknown keys, and missing keys use the defaults on this page. When a required key is missing or a value is invalid, the object falls back to the object layer (SHAPE-15) and the whole page is not rejected.
* **PRESET-5** Unknown `preset` name: fall back to the object layer. Private presets use the form `x-vendor-name`, for example `x-inkeys-protractor`.
* **PRESET-6** Curves are sampled into polylines with a maximum error of **0.25 Canvas units**: for an arc of radius `R`, each segment's angle is `step = 2 × acos(1 − tol / R)`, where `tol = 0.25 / max(1, M)` and `M` is the largest singular value of the linear part of the object's `transform`; when `R ≤ tol`, `step = π / 2`.

### `construction` fields

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `start` | Point | — | Start point; meaning varies by preset |
| `end` | Point | — | End point; meaning varies by preset |
| `vertices` | `Array<Point>` | — | Vertex list; edited triangles and quadrilaterals, or polylines and polygons |
| `mode` | int32 | See each preset | Creation mode: `0` Drag (drag out a bounding box), `1` Center (center + radius) |
| `constraint` | int32 | `0` | `0` Free, `1` Isosceles, `2` Equilateral |
| `constraintVertex` | uint32 | `0` | Index `a` (`0`–`2`) of the triangle's constrained vertex; the base is vertex `(a+2)%3 → (a+1)%3` |
| `cornerRadius` | float32 | `0` | Corner radius of a rectangle |
| `sides` | uint32 | `3` | Number of sides |
| `sweep` | float32 | — | Arc sweep angle in radians; positive is clockwise (y axis down) |
| `height` | float32 | — | Height of a solid, along the screen's vertical direction; negative is upward; must not be `0` |
| `baseSize` | Point | — | Length (`x`) and width (`y`) of a cuboid's base |
| `radius` | float32 | — | Circumradius of the base of a cylinder, cone, prism or pyramid |
| `baseRotation` | float32 | `0` | Rotation of the base around the vertical axis, in radians; the projection direction does not change |
| `mirrored` | bool | `false` | Direction of the oblique axis: `false` toward the upper right at 45°, `true` toward the upper left at 135° |
| `offset` | Point | `{0, 0}` | Offset of the top face or apex relative to the base center (model coordinates, rotating with `baseRotation`) |
| `right` | bool | `false` | Right prism or right pyramid: when `true`, `offset` must be `{0, 0}` |

### style

`object.style` stores the style used for editing. The `stroke` / `fill` on the parts are computed from it.

| Field | Type | Default | Description |
| --- | --- | --- | --- |
| `stroke` | bool | `true` | Whether to stroke; at least one of `stroke` and `fill` is `true` |
| `fill` | bool | `false` | Whether to fill; only for presets that can be filled |
| `strokeColor` | Color Map | Black | Stroke color |
| `fillColor` | Color Map | Black | Fill color |
| `strokeOpacity` | float32 | `1` | Stroke opacity |
| `fillOpacity` | float32 | `1` | Fill opacity |
| `width` | float32 | `2` | Line width, in **local units**; a part's stroke width = `width × √\|det T\|` |
| `linePattern` | int32 | `0` | `0` Solid, `1` Dashed, `2` Dotted, `3` DashDot |
| `dashOffset` | float32 | `0` | Dash offset, in Canvas units; not scaled by `transform` |

* **PRESET-7** `linePattern` is converted into the parts' `dashArray` according to the table below (`w` is the part's stroke width), using Round caps:

  | `linePattern` | `dashArray` |
  | --- | --- |
  | Solid | Empty |
  | Dashed | `[4w, 6w]` |
  | Dotted | `[0, 3w]` |
  | DashDot | `[4w, 5w, 0, 5w]` |

### aux

`object.aux` is a bitmask of auxiliary markers:

| Bit | Name | Applicable presets | Generated auxiliary parts |
| --- | --- | --- | --- |
| `1` | Center | `circle`, `regular-polygon`, `arc`, `sector` | One solid Circle at the center |
| `2` | Foci | `ellipse` | One solid Circle at each of the two foci |
| `4` | Diagonals | `rectangle`, `rounded-rectangle`, `parallelogram`, `rhombus`, `trapezoid` | Two diagonals (vertices 0→2, 1→3), Dashed |

* **PRESET-8** Auxiliary parts come after the body parts and count toward `partCount`. A point is a Circle with only a fill and no stroke: its radius is `max(part stroke width, 2)`, its color is the stroke color and its opacity is `strokeOpacity` (when there is no stroke, the fill color and `fillOpacity`); objects with only a fill and no stroke do not generate auxiliary parts. Bits that do not apply are ignored.

## Planar presets

Let `s = start`, `e = end`, `l = min(s.x, e.x)`, `r = max(s.x, e.x)`, `t = min(s.y, e.y)`, `b = max(s.y, e.y)`, `w = r − l`, `h = b − t`, `cx = l + w/2`, `cy = t + h/2`.

| `preset` | Required parameters | Local geometry | Parts |
| --- | --- | --- | --- |
| `line` | `start`, `end` | Segment `s → e` | Line ×1 |
| `arrow` | `start`, `end` | Shaft `s → e`; arrowhead see PRESET-9 | Line + Polyline |
| `rectangle` | `start`, `end` | Bounding box `(l, t)`–`(r, b)`; corner radius `min(cornerRadius, min(w, h) / 2)` | Rectangle ×1 |
| `rounded-rectangle` | `start`, `end` | Same as above, corner radius fixed at `min(w, h) × 0.2` | Rectangle ×1 |
| `circle` | `start`, `end`, `mode` | See PRESET-10 | Circle ×1 |
| `ellipse` | `start`, `end` | Ellipse inscribed in the bounding box, center `(cx, cy)`, semi-axes `w/2`, `h/2` | Ellipse ×1 |
| `triangle` | `start`, `end` | See PRESET-11 | Polygon ×1 |
| `parallelogram` | `start`, `end` | `k = (e.x − s.x) / 4`; vertices `s`, `(e.x − k, s.y)`, `e`, `(s.x + k, e.y)` | Polygon ×1 |
| `rhombus` | `start`, `end` | Midpoints of the four sides of the bounding box: `(cx, t)`, `(r, cy)`, `(cx, b)`, `(l, cy)` | Polygon ×1 |
| `trapezoid` | `start`, `end` | `(l + w/4, t)`, `(r − w/4, t)`, `(r, b)`, `(l, b)` | Polygon ×1 |
| `regular-polygon` | `start` (center), `end` (first vertex), `sides` (3–14) | Vertex `i` = `e − s` rotated around `s` by `2πi / sides` (clockwise) | Polygon ×1 |
| `polyline` | `vertices` (≥ 2) | Connected in order | Polyline ×1 |
| `polygon` | `vertices` (≥ 3) | Simple polygon: not self-intersecting, area not 0 | Polygon ×1 |
| `arc` | `start` (center), `end` (start point), `sweep` | See PRESET-12 | Polyline ×1 |
| `sector` | Same as `arc` | See PRESET-12 | Polygon ×1 |

* **PRESET-9** Arrow: `d = (e − s) / |e − s|`, arrowhead length `L = 3 × style.width`, `base = e − d × L`, `n = (−d.y, d.x)`. The arrowhead part is a three-point Polyline `[base + n × 1.5 × style.width, e, base − n × 1.5 × style.width]`, **always solid**, even when the shaft is dashed. The arrowhead does not use Markers (SHAPE-9).
* **PRESET-10** Circle: when `mode = 1` (Center), the center is `s` and the radius is `|e − s|`; when `mode = 0` (Drag), the side length is `side = max(w, h)`, the radius is `side / 2`, and the center is `s + (sx, sy) × side / 2`, where `sx` and `sy` are the signs of the corresponding components of `e − s` (`+1` when `0`). The `mode` of `circle` defaults to `1`.
* **PRESET-11** Triangle: when `vertices` (3 points) is present, it is used directly. Otherwise: when `constraint = 2` (Equilateral), an equilateral triangle is drawn with `s` as the center and `e` as the first vertex (same as `regular-polygon`); in all other cases the vertices are `(cx, t)`, `(r, b)`, `(l, b)`. For `constraint = 1` (Isosceles), `vertices` must have the constrained vertex on the perpendicular bisector of the base.
* **PRESET-12** Arc: center `s`, radius `R = |e − s|`, start angle `atan2(e.y − s.y, e.x − s.x)`, sweep `sweep`, `0 < |sweep| ≤ 2π`. Use `max(2, ceil(|sweep| / step))` segments as specified in PRESET-6. Sample the arc at equal angular intervals, including both endpoints. A sector adds the center after the arc points to close it; when `|sweep| = 2π`, the center is not added and the last point, which coincides with the first, is removed.
* **PRESET-13** After `parallelogram`, `rhombus` or `trapezoid` is edited, `vertices` (4 points) is written: a parallelogram satisfies `v0 + v2 = v1 + v3`; a rhombus additionally requires four equal sides; a trapezoid with `constraint = 0` keeps its top and bottom bases horizontal (`v0.y = v1.y`, `v2.y = v3.y`), and any tilt goes into `transform`.

## Solid presets

Solids are drawn on the plane with oblique (cabinet) projection: the base lies in the "model plane" and is projected into a parallelogram or ellipse, then the height is extruded along the screen's vertical direction.

| `preset` | Required parameters | Base | Parts |
| --- | --- | --- | --- |
| `cuboid` | `start` (base center), `height`, `baseSize` | Rectangle `(±baseSize.x/2, ±baseSize.y/2)` | Line ×12 |
| `cube` | Same as above, `baseSize.x = baseSize.y = \|height\|` | Square | Line ×12 |
| `cylinder` | `start`, `height`, `radius` | Circle | Line + Polyline; count varies with visibility |
| `cone` | `start`, `height`, `radius` | Circle; the top converges to an apex | Line + Polyline |
| `prism` | `start`, `height`, `radius`, `sides` (3–8) | Regular `sides`-gon | Line ×3n |
| `pyramid` | `start`, `height`, `radius`, `sides` (3–8) | Regular `sides`-gon; the top converges to an apex | Line ×2n |

`end` does not take part in the geometry of solids.

### Projection

* **PRESET-14** Projection coefficients `(kx, ky)`: for `cuboid`, `cube`, `prism` and `pyramid` they are `(k, −k)`, where `k = 1 / (2√2) ≈ 0.3535533906`; when `mirrored = true`, `kx` is negated. For `cylinder` and `cone` they are `(0, −1/3)`, unaffected by `mirrored`.
* **PRESET-15** A model point `(x, y, z)` is first rotated around the vertical axis by `θ = baseRotation`: `x' = cosθ·x − sinθ·y`, `y' = sinθ·x + cosθ·y`; it is then projected to the local point `start + (x' + kx·y', ky·y' + z)`. The base is `z = 0` and the top face is `z = height`; the model coordinates of the top face and apex additionally have `offset` added.
* **PRESET-16** The base circumference of a cylinder or cone is sampled per PRESET-6, with `R` taken as `radius × M'` (`M'` is the largest singular value of the matrix `[[1, 0], [kx, ky]]`); the number of segments is at least 32 and rounded up to a multiple of 4. The first sample point is the model point `(radius·cosθ, −radius·sinθ)`, so that the four axis endpoints fall on the extremes of the projected ellipse. In addition, sample points are inserted at the tangent points of the two silhouette generators: let the line of sight `V` be as in PRESET-17, `a = V.x − V.z·offset.x / height`, `b = V.y − V.z·offset.y / height`, `c = cone ? −V.z·radius / height : 0`; when `|c| < hypot(a, b)`, insert points of radius `radius` at angles `atan2(b, a) ± acos(c / hypot(a, b))`, then re-sort by angle.

### Hidden edges

* **PRESET-17** The line-of-sight vector is `V = (kx·cosθ − sinθ, −kx·sinθ − cosθ, ky)`. Take the interior point of the solid `I = (offset.x / 2, offset.y / 2, height / 2)`, and orient each face's normal `n` outward (positive dot product with "a point on the face − I"). A face with `dot(n, V) < −10⁻⁶ × |n|` is a **back face**.
* **PRESET-18** An edge is **hidden** if and only if both faces adjacent to it are back faces. Hidden edges are written as dashed lines (`linePattern = Dashed`); visible edges keep the object style.

### Part order

* **PRESET-19** Base vertices are numbered in the following order: for cuboids and cubes, `v0 = (−bx/2, −by/2)`, `v1 = (bx/2, −by/2)`, `v2 = (bx/2, by/2)`, `v3 = (−bx/2, by/2)` (`bx`, `by` are `baseSize.x`, `baseSize.y`); for prisms and pyramids, the regular polygon vertices before the PRESET-15 rotation, `v0 = (radius, 0)`, each subsequent one rotated clockwise by `2π / sides`. Base edge `i` is `vi → v(i+1)`; side face `i` is formed by base edge `i` and the corresponding top edge or apex; lateral edge `i` starts at `vi`. For each `i = 0 … n−1`, output in order: base edge `i`, top edge `i` (none for pyramids and cones), lateral edge `i`. Cylinders and cones have no straight base or top edges, and lateral edges are output only at the silhouette generators; the circumference of the base (and of the cylinder's top face) is cut into segments by visibility, starting at a visibility change, and consecutive arcs with the same visibility are merged into one Polyline.
* **PRESET-20** Solids are stroked only, not filled; the object `transform` may only be uniform scaling, flipping and translation (no rotation), and the orientation is expressed by `baseRotation`.

## Closed dashes

* **PRESET-21** Dashes on a closed shape (rectangle, circle, polygon, etc.) have their phase fixed by four anchors: let the outline perimeter be `P` and the distance from the outline's start point be `d`; then `quarter = P / 4`, `centered = d − quarter × floor(d / quarter + 0.5)`, and the phase coordinate is `|centered| + (Dotted ? 0 : 2w)`. Each anchor is always the midpoint of a dash (a dot for dotted lines), and the pattern extends symmetrically to both sides. The phase coordinate has the same direction as `dashOffset` (SHAPE-26).
* **PRESET-22** Outline start point: for a polygon, the first vertex; for a square-cornered rectangle, the top-left corner; for a rounded rectangle, the start of the top-right corner arc, clockwise; for circles and ellipses, the local angle `0` at `(cx + rx, cy)`.
* **PRESET-23** When writing parts, if there is a fill, first write a part with only the fill; then split the stroke by `[kP/8, (k+1)P/8]` into 8 Polylines, reversing the odd-numbered segments, each with `dashOffset = style.dashOffset + (Dotted ? 0 : 2w)` (SHAPE-8). Readers drawing these 8 segments with the ordinary dash rules get a symmetric appearance.

## Legacy shapes

The following presets have no `construction`; the parts themselves are authoritative (SHAPE-13):

| `preset` | Parts |
| --- | --- |
| `legacy-solid-line` | Line, solid |
| `legacy-dashed-line` | Line, `dashArray = [4w, 6w]` |
| `legacy-outline-rectangle` | Rectangle, stroke only, with small rounded corners |
| `legacy-filled-rectangle` | Rectangle, fill only |

## Related

* [Shape Block](../blocks/shape)
* [Nibs and Caps](../common/nib)
