teng/rendering/mod.rs
1//! Rendering module for terminal-based output.
2//!
3//! This module provides the core rendering components for the `teng` library,
4//! enabling you to display graphics and text in a terminal environment.
5//!
6//! **Sub-modules:**
7//!
8//! * [`color`]: Defines the [`Color`] enum for specifying colors.
9//! * [`display`]: Defines the [`Display`] struct, a 2D pixel buffer.
10//! * [`pixel`]: Defines the [`Pixel`] struct, the basic unit of rendering.
11//! * [`render`]: Provides the [`Render`] trait for objects that can be rendered.
12//! * [`renderer`]: Defines the [`Renderer`] trait and implementations for rendering to the terminal.
13//!
14//! **Key Concepts:**
15//!
16//! * **Pixels:** The fundamental unit of rendering, represented by the [`Pixel`] struct. Pixels define a character and its foreground and background colors.
17//! * **Display Buffer:** The [`Display`] struct is a 2D grid of pixels that acts as an in-memory representation of the terminal display.
18//! * **Renderer:** The [`Renderer`] trait defines the interface for rendering operations. [`DisplayRenderer`] is a concrete implementation that renders to the terminal using `crossterm`.
19//! * **Renderable Objects:** Anything that implements the [`Render`] trait can be drawn to the display using a `Renderer`. This includes strings, characters, pixels, and sprites.
20//!
21//! **Rendering Process (Simplified):**
22//!
23//! 1. Create a `DisplayRenderer` (which manages the terminal output).
24//! 2. Get a mutable reference to the `Renderer` within your `Component::render()` method.
25//! 3. Use methods like `Renderer::render_pixel()` and `Render::render()` to draw pixels and renderable objects to the `Renderer`.
26//! 4. The `Renderer` updates its internal `Display` buffer.
27//! 5. Call `Renderer::flush()` to write the contents of the `Display` buffer to the terminal, efficiently updating only the changed pixels.
28//!
29//! [`Color`]: crate::rendering::color::Color
30//! [`Display`]: crate::rendering::display::Display
31//! [`Pixel`]: crate::rendering::pixel::Pixel
32//! [`Render`]: crate::rendering::render::Render
33//! [`Renderer`]: crate::rendering::renderer::Renderer
34//! [`DisplayRenderer`]: crate::rendering::renderer::DisplayRenderer
35
36pub mod color;
37pub mod display;
38pub mod pixel;
39pub mod render;
40pub mod renderer;