Nothing

Attached drawables

Attach artwork to a shape’s bounds, contour or authored vertices.

Read as Markdown

A drawable written inside a shape is attached to that shape's geometry. One locator names the point of the geometry where the drawable's origin sits. Keying the geometry updates each locator against the sampled host. An unlocated child retains its frame at the host’s local origin. Keying a locator moves one drawable over it. Everything else in the scene keeps its explicit coordinates. Spatial composition · Cases · Guide entry · Precedents

The chapter adds no ids and no references. It adds one nesting rule, five attributes and one rule about paint order. Relations between siblings, sizes taken from a host and container layout are outside it.

An arrow on a line

<scene width="640" height="360" frame-rate="24">
  <shape>
    <polyline points="80,250 230,110 400,230 560,100"/>
    <stroke stroke-width="3"><paint><solid color="#8A93A6FF"/></paint></stroke>
    <shape vertex="1">
      <circle r="7"/>
      <fill><paint><solid color="#F4F4F5FF"/></paint></fill>
    </shape>
    <shape vertex="3" orient="auto">
      <polygon points="-6,-11 16,0 -6,11"/>
      <fill><paint><solid color="#FFC23DFF"/></paint></fill>
    </shape>
  </shape>
</scene>

The dot's origin is on the second point of the line, at (230, 110). The arrowhead's origin is on the last, at (560, 100), turned −39.094° to face the way the line arrives. Each is drawn in its own coordinates around that origin, as an SVG marker is drawn around its reference point.

Change or sampleExpected result
Switch points to 80,180 250,260 380,90 560,200 with a held key at frame 30 and fill="freeze".From frame 30 the dot is at (250, 260). The arrowhead follows the last point. No value on either attached shape changes.
Change the arrowhead's vertex="3" to vertex="2".It sits at (400, 230) and faces −1.938°, halfway between arriving at 35.218° and leaving at −39.094°. One value changes in the source.
Use vertex="1.5" on a third shape.Its origin is at (315, 170), halfway along the stretch from the second point to the third.
Wrap the dot in a group with no attributes.Nothing moves.
Set translate-y="-18" on the dot.It sits 18 above the point. The translation is the offset from the point.

Hosts

The host of a drawable is the nearest enclosing shape. A drawable with no enclosing shape has the scene as its host. A shape, group or sequence can be written directly inside a shape, beside its geometry and paint.

A group and an inline sequence have no geometry and are never hosts. A drawable inside one is attached to the host outside it, and the group's transform then moves it like any other content. A referenced scene is its own document: its drawables have that scene as their host, and its placement hosts nothing.

A host's geometry is its own. What is attached to a shape never changes that shape's bounds, contour or vertices, and never changes the bounds its image paint uses.

What a geometry offers

GeometryBoundsContourVertices
rectThe registered box before corner rounding.The contour a stroke trims: from the end of the top-left corner, clockwiseNone
circle, ellipseThe registered center plus and minus the radiiFrom the rightmost point, clockwiseNone
lineOf its two endpointsFrom the first endpoint to the secondThe endpoints, 0 and 1
polylineOf its pointsThrough the points in authored orderThe points, from 0
polygonOf its pointsThe same, with the return to the first pointThe points, from 0
pathOf the curves it draws, in every subpath. Control points do not count.Its one subpath in command order, with its closing stretch when it ends in Z. A command after a close starts another subpath.The initial point, then the end point of each segment, counting the segments of repeated arguments. A close adds none.
textThe box of its lines, defined belowNoneNone
booleanOf the resulting regionNoneNone
the sceneFrom (0, 0) to the resolved canvas width and heightAs a rect at the origin with square cornersNone

Bounds and contours are those of the geometry in the host's local coordinates, before any stroke, shadow, filter or transform. A contour and its direction are exactly those of stroke trimming, so a stroke's trim and a drawable's along measure the same distance. A path with several subpaths has bounds and no single contour.

Text. The box of a text runs from the first baseline minus the ascent to the last baseline plus the descent. Use the horizontal font metrics of the text element’s sampled face and size, as defined in text layout. Spans do not change them. With an inline-size the box is that wide. Without one it is as wide as the widest line. Either way the box is placed at x by text-anchor, as a line of that width would be. Empty copy has one empty line. Its natural width is zero. An authored inline-size still supplies its box width.

