# NCF Level 1 specification

[Canonical page](https://nothing.graphics/docs/format/spec) · [Page source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/spec/README.md)

The Level 1 document contract for source, diagnostics, canvas, clocks and scene order.



**Ratified internal rehearsal · 0.9.0.** A `.nothing` file describes an editable 2D scene. The same
source can be opened as artwork, sampled at a time, or placed in another
composition. Level 1 defines the meaning of the source independently of any
renderer, editor, or conversion tool. “Level 1” names this specification. It
introduces no version attribute or file migration. The first review draft and
subsequent contract decisions are listed under Unreleased. [Changelog](https://nothing.graphics/docs/format/changelog)

Start here for the document contract. The chapters below define how its
contents evaluate. A rule marked open identifies a limit of Level 1.

| Chapter                                                                            | What it defines                                                                                                                                |
| ---------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| [Graphics](https://nothing.graphics/docs/format/spec/graphics)                     | Shape geometry, editable boolean operands, multiple paints and strokes, gradients, images, masks, and compositing                              |
| [Boxed geometry](https://nothing.graphics/docs/format/spec/boxed-geometry)         | Registration, contour displacement and resize behavior for rectangles, circles and ellipses                                                    |
| [Image effects](https://nothing.graphics/docs/format/spec/filters)                 | Drawable-owned backdrop blur, ordered source filters, Gaussian blur, alpha-based drop and inner shadows, and outer and inset rectangle shadows |
| [Animation](https://nothing.graphics/docs/format/spec/animation)                   | Property ownership, base values, key addresses, interpolation, repetition, and seeking                                                         |
| [Sequences](https://nothing.graphics/docs/format/spec/sequences)                   | Placement of picture, sound, and nested compositions, local clocks, and audio mixing                                                           |
| [Attached drawables](https://nothing.graphics/docs/format/spec/attached-drawables) | Placement on bounds, a contour or a vertex, host ownership, facing and paint order                                                             |
| [Spatial composition](https://nothing.graphics/docs/format/spec/spatial)           | Groups, local coordinates, pivots, cameras, mask ownership, and composited opacity                                                             |
| [Fonts](https://nothing.graphics/docs/format/spec/fonts)                           | Family and weight requests, host font sources, coverage fallback and reproducible layout                                                       |
| [Text](https://nothing.graphics/docs/format/spec/text)                             | Editable copy, styled spans, font input, line layout, and replacement keys                                                                     |
| [Contour trim](https://nothing.graphics/docs/format/spec/contour-trim)             | Select a distance interval for one stroke while retaining its source geometry                                                                  |

Level 1 defines the 2D camera. A separate perspective trial exercises the ratified optical behavior with proposed spatial authoring syntax. [Perspective optics](https://nothing.graphics/docs/format/spec/perspective-camera-optics) · [Scene camera RFC](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md)

The [scene format type model](https://nothing.graphics/docs/format/spec/type-model) defines the structural reference
for all 32 Level 1 elements and the explicitly labeled spatial trial.

## A complete document [#a-complete-document]

```xml
<scene width="64" height="64">
  <shape translate-x="28" translate-y="28">
    <rect width="40" height="40"/>
    <fill><paint><solid color="#CD6843FF"/></paint></fill>
  </shape>
</scene>
```

This still has a transparent 64 × 64 canvas. The rectangle is centered at (28, 28), with its upper-left corner at (8, 8). A second fill paint would cover the same rectangle.
A sibling stroke would follow its contour. Changing the canvas width and
changing the rectangle width are distinct edits. To move the entire shape
by a further (4, 8), set `translate-x="32" translate-y="36"` on the shape. Its paints
and mask follow it. Each axis is an independently keyable scalar, with the
same translation semantics as the two components of SVG translation.
[SVG coordinate systems](https://www.w3.org/TR/SVG2/coords.html#TransformProperty)

### Source and names [#source-and-names]

Use UTF-8 XML 1.0 with one unnamespaced `scene` root. The ASCII vocabulary
is case-sensitive. UTF-8 also accommodates literal copy, filenames and comments.
An XML declaration is optional. XML quoting, numeric character references,
and the five predefined entity references have their XML meanings. The
document grammar admits comments and whitespace between elements. Character
data is significant inside `text` and `span`; elsewhere only inter-element
whitespace is permitted. See [text content](https://nothing.graphics/docs/format/spec/text) before indenting mixed
content. A DTD, processing instruction, or unknown element requires a diagnostic. [XML 1.0](https://www.w3.org/TR/xml/)

Attributes outside the Level 1 vocabulary are permitted on any element.
Their values are opaque to NCF evaluation and have no effect on the sampled
picture, audio mix, or animation. Source-preserving editors retain them on
unrelated edits. An unqualified core attribute still requires its specified
owner and value. A namespaced attribute has a distinct expanded name even
when its local spelling matches a core field. A host can supply a list of
well-known attribute names to a spelling checker. That list affects lint
diagnostics only. [Host vocabulary example](https://github.com/gridaco/nothing/blob/main/ncf/examples/host-labels/README.md)

Read a scalar number as a finite signed decimal in local units unless its
property gives another unit. The lexical form is an optional sign, decimal
digits with an optional fractional part (or a leading dot followed by
digits), and an optional decimal exponent with sign. For example, `8`,
`0.5`, `.5`, and `5e-1` are numbers. Property ranges still apply. Clock
values, frame rates, colors, point lists, and path data have their own
grammars. Resolve names on their owning element. For example, `fill` on
`animate` is an end-of-animation policy. Its spelling as a child of
`shape` introduces a paint operation. [Keyword table](https://github.com/gridaco/nothing/blob/main/ncf/docs/vocabulary.md)

### Canvas and clock [#canvas-and-clock]

* Supply `width` and `height` together as positive finite numbers to give
  the scene a fixed canvas. Its origin is the top left, x increases right,
  and y increases down. The visible region spans zero to the declared
  width and height. Geometry can extend beyond those boundaries.
* With both dimensions omitted, the caller supplies the viewport for visual
  sampling. A referenced scene without dimensions uses its enclosing
  viewport. Rendering needs a known extent. A lone dimension is an error.
  Changing an object's bounds never implicitly resizes the canvas.
* The first SVG exchange case uses a matching viewport at one local unit per
  CSS pixel. Export resolution is a separate input. Responsive sizing,
  automatic fit on resize, and authored `viewBox` transforms remain open.
  Sources with different dimensions can already be placed at their native
  size and scaled explicitly. [Source coordinates](https://nothing.graphics/docs/format/spec/sequences#source-coordinates)
  SVG distinguishes viewport establishment from
  the transform into user coordinates. [SVG coordinate systems](https://www.w3.org/TR/SVG2/coords.html)
* Optional `background="#RRGGBBAA"` fills the resolved scene viewport once,
  beneath all drawable children. The default is transparent black
  (`#00000000`). Background alpha participates in ordinary compositing.
  On resize the fill follows the viewport. A referenced scene uses its own
  resolved viewport and local time. Its placement transforms, clips, masks,
  and fades the entire picture, background included. Inline sequences and
  groups start transparent. The scene owns its background color track.
  [Color sampling](https://nothing.graphics/docs/format/spec/animation#property-types-and-exceptions)
* A scene containing a placement or a property track declares `frame-rate`.
  A still containing neither can omit it. Canvas dimensions
  and frame rate are document settings. Moving a key and changing the rate
  have distinct meanings. [Frame and time addresses](https://nothing.graphics/docs/format/spec/animation#key-addresses)

### From source to a sample [#from-source-to-a-sample]

A scene owns zero or more shapes, groups, and sequence placements in drawing order.
An optional named 2D camera frames their combined scene coordinates in the
viewport. A camera declaration consumes no paint slot. [Cameras](https://nothing.graphics/docs/format/spec/spatial#cameras)
Start with the sampled scene background and silence. Resolve at Base to inspect
authored properties, or at an explicit instant to obtain animated values.
A nested drawable can take its position from its host’s sampled geometry. Each group passes the enclosing time to its children. For each active
placement, map parent time to source time before resolving its contents.
Resolve text and its font inputs before using glyph geometry. Each stroke
can select part of the shared contour. Apply each drawable's local mask
and opacity to its assembled picture, then place that result in the parent.
Spatial operations preserve the audio mix. A composition
contributes its composited picture and audio mix to its parent. The same
document, resources, viewport, and sampling environment must give the same
result when seeking back to an instant. [Shape evaluation](https://nothing.graphics/docs/format/spec/graphics) ·
[Sampling sequences](https://nothing.graphics/docs/format/spec/sequences#resolving-a-composition-at-time-t)

### Source-preserving editing [#source-preserving-editing]

An editor must be able to locate an authored element, property, or key in
the specific source file that owns it. Syntax positions belong to a revision
of that file. Two equal paint values on different strokes are distinct
targets. A nested scene's placement belongs to the parent file, and an edit
to the referenced artwork belongs to the referenced file.

For a save without edits, preserve every byte. For a value change on an
existing attribute, replace only the bytes of the selected value. Preserve
the surrounding quotes, indentation, comments, sibling order, line endings,
and the other occurrences of that value. A literal-copy edit targets the
selected character-data range or held key in its owning text or span. Adding an absent property or a new
key is a structural edit at its owner. Reopening the file must reproduce the
edit. Full-fidelity syntax trees are one precedent for retaining tokens,
trivia, and source locations. The format specifies the observable edit.
[Roslyn syntax model](https://learn.microsoft.com/en-us/dotnet/csharp/roslyn-sdk/work-with-syntax)

### Diagnostics and evidence [#diagnostics-and-evidence]

A reader can recognize syntax that its renderer cannot evaluate. When a
requested operation encounters malformed source, an invalid owner or value,
a missing resource, or an unsupported construct, a strict reader reports the
reason and refuses that result. A best-effort renderer identifies any
degradation at its source. Include the file and an element or attribute
location. For malformed XML, a byte position or line and column suffices.
Source-preserving tools retain unedited source even when a construct is
unavailable for rendering.

The [rectangle exchange case](https://github.com/gridaco/nothing/blob/main/ncf/conformance/rectangle.md) supplies a
complete SVG input, native counterpart, expected samples, and a byte-local
edit. The [composition cases](https://github.com/gridaco/nothing/blob/main/ncf/conformance/README.md) exercise graphics and
timing together. These are expectations for implementations. The
[vocabulary check](https://github.com/gridaco/nothing/blob/main/ncf/tools/vocabulary.py) checks the authoring examples
against the inventory. The [moving card](https://github.com/gridaco/nothing/blob/main/ncf/conformance/composition-card.md)
exercises copy replacement, source slip, framing, stroke trim, and group opacity together.

## Scope under review [#scope-under-review]

| Area                       | In this draft                                                                                                                       | Decision still needed                                                                                                                  |
| -------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| Content and geometry       | Basic shapes, per-corner rectangle radii, paths and editable boolean geometry                                                       | Standalone images, further path and shape coverage                                                                                     |
| Text and layout            | Horizontal text layout, literal mixed content, stable styled spans and held copy                                                    | Selection by laid-out unit, path baselines, inline objects and container layout                                                        |
| Structure and placement    | Geometry attachments, spatial groups, pivoted scale, X-skew and rotation, independent parent and source clocks                      | Arbitrary matrices and automatic fitting on resize                                                                                     |
| Appearance and compositing | Local masks, isolated opacity, ordered paints, drawable blend modes, pass-through scopes, source filters, backdrop blur and shadows | Additional blend modes, general filters and host-defined shaders                                                                       |
| Geometry modifiers         | Independent strokes and whole-path trim across authored contours                                                                    | [Shape-wide modifiers and derived geometry branches](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/geometry-modifiers.md)      |
| Time and exchange          | Local property tracks, unit-speed nested sequences, fixed-viewport rectangle exchange                                               | Reusable animation, retiming and the remaining [SVG crosswalk](https://github.com/gridaco/nothing/blob/main/ncf/docs/svg-crosswalk.md) |

The [design doctrine](https://github.com/gridaco/nothing/blob/main/ncf/DOCTRINE.md) gives the criteria for reviewing these
decisions. The [authoring guide](https://nothing.graphics/docs/format/llms.txt) teaches the current vocabulary.
