# Draw with paints and strokes

[Canonical page](https://nothing.graphics/docs/format/guides/paints-and-strokes) · [Page source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/docs/guides/paints-and-strokes.md)

Choose geometry, paint its interior and contour, then reveal a stroke by distance.



A `shape` holds one geometry. Its contour can give a filled region, a stroke centerline, or both. Start with a rectangle, circle, or ellipse for a boxed primitive, a polyline for an open series of edges, or a `path` for SVG path commands and multiple subpaths. Use a `polygon` to close a point list. Put editable operand shapes inside `boolean` when the result should follow a union, intersection, subtraction, or exclusion. [Shapes and path data](https://nothing.graphics/docs/format/spec/graphics#shapes) · [Boolean geometry](https://nothing.graphics/docs/format/spec/graphics#boolean-geometry)

## Paint the interior or the edge [#paint-the-interior-or-the-edge]

* Give the shape one `fill` with paints in the order you want them applied. Each `paint` contains one value, such as a solid color or a gradient. Put an opaque base first and translucent paint after it. A paint’s blend mode combines it with the existing paint stack or enclosing scope as applicable.
* Give the shape sibling `stroke` elements to trace the same contour at different widths. A wide stroke before a narrow stroke makes a casing with a center stripe. Set caps for the ends and joins for corners. Use centered alignment for open contours.
* Use a local image as a rectangle’s paint for still artwork. For example, `preserveAspectRatio="xMidYMid slice"` centers and covers the rectangle. Resolve `href` relative to the scene that declares it. [Paint and stroke rules](https://nothing.graphics/docs/format/spec/graphics#paint) · [Runnable linked-artwork scene](https://github.com/gridaco/nothing/blob/main/ncf/examples/linked-artwork/scene.nothing)

## Reveal a signature across a pen lift [#reveal-a-signature-across-a-pen-lift]

The [signature scene](https://github.com/gridaco/nothing/blob/main/ncf/conformance/signature-write-on.nothing) is a hand-authored Bézier path. One subpath forms the lettering and a second forms its underline. The stroke has round tips and turns. With its `trim` end animated from 0 to 1 over 96 frames at 24 fps, the path writes on over four seconds. Around frame 74 the first subpath is complete. The pen lifts to the underline’s start and the next visible ink appears there. Shorten the reveal by changing the last key’s frame from 96 to 48. The shape and traversal order stay the same.

### Predict the distance across disconnected subpaths [#predict-the-distance-across-disconnected-subpaths]

The [compound trim fixture](https://github.com/gridaco/nothing/blob/main/ncf/conformance/compound-trim.nothing) starts with a path `M8 10h48 M72 10h16`. The two drawn pieces measure 48 and 16 units, totaling 64. Each `M` positions the pen, with zero drawn distance. An animated `trim` on the stroke reveals a fraction of the total, using just the length of the drawn segments.

| Sample at 24 fps | Stroke end fraction | What paints                                                                                                                                    |
| ---------------- | ------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| Frame 4          | 0.5                 | The first 32 units. The top stroke centerline reaches x = 40, before its round cap.                                                            |
| Frame 6          | 0.75                | All 48 units of the first line. The second line is still clear. On the middle row, the closing command finishes the fourth edge of the square. |
| Frame 8          | 1                   | Both lines. The second line reaches x = 88, before its round cap.                                                                              |

The bottom stroke uses a fixed trim window from 0.625 to 0.875. It paints eight units on either side of the pen lift as two separate pieces. To add a guide behind the reveal, add a wide untrimmed stroke before the animated stroke. Both keep reading the same path when you edit a segment. [Contour trim and distance](https://nothing.graphics/docs/format/spec/contour-trim#directed-contour-and-distance) · [Conformance observations](https://github.com/gridaco/nothing/blob/main/ncf/conformance/README.md)

For a still, [build a solid paint stack or gradient](https://nothing.graphics/docs/format/guides/paint-stacks). To remove a region while keeping its source geometry editable, [cut a hole with a boolean](https://nothing.graphics/docs/format/guides/cutouts).

## Examples

[Download the complete .nothing source](https://nothing.graphics/format/signature-trim/source.nothing) · [Source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/conformance/signature-write-on.nothing)

Rendered with ncf-preview at 260 × 160.

- [Frame 24 · Opening loop](https://nothing.graphics/format/signature-trim/24.webp). Dark blue ink forms the opening loop. The later letter strokes and the underline are still blank.
- [Frame 72 · Final letter](https://nothing.graphics/format/signature-trim/72.webp). The stroke reaches the final letter and the underline is still absent. The pen lift adds zero length.
- [Frame 84 · Underline in progress](https://nothing.graphics/format/signature-trim/84.webp). The lettering is complete. A separate ink stroke grows from left to right beneath it.
- [Frame 96 · Complete signature](https://nothing.graphics/format/signature-trim/96.webp). The blue underline reaches its rounded final cap beneath the completed lettering.

```xml
  <shape>
    <path d="M24 91 C59 87 105 60 107 33 C109 14 86 21 74 52 C61 86 65 115 40 119 C23 122 27 102 48 101 C68 99 78 117 98 106 C109 100 117 89 120 81 C123 70 109 72 103 86 C95 104 104 112 115 103 C125 96 131 81 125 78 C120 76 118 87 130 89 C137 90 148 83 153 76 C148 85 134 109 147 109 C160 109 176 85 184 74 C178 84 163 110 176 109 C190 109 203 92 223 85 M40 140 C85 127 159 121 202 124 C217 125 232 122 243 117"/>
    <stroke stroke-width="3" stroke-linecap="round" stroke-linejoin="round">
      <trim start="0" end="0">
        <animate attributeName="end" fill="freeze">
          <key frame="0" value="0" ease="linear"/>
          <key frame="96" value="1"/>
        </animate>
      </trim>
      <paint><solid color="#173F5BFF"/></paint>
    </stroke>
  </shape>
```
