Python authoring cheatsheet
Animate projects import the library-owned manifest namespace. Do not create a
project-local manifest.py. The compiler loads project.json, activates the
selected packages and dependencies, and supplies that manifest to Video2d.
from manifest import Circle, FadeIn, Move, Position, Video2d
def build(seq, frame):
ball = Circle(frame, Position(100, 200), 12, fill=(230, 240, 100))
seq.show(FadeIn(ball, time=.25))
seq.show(Move(ball, Position(300, 0), time=1))
seq.show(.5)
def make_video():
return Video2d(build, resolution=(800, 450), fps=60)
Construct entities inside build; keep imports, classes, and helper functions
at module scope. Move is relative; MoveTo and AbsoluteTransition are
absolute. Sequence runs in order, Bundle runs concurrently, and
seq.show(seconds) holds the current state. Avoid overlapping writes to one
property.
Properties and components
entity.props.position() reads the authored local snapshot;
entity.props.position.resolve() includes inherited state. The uncalled
property is an animation target: SetProperty(entity.props.opacity, 0).
Assign complete values such as Position(10, 20). Group and TextGrid own
children; compound components extend EntityWithChildren and attach primitives
to self. Position is local to the parent and opacity multiplies through it.
Register custom properties before the first instance, preferably in a package's
register() hook:
Meter.defineProp('value', 0.)
meter.props.value = .5
seq.show(AbsoluteTransition('value', meter, 1., time=.4))
See the guides for components, property inheritance, and animations.
Project manifest and packages
project.json has version: 2, exact packages, logical assets, custom
colors, and package color_schemes. Use from manifest import assets, colors,
color_schemes, project; use assets[name], colors[name], and
color_schemes['neutral.colors'][name]. Local packages are selected with
package_overrides; never edit generated project.lock.json.
{
"version": 2,
"packages": {"Video2D": "1.0.0", "Neutral": "1.0.0"},
"assets": {"logo": "assets/logo.svg"},
"colors": {"ink": [30, 35, 45]},
"color_schemes": {"neutral.colors": {"background": [248, 249, 252]}}
}
Python plugin IDs become namespaces: chart.python is manifest.chart and
code.python is manifest.code. Palette, renderer, and data-source plugins do
not create Python modules. Package code uses its injected manifest and
manifest.python('dependency.plugin') for dependencies.
Text, data, and paths
Use TextGrid with an explicit Font; insert_highlighted requires a complete
palette. Read declared services through project.data.read(source_id, request);
the host supplies endpoints and credentials. Do not make direct network calls,
spawn subprocesses, write files, or call exporters from project source.
MotionPath and MoveAlong animate a route independently of FPS:
route = MotionPath.arc(center=(200, 200), radius=100,
start_angle=0, sweep_angle=math.pi / 2)
seq.show(MoveAlong(ball, route, time=2))
The host provides fonts and installed packages. Missing assets, fonts, services, or package versions are errors; the runtime does not silently substitute them.