Module prelude

Module prelude 

Source
Expand description

Prelude module for convenient imports.

This module re-exports the most commonly used types from dotmax, allowing you to import everything you need with a single statement:

use dotmax::prelude::*;

This follows the standard Rust convention used by libraries like std::prelude, tokio::prelude, and serde::prelude.

§What’s Included

§Core Types

§Drawing Primitives

§Animation

§Color System

§Feature-Gated Exports

With the image feature enabled, also includes:

  • ImageRenderer: High-level image-to-braille rendering
  • DitheringMethod: Dithering algorithm selection

§Note on Result

This prelude exports dotmax::Result<T> which is an alias for std::result::Result<T, DotmaxError>. If you need to use a different error type (like Box<dyn std::error::Error>), use the fully qualified std::result::Result instead.

§Examples

§Basic Grid Usage

use dotmax::prelude::*;

// Create a grid and draw some shapes
let mut grid = BrailleGrid::new(80, 24)?;
draw_line(&mut grid, 0, 0, 100, 50)?;
draw_circle(&mut grid, 80, 48, 30)?;

§Animation Loop

use dotmax::prelude::*;

// AnimationLoop::new(width, height) returns an AnimationLoopBuilder
let animation = AnimationLoop::new(80, 24)
    .fps(30);

§Color Schemes

use dotmax::prelude::*;

let scheme = heat_map();
let capability = detect_color_capability();

§Image Rendering (with image feature)

use dotmax::prelude::*;
use std::path::Path;

let grid = ImageRenderer::new()
    .load_from_path(Path::new("image.png"))?
    .resize_to_terminal()?
    .dithering(DitheringMethod::FloydSteinberg)
    .render()?;

Re-exports§

pub use crate::BrailleGrid;
pub use crate::Color;
pub use crate::DotmaxError;
pub use crate::Result;
pub use crate::TerminalBackend;
pub use crate::TerminalCapabilities;
pub use crate::TerminalRenderer;
pub use crate::primitives::draw_circle;
pub use crate::primitives::draw_circle_colored;
pub use crate::primitives::draw_line;
pub use crate::primitives::draw_line_colored;
pub use crate::primitives::draw_polygon;
pub use crate::primitives::draw_polygon_colored;
pub use crate::primitives::draw_rectangle;
pub use crate::primitives::draw_rectangle_colored;
pub use crate::AnimationLoop;
pub use crate::AnimationLoopBuilder;
pub use crate::DifferentialRenderer;
pub use crate::FrameBuffer;
pub use crate::FrameTimer;
pub use crate::PrerenderedAnimation;
pub use crate::apply_color_scheme;
pub use crate::apply_colors_to_grid;
pub use crate::blue_purple;
pub use crate::cyan_magenta;
pub use crate::detect_color_capability;
pub use crate::grayscale;
pub use crate::green_yellow;
pub use crate::heat_map;
pub use crate::monochrome;
pub use crate::rainbow;
pub use crate::ColorCapability;
pub use crate::ColorScheme;
pub use crate::ColorSchemeBuilder;
pub use crate::quick::grid;
pub use crate::quick::grid_sized;
pub use crate::quick::show;