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
supersampletimes 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. Theyuv420ppixel 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¶
|
Render |
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 * fpsframes of the camera turningdegreesaboutaxis.axisis a screen axis (up,right,view), a data axis (x,y,z), or an xyz vector (seeneu_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.encodeis"auto"(encode if ffmpeg is found),True(encode or raise) orFalse(frames only).outputis the mp4, by default the folder’s name plus.mp4;ffmpegnames 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'¶