Hosts at their limits. Bounds and contours come from the authored numbers. A rectangle of zero width keeps bounds of zero extent and keeps its contour. A contour of one point, or of several points in one place, has no length: along and vertex give that point, with direction 0. A point list or path with no coordinates at all has no bounds and no contour. The same holds for one the draft rejects as malformed. Every locator on such a host gives the origin, with no further report. A boolean whose result is empty has no bounds, and u and v on it give the origin.

Locators

A locator is an attribute of the attached shape, group or sequence. Each is a finite number and an ordinary animated property.

LocatorThe point of the host
u, vu is a share of the bounds' width, measured from their left edge: x = left + u × (right − left). v is the same for the height, from the top. Each is optional and independent. An omitted one contributes 0, so the drawable stays at its parent's origin on that axis. Values outside 0 to 1 lie outside the bounds.
alongA share of the contour's length from its start. On an open contour it lies in 0 to 1. On a closed contour it is unwrapped: use its fractional part, so 1.25 is a quarter of the second lap and −0.25 is three quarters.
vertexA whole number is that vertex. A fraction is a share of the contour's length from that vertex to the next, so 1.5 is halfway along that stretch. On an open contour with n vertices it lies in 0 to n − 1. On a closed contour the stretch after the last vertex returns to the first, and v and v + n name the same point.

One kind per drawable. u and v together are one kind, along is another and vertex a third. The kind is read from the source: an attribute or a track for it counts, whatever it samples to and even when its value is dropped. A drawable with none sits at its parent's origin, with its ordinary local transform.

A vertex within 0.000001 of a whole number is that vertex. A locator with a track needs an authored base, as an animated inline-size does.

Facing the contour. orient is none, the default, or auto. With auto, the drawable is turned about the point to face the direction of the contour there. It needs along or vertex. It switches with held keys.

The direction at a point is the way the contour leaves it, as an angle measured like rotate. On a curve that is the tangent. At a corner it is the direction of the stretch that follows. The last point of an open contour uses the direction it arrives by. Stretches of no length are skipped.

A whole vertex is the exception, and follows SVG's marker: it faces halfway between the arriving and the leaving direction, through the smaller turn. If the two are exactly opposite it faces the leaving direction. The first vertex of an open contour has only a leaving direction and the last only an arriving one. A share of the length can fall on a corner only by coincidence of arithmetic, so along never uses the halfway rule.

Placing an attached drawable

Let P be the point the locator gives, in the host's coordinates, and θ the direction that orient="auto" adds, otherwise 0. For a local point v of the drawable, with the pivot p, translation d and the rotation, shear and scale of the spatial chapter:

in the parent:  P + R(θ) × ( d + p + R × K × S × (v − p) )

With no transform of its own, the drawable's origin lands on P. translate-x and translate-y are the offset from P. orient="auto" turns that whole frame about P, so the offset turns with the contour: translate-y="-4" is 4 to the left of the direction of travel. The drawable's own rotate still turns it about its own pivot inside that frame, so its facing is θ plus rotate. Then each ancestor's map applies out to the scene, as before.

When groups or inline sequences lie between the drawable and its host, P is still computed in the host's coordinates and used as written in the parent's. A group with no transform therefore changes nothing. A group that is itself attached, or transformed, moves its content like any group: a drawable inside it is then off its point by the group's own map.

The host's transform carries what is attached to it. Scaling a host scales its attachments. To resize a card and keep a badge's size, key the card's geometry.

Order and compositing

Attached drawables paint in document order. One written before the shape's geometry element paints beneath the shape's own paint. One written after it paints above, including one written between the geometry and the fill. This gives a meaning to the position of the geometry element, which had none. A fill, a stroke, a shadow, a filter and a mask keep their meaning wherever they are written.

  1. Draw the attached drawables written before the geometry, in order.
  2. Draw the shape's outer box shadows, fill, inset box shadows and strokes.
  3. Draw the attached drawables written after the geometry, in order.
  4. Run the shape's filter on that picture, apply its mask and its opacity once, then its transform. A shape with a backdrop filter combines this source with the picture at its paint position using the backdrop rule.

By default a shape assembles its attached drawables on transparency. An unfiltered pass-through shape draws into its parent scope. A card at opacity 0.5 with a badge overlapping its corner has alpha 0.5 throughout, including the overlap. Inside that picture the drawables beneath are earlier operations of the same shape, so the bottom blend mode of the shape's fill sees them. Each attachment uses its own layer blend mode.

