# Frame a scene with cameras

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

Reframe the whole scene and cut between named views without editing the artwork.



Declare a 2D `camera` at the scene root and select its `id` with the scene’s `camera` attribute. Put your point of interest at `center-x` and `center-y` to bring it to the viewport center. Set `zoom` greater than 1 for a tighter view. `roll` rotates the camera axes clockwise, so artwork to the right of the center moves up at +90°. Camera framing follows the drawable transforms. The background still fills the fixed viewport. [Camera defaults and projection](https://nothing.graphics/docs/format/spec/spatial#cameras)

## Cut between named views [#cut-between-named-views]

Put a held `camera` track on the scene to choose the view. Put continuous numeric tracks on the individual camera to pan or zoom within that view. In the [runnable camera scene](https://github.com/gridaco/nothing/blob/main/ncf/conformance/cameras/index.nothing), a red marker centered at scene coordinates (32, 22) appears at the following picture coordinates.

| Frame at 24 fps | Selected view                               | Marker position |
| --------------- | ------------------------------------------- | --------------- |
| 11              | Wide, the default view                      | (32, 22)        |
| 12              | Tracking, center (35, 20) and zoom 2        | (44, 44)        |
| 24              | Rolled +90° around viewport center (50, 40) | (32, 58)        |
| 36              | Wide again                                  | (32, 22)        |

The tracking view has already sampled half of its center-X track by frame 12. Move the selector’s frame-12 cut to frame 18 and the camera’s center at the new cut becomes (37.5, 20). The marker then appears at (39, 44). The camera’s numeric track remains on the scene clock, independent of when it is selected. [Camera-cut observations](https://github.com/gridaco/nothing/blob/main/ncf/conformance/README.md#camera-cuts)

A referenced scene frames and clips its own picture before the parent places it. This sample also places a [child scene with a close camera](https://github.com/gridaco/nothing/blob/main/ncf/conformance/cameras/child.nothing). A parent view can reframe the result of that placement, including the child’s background. The 2D framing above is Level 1. Perspective optics are specified separately, and spatial authoring with planes is a trial. [Perspective optics](https://nothing.graphics/docs/format/spec/perspective-camera-optics) · [Spatial camera trial](https://github.com/gridaco/nothing/blob/main/ncf/rfcs/spatial-cameras.md)

## Examples

[Download the complete .nothing source](https://nothing.graphics/format/camera-cuts/source.nothing) · [Source on GitHub](https://github.com/gridaco/nothing/blob/main/ncf/conformance/cameras/index.nothing)

Rendered with ncf-preview at 100 × 80.

Bound resources

- [ncf/conformance/cameras/child.nothing](https://nothing.graphics/format/camera-cuts/child.nothing)

- [Frame 11 · Wide](https://nothing.graphics/format/camera-cuts/11.webp). The red marker sits near (32, 22). The red square inside the referenced child scene is already framed before placement.
- [Frame 12 · Tracking](https://nothing.graphics/format/camera-cuts/12.webp). A held key cuts to the 2× zoom of the tracking camera. The red marker moves to (44, 44).
- [Frame 24 · Rolled](https://nothing.graphics/format/camera-cuts/24.webp). The next held key cuts to a rolled view. The red marker appears at (32, 58).

```xml
<scene width="100" height="80" frame-rate="24" background="#101820FF" camera="wide">
  <camera id="wide"/>
  <camera id="tracking" center-x="30" center-y="20" zoom="2">
    <animate attributeName="center-x" fill="freeze">
      <key frame="0" value="30" ease="linear"/>
      <key frame="24" value="40"/>
    </animate>
  </camera>
  <camera id="rolled" roll="90"/>
  <camera id="beyond" center-x="110"/>
  <animate attributeName="camera" fill="freeze">
    <key frame="0" value="wide" ease="hold"/>
    <key frame="12" value="tracking" ease="hold"/>
    <key frame="24" value="rolled" ease="hold"/>
    <key frame="36" value="wide" ease="hold"/>
    <key frame="48" value="beyond"/>
  </animate>
  <shape>
    <rect anchor-u="0" anchor-v="0" offset-x="30" offset-y="20" width="4" height="4"/>
    <fill><paint><solid color="#E93434FF"/></paint></fill>
  </shape>
  <shape>
    <rect anchor-u="0" anchor-v="0" offset-x="108" offset-y="38" width="4" height="4"/>
    <fill><paint><solid color="#45CF80FF"/></paint></fill>
  </shape>
  <sequence href="child.nothing" begin="0f" dur="49f" source-start="0s"
            translate-x="70" translate-y="12"/>
</scene>
```
