▼V Reference
52 Find a task or a name
53 Modules to require
54 Scenes and sampling
55 Scene states
56 Animation requests
57 Native model details
58 Visuals
59 Geometry
60 Number Lines and Coordinate Decorations
61 Point Markers, Scatter Plots, and Filled Areas
62 Probability and Statistical Diagrams
63 Calculus lessons
64 Colors
65 Slides
66 Slide command-line tools
67 Source Programs and Authored Timelines
68 Interactive Preview and Inspection
69 Preview controls and diagnostics
70 Projects and Final Rendering
71 Project execution and cache details
72 Pict Renderer Protocol
73 3D reference map
74 3D:   Objects, groups, and paths
75 3D:   Cameras and projection
76 3D:   Views inside a Scene
77 3D:   Animating 3D objects
78 3D:   Animating the 3D camera
79 3D:   Cuts, caps, and section measurements
80 3D:   Supplementary surface, section, and annotation bindings
81 3D:   Cuts, sections, and numerical volume
82 3D:   Vectors
83 3D:   Linear maps and rotations
84 3D:   Affine transforms
85 3D:   Bounds, rays, and planes
86 3D:   Spatial maps and homotopies
87 3D:   Materials and lights
88 3D:   Lighting inspection
89 3D:   Shadow descriptors and stable bounds
90 3D:   Finite-light animation
91 3D:   Software finite-light evaluation
92 3D:   Colour space and final output
93 3D:   Relations and geometric annotations
94 3D:   Projected labels
95 3D:   Textured billboards
96 3D:   Spatial curves and vector diagrams
97 3D:   Spatial anchors and label layout
98 3D:   Anchors and projected labels
99 3D:   Parametric surfaces and calculus
100 3D:   Adaptive, trimmed, and implicit surfaces
101 3D:   Constructive solids
102 3D:   Surface constructors and queries
103 3D:   Meshes
104 3D:   Triangle topology
105 3D:   Polygonal faces
106 3D:   Deterministic convex hulls
107 3D:   Polyhedral duals
108 3D:   Schlegel diagrams and polyhedral nets
109 3D:   Conservative mesh correspondence
110 3D:   Topology-safe mesh matching
111 3D:   Checking and repairing mesh orientation
112 3D:   Clipping, sections, and transparency
113 3D:   Prepared spatial ODE trajectories and vector fields
114 3D:   Seeds and streamline sets
115 3D:   Poincare sections and return maps
116 3D:   Equilibria and local linearization
117 3D:   Flow maps and volume change
118 3D:   Drawing and inspecting trajectories
119 3D:   Reading prepared trajectories
120 3D:   Drawing vector fields and particles
121 3D:   Trajectory display
122 3D:   Spatial inspection and exact picking
123 3D:   Retained renderer backends
124 3D:   Compiled geometry and instances
125 3D:   Frame requests and results
126 3D:   Software rendering and statistics
127 3D:   Optional Racket/  Open  GL backend
128 Experimental Derived Visuals
129 Source Package Hygiene
On this page:
scene?
make-scene
scene-add
scene-remove
scene-ref
scene-visual-at
scene-set-value
scene-remove-value
scene-current-value
scene-value-at
scene-set-camera
scene-play
scene-wait
scene-sample
scene-animation-inspections-at
animation-inspection?
animation-inspection-kind
animation-inspection-data
scene-camera-at
scene-duration
scene-current-state
scene-current-camera
scene-clip-count
9.3

54 Scenes and sampling🔗ℹ

Use these operations to build a Scene and ask for its state at a time. For a short first program, see Quick Start: a moving circle.

procedure

(scene? value) → boolean?

  value : any/c
Returns #t when value is a scene timeline.

procedure

(make-scene [initial-state #:camera camera]) → scene?

  initial-state : scene-state? = empty-scene-state
  camera : camera? = default-camera
Creates a zero-duration scene whose current semantic state is initial-state and whose current camera is camera. The new scene contains no clips.

procedure

(scene-add scene visual ...) → scene?

  scene : scene?
  visual : visual?
Returns a scene with each supplied Visual added instantaneously at the current scene time. No clip is appended and duration does not change.

Visuals are added in argument order. Each later argument is placed in front of earlier Visuals. Adding a top-level identity already present as a Visual or named scalar in the current state raises an exception. A group is added as one top-level Visual; its child order remains internal to the group. A derived-visual? is likewise stored as one top-level identity and is resolved only when concrete geometry is requested.

An instantaneous addition at the exact end of a scene is not normally included in frame sampling. Follow it with scene-wait or scene-play when it must be visible in rendered output. Supplying no Visuals returns an equivalent scene.

procedure

(scene-remove scene target ...) → scene?

  scene : scene?
  target : (or/c visual? symbol? visual-path?)
Returns a scene with each addressed target removed instantaneously from the current state. No clip is appended and duration does not change. Removing a nested path rebuilds only its ancestor groups; top-level drawing order is preserved. Removing an absent target raises an exception. Supplying no targets returns an equivalent scene.

procedure

(scene-ref scene target) → visual?

  scene : scene?
  target : (or/c visual? symbol? visual-path?)
Returns the concrete addressed Visual from the scene’s current endpoint state.

procedure

(scene-visual-at scene target time) → visual?

  scene : scene?
  target : (or/c visual? symbol? visual-path?)
  time : (and/c finite-real? (>=/c 0))
Samples scene at time and returns the concrete addressed Visual. Nested child transforms remain local to their containing group.

procedure

(scene-set-value scene id value) → scene?

  scene : scene?
  id : (or/c symbol? scene-parameter?)
  value : any/c
Adds or replaces one named interpolable semantic value instantaneously at the current scene time. No clip is appended and duration does not change. A value ID may not collide with a top-level Visual ID. Earlier clips retain their stored value snapshots.

The two-argument shorthand (scene-set-value scene parameter) accepts a scene-parameter? and installs its declared initial value.

procedure

(scene-remove-value scene id) → scene?

  scene : scene?
  id : (or/c symbol? scene-parameter?)
Removes one named semantic value instantaneously. Removing an absent value raises an exception and does not append a timeline clip.

procedure

(scene-current-value scene id) → any/c

  scene : scene?
  id : (or/c symbol? scene-parameter?)
Returns one named interpolable semantic value from the scene’s stored endpoint state.

procedure

(scene-value-at scene id time) → any/c

  scene : scene?
  id : (or/c symbol? scene-parameter?)
  time : (and/c finite-real? (>=/c 0))
Samples one named interpolable semantic value directly at absolute scene time. The same closed timeline bounds as scene-sample apply.

procedure

(scene-set-camera scene camera) → scene?

  scene : scene?
  camera : camera?
Returns a scene whose current camera is camera. The replacement is instantaneous: no clip is appended and duration does not change. Earlier clips keep their stored cameras.

An instantaneous replacement at the exact end of a scene is not normally included in frame sampling. Follow it with scene-wait or scene-play when the replacement must appear in rendered output.

procedure

(scene-play scene    
  request ...    
  [#:duration duration    
  #:easing easing]) → scene?
  scene : scene?
  request : 
(or/c timed-animation-request?
      succession-animation-request?
      animation-group-animation-request?
      lagged-start-animation-request?
      style-to-animation-request?
      value-to-request?
      move-to-request?
      move-along-path-request?
      orient-along-path-request?
      rotate-to-request?
      rotate-by-request?
      scale-to-request?
      scale-by-request?
      stroke-width-to-request?
      fill-color-to-request?
      stroke-color-to-request?
      fade-to-request?
      fade-in-request?
      fade-out-request?
      enter-request?
      leave-request?
      morph-to-request?
      morph-to-normalized-request?
      morph-to-aligned-request?
      morph-to-open-aligned-request?
      morph-to-open-compound-aligned-request?
      morph-to-mixed-compound-aligned-request?
      morph-to-topology-changing-request?
      morph-to-compound-aligned-request?
      transform-formula-parts-request?
      create-request?
      uncreate-request?
      write-in-request?
      unwrite-request?
      camera-pan-to-request?
      camera-pan-by-request?
      camera-zoom-to-request?
      camera-zoom-by-request?
      camera-follow-request?
      camera-fit-request?)
  duration : (or/c false/c (and/c finite-real? positive?)) = #f
  easing : (procedure-arity-includes/c 1) = linear
Appends one play clip. When no timed, succession, animation-group, or lagged-start value is present, Visual/scalar and camera request values run simultaneously and share duration and easing.

When #:duration is omitted, ordinary requests default to one second. A direct write-in uses Manim’s default instead: one second for fewer than fifteen writable leaves and two seconds for fifteen or more. An explicit positive duration always takes precedence.

When at least one timing/composition value is present, every Visual, scalar, or camera request resolves to one or more concrete local intervals. A top-level timed value uses literal second-based start and duration and may wrap either one leaf or one composition. An ordinary unwrapped top-level Visual or camera request spans the complete enclosing clip.

Inside compositions, unwrapped direct children contribute one timing unit and a timed direct child contributes (+ start duration) units. A succession places those spans consecutively, an animation group starts them together and scales against the longest span, and a lagged start offsets raw starts by its lag ratio before scaling the complete envelope. Bare nested compositions remain one-unit direct children unless explicitly wrapped by timed. All three composition forms may nest arbitrarily with timed Visual/camera composition children.

Equal-start Visual leaves are compiled together against one prepared local start state. A later start batch is compiled against the exact semantic state sampled at that local boundary, so a touching relative request starts from the previous request’s exact endpoint rather than the enclosing clip start. Sampling remains direct and does not depend on rendering prior frames.

Structural introduction requests are installed only at their local start. A create request adds an empty-path placeholder, fade-in adds the complete Visual at opacity zero, and enter adds an affine/opacity appearance proxy. Requests beginning at that same local time share the prepared state, so movement, rotation, scaling, opacity, and compatible geometry changes can compose with an introduction. A fade-out, uncreate, or leave removal may not end while another animation of that target remains active; reintroduction at the exact removal boundary is allowed.

Positive-measure overlap on the same Visual component is rejected. Touching intervals are not overlap and are legal. Requests for disjoint components may overlap freely.

Camera requests use the same local intervals. A later pan, zoom, fit, or follow compiles from the exact camera view at its local start. camera-pan-by therefore adds to that local center, and camera-zoom-by divides that local visible width by its magnification factor. A camera-follow captures its target’s frame offset at the start of its own interval, samples the target’s actual local Visual state while active, and holds the resulting endpoint view after it ends. A camera-fit request remains a concrete center/width snapshot measured when it was constructed. Camera and Visual requests may appear in any order.

A single list of requests can be supplied in place of separate request arguments:

(scene-play scene
            (list (move-to 'a (vec2 2 0))
                  (rotate-by 'a 1)
                  (camera-pan-to (vec2 1 0))
                  (camera-zoom-by 2))
            #:duration 2)

At least one request is required. Each composition value itself also requires at least one child. In the full-clip case, two simultaneous requests may target the same Visual when every component they change is disjoint. With local timing, the same rule applies only where the request intervals overlap. The components in this version are translation, rotation, scale, opacity, path geometry, formula parts, and scene presence. Both move-to and move-along-path reserve translation. orient-along-path, rotate-to, and rotate-by reserve rotation. A request can change more than one component: fade-in and fade-out change opacity and presence; enter changes presence plus only its nonidentity affine/opacity components; leave does the same and reserves presence when it removes; create and uncreate change path geometry and presence, and transform-formula-parts changes formula parts and reserves presence.

Two overlapping requests may not change the same component for the same identity. Exact endpoint touching is allowed. Thus overlapping opacity requests conflict. Strict morphing, normalized morphing, creation, and uncreation conflict on path geometry. Two formula-part transformations conflict on formula parts. A formula-part transformation also conflicts with a same-target structural introduction or removal because both reserve presence. Requests for different identities do not conflict.

The camera center and visible world width are separate camera components. Pan and follow requests change the center. Zoom requests change visible width. A fit request changes both. One follow request and one zoom request may run together. Overlapping requests that reserve the same camera component raise an exception, so fit conflicts with pan, follow, zoom, or another fit for the same local interval. Touching camera intervals are legal and hand off exactly. Camera components do not conflict with Visual components.

Before easing is called, progress is clamped to the closed unit interval. The easing result must be a finite real and is also clamped to that interval. A normal easing procedure should map 0 to 0 and 1 to 1. Transform component endpoints follow the easing result.

Introduction, removal, and formula-part transformation requests have structural endpoint rules. For an untimed request the structural endpoint is the play-clip boundary; for a timed request it is the local interval endpoint. At that endpoint, a completed create contains the complete original path, a completed fade-in contains the supplied final opacity, a completed enter contains its exact authored Visual, and a completed transform-formula-parts contains the exact destination part list. A completed uncreate, fade-out, or removing leave removes its target. These rules apply even when easing does not map one to one. Such an easing procedure can therefore cause a discontinuity at the request endpoint.

A fade-to, morph-to, morph-to-normalized, morph-to-aligned, morph-to-open-aligned, morph-to-open-compound-aligned, or morph-to-compound-aligned request has no structural endpoint override. Like movement, rotation, scale, camera pan, camera zoom, camera fit, and camera follow, its final sampled value follows the easing result. A normalized morph preserves the exact source at eased progress zero and the exact requested destination at eased progress one. Camera animation preserves pixel dimensions and background throughout the clip.

procedure

(scene-wait scene duration) → scene?

  scene : scene?
  duration : (and/c finite-real? positive?)
Appends a wait clip that holds the current Visual state and current camera unchanged for duration seconds.

procedure

(scene-sample scene time) → scene-state?

  scene : scene?
  time : (and/c finite-real? (>=/c 0))
Returns the complete scene state at absolute time. Time must lie in the closed interval from 0 through (scene-duration scene).

Clip intervals are half-open. Sampling the exact total duration returns scene-current-state. This procedure samples only the Visual state; it does not apply camera animations. Camera values are sampled separately with scene-camera-at.

procedure

(scene-animation-inspections-at scene time)

 → (listof animation-inspection?)
  scene : scene?
  time : (and/c finite-real? (>=/c 0))
Returns the immutable inspection records retained for active animation leaves at time. Inspection describes semantic planning data only: it never exposes renderer-private mutable resources. At an exact final scene endpoint, the final clip’s retained records remain available even though its visual structural cleanup has already occurred.

procedure

(animation-inspection? value) → boolean?

  value : any/c
Recognizes an immutable animation-inspection record.

procedure

(animation-inspection-kind inspection) → any/c

  inspection : animation-inspection?
Returns the request-family symbol, such as 'enter, 'leave, 'reveal-in, 'reveal-out, or 'pulse.

procedure

(animation-inspection-data inspection) → any/c

  inspection : animation-inspection?
Returns immutable semantic explanation data. For enter and leave, the data records the target, lifecycle, authored relative factors, written components, collapse flag, and exact removal action. For hard-clip reveals, it records the target, lifecycle, immutable front, written components, and exact removal action; the renderer-private clip wrapper and frozen layout measurement are never exposed. For pulse, it records the target, cycle count, written components, and the exact source-restoration endpoint action. For confetti, it records the resolved launch origin, explicit seed, generated count, overlay identity, and deterministic helper IDs; no mutable renderer or random-generator state is exposed.

procedure

(scene-camera-at scene time) → camera?

  scene : scene?
  time : (and/c finite-real? (>=/c 0))
Returns the complete camera at absolute time. Time must lie in the same closed interval accepted by scene-sample. Clip intervals are half-open. Sampling the exact total duration returns scene-current-camera. This procedure samples only the camera. For a follow request, the timeline internally samples the followed target’s semantic Visual state at the same absolute time, including local timing and sequential/parallel/lagged composition. It never depends on earlier rendered frames.

procedure

(scene-duration scene) → (and/c finite-real? (>=/c 0))

  scene : scene?
Returns the total duration in seconds.

procedure

(scene-current-state scene) → scene-state?

  scene : scene?
Returns the state after all operations currently in the timeline. This is also the state returned by sampling the exact scene duration. A completed create, fade-in, or enter contributes its complete Visual. A completed uncreate, fade-out, or removing leave contributes no Visual for its target identity. A retained leave contributes its exact relative final appearance.

procedure

(scene-current-camera scene) → camera?

  scene : scene?
Returns the camera after all operations currently in the timeline. This is also the camera returned by scene-camera-at at the exact scene duration. An unusual easing procedure can leave the current camera before a requested pan, zoom, fit, or follow endpoint, just as it can leave a moved Visual before its destination.

procedure

(scene-clip-count scene) → exact-nonnegative-integer?

  scene : scene?
Returns the number of play and wait clips. Instantaneous Visual additions, Visual removals, and camera replacements do not increase this count.