neu_draw.backends.animation

Render an orbit of a view to numbered PNG frames, and encode them if ffmpeg is found.

The camera maths is neu_draw.orbit. Here:

  • one offscreen renderer is used for the whole run;

  • frames are rendered at supersample times the requested size and box-averaged down, which antialiases them;

  • each frame is written to a temporary name and renamed, so a killed run leaves no partial frame. The parameters are saved in animation.json, and a rerun into the same folder resumes only if they match, so frames of two different orbits never mix;

  • ffmpeg is looked for, not assumed (find_ffmpeg()). Without one, the frames are kept and the command is printed. The yuv420p pixel format is needed for the mp4 to play in PowerPoint, Keynote or Slack, and it requires even frame dimensions, so odd ones are refused before rendering.

Attributes

Functions

orbit(view, directory, *[, degrees, seconds, fps, ...]) → neu_draw.video.Orbit

Render seconds * fps frames of the camera turning degrees about axis.

Module Contents

neu_draw.backends.animation.orbit(view, directory: str, *, degrees: float = 360.0, seconds: float = 12.0, fps: float = 30.0, axis: Any = 'up', light: str = 'camera', ease: str = 'linear', size: tuple[int, int] | None = None, supersample: int = 2, legend: bool = True, overwrite: bool = False, encode: Any = 'auto', output: str | None = None, ffmpeg: str | None = None, progress: Callable[[int, int], None] | None = None) → neu_draw.video.Orbit

Render seconds * fps frames of the camera turning degrees about axis.

axis is a screen axis (up, right, view), a data axis (x, y, z), or an xyz vector (see neu_draw.orbit). light="camera" turns the directional lights with the camera, so the shading stays fixed on the object; "fixed" leaves them, so the shading sweeps across it. The view is left unchanged.

encode is "auto" (encode if ffmpeg is found), True (encode or raise) or False (frames only). output is the mp4, by default the folder’s name plus .mp4; ffmpeg names the executable. ffmpeg is looked up before rendering, so a bad path fails at once.

Returns an Orbit: the video’s path if one was written, the line that would write it if not.

neu_draw.backends.animation.LIGHTS = ('camera', 'fixed')
neu_draw.backends.animation.PARAMS_FILE = 'animation.json'
neu_draw.backends.animation.PNG_SIGNATURE = b'\x89PNG\r\n\x1a\n'