Python API reference
In a project, import entities and animations from manifest. Its namespace also exposes the project’s selected packages, assets, and colors. Standalone library imports appear under their defining modules below.
First moving shape · Project configuration
manifest
Font(family: str, weight: int = 400, style: str = 'normal')
Request a font family, numeric weight, and style.
Args
family— Nonempty family name, for example Source Code Pro.weight— Integer from 1 to 1000; 400 is normal weight.style— normal, italic, or oblique.
Raises
ValueError— A request field is invalid.
Select an available project font by family, weight, and style.
Inheritance(resolve_func, *inputs: InheritanceInput)
Describe a serializable property inheritance rule.
Args
resolve_func— Function combining inputs with supported arithmetic expressions. *inputs: Ordered InheritanceInput declarations.
The function is traced during construction. Use vector(), sin(), and cos() for expressions; Python conditionals and comparisons on traced inputs are unsupported.
resolve(props: Properties)
Evaluate the inheritance rule against the supplied authoring Properties.
InheritanceInput(scope: InheritanceScope, property_name: str, resolved: bool = True, default: Any | None = None)
Declare one argument to an inheritance expression.
Args
scope— parent or self.property_name— Property to read from that scope.resolved— Resolve parent inheritance recursively when true; self reads stay local.default— Value used when the requested property or parent is absent.
Interpolation
Keyframe interpolation modes: Hold, Linear, and SmoothStep.
Hold keeps the preceding value until the next keyframe. Linear interpolates uniformly; SmoothStep eases in and out. Enum values are hold, linear, smoothstep.
CurrentValue
Preserve the value at this point in the authoring timeline.
materialize(current)
Return current unchanged.
LiteralValue(value)
Replace a property value with the supplied literal when materialized.
materialize(current)
Return the configured literal, ignoring the current value.
AddValue(delta)
Add delta to the value present when the operation is materialized.
materialize(current)
Apply the configured function to the current value.
Entity(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
Base authoring entity with a parent and animatable property collection.
Args
parent— Parent entity, or None for a root.props— Initial property names and values or property definitions.id— Optional explicit identity; normally let the sequence assign it.property_stack— Explicit root authoring context. Children share their parent context.
Access property targets through props; call a target to read the current local value, or call resolve() for inherited values. Reads return snapshots.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
EntityWithChildren(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
Base for compound components whose rendered children follow a timeline.
Pass a parent and initial properties to the constructor, then construct child entities with self as parent. Child attachment updates the children property. Expose named child groups for callers to animate independently.
entity_attached(entity)
Append an attached entity to this component’s timeline-aware children property.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
scale_path(commands, scale)
Resolve normalized path coordinates through an explicit inheritance expression.
vector(*values)
Construct a vector from components, preserving traced inheritance expressions.
Returns a NumPy vector for ordinary values and an expression when any input is traced.
SequenceBuilder(sequence_stack: SequenceStack, name: str)
Author a named timeline by inserting animations and reusable subsequences.
Video2d supplies a builder to its callback. Use show() to append animations or holds; use build_sequence() to capture a reusable branch.
build_sequence(builder_function: Callable[..., None], *entities: Entity | str | float, name: str | None=None) -> Sequence
Capture a nested builder callback as a reusable Sequence.
Args
builder_function— Function receiving a child builder followed by entities. *entities: Arguments forwarded to the callback.name— Optional branch name; defaults to the callback name.
Returns
A captured Sequence, which must be inserted with show() to play it.
The child authoring context is finalized even if the callback raises.
finalize()
Close this builder context and return its captured Sequence.
Calling again returns the same sequence. Finalize nested builders first; an out-of-order call raises ValueError. Video2d manages this lifecycle automatically.
show(*args: Animation | TimeUnit | float | None) -> None
Append animations in parallel, or hold for a duration.
With no arguments, hold for one second. A numeric first argument is a duration in seconds; a TimeUnit uses its own units. Otherwise all arguments form a Bundle.
show_static(time: TimeUnit | float)
Append a hold lasting time seconds or the supplied TimeUnit.
show_animation(*animations: Animation)
Insert animations together and advance the authored property state.
SequenceStack()
Advanced authoring context. Prefer the builder supplied to a Video2d callback.
push(seq, name='root')
Enter a new authoring context for the supplied sequence builder.
pop()
Leave the active context; raise ValueError if the stack is empty.
get_latest_value(key)
Read a property value from the active authoring context.
update_latest_value(key, value)
Update a property value in the active authoring context.
sequence_builder()
Return the active sequence builder.
register_property(initial_value)
Allocate a property ID and register its initial value in the active context.
register_entity(entity, id=None)
Register an entity for use in the current animation and return its identifier.
Sequence(*animations: Animation | None)
Play animations consecutively, ignoring None entries.
Use Bundle for parallel motion. Treat an animation's returned timeline as immutable after scheduling it.
add(*animations: Animation | None)
Append captured animation timelines sequentially, ignoring None entries.
Sequences are captured at insertion. Later additions to a child sequence do not rewrite an already inserted occurrence.
timeline()
Return the relative timeline for this sequence.
Treat the returned structure as immutable after scheduling it.
Bundle(*animations: Animation | None)
Run animations concurrently from the same start time.
None entries are ignored. The bundle lasts as long as its longest child. Avoid concurrent writes to the same property.
timeline()
Return a timeline containing all child timelines at offset zero.
Repeat(animation: Animation, times: int)
Schedule consecutive copies of an animation.
times must be a nonnegative integer. Zero schedules no work. For example, Repeat(Move(ball, (20, 0), time=0.5), times=3) moves 60 units in 1.5 seconds.
timeline() -> Timeline
Return the relative timeline contributed by this animation.
Pause(time: TimeUnit | float=1)
Hold the scene for a nonnegative duration.
A numeric time is seconds; a TimeUnit retains its native time format. Raises ValueError for a negative duration.
timeline()
Return a timeline ending after the configured hold.
Delay(time: TimeUnit | float, animation: Animation)
Wait for time, then run animation.
Numeric time is measured in seconds; explicit TimeUnit values are supported.
add(*animations: Animation | None)
Append captured animation timelines sequentially, ignoring None entries.
Sequences are captured at insertion. Later additions to a child sequence do not rewrite an already inserted occurrence.
timeline()
Return the relative timeline for this sequence.
Treat the returned structure as immutable after scheduling it.
SetProperty(property: Property, value: Value | object)
Set a property instantaneously when this animation is inserted.
Args
property— A property target, such as box.props.opacity, without calling it.value— A literal value or a Value operation.
Literal values are cloned so later edits do not rewrite the animation.
timeline() -> Timeline
Return a zero-time property keyframe.
Animation
Protocol for custom animations.
Implement timeline() to return a relative Timeline. Do not mutate its structure after insertion into a Sequence. Composition with existing animations is usually simpler than constructing keyframes directly.
timeline() -> Timeline
Return the relative timeline contributed by this animation.
Timeline(*keyframes: KeyFrame)
A relative timeline of keyframes and nested timelines.
Construct with KeyFrame objects sharing a time format. Add nested timelines at an explicit offset with add(). Use through Animation.timeline() for low-level custom animation; prefer Sequence and Bundle for ordinary composition.
check_format(*keyframes)
Adopt the first keyframe time format and reject incompatible formats.
add(element: KeyFrame | Self, start_time: TimeUnit | None=None) -> None
Insert a keyframe or a nested timeline at a relative offset.
Args
element— KeyFrame or child Timeline.start_time— Offset for a child timeline; defaults to zero in the active format.
The timeline remains sorted. Keyframes use their own time; offsets apply only to child timelines. Incompatible formats raise ValueError.
end_time() -> TimeUnit
Return the latest keyframe or nested timeline endpoint. Empty timelines end at zero seconds.
iter_events(reverse=False)
Iterate events chronologically, or in reverse when reverse=True.
Returned times use this timeline's format. Equal-time events retain authored nesting order.
flatten() -> Timeline
Return a new flat Timeline with nested offsets mapped into this time format.
PropertyKeyFrame(time: TTime, property: Optional[Property], value: Optional[Value | PropertyDelta], interpolation: Interpolation = Interpolation.Hold, options: dict[str, Any] | None = None)
A property value operation at a relative time.
Args
time— Relative TimeUnit.property— Property target, or None for a non-property event.value— Value operation applied at this keyframe.interpolation— Interpolation from this keyframe towards the next one.options— Opaque extension metadata, interpreted by a media adapter.
Use CurrentValue() to capture the starting value and LiteralValue(target) or AddValue(delta) for the endpoint of a custom transition.
Seconds(seconds: float)
A duration or relative time measured in seconds.
Supports addition, ordering, and negation with other Seconds values. Use TimeMap for conversion to frame units. Animation constructors reject negative durations.
TimeUnit
Protocol for relative time values carrying a format.
Seconds and Frame implement it; timeline composition uses their format for conversion.
ZeroFromTime(unit: TimeUnit)
Return zero in the same format as the supplied time value.
TimeMap
The default converter between seconds and frame units.
TimeMap is the shared instance. Frame formats take precedence over seconds when composing mixed-format timelines.
add_mapping(from_format: type[TFromFormat], to_format: type[TToFormat], function: Callable[[TFromUnit, TToFormat], TToUnit])
Register a conversion function for a pair of time-format types.
find_map_function(from_format: type, to_format: type)
Return the registered conversion for two format types; raises KeyError if absent.
map(from_time: TimeUnit, to_format: TimeFormat)
Convert from_time into to_format, returning it unchanged when formats match.
set_precedent(*format: type[TimeFormat])
Set format types in highest-to-lowest priority for timeline composition.
get_highest_precedent(formats: Iterable[TimeFormat | None]) -> TimeFormat
Choose the highest-priority supplied format.
Returns seconds when all inputs are None or absent; raises ValueError if no provided format is registered in the precedence order.
FrameFormat(frame_rate: Fraction)
Describe a positive frame rate for timeline time values.
zero()
Return frame zero at this format’s frame rate.
__eq__(value: object, /) -> bool
Return whether another value represents the same time format. Frame formats compare their frame rates.
Video2dManifest(packages=(), *, package_paths=None, colors=None, color_schemes=None, data_transport=None)
Resolve packages and activate Python plugins before constructing entities.
Package roots are explicit or supplied through CODEANIMATE_PACKAGE_PATH. Package descriptors and entry points are trusted installed code.
from_file(path='project.json', *, package_paths=None, data_transport=None)
Load the editable project manifest, resolving assets relative to its file.
python(identifier)
Load a declared Python plugin and return its module.
Args
identifier— Plugin ID, for example chart.python, from a selected package.
The module receives this manifest and runs its optional register() hook once per package-content identity in the process. Subsequent calls reuse the loaded module.
Raises
ValueError— The ID refers to a non-Python plugin or an invalid entry path.KeyError— The ID is not declared by the selected packages.
activate()
Load all declared Python plugins before entity construction.
Video2d calls this automatically; explicit calls are useful when registration must precede entities constructed outside the video callback.
document()
Return serializable package pins, plugin declarations, and palette metadata.
MotionPath(_start: tuple, _encoded: str, _end: tuple)
Immutable, single-contour path in local coordinates. Use the class constructors.
arc(*, center: Vector2, radius: float, start_angle: float, sweep_angle: float) -> Self
An exact circular arc; radians, positive sweep clockwise in screen coordinates.
from_commands(commands: Iterable[PathCommand]) -> Self
Build from absolute M/L/Q/C/Z commands with exactly one initial M.
from_svg_path(d: str) -> Self
Parse SVG path data; SVG elliptical arcs use the existing cubic approximation.
start() -> tuple[float, float]
Immutable first point.
end() -> tuple[float, float]
Immutable last point.
NumericVector
Numeric components supplied by a tuple, list, or NumPy array.
__iter__() -> Iterator[float]
Iterate over the numeric components in vector order.
__len__() -> int
Return the number of numeric components.
__getitem__(index: int, /) -> float
Return the numeric component at the supplied integer index.
type PathCommand = _Sequence[str | float]
A path operation expressed as a sequence containing the command name and its numeric arguments.
type RGBColor = NumericVector
Red, green, and blue components in that order, supplied as a numeric vector.
type Vector2 = NumericVector
A two-component numeric vector such as a position or displacement.
type EntitySelection = Entity | Iterable[Entity]
One entity or an iterable of entities to which the same animation applies.
type Duration = TimeUnit | float
Animation duration supplied as a time unit or a number of seconds.
type InterpolationMode = Interpolation | Literal['linear', 'smoothstep', 'hold']
Interpolation for a property transition. Supply an Interpolation value or the name linear, smoothstep, or hold.
Position(x: float, y: float) -> np.ndarray
Create a two-component NumPy vector in local coordinates.
Args
x— Horizontal coordinate; positive values move right.y— Vertical coordinate; positive values move down.
Returns
A new vector suitable for positions, sizes, and movement deltas.
Right(x: float) -> np.ndarray
Return a local displacement of x units to the right.
Left(x: float) -> np.ndarray
Return a local displacement of x units to the left.
Down(y: float) -> np.ndarray
Return a local displacement of y units downwards.
Up(y: float) -> np.ndarray
Return a local displacement of y units upwards.
asSeq(entities: T | Iterable[T]) -> tuple[T, ...]
Wrap a single entity in a tuple or materialize an iterable of entities as a tuple.
PositionProperty(initial_value: Vector2)
A position property inheriting parent position and scale.
OpacityProperty(initial_value: float=1)
An opacity property multiplied by its parent opacity.
ParentProperty(name: str, default: object)
An explicit copy of a resolved parent property, with a literal root default.
CoordinateProperty(name: str, value: float | Vector2)
Author in parent units; serialize the multiplication as inheritance.
PathCoordinatesProperty(commands: _Sequence[PathCommand])
Path coordinates transformed by the configured inheritance expression.
ResolutionProperty()
An omitted resolution follows the parent through the visual hierarchy.
visual_properties(position: Vector2 | None=None, resolution: Vector2 | None=None, **values: object) -> dict[str, object]
Create initial properties for a visual entity.
Args
position— Local origin; defaults to Position(0, 0).resolution— Explicit viewport size, or None to inherit it from the parent. **values: Additional properties or overrides.
Returns
A dictionary containing position, opacity and resolution definitions. Position includes the parent origin/scale; opacity multiplies with the parent.
container_properties(position: Vector2 | None=None, **values: object) -> dict[str, object]
Containers forward coordinate scale through the ownership hierarchy.
Video2d(sequence_func: Callable[[SequenceBuilder, Frame], None], resolution: Vector2=(1920, 1080), fps: int | float | Fraction=60, background_color: RGBColor=(0, 0, 0), *, fonts: object=None, manifest: Video2dManifest | None=None)
Build a complete animation by invoking a sequence callback.
Args
sequence_func— Callback receiving a SequenceBuilder and root Frame.resolution— Output width and height in pixels.fps— Playback frames per second.background_color— Background RGB triple, with channels from 0 to 255.fonts— Optional font configuration; Animate supplies the project's fonts.manifest— Package, palette, asset, and data-source configuration.
Package activation happens before the callback constructs entities. In Animate, return this object from make_video(); the host compiles and renders it.
root_id()
Return the generated identity of the root Frame.
resolution()
Return the authored output width and height in pixels.
fps()
Return the authored playback frame rate.
num_frames()
Return the frame count, including the frame at the timeline endpoint.
dom_document()
Compile the authored timeline into the renderer-independent DOM dictionary.
serialize()
Return the compiled DOM as compact UTF-8 JSON bytes.
Raises
ValueError— A numeric value cannot be represented as finite JSON.
export_fonts(directory: str | PathLike[str]) -> None
Copy resolved immutable assets for serving at /assets/fonts/.
font_directory()
Return the directory containing resolved font cache assets.
dom_metadata(document: dict | None=None) -> dict
Return the node inspection index for a supplied or newly compiled DOM.
Frame(stack: SequenceStack, resolution: Vector2=(1920, 1080), fps: int | float | Fraction=60, background_color: RGBColor=(0, 0, 0))
Root visual container created by Video2d.
The builder callback receives this entity; attach top-level components to it. Its resolution, fps, and background_color properties describe the video.
entity_attached(entity)
Append an attached entity to this component’s timeline-aware children property.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
Group(parent: Entity, position: Vector2 | None=None, **values: object)
Group child entities under a shared local transform.
Args
parent— Container receiving this group.position— Local origin; defaults to the origin of the parent. **values: Additional container properties, such as opacity or rotation.
Moving or fading a group affects its rendered descendants.
entity_attached(entity)
Append an attached entity to this component’s timeline-aware children property.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
Character(parent: Entity, position: Vector2 | None, char: object, color: RGBColor=(255, 255, 255), font_size: float=48, opacity: float=1, *, font: Font, align: Literal['left', 'center', 'right'] | None=None)
Render one text value using a resolved font.
Args
parent— Entity defining the local coordinate system.position— Local position, in cells when attached to a TextGrid.char— Value converted to text.color— RGB foreground color.font_size— Font size in pixels.opacity— Initial opacity.font— Font request resolved through the parent font registry.align— Horizontal alignment. Right-aligned ink stays left of the anchor.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
shape_properties(position: Vector2 | None, *, fill: RGBColor | None=(0, 0, 0), stroke: RGBColor | None=None, **values: object) -> dict[str, object]
Create visual and paint defaults for vector shapes.
Args
position— Local origin.fill— RGB fill or None for no fill.stroke— RGB stroke or None for no stroke. **values: Paint/property overrides.
Returns
A property dictionary with stroke_width=1, fill_opacity=1, stroke_opacity=1, nonzero fill_rule, butt line caps, miter joins, miter limit 4, no dash pattern, zero dash offset and identity affine transform.
Shape(parent: Entity, position: Vector2 | None, geometry: Mapping[str, object], **paint: object)
Base entity for vector geometry with fill, stroke, and transform properties.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
Rectangle(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
Create a rectangle at a local position with a width/height size vector.
Pass fill, stroke, stroke_width, opacity, or other shape properties as keywords. Animate props.size to change geometry and props.position to move the rectangle.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
Circle(parent: Entity, position: Vector2 | None, radius: float, **paint: object)
Create a circle at a local position with the given radius.
Parent coordinate scaling also scales its rendered radii. Paint keywords follow Shape.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
Ellipse(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
Create an ellipse using a local position and size vector.
Paint keywords follow Shape.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
Line(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
Create a line from position to position + size in local coordinates.
Defaults to a black stroke and no fill; override paint with keyword arguments.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
Arrow(parent: Entity, position: Vector2 | None, size: Vector2, *, arrowhead_size: float=10.0, **paint: object)
Create a line with an arrowhead.
Args
parent— Parent entity.position— Local start position.size— Displacement from start to endpoint.arrowhead_size— Arrowhead size, defaulting to 10. **paint: Shape paint and transform properties.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
Path(parent: Entity, position: Vector2 | None, commands: _Sequence[PathCommand], **paint: object)
Create vector geometry from path commands in the parent coordinate system.
Use from_svg_path for SVG path-data strings; importing whole SVG documents is not supported by this class.
from_svg_path(parent: Entity, position: Vector2 | None, *, d: str, **paint: object) -> Self
Parse an SVG path-data string d and create a Path.
The parent and position define placement; paint keywords are forwarded unchanged.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
entity_attached(entity)
Hook called when a child is attached. The base Entity implementation does nothing.
RelativeTransition(propertyName: str, entities: EntitySelection, delta: object, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
Animate a property by adding a delta to its authored value.
Args
propertyName— Name in each entity.props collection.entities— One entity or an iterable of entities.delta— Value added to the starting value.time— Nonnegative duration, in seconds unless a TimeUnit is supplied.interpolation— Interpolation enum or compatible value.
Raises
ValueError— The duration is negative or interpolation is unsupported.
Avoid scheduling overlapping writes to the same property.
endpoint()
Return the relative value operation used at the transition endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
AbsoluteTransition(propertyName: str, entities: EntitySelection, delta: object, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
Animate a property to an absolute target.
Uses the RelativeTransition constructor; its delta argument is the target value rather than an increment. The starting value is resolved at insertion.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
Move(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
Move entities by a relative local-coordinate delta.
Accepts one entity or an iterable, a Position delta, and a nonnegative duration in seconds or a TimeUnit. The default interpolation is SmoothStep.
endpoint()
Return the relative value operation used at the transition endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
MoveTo(entities: EntitySelection, position: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
Move entities to an absolute position in their parent coordinate system.
Accepts one entity or an iterable. Numeric time is in seconds. For example, MoveTo(ball, (120, 40), time=1) ends at (120, 40) regardless of where the ball starts. A child of a Grid uses cell coordinates.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
MoveAlong(entities: EntitySelection, path: MotionPath, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep, *, relative: bool=True)
Move entities along immutable geometry, easing once over its total distance.
Relative paths are anchored at each entity's position when scheduled. Absolute paths use parent coordinates. Time follows Move's seconds/TimeUnit convention.
timeline()
Record start and endpoint events with opaque Video2D authoring options.
Fade(entities: EntitySelection, end: float=1, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
Animate opacity to end, normally between zero and one.
The default duration is 0.125 seconds with linear interpolation.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
FadeIn(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear, zero_opacity: bool=True)
Animate opacity to one.
Construction sets opacity to zero unless zero_opacity=False. Construct this animation before preceding holds if the entities should start hidden.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
FadeOut(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
Fade one entity or an iterable to zero opacity.
Numeric time is in seconds and the default interpolation is linear. Each entity stays in the scene, so a later FadeIn can reveal it again.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
Background(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
Animate character background intensity to one.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
Foreground(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
Animate character background intensity to zero.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
ColorShift(entities: EntitySelection, target_color: RGBColor, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
Animate the color property to an RGB target_color triple.
endpoint()
Return a literal target operation for the endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
Blink(entities: EntitySelection, num_times: int=3, time_per_blink: Duration=0.1)
Alternate opacity zero and one num_times, holding each for time_per_blink seconds.
add(*animations: Animation | None)
Append captured animation timelines sequentially, ignoring None entries.
Sequences are captured at insertion. Later additions to a child sequence do not rewrite an already inserted occurrence.
timeline()
Return the relative timeline for this sequence.
Treat the returned structure as immutable after scheduling it.
CharacterChange(chars: Character | Iterable[Character], string: object)
Replace character values pairwise with string at the current time.
Characters and string are zipped; extra values in either input are ignored.
timeline()
Return a timeline containing all child timelines at offset zero.
ValueFade(chars: Character | Iterable[Character], string: object)
Fade characters out, replace their values, and fade them in.
add(*animations: Animation | None)
Append captured animation timelines sequentially, ignoring None entries.
Sequences are captured at insertion. Later additions to a child sequence do not rewrite an already inserted occurrence.
timeline()
Return the relative timeline for this sequence.
Treat the returned structure as immutable after scheduling it.
Type(chars: Character | Iterable[Character], seconds_per_char: Duration=0.04)
Reveal characters in row/column order with a pause after each character.
seconds_per_char also adds a pause when moving to a new row.
add(*animations: Animation | None)
Append captured animation timelines sequentially, ignoring None entries.
Sequences are captured at insertion. Later additions to a child sequence do not rewrite an already inserted occurrence.
timeline()
Return the relative timeline for this sequence.
Treat the returned structure as immutable after scheduling it.
ExpandSize(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
Increase the size property by a delta over time.
endpoint()
Return the relative value operation used at the transition endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
ShrinkSize(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
Decrease the size property by a delta over time.
endpoint()
Return the relative value operation used at the transition endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
video_main(make_video: Callable[[], Video2d]) -> None
Compile an authoring script to DOM JSON; native exports use Exporter.
Properties(parent: Entity | None, props: dict[str, PropertyInitValue], *, property_stack: SequenceStack | None=None)
Named animation targets and current authoring values.
Reading props.position returns a target; props.position() returns a local snapshot. props.position.resolve() includes inheritance. Assign complete values to registered properties. Unknown names raise AttributeError or KeyError.
parent()
Return the entity that supplies inherited property values, or None at the root.
optional_scale(value, scale)
Multiply optional numeric geometry; None remains absent.
type GridCrop = Iterable[Vector2] | Iterable[float]
Crop coordinates supplied as an iterable of two-component points or an iterable of numeric coordinates.
CropProperty(value: GridCrop | None=None)
An optional crop rectangle transformed by the grid scale.
cell_metrics(filename: str | PathLike[str], size: float) -> tuple[tuple[int, int], int]
Return pixel cell size and extra padding from the font's layout metrics.
Fixed-width fonts use their common advance and recommended baseline distance. Proportional fonts retain space-width cells; glyphs can overhang those cells.
GridMatch(chars: Iterable[Character], groups: dict[str, list[Character]], match: re.Match[str])
List of matched characters with named regex groups.
Use match["group_name"] or match.groups for captured character lists. The original Python regex match is available as match.match.
Grid(parent: Entity, cell_size: Vector2, *, position: Vector2 | None=None, resolution: Vector2 | None=None, crop: GridCrop | None=None, id: str | None=None, **properties: object)
Uniform coordinate cells for arbitrary child entities.
pixel_position(position: Vector2) -> np.ndarray
Convert a cell-space position to resolved scene coordinates.
top_line(line: float, offset_from_top: float=0) -> None
Immediately position a row offset_from_top cells below the top edge.
center_line(line: float) -> None
Immediately center a row vertically in the resolved grid viewport.
entity_attached(entity)
Append an attached entity to this component’s timeline-aware children property.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
TextGrid(parent: Entity, font_size: float=48, font: Font | None=None, show_line_numbers: bool=False, resolution: Vector2 | None=None, color: RGBColor=(255, 255, 255), id: str | None=None, *, line_number_color: RGBColor | None=None)
Arrange text characters in a cell coordinate system.
Args
parent— Parent container.font_size— Font size in pixels.font— Font request; defaults to registered JetBrains Mono Regular, then registered Source Code Pro Regular for migrated projects. Legacy builds without a project font manifest use Source Code Pro.show_line_numbers— Whether to construct line-number labels.resolution— Optional grid resolution.color— Default RGB text color.id— Optional explicit entity identity.line_number_color— Gutter RGB color. Defaults to black.
The outer position uses parent coordinates; characters use cell coordinates.
set_font_size(props: Properties, font_size: float) -> None
Update grid cell metrics and existing child character font sizes.
insert_spans(spans: Iterable[tuple[str, RGBColor]], opacity: float=1) -> list[Character]
Insert (text, RGB color) pairs and return their combined Character list.
insert(text: object, color: RGBColor | None=None, opacity: float=1, inserted: list[Character] | None=None) -> list[Character]
Insert plain text at the current cursor and return created Characters.
Args
text— Value converted to text. Newlines advance the cursor to a new row.color— RGB override; defaults to the grid color.opacity— Initial character opacity.inserted— Optional list to append created characters to.
Spaces advance the cursor without creating Character entities. Carriage returns are ignored. Membership and cursor changes are recorded in the authoring timeline.
clear_chars()
Remove all current characters and reset the cursor to cell (0, 0).
text(chars: Collection[Character] | None=None, include_hidden: bool=False) -> str
Reconstruct text in row/column order from current character positions.
Args
chars— Character subset; defaults to all current grid characters.include_hidden— Include zero-opacity characters when true.
Rows are right-trimmed; negative positions are omitted.
insert_new_line()
Move the cursor to column zero on the next row.
remove_hidden()
Remove current characters whose local opacity is zero or negative.
remove_line(*line: float) -> None
Remove characters in the supplied row indices without shifting other rows.
remove(chars: Container[Character]) -> None
Remove characters from current membership and rendered children.
The cursor and remaining positions are unchanged. Earlier timeline membership is preserved; this is an authored removal, not deletion of past history.
line(*line: float) -> list[Character]
Return characters in any supplied row index.
except_line(*line: float) -> list[Character]
Return characters outside the supplied row indices.
lines(start: float, end: float) -> list[Character]
Return characters in rows start through end, inclusive.
except_lines(start: float, end: float) -> list[Character]
Return characters outside the inclusive row interval.
right(col: float, lines: Iterable[Character] | None=None) -> list[Character]
Return characters strictly right of col; lines optionally supplies a character subset.
left(col: float, lines: Iterable[Character] | None=None) -> list[Character]
Return characters strictly left of col; lines optionally supplies a character subset.
right_of(chars: Character | Iterable[Character], one_line: bool=True) -> list[Character]
Return characters right of the last character in row/column order.
With one_line=True, restrict to that character’s row. chars must be nonempty.
left_of(chars: Character | Iterable[Character], one_line: bool=True) -> list[Character]
Return characters left of the last character in row/column order.
With one_line=True, restrict to that character’s row. chars must be nonempty.
col(*col: float, lines: Iterable[Character] | None=None) -> list[Character]
Return characters in the supplied columns, optionally restricted to a character subset.
cols(start: float, end: float, lines: Iterable[Character] | None=None) -> list[Character]
Return characters in columns start through end, inclusive.
except_cols(start: float, end: float, lines: Iterable[Character] | None=None) -> list[Character]
Return characters outside the inclusive column interval.
below(line: float) -> list[Character]
Return characters in rows strictly below line.
background(chars: Iterable[Character] | None=None) -> list[Character]
Return characters with a truthy current background property.
foreground(chars: Iterable[Character] | None=None) -> list[Character]
Return characters with a false current background property.
above(line: float) -> list[Character]
Return characters in rows strictly above line.
line_and_below(line: float) -> list[Character]
Return characters in line and all following rows.
range(start: Vector2, end: Vector2) -> list[Character]
Return characters in reading order from start cell inclusive to end cell exclusive.
find_chars(regex: str | re.Pattern[str], chars: Collection[Character] | None=None) -> list[Character]
Return the flattened character lists of all regex matches in the current text.
find(regex: str | re.Pattern[str], chars: Collection[Character] | None=None) -> list[GridMatch]
Find regex matches and return GridMatch lists with named captured groups.
Args
regex— Python regex string or compiled pattern. Strings use re.DOTALL.chars— Optional subset to search; defaults to all current grid characters.
Search uses current text and character positions. Use host frame inspection for queries at arbitrary playback times; this method reads the authoring context.
pixel_position(position: Vector2) -> np.ndarray
Convert a cell-space position to resolved scene coordinates.
top_line(line: float, offset_from_top: float=0) -> None
Immediately position a row offset_from_top cells below the top edge.
center_line(line: float) -> None
Immediately center a row vertically in the resolved grid viewport.
entity_attached(entity)
Append an attached entity to this component’s timeline-aware children property.
defineProp(name: str, value: PropertyInitValue) -> None
Register a default before this class or any subclass is instantiated.
Definitions follow Python's MRO; constructor properties override defaults. Registration is process-wide and does not modify existing instances.
ScaleFont(grid: TextGrid, new_size: float, time: Duration=0.25, interpolation: InterpolationMode=Interpolation.Linear)
Animate font size and cell metrics together.
Args
grid— TextGrid to resize.new_size— Target font size in pixels.time— Duration in seconds or a TimeUnit; defaults to 0.25 seconds.interpolation— Interpolation mode, linear by default.
Existing character children receive the same target font size.
timeline()
Return a timeline containing all child timelines at offset zero.
AnimateGridScale(grid: TextGrid, new_size: float, time: Duration=0.25, interpolation: InterpolationMode=Interpolation.Linear)
Compatibility name for the ScaleFont animation.
timeline()
Return a timeline containing all child timelines at offset zero.
Scroll(grid: Grid, start_line: float, target_y: float, time: Duration | None=None, interpolation: InterpolationMode=Interpolation.SmoothStep)
Move a grid so start_line reaches target_y in resolved coordinates.
If time is omitted, duration is based on row distance and capped at 0.5 seconds. The grid must have positive cell dimensions; positioning helpers use its resolved resolution to identify the viewport.
center_line(grid: Grid, line: float, time: Duration | None=None) -> Scroll
Animate a row to the vertical center of the grid viewport.
top_line(grid: Grid, line: float, offset_from_top: float=0, time: Duration | None=None) -> Scroll
Animate a row to offset_from_top cells below the viewport top.
bottom_line(grid: Grid, line: float, offset_from_bottom: float=0, time: Duration | None=None) -> Scroll
Animate a row to offset_from_bottom cells above the viewport bottom.
endpoint()
Return the relative value operation used at the transition endpoint.
timeline()
Build the relative timeline with starting and ending property keyframes.
TimeFormat
Protocol defining a time representation and its zero value.
__eq__(value: object, /) -> bool
Return whether another value represents the same time format. Frame formats compare their frame rates.
zero() -> Any
Return zero in this time format.
Property(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
An animation target with an initial value and authoring-context identity.
Call the property to read its current local value; resolve() applies inheritance. Use set_value() for an instantaneous authored change. Reads describe current authored state; use inspection tools for arbitrary playback frames.
set_value(value)
Schedule an instantaneous SetProperty in the current authoring context.
clone_value(value)
Copy a literal value so later changes do not alter authored history.
resolve()
Return the current inherited value, or the local value when no inheritance rule exists.
Value
Protocol for an operation evaluated against a current property value.
materialize(current: T) -> T
Apply this operation to the current value and return its result.
KeyFrame(time: TTime)
A timeline event at a relative time.
Args
time— TimeUnit measured from the timeline origin.
A plain event extends duration without changing a property.
MarkerKeyFrame(time: TTime, name: str, description: str)
A named timeline marker with a description.
EntityInitialKeyFrame(time: TTime, entity: Entity)
A keyframe recording when an entity enters the scene.
SubTimeline(timeline: Timeline, time: TTime)
A nested timeline paired with its offset in the containing timeline.
InitializeEntity(entity: Entity)
An animation that records an entity entering the scene at time zero.
timeline() -> Timeline
Return the entity initialization keyframe at zero seconds.
Expr(node: dict)
A serializable expression traced while defining property inheritance.
wrap(value)
Preserve an expression or wrap a plain value as a literal expression.
binary(op, other)
Create a binary expression using this value and the supplied operand.
sin(value)
Return the sine of a numeric value or a traced inheritance expression, in radians.
cos(value)
Return the cosine of a numeric value or a traced inheritance expression, in radians.
InheritanceScope
Select the parent or current entity as an inheritance input scope.
ScalarProperty(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
An animated scalar property with the standard property value semantics.
set_value(value)
Schedule an instantaneous SetProperty in the current authoring context.
clone_value(value)
Copy a literal value so later changes do not alter authored history.
resolve()
Return the current inherited value, or the local value when no inheritance rule exists.
ListProperty(props: Properties, name: str, initial_value: Iterable, property_stack: SequenceStack, inheritance: Inheritance | None=None)
An animated list whose reads return snapshots of its elements.
set_value(value)
Assign a list or a deferred Value operation to this property.
append(value)
Append an item through a deferred list operation.
pop(index=-1)
Remove the item at index through a deferred list operation.
clone_value(value)
Copy each list element into an independent snapshot.
resolve()
Return the current inherited value, or the local value when no inheritance rule exists.
VectorProperty(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
An animated NumPy vector with read-only snapshot reads.
clone_value(value)
Return a new NumPy array containing the supplied values.
set_value(value)
Schedule an instantaneous SetProperty in the current authoring context.
resolve()
Return the current inherited value, or the local value when no inheritance rule exists.
NoOpValue
A sentinel indicating that an operation does not change a value.
DerrivedValue(function: Callable[[T], T])
Compute a property value by applying a function to its current value.
materialize(current)
Apply the configured function to the current value.
AppendListValue(item)
A deferred operation that appends one item to a list.
materialize(current)
Append the stored item to current and return that list.
PopListValue(index=-1)
A deferred operation that removes a list element by index.
materialize(current)
Remove the indexed element from current and return that list.
type PropertyInitValue = PropertyDefinition | str | float | int | Entity | list[PropertyInitValue] | tuple[PropertyInitValue]
Initial entity property value. Supply a property definition, a scalar, an entity reference, or a list or tuple of initial values.
PropertyDefinition
Protocol describing an initial property value and optional inheritance.
Frames60(frames: int)
Return a Frame time value at 60 frames per second.
Frames30(frames: int)
Return a Frame time value at 30 frames per second.
SecondFormat
The time format used by values expressed in seconds.
zero()
Return a Seconds value representing zero.
TimeMapping()
Registry of conversions between time-format types.
add_mapping(from_format: type[TFromFormat], to_format: type[TToFormat], function: Callable[[TFromUnit, TToFormat], TToUnit])
Register a conversion function for a pair of time-format types.
find_map_function(from_format: type, to_format: type)
Return the registered conversion for two format types; raises KeyError if absent.
map(from_time: TimeUnit, to_format: TimeFormat)
Convert from_time into to_format, returning it unchanged when formats match.
set_precedent(*format: type[TimeFormat])
Set format types in highest-to-lowest priority for timeline composition.
get_highest_precedent(formats: Iterable[TimeFormat | None]) -> TimeFormat
Choose the highest-priority supplied format.
Returns seconds when all inputs are None or absent; raises ValueError if no provided format is registered in the precedence order.
DefaultTimeMap()
See DefaultTimeMap for the signature and behavior.
set_default_transport(transport)
Install the runner-owned broker connection before importing user code.
DataSources(manifest, transport=None)
Read declared data sources through a host-owned broker transport.
Access as manifest.data. The transport is supplied by the runner; animation source should not configure endpoints or credentials.
read(source_id, request, *, refresh=False)
Return a JSON response for a declared data-source plugin.
Args
source_id— Plugin ID from a selected package.request— JSON-compatible request payload, with finite numeric values.refresh— Ask the broker to refresh its cached response.
Raises
ValueError— The source is undeclared or the payload is invalid JSON.RuntimeError— No transport is configured or the broker reports failure.
StreamTransport(reader, writer)
One outstanding request at a time over dedicated text streams.
HttpTransport(base)
Connect trusted native authoring to a separately running host broker.
project
Resolved Video2dManifest for this project.
colors
Custom project colors.
color_schemes
Plugin palettes keyed by color-scheme ID, including per-scheme overrides.
assets
Declared asset paths resolved relative to project.json.
data
Declared data-source access through the host broker.
codeanimate.video2d
Font(family: str, weight: int = 400, style: str = 'normal')
See Font for the signature and behavior.
Inheritance(resolve_func, *inputs: InheritanceInput)
See Inheritance for the signature and behavior.
InheritanceInput(scope: InheritanceScope, property_name: str, resolved: bool = True, default: Any | None = None)
See InheritanceInput for the signature and behavior.
Interpolation
See Interpolation for the signature and behavior.
CurrentValue
See CurrentValue for the signature and behavior.
LiteralValue(value)
See LiteralValue for the signature and behavior.
AddValue(delta)
See AddValue for the signature and behavior.
Entity(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See Entity for the signature and behavior.
EntityWithChildren(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See EntityWithChildren for the signature and behavior.
scale_path(commands, scale)
See scale_path for the signature and behavior.
vector(*values)
See vector for the signature and behavior.
SequenceBuilder(sequence_stack: SequenceStack, name: str)
See SequenceBuilder for the signature and behavior.
SequenceStack()
See SequenceStack for the signature and behavior.
Sequence(*animations: Animation | None)
See Sequence for the signature and behavior.
Bundle(*animations: Animation | None)
See Bundle for the signature and behavior.
Repeat(animation: Animation, times: int)
See Repeat for the signature and behavior.
Pause(time: TimeUnit | float=1)
See Pause for the signature and behavior.
Delay(time: TimeUnit | float, animation: Animation)
See Delay for the signature and behavior.
SetProperty(property: Property, value: Value | object)
See SetProperty for the signature and behavior.
Animation
See Animation for the signature and behavior.
Timeline(*keyframes: KeyFrame)
See Timeline for the signature and behavior.
PropertyKeyFrame(time: TTime, property: Optional[Property], value: Optional[Value | PropertyDelta], interpolation: Interpolation = Interpolation.Hold, options: dict[str, Any] | None = None)
See PropertyKeyFrame for the signature and behavior.
Seconds(seconds: float)
See Seconds for the signature and behavior.
TimeUnit
See TimeUnit for the signature and behavior.
ZeroFromTime(unit: TimeUnit)
See ZeroFromTime for the signature and behavior.
TimeMap
See TimeMap for the signature and behavior.
FrameFormat(frame_rate: Fraction)
See FrameFormat for the signature and behavior.
Video2dManifest(packages=(), *, package_paths=None, colors=None, color_schemes=None, data_transport=None)
See Video2dManifest for the signature and behavior.
MotionPath(_start: tuple, _encoded: str, _end: tuple)
See MotionPath for the signature and behavior.
NumericVector
See NumericVector for the signature and behavior.
type PathCommand = _Sequence[str | float]
See PathCommand for the signature and behavior.
type RGBColor = NumericVector
See RGBColor for the signature and behavior.
type Vector2 = NumericVector
See Vector2 for the signature and behavior.
type EntitySelection = Entity | Iterable[Entity]
See EntitySelection for the signature and behavior.
type Duration = TimeUnit | float
See Duration for the signature and behavior.
type InterpolationMode = Interpolation | Literal['linear', 'smoothstep', 'hold']
See InterpolationMode for the signature and behavior.
Position(x: float, y: float) -> np.ndarray
See Position for the signature and behavior.
Right(x: float) -> np.ndarray
See Right for the signature and behavior.
Left(x: float) -> np.ndarray
See Left for the signature and behavior.
Down(y: float) -> np.ndarray
See Down for the signature and behavior.
Up(y: float) -> np.ndarray
See Up for the signature and behavior.
asSeq(entities: T | Iterable[T]) -> tuple[T, ...]
See asSeq for the signature and behavior.
PositionProperty(initial_value: Vector2)
See PositionProperty for the signature and behavior.
OpacityProperty(initial_value: float=1)
See OpacityProperty for the signature and behavior.
ParentProperty(name: str, default: object)
See ParentProperty for the signature and behavior.
CoordinateProperty(name: str, value: float | Vector2)
See CoordinateProperty for the signature and behavior.
PathCoordinatesProperty(commands: _Sequence[PathCommand])
See PathCoordinatesProperty for the signature and behavior.
ResolutionProperty()
See ResolutionProperty for the signature and behavior.
visual_properties(position: Vector2 | None=None, resolution: Vector2 | None=None, **values: object) -> dict[str, object]
See visual_properties for the signature and behavior.
container_properties(position: Vector2 | None=None, **values: object) -> dict[str, object]
See container_properties for the signature and behavior.
Video2d(sequence_func: Callable[[SequenceBuilder, Frame], None], resolution: Vector2=(1920, 1080), fps: int | float | Fraction=60, background_color: RGBColor=(0, 0, 0), *, fonts: object=None, manifest: Video2dManifest | None=None)
See Video2d for the signature and behavior.
Frame(stack: SequenceStack, resolution: Vector2=(1920, 1080), fps: int | float | Fraction=60, background_color: RGBColor=(0, 0, 0))
See Frame for the signature and behavior.
Group(parent: Entity, position: Vector2 | None=None, **values: object)
See Group for the signature and behavior.
Character(parent: Entity, position: Vector2 | None, char: object, color: RGBColor=(255, 255, 255), font_size: float=48, opacity: float=1, *, font: Font, align: Literal['left', 'center', 'right'] | None=None)
See Character for the signature and behavior.
shape_properties(position: Vector2 | None, *, fill: RGBColor | None=(0, 0, 0), stroke: RGBColor | None=None, **values: object) -> dict[str, object]
See shape_properties for the signature and behavior.
Shape(parent: Entity, position: Vector2 | None, geometry: Mapping[str, object], **paint: object)
See Shape for the signature and behavior.
Rectangle(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
See Rectangle for the signature and behavior.
Circle(parent: Entity, position: Vector2 | None, radius: float, **paint: object)
See Circle for the signature and behavior.
Ellipse(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
See Ellipse for the signature and behavior.
Line(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
See Line for the signature and behavior.
Arrow(parent: Entity, position: Vector2 | None, size: Vector2, *, arrowhead_size: float=10.0, **paint: object)
See Arrow for the signature and behavior.
Path(parent: Entity, position: Vector2 | None, commands: _Sequence[PathCommand], **paint: object)
See Path for the signature and behavior.
RelativeTransition(propertyName: str, entities: EntitySelection, delta: object, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See RelativeTransition for the signature and behavior.
AbsoluteTransition(propertyName: str, entities: EntitySelection, delta: object, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See AbsoluteTransition for the signature and behavior.
Move(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See Move for the signature and behavior.
MoveTo(entities: EntitySelection, position: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See MoveTo for the signature and behavior.
MoveAlong(entities: EntitySelection, path: MotionPath, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep, *, relative: bool=True)
See MoveAlong for the signature and behavior.
Fade(entities: EntitySelection, end: float=1, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See Fade for the signature and behavior.
FadeIn(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear, zero_opacity: bool=True)
See FadeIn for the signature and behavior.
FadeOut(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See FadeOut for the signature and behavior.
Background(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See Background for the signature and behavior.
Foreground(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See Foreground for the signature and behavior.
ColorShift(entities: EntitySelection, target_color: RGBColor, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See ColorShift for the signature and behavior.
Blink(entities: EntitySelection, num_times: int=3, time_per_blink: Duration=0.1)
See Blink for the signature and behavior.
CharacterChange(chars: Character | Iterable[Character], string: object)
See CharacterChange for the signature and behavior.
ValueFade(chars: Character | Iterable[Character], string: object)
See ValueFade for the signature and behavior.
Type(chars: Character | Iterable[Character], seconds_per_char: Duration=0.04)
See Type for the signature and behavior.
ExpandSize(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See ExpandSize for the signature and behavior.
ShrinkSize(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See ShrinkSize for the signature and behavior.
video_main(make_video: Callable[[], Video2d]) -> None
See video_main for the signature and behavior.
codeanimate.video2d.entities.grid
Font(family: str, weight: int = 400, style: str = 'normal')
See Font for the signature and behavior.
Inheritance(resolve_func, *inputs: InheritanceInput)
See Inheritance for the signature and behavior.
InheritanceInput(scope: InheritanceScope, property_name: str, resolved: bool = True, default: Any | None = None)
See InheritanceInput for the signature and behavior.
Interpolation
See Interpolation for the signature and behavior.
CurrentValue
See CurrentValue for the signature and behavior.
LiteralValue(value)
See LiteralValue for the signature and behavior.
AddValue(delta)
See AddValue for the signature and behavior.
Entity(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See Entity for the signature and behavior.
EntityWithChildren(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See EntityWithChildren for the signature and behavior.
scale_path(commands, scale)
See scale_path for the signature and behavior.
vector(*values)
See vector for the signature and behavior.
SequenceBuilder(sequence_stack: SequenceStack, name: str)
See SequenceBuilder for the signature and behavior.
SequenceStack()
See SequenceStack for the signature and behavior.
Sequence(*animations: Animation | None)
See Sequence for the signature and behavior.
Bundle(*animations: Animation | None)
See Bundle for the signature and behavior.
Repeat(animation: Animation, times: int)
See Repeat for the signature and behavior.
Pause(time: TimeUnit | float=1)
See Pause for the signature and behavior.
Delay(time: TimeUnit | float, animation: Animation)
See Delay for the signature and behavior.
SetProperty(property: Property, value: Value | object)
See SetProperty for the signature and behavior.
Animation
See Animation for the signature and behavior.
Timeline(*keyframes: KeyFrame)
See Timeline for the signature and behavior.
PropertyKeyFrame(time: TTime, property: Optional[Property], value: Optional[Value | PropertyDelta], interpolation: Interpolation = Interpolation.Hold, options: dict[str, Any] | None = None)
See PropertyKeyFrame for the signature and behavior.
Seconds(seconds: float)
See Seconds for the signature and behavior.
TimeUnit
See TimeUnit for the signature and behavior.
ZeroFromTime(unit: TimeUnit)
See ZeroFromTime for the signature and behavior.
TimeMap
See TimeMap for the signature and behavior.
FrameFormat(frame_rate: Fraction)
See FrameFormat for the signature and behavior.
Video2dManifest(packages=(), *, package_paths=None, colors=None, color_schemes=None, data_transport=None)
See Video2dManifest for the signature and behavior.
MotionPath(_start: tuple, _encoded: str, _end: tuple)
See MotionPath for the signature and behavior.
NumericVector
See NumericVector for the signature and behavior.
type PathCommand = _Sequence[str | float]
See PathCommand for the signature and behavior.
type RGBColor = NumericVector
See RGBColor for the signature and behavior.
type Vector2 = NumericVector
See Vector2 for the signature and behavior.
type EntitySelection = Entity | Iterable[Entity]
See EntitySelection for the signature and behavior.
type Duration = TimeUnit | float
See Duration for the signature and behavior.
type InterpolationMode = Interpolation | Literal['linear', 'smoothstep', 'hold']
See InterpolationMode for the signature and behavior.
Position(x: float, y: float) -> np.ndarray
See Position for the signature and behavior.
Right(x: float) -> np.ndarray
See Right for the signature and behavior.
Left(x: float) -> np.ndarray
See Left for the signature and behavior.
Down(y: float) -> np.ndarray
See Down for the signature and behavior.
Up(y: float) -> np.ndarray
See Up for the signature and behavior.
asSeq(entities: T | Iterable[T]) -> tuple[T, ...]
See asSeq for the signature and behavior.
PositionProperty(initial_value: Vector2)
See PositionProperty for the signature and behavior.
OpacityProperty(initial_value: float=1)
See OpacityProperty for the signature and behavior.
ParentProperty(name: str, default: object)
See ParentProperty for the signature and behavior.
CoordinateProperty(name: str, value: float | Vector2)
See CoordinateProperty for the signature and behavior.
PathCoordinatesProperty(commands: _Sequence[PathCommand])
See PathCoordinatesProperty for the signature and behavior.
ResolutionProperty()
See ResolutionProperty for the signature and behavior.
visual_properties(position: Vector2 | None=None, resolution: Vector2 | None=None, **values: object) -> dict[str, object]
See visual_properties for the signature and behavior.
container_properties(position: Vector2 | None=None, **values: object) -> dict[str, object]
See container_properties for the signature and behavior.
Video2d(sequence_func: Callable[[SequenceBuilder, Frame], None], resolution: Vector2=(1920, 1080), fps: int | float | Fraction=60, background_color: RGBColor=(0, 0, 0), *, fonts: object=None, manifest: Video2dManifest | None=None)
See Video2d for the signature and behavior.
Frame(stack: SequenceStack, resolution: Vector2=(1920, 1080), fps: int | float | Fraction=60, background_color: RGBColor=(0, 0, 0))
See Frame for the signature and behavior.
Group(parent: Entity, position: Vector2 | None=None, **values: object)
See Group for the signature and behavior.
Character(parent: Entity, position: Vector2 | None, char: object, color: RGBColor=(255, 255, 255), font_size: float=48, opacity: float=1, *, font: Font, align: Literal['left', 'center', 'right'] | None=None)
See Character for the signature and behavior.
shape_properties(position: Vector2 | None, *, fill: RGBColor | None=(0, 0, 0), stroke: RGBColor | None=None, **values: object) -> dict[str, object]
See shape_properties for the signature and behavior.
Shape(parent: Entity, position: Vector2 | None, geometry: Mapping[str, object], **paint: object)
See Shape for the signature and behavior.
Rectangle(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
See Rectangle for the signature and behavior.
Circle(parent: Entity, position: Vector2 | None, radius: float, **paint: object)
See Circle for the signature and behavior.
Ellipse(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
See Ellipse for the signature and behavior.
Line(parent: Entity, position: Vector2 | None, size: Vector2, **paint: object)
See Line for the signature and behavior.
Arrow(parent: Entity, position: Vector2 | None, size: Vector2, *, arrowhead_size: float=10.0, **paint: object)
See Arrow for the signature and behavior.
Path(parent: Entity, position: Vector2 | None, commands: _Sequence[PathCommand], **paint: object)
See Path for the signature and behavior.
RelativeTransition(propertyName: str, entities: EntitySelection, delta: object, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See RelativeTransition for the signature and behavior.
AbsoluteTransition(propertyName: str, entities: EntitySelection, delta: object, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See AbsoluteTransition for the signature and behavior.
Move(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See Move for the signature and behavior.
MoveTo(entities: EntitySelection, position: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See MoveTo for the signature and behavior.
MoveAlong(entities: EntitySelection, path: MotionPath, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep, *, relative: bool=True)
See MoveAlong for the signature and behavior.
Fade(entities: EntitySelection, end: float=1, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See Fade for the signature and behavior.
FadeIn(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear, zero_opacity: bool=True)
See FadeIn for the signature and behavior.
FadeOut(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See FadeOut for the signature and behavior.
Background(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See Background for the signature and behavior.
Foreground(entities: EntitySelection, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See Foreground for the signature and behavior.
ColorShift(entities: EntitySelection, target_color: RGBColor, time: Duration=0.125, interpolation: InterpolationMode=Interpolation.Linear)
See ColorShift for the signature and behavior.
Blink(entities: EntitySelection, num_times: int=3, time_per_blink: Duration=0.1)
See Blink for the signature and behavior.
CharacterChange(chars: Character | Iterable[Character], string: object)
See CharacterChange for the signature and behavior.
ValueFade(chars: Character | Iterable[Character], string: object)
See ValueFade for the signature and behavior.
Type(chars: Character | Iterable[Character], seconds_per_char: Duration=0.04)
See Type for the signature and behavior.
ExpandSize(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See ExpandSize for the signature and behavior.
ShrinkSize(entities: EntitySelection, delta: Vector2, time: Duration=0.5, interpolation: InterpolationMode=Interpolation.SmoothStep)
See ShrinkSize for the signature and behavior.
video_main(make_video: Callable[[], Video2d]) -> None
See video_main for the signature and behavior.
Properties(parent: Entity | None, props: dict[str, PropertyInitValue], *, property_stack: SequenceStack | None=None)
See Properties for the signature and behavior.
optional_scale(value, scale)
See optional_scale for the signature and behavior.
type GridCrop = Iterable[Vector2] | Iterable[float]
See GridCrop for the signature and behavior.
CropProperty(value: GridCrop | None=None)
See CropProperty for the signature and behavior.
cell_metrics(filename: str | PathLike[str], size: float) -> tuple[tuple[int, int], int]
See cell_metrics for the signature and behavior.
GridMatch(chars: Iterable[Character], groups: dict[str, list[Character]], match: re.Match[str])
See GridMatch for the signature and behavior.
Grid(parent: Entity, cell_size: Vector2, *, position: Vector2 | None=None, resolution: Vector2 | None=None, crop: GridCrop | None=None, id: str | None=None, **properties: object)
See Grid for the signature and behavior.
TextGrid(parent: Entity, font_size: float=48, font: Font | None=None, show_line_numbers: bool=False, resolution: Vector2 | None=None, color: RGBColor=(255, 255, 255), id: str | None=None, *, line_number_color: RGBColor | None=None)
See TextGrid for the signature and behavior.
ScaleFont(grid: TextGrid, new_size: float, time: Duration=0.25, interpolation: InterpolationMode=Interpolation.Linear)
See ScaleFont for the signature and behavior.
AnimateGridScale(grid: TextGrid, new_size: float, time: Duration=0.25, interpolation: InterpolationMode=Interpolation.Linear)
See AnimateGridScale for the signature and behavior.
Scroll(grid: Grid, start_line: float, target_y: float, time: Duration | None=None, interpolation: InterpolationMode=Interpolation.SmoothStep)
See Scroll for the signature and behavior.
codeanimate.sequence
Seconds(seconds: float)
See Seconds for the signature and behavior.
TimeFormat
See TimeFormat for the signature and behavior.
TimeUnit
See TimeUnit for the signature and behavior.
TimeMap
See TimeMap for the signature and behavior.
Entity(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See Entity for the signature and behavior.
Interpolation
See Interpolation for the signature and behavior.
LiteralValue(value)
See LiteralValue for the signature and behavior.
Property(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
See Property for the signature and behavior.
Value
See Value for the signature and behavior.
KeyFrame(time: TTime)
See KeyFrame for the signature and behavior.
PropertyKeyFrame(time: TTime, property: Optional[Property], value: Optional[Value | PropertyDelta], interpolation: Interpolation = Interpolation.Hold, options: dict[str, Any] | None = None)
See PropertyKeyFrame for the signature and behavior.
MarkerKeyFrame(time: TTime, name: str, description: str)
See MarkerKeyFrame for the signature and behavior.
EntityInitialKeyFrame(time: TTime, entity: Entity)
See EntityInitialKeyFrame for the signature and behavior.
SubTimeline(timeline: Timeline, time: TTime)
See SubTimeline for the signature and behavior.
Timeline(*keyframes: KeyFrame)
See Timeline for the signature and behavior.
SequenceStack()
See SequenceStack for the signature and behavior.
SequenceBuilder(sequence_stack: SequenceStack, name: str)
See SequenceBuilder for the signature and behavior.
Animation
See Animation for the signature and behavior.
Sequence(*animations: Animation | None)
See Sequence for the signature and behavior.
Repeat(animation: Animation, times: int)
See Repeat for the signature and behavior.
Bundle(*animations: Animation | None)
See Bundle for the signature and behavior.
Pause(time: TimeUnit | float=1)
See Pause for the signature and behavior.
InitializeEntity(entity: Entity)
See InitializeEntity for the signature and behavior.
SetProperty(property: Property, value: Value | object)
See SetProperty for the signature and behavior.
Delay(time: TimeUnit | float, animation: Animation)
See Delay for the signature and behavior.
codeanimate.sequence.properties
Interpolation
See Interpolation for the signature and behavior.
Expr(node: dict)
See Expr for the signature and behavior.
sin(value)
See sin for the signature and behavior.
cos(value)
See cos for the signature and behavior.
vector(*values)
See vector for the signature and behavior.
optional_scale(value, scale)
See optional_scale for the signature and behavior.
scale_path(commands, scale)
See scale_path for the signature and behavior.
InheritanceScope
See InheritanceScope for the signature and behavior.
InheritanceInput(scope: InheritanceScope, property_name: str, resolved: bool = True, default: Any | None = None)
See InheritanceInput for the signature and behavior.
Inheritance(resolve_func, *inputs: InheritanceInput)
See Inheritance for the signature and behavior.
Property(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
See Property for the signature and behavior.
ScalarProperty(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
See ScalarProperty for the signature and behavior.
ListProperty(props: Properties, name: str, initial_value: Iterable, property_stack: SequenceStack, inheritance: Inheritance | None=None)
See ListProperty for the signature and behavior.
VectorProperty(props: Properties, name: str, initial_value: object, sequence_stack: SequenceStack, inheritance: Inheritance | None=None)
See VectorProperty for the signature and behavior.
NoOpValue
See NoOpValue for the signature and behavior.
Value
See Value for the signature and behavior.
LiteralValue(value)
See LiteralValue for the signature and behavior.
CurrentValue
See CurrentValue for the signature and behavior.
DerrivedValue(function: Callable[[T], T])
See DerrivedValue for the signature and behavior.
AddValue(delta)
See AddValue for the signature and behavior.
AppendListValue(item)
See AppendListValue for the signature and behavior.
PopListValue(index=-1)
See PopListValue for the signature and behavior.
type PropertyInitValue = PropertyDefinition | str | float | int | Entity | list[PropertyInitValue] | tuple[PropertyInitValue]
See PropertyInitValue for the signature and behavior.
PropertyDefinition
See PropertyDefinition for the signature and behavior.
Properties(parent: Entity | None, props: dict[str, PropertyInitValue], *, property_stack: SequenceStack | None=None)
See Properties for the signature and behavior.
Entity(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See Entity for the signature and behavior.
EntityWithChildren(parent: Entity | None, props: dict[str, PropertyInitValue], id: str | None=None, *, property_stack: SequenceStack | None=None)
See EntityWithChildren for the signature and behavior.
codeanimate.sequence.time
TimeFormat
See TimeFormat for the signature and behavior.
TimeUnit
See TimeUnit for the signature and behavior.
FrameFormat(frame_rate: Fraction)
See FrameFormat for the signature and behavior.
ZeroFromTime(unit: TimeUnit)
See ZeroFromTime for the signature and behavior.
Frame(frame_rate: int | Fraction, frame: int)
A relative frame count at a positive frame rate.
Args
frame_rate— Frames per second, represented exactly as a Fraction.frame— Frame count.
Arithmetic between frame values requires matching rates. This is a time value, not the visual Frame entity exported by codeanimate.video2d.
from_seconds(seconds: float, frame_rate: int | Fraction) -> Self
Convert seconds to frames by rounding to the nearest frame at frame_rate.
Raises ValueError if frame_rate is not positive.
to_frame_rate(frame_rate: int | Fraction) -> Self
Convert to another positive frame rate, rounding down to a whole frame.
to_seconds() -> float
Return the frame count divided by its rate as seconds.
Frames60(frames: int)
See Frames60 for the signature and behavior.
Frames30(frames: int)
See Frames30 for the signature and behavior.
SecondFormat
See SecondFormat for the signature and behavior.
TimeMapping()
See TimeMapping for the signature and behavior.
DefaultTimeMap()
See DefaultTimeMap for the signature and behavior.
TimeMap
See TimeMap for the signature and behavior.
Seconds(seconds: float)
See Seconds for the signature and behavior.
codeanimate.video2d.data_source
set_default_transport(transport)
See set_default_transport for the signature and behavior.
DataSources(manifest, transport=None)
See DataSources for the signature and behavior.
StreamTransport(reader, writer)
See StreamTransport for the signature and behavior.
HttpTransport(base)
See HttpTransport for the signature and behavior.