Skip to content

Video Renderer

lerax.render.VideoRenderer

Bases: Abstract2DRenderer

Renderer wrapper that records frames to a video file.

It forwards all drawing operations to the underlying renderer and captures the framebuffer on each call to draw(). When close() is called, the accumulated frames are written to output_path as a video.

Note

This renderer is not JIT-safe and is intended for use in Python loops (e.g. via env.render_states / env.render_stacked).

Attributes:

Name Type Description
transform Transform

Transform from world space to pixel space.

inner Abstract2DRenderer

The underlying renderer to which drawing operations are forwarded.

output_path str

Path to the output video file.

fps float

Frames per second for the output video.

frames list

List of captured frames.

Parameters:

Name Type Description Default
inner Abstract2DRenderer

The underlying renderer to which drawing operations are forwarded.

required
output_path str

Path to the output video file.

required
fps float

Frames per second for the output video.

60.0

transform instance-attribute

transform: Transform = inner.transform

inner instance-attribute

inner: Abstract2DRenderer = inner

output_path instance-attribute

output_path: str = output_path

fps instance-attribute

fps: float = fps

frames instance-attribute

frames: list = []

__init__

__init__(
    inner: Abstract2DRenderer,
    output_path: str,
    fps: float = 60.0,
) -> None

open

open()

close

close()

draw

draw()

clear

clear()

draw_circle

draw_circle(
    center: Float[ArrayLike, "2"],
    radius: Float[ArrayLike, ""],
    color: Color,
)

draw_line

draw_line(
    start: Float[ArrayLike, "2"],
    end: Float[ArrayLike, "2"],
    color: Color,
    width: Float[ArrayLike, ""] = 1,
)

draw_rect

draw_rect(
    center: Float[ArrayLike, "2"],
    w: Float[ArrayLike, ""],
    h: Float[ArrayLike, ""],
    color: Color,
)

draw_polygon

draw_polygon(
    points: Float[ArrayLike, "num 2"], color: Color
)

draw_text

draw_text(
    center: Float[ArrayLike, "2"],
    text: str,
    color: Color,
    size: Float[ArrayLike, ""] = 12,
)

draw_polyline

draw_polyline(
    points: Float[ArrayLike, "num 2"], color: Color
)

draw_ellipse

draw_ellipse(
    center: Float[ArrayLike, "2"],
    w: Float[ArrayLike, ""],
    h: Float[ArrayLike, ""],
    color: Color,
)

as_array

as_array() -> Float[ArrayLike, 'H W 3']