Mask sources. A mask's source shape is written inside its owner, so it takes a locator like any drawable there. Its host is the nearest enclosing shape: the owner itself when the owner is a shape. An iris can open from u="0.5" v="0.5" of a word whatever the word is. Drawables attached to a mask source are part of its rendered picture. An alpha or luminance mask sees them. A geometry mask takes the source's own geometry and ignores them, as it ignores the source's paint.

Boolean operands. An operand supplies geometry to the shape that is being built, so it takes no locator. Drawables written inside an operand are reported and contribute nothing.

Sequences. A sequence can be attached. Its locators, and their keys, use the enclosing composition's time. What an inline sequence holds uses source time and is attached to the host outside the sequence, whose geometry is sampled at the host's own time. Attachment does not change sound. A mask source and an operand contribute no sound.

Animation

u, v, along and vertex are continuous values with hold, linear and spline segments. orient is discrete. A track on a locator needs an authored base on the drawable, so the locator always has a value.

Three controls stay independent. The same test the doctrine uses for a road's casing applies here.

The artist keysWhat movesWhat stays
The host's geometry: a point, a width, the copyEvery point on it, and so everything attachedEach attached drawable's own values
One locatorThat drawable, over the hostThe host and its other attachments
A transformThat drawable and what is attached to it, rigidlyIts host and its siblings

What is reported

Report each condition at its source. A strict reader refuses the affected sample. A best-effort reader uses the result in the table. Check the active locator value against the host geometry at that instant. For example, a held geometry key can reduce the vertex count and put a previously valid index past the end. A linter can also check authored values ahead of time.

SourceResult
More than one kind of locator on a drawableNone is used. The drawable sits at its parent's origin.
along or vertex on a host with no single contour: text, a boolean, a path with several subpathsThe same
vertex on a host with a contour and no vertices: a rectangle, a circle, an ellipse, the sceneThe same
A point that is not finite, from a share or a geometry too large to computeThe same
A locator with a track and no authored baseThat locator has no value: for u or v that axis is at 0, and for along or vertex the drawable sits at its parent's origin
A locator that is not a finite numberThe same as having no value. Its kind still counts.
A sampled along or vertex outside an open contourThe nearest end
orient="auto" with no along or vertex, or an orient that is not a valueNo rotation is added
A locator, or orient, on a boolean operandNot used
A drawable written inside a boolean operandReport at the operand. Ignore the nested drawable’s picture and sound

These are all the conditions this chapter adds. A drawable depends on its host's geometry and on nothing beside it, so there is no reference to resolve, no order to find and no cycle.

Evaluating

  1. Sample every property at its owner's time.
  2. Resolve the host's geometry from its own sampled properties: lay out text, then find the bounds, the contour and the vertices.
  3. For each drawable whose host this is, including a mask source and anything reached through groups and inline sequences, find P and θ from its locator and compose its map.
  4. Descend. Each shape is the host of what is written inside it.

No step reads the host's transform or paint, or another drawable's place, to find a point. An operand's transform is part of a boolean's geometry and is read as such. The scene resolves in one pass from the root, and seeking to an instant gives the same result as playing to it.

A card and what sits on it

<shape translate-x="120" translate-y="70">
  <rect width="220" height="130" anchor-u="0" anchor-v="0" corner-radius="18"/>
  <fill><paint><solid color="#1E2430FF"/></paint></fill>
  <shape translate-x="22" translate-y="46">
    <text x="0" y="0" font-family="PT Serif" font-size="28" font-weight="700">Northline</text>
    <fill><paint><solid color="#F4F4F5FF"/></paint></fill>
  </shape>
  <shape u="1" v="0">
    <circle r="16"/>
    <fill><paint><solid color="#FF5A36FF"/></paint></fill>
  </shape>
  <shape u="1" v="1" translate-x="-22" translate-y="-20">
    <text x="0" y="0" text-anchor="end" font-family="PT Serif" font-size="16">updated 09:41</text>
    <fill><paint><solid color="#8A93A6FF"/></paint></fill>
  </shape>
</shape>
Change or sampleExpected result
As writtenThe badge's center is on the top-right corner at scene (340, 70). The footer's origin is 22 left of and 20 above the bottom-right corner, at (318, 180), and its text ends there on that baseline. The title has no locator and stays at (142, 116).
Key the rectangle's width to 400 and height to 220.The badge is at (520, 70) and the footer at (498, 270). The title has not moved. The edit changes two values on the rectangle.
Replace the rect with an ellipse of the same bounds.The badge and footer keep their places on the bounds. u and v survive a change of geometry.
Set opacity="0.5" on the card.The card, title, badge and footer fade as one picture.
Move the badge's element above the rect.It paints beneath the card. Its place is unchanged.

A unit that follows a number uses the same rule with text as the host. With the number's x and y at 0, u="1" and no v puts the unit at the end of the number, on its baseline. Replacing the copy moves the unit.

Editing

GestureSource patch
Drag an attached drawable off its pointtranslate-x and translate-y on that drawable
Slide it along the hostOne locator value
Move a point of the host, or change a size or the copyThe geometry's own values. Nothing attached is rewritten.
Insert or delete a point of the hostA structural edit. vertex counts points, so the editor renumbers the vertex bases and keys of everything attached to that host, through groups, sequences and mask sources.
Group attached drawablesThe group element is added around them. No value changes.
Move a drawable into or out of a hostA structural edit. The editor rewrites its locator and translation to keep its place at the current instant.

Vocabulary

KindOwnerNameValuesMeaning
elementshape (added to the existing owners)shape, group, sequenceA drawable attached to the shape's geometry.
attributeshape, group, sequenceu, vShares of the width and height of the host's bounds. Each is optional.
attributeshape, group, sequencealongShare of the length of the host's contour, in the measure a trim uses.
attributeshape, group, sequencevertexAn authored point of the host's contour, from 0. A fraction lies between two.
attributeshape, group, sequenceorientnone, autoAdd the contour's direction at the point to the rotation.

Nested drawables and the five unqualified attributes on their specified owners have Level 1 meaning. Earlier drafts treated these names as render-neutral host attributes. A host that uses one of these spellings for its own metadata can move it into its own XML namespace.

SVG interchange

An importer writes each SVG marker as attached drawables: one per vertex the marker property covers, with vertex set and orient="auto" when the marker's orient is auto. refX and refY become an offset of the marker's content. An importer identifies each loss.

  • The shared definition becomes copies, so editing one arrowhead no longer edits them all.
  • A marker in strokeWidth units is written at its resolved size and no longer follows the stroke width.
  • SVG assigns start and end to the first and last vertices of the entire path, and marks the intervening vertices across subpaths. A path with several subpaths has no vertices here, so the importer splits it into one shape per subpath or writes the markers at resolved positions. Splitting a compound path can change its fill or stroke, so retain the original painted path and use unpainted subpath guides when needed.
  • A marker's viewport clips its content by default. The importer adds a mask or reports the difference.
  • paint-order can put markers between the fill and the stroke. Attached drawables paint beneath all of a shape's own paint or above all of it.

For a compatible SVG motion animation or CSS motion path, write an unpainted path host and put along on its moving child. Add orient="auto" to match automatic tangent rotation. Resolve units, anchor and transform order, and convert progress and timing on the child.

For a compatible set of oriented vertex decorations, an exporter can synthesize SVG marker definitions when role, scale, facing, clipping and paint order agree. A closed seam may carry separate SVG start and end markers at the same point. Resolve or report context-dependent marker paint and any difference at a reversing corner. SVG 2 markers

Export has no SVG form for u and v on arbitrary bounds or for text as a host. An exporter writes the resolved transform at each sample and reports that the attachment is lost.

Outside this chapter

These were considered and left out. Each is a real need and none is blocked by the rules above.

  1. Relations between siblings. One drawable placed against another by name. That is the pin proposal, which stays a separate study (gridaco/nothing#147).
  2. Size from a host. A plate behind a word and an underline as wide as it need two points of the host. A locator gives one.
  3. A flat run. Words that follow each other without nesting. Attached words can chain, one inside the other, but a transform or opacity on one then carries the rest.
  4. Upright attachment. Following a point without taking the host's rotation.
  5. Repetition. One drawable on every vertex, or at intervals. A generator writes the copies.
  6. More of text. The end of the last line, the baseline of a line other than the first, and a contour for text or a boolean.
  7. Vertices of a rectangle or an ellipse. They have none today. A rectangle's corners are reachable as u and v.
  8. Surfaces. A 3D host would take u and v on its surface with the same rule. It needs a projection, an order by depth and a facing rule of its own.

Readers sample point lists and path data before measuring a contour. A change in vertex count or command structure requires a held segment.

Design evidence

Precedents. SVG's marker is the model: the shape owns what marks it, and the marker's own coordinates decide which part lands on the point. along with orient is the motion path of CSS and After Effects, made a shape in the scene that several drawables share. u and v are the normalized anchors of Unity and Godot, read from a geometry's bounds in place of a layout box. A one-way dependency is what separates this from a CAD sketch, whose two-way relations need a solver. Precedent study

Decisions. Each was a choice between written alternatives.

DecisionAlternativeWhy this one
The attached drawable is nested in the shape and carries its own locator.A wrapper element that owns the locator. A container that names one child as a guide.It is the flattest form that states ownership. A shape with no paint is already an invisible guide, and a painted host needs no copy of its geometry. Nesting is how a mask source and a boolean operand already state membership.
A group passes through to the host outside it.Report a locator inside a group.Grouping is the commonest structural edit and must not move anything. A group has no bounds here, so passing through is one sentence.
Paint order follows the position of the geometry element.Attached drawables always paint above. An attribute for beneath.A glow or plate behind its host is common. Document order already orders drawables and strokes.
along faces the way the contour leaves. A whole vertex faces halfway through its corner.Halfway at every corner. Leaving at every corner.A whole vertex is SVG's mid marker and must import unchanged. A share of the length lands exactly on a corner only by rounding, so a halfway rule there would differ between implementations for one frame.
A keyed locator needs a base.A released track leaves the drawable at the origin.The drawable would jump between the origin and the contour. The draft already asks an animated inline-size for a base.
A report is tested at each sample.Reports about authored values only.A host's point count and closure can change at a key.
Three kinds of locator, one per drawable.One attribute with a typed value. Named points such as top-right.A number keys and interpolates. Bounds, length and vertex are three different addresses: a share of the length suits travel, and a vertex stays on the author's point when the others move.
u and v are independent, and an omitted one is 0.Both required. Default 0.5.A drawable can take one axis from the host and keep the other explicit. With text at (0, 0), u="1" alone is the end of the line on its baseline.
along uses the trim's contour and range rules.A second parameterization.One concept, one measure. The road case drives a trim and a locator with the same keys.
A reported locator leaves the drawable at its parent's origin.Use the first of several.One result for every structural problem, and the picture shows that something is wrong.
Omitted u or v is 0 on that axis.The geometry's own anchor, such as a text's x and y.Zero is the same for every geometry and is what a drawable with no locator gets. It costs the idiom below: keep a text's y at 0 to reach its baseline.
The offset turns with orient.Offset in the host's axes.A label beside a moving point stays on the same side of the path. CSS motion path composes the same way.

Traps found in review. An independent review listed what an author is likely to get wrong. None is unsound. Each is taught in the guide or recorded as outside the chapter.

  • An omitted v is the parent's y = 0. It is neither an edge of the bounds nor the baseline. With <text x="40" y="120">, a unit with u="1" sits 120 above the baseline. Keep the text's x and y at 0 and move its shape.
  • Locators add through an attached group. A group at u="1" v="1" holding a drawable at u="1" v="1" puts that drawable at twice the corner.
  • A transformed group takes its content off the contour.
  • Two shares. A fraction of a vertex is a share of one stretch. along is a share of the whole contour.
  • vertex counts points. Inserting a point renumbers the ones after it. On a closed contour a number past the last vertex wraps without a report.
  • Scaling a host scales what is attached. A scale pop on a card pops its badge with it.

What ran. The cases carry expectations a second implementation can read: 21 scenes and 235 checks, each derived by hand with arithmetic text metrics. They include the positions the draft publishes for its trimmed road and the worked numbers of its spatial chapter. A property run generates random documents, hostile values among them, and checks eight invariants, such as that grouping moves nothing and that nothing outside a drawable's subtree depends on it. Three deliberately broken resolvers are each caught. Four authors who saw only the guide wrote four briefs correctly and answered every reading question. An independent review found no fundamental flaw, and its findings are folded into the rules above. The README records each result.

On this page