Shape Preset Registry
About 2427 words
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.
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
constructionmay 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
constructionare all local coordinates of the object (beforetransform), with the y axis pointing down and the same units as the Canvas. Final parts = the local geometry transformed by the object'stransform. - PRESET-3 Points are written as
{ x: float32, y: float32 }, consistent with Shape geometry. - PRESET-4
constructionwrites 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
presetname: fall back to the object layer. Private presets use the formx-vendor-name, for examplex-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 isstep = 2 × acos(1 − tol / R), wheretol = 0.25 / max(1, M)andMis the largest singular value of the linear part of the object'stransform; whenR ≤ 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
linePatternis converted into the parts'dashArrayaccording to the table below (wis the part's stroke width), using Round caps:linePatterndashArraySolid 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 ismax(part stroke width, 2), its color is the stroke color and its opacity isstrokeOpacity(when there is no stroke, the fill color andfillOpacity); 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.
lineLine segmentarrowArrow, the arrowhead is always solidrectangleRectanglerounded-rectangleRounded rectangle, radius = short side × 0.2circleCircle, mode 1: s is the centerellipseEllipse, inscribed in the boxtriangleTriangleparallelogramParallelogram, k = (e.x − s.x) / 4rhombusRhombus, midpoints of the box sidestrapezoidTrapezoidregular-polygonRegular polygon, sides 5, s is the centerpolylinePolyline, connects vertices in orderpolygonPolygon, vertices close automaticallyarcArc, sweep −4π/3: s is the center, e the startsectorSector, sweep −3π/2: the arc returns to the centerstart or verticesendVertex computed from the parametersBox or radius (guide line, not a part)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 lengthL = 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 issand the radius is|e − s|; whenmode = 0(Drag), the side length isside = max(w, h), the radius isside / 2, and the center iss + (sx, sy) × side / 2, wheresxandsyare the signs of the corresponding components ofe − s(+1when0). Themodeofcircledefaults to1. - PRESET-11 Triangle: when
vertices(3 points) is present, it is used directly. Otherwise: whenconstraint = 2(Equilateral), an equilateral triangle is drawn withsas the center andeas the first vertex (same asregular-polygon); in all other cases the vertices are(cx, t),(r, b),(l, b). Forconstraint = 1(Isosceles),verticesmust have the constrained vertex on the perpendicular bisector of the base. - PRESET-12 Arc: center
s, radiusR = |e − s|, start angleatan2(e.y − s.y, e.x − s.x), sweepsweep,0 < |sweep| ≤ 2π. Usemax(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,rhombusortrapezoidis edited,vertices(4 points) is written: a parallelogram satisfiesv0 + v2 = v1 + v3; a rhombus additionally requires four equal sides; a trapezoid withconstraint = 0keeps its top and bottom bases horizontal (v0.y = v1.y,v2.y = v3.y), and any tilt goes intotransform.
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: 'cuboid'height: -110, baseSize: { x: 150, y: 110 }baseRotation: 0.5 (about 29°) mirrored: falselinePattern Dashedpreset | 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): forcuboid,cube,prismandpyramidthey are(k, −k), wherek = 1 / (2√2) ≈ 0.3535533906; whenmirrored = true,kxis negated. Forcylinderandconethey are(0, −1/3), unaffected bymirrored. - 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 pointstart + (x' + kx·y', ky·y' + z). The base isz = 0and the top face isz = height; the model coordinates of the top face and apex additionally haveoffsetadded. - PRESET-16 The base circumference of a cylinder or cone is sampled per PRESET-6, with
Rtaken asradius × 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 sightVbe 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 radiusradiusat anglesatan2(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 solidI = (offset.x / 2, offset.y / 2, height / 2), and orient each face's normalnoutward (positive dot product with "a point on the face − I"). A face withdot(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,byarebaseSize.x,baseSize.y); for prisms and pyramids, the regular polygon vertices before the PRESET-15 rotation,v0 = (radius, 0), each subsequent one rotated clockwise by2π / sides. Base edgeiisvi → v(i+1); side faceiis formed by base edgeiand the corresponding top edge or apex; lateral edgeistarts atvi. For eachi = 0 … n−1, output in order: base edgei, top edgei(none for pyramids and cones), lateral edgei. 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
transformmay only be uniform scaling, flipping and translation (no rotation), and the orientation is expressed bybaseRotation.
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
Pand the distance from the outline's start point bed; thenquarter = 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 asdashOffset(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
0at(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 withdashOffset = 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 |