pub struct Renderer { /* private fields */ }Expand description
High-level WebGL2 renderer for terminal-style applications.
The Renderer manages the WebGL2 rendering context, canvas, and provides
a simplified interface for rendering drawable objects. It handles frame
management, viewport setup, and coordinate system transformations.
Implementations§
Source§impl Renderer
impl Renderer
Sourcepub fn create(
canvas_id: &str,
auto_resize_canvas_css: bool,
) -> Result<Self, Error>
pub fn create( canvas_id: &str, auto_resize_canvas_css: bool, ) -> Result<Self, Error>
Creates a new renderer by querying for a canvas element with the given ID.
Sourcepub fn canvas_padding_color(self, color: u32) -> Self
pub fn canvas_padding_color(self, color: u32) -> Self
Sets the background color for the canvas area outside the terminal grid.
Sourcepub fn create_with_canvas(
canvas: HtmlCanvasElement,
auto_resize_canvas_css: bool,
) -> Result<Self, Error>
pub fn create_with_canvas( canvas: HtmlCanvasElement, auto_resize_canvas_css: bool, ) -> Result<Self, Error>
Creates a new renderer from an existing HTML canvas element.
Sourcepub fn clear(&mut self, r: f32, g: f32, b: f32)
pub fn clear(&mut self, r: f32, g: f32, b: f32)
Clears the framebuffer with the specified color.
Sourcepub fn begin_frame(&mut self)
pub fn begin_frame(&mut self)
Begins a new rendering frame.
Sourcepub fn render(&mut self, drawable: &impl Drawable) -> Result<(), Error>
pub fn render(&mut self, drawable: &impl Drawable) -> Result<(), Error>
Renders a drawable object.
Sourcepub fn canvas(&self) -> &HtmlCanvasElement
pub fn canvas(&self) -> &HtmlCanvasElement
Returns a reference to the HTML canvas element.
Sourcepub fn canvas_size(&self) -> (i32, i32)
pub fn canvas_size(&self) -> (i32, i32)
Returns the current canvas dimensions as a tuple.
Sourcepub fn logical_size(&self) -> (i32, i32)
pub fn logical_size(&self) -> (i32, i32)
Returns the logical size of the canvas in pixels.
Sourcepub fn physical_size(&self) -> (i32, i32)
pub fn physical_size(&self) -> (i32, i32)
Returns the physical size of the canvas in pixels, taking into account the device pixel ratio.
Sourcepub fn is_context_lost(&self) -> bool
pub fn is_context_lost(&self) -> bool
Checks if the WebGL context has been lost.
Sourcepub fn restore_context(&mut self) -> Result<(), Error>
pub fn restore_context(&mut self) -> Result<(), Error>
Restores the WebGL context after a context loss event.