Expand description
Rendering module for terminal-based output.
This module provides the core rendering components for the teng library,
enabling you to display graphics and text in a terminal environment.
Sub-modules:
color: Defines theColorenum for specifying colors.display: Defines theDisplaystruct, a 2D pixel buffer.pixel: Defines thePixelstruct, the basic unit of rendering.render: Provides theRendertrait for objects that can be rendered.renderer: Defines theRenderertrait and implementations for rendering to the terminal.
Key Concepts:
- Pixels: The fundamental unit of rendering, represented by the
Pixelstruct. Pixels define a character and its foreground and background colors. - Display Buffer: The
Displaystruct is a 2D grid of pixels that acts as an in-memory representation of the terminal display. - Renderer: The
Renderertrait defines the interface for rendering operations.DisplayRendereris a concrete implementation that renders to the terminal usingcrossterm. - Renderable Objects: Anything that implements the
Rendertrait can be drawn to the display using aRenderer. This includes strings, characters, pixels, and sprites.
Rendering Process (Simplified):
- Create a
DisplayRenderer(which manages the terminal output). - Get a mutable reference to the
Rendererwithin yourComponent::render()method. - Use methods like
Renderer::render_pixel()andRender::render()to draw pixels and renderable objects to theRenderer. - The
Rendererupdates its internalDisplaybuffer. - Call
Renderer::flush()to write the contents of theDisplaybuffer to the terminal, efficiently updating only the changed pixels.