Skip to main content

Crate eger

Crate eger 

Source
Expand description

eger — a high-level, parallel ASCII-art media pipeline built on top of iascii.

  • config — fluent Config/ConfigBuilder describing input, output, sizing, and parallelism.
  • image — single-image and Rayon-parallel batch image → ASCII rendering. Always available.
  • video (requires the video feature) — video → ASCII frame-sequence rendering, streamed through ffmpeg with chunked Rayon-parallel conversion, plus terminal playback.
  • render — output targets: stdout, file, String, or Vec<String>, plus terminal-size detection (render::terminal_size) and cursor-addressed diffed playback (render::diff_frame, [render::play_terminal_diffed]) as a lower-flicker alternative to clear-and-redraw.
  • text — text → ANSI coloring/animation: built-in styles (Typewriter, Rainbow, Wave, Blink, Marquee, Pulse) plus custom animations driven by an external program or a Rust closure. Always available (no video feature needed, except for the async play_text_async/stream_text_frames variants).
  • banner — multi-line “big text” banners: the same animation styles as text, rendered as block letters instead of a single line.
  • colorize — per-cell (as opposed to text/banner’s per-character) color animation for any block of plain ASCII text — a converted image, a decoded GIF/video frame, banner text, or anything else — including colorize::PixelAnimation::Custom for fully custom, mathematically-defined coloring functions.
  • color — reusable color::ColorTransforms (grayscale, invert, sepia, brightness/contrast/saturation, hue rotation, tinting) shared by dither (transform-then-quantize), colorize (colorize::PixelAnimation::Transformed layers one on top of any other animation), and [wasm] (exposed directly for post-processing already-rendered art in the browser).
  • segment — partitions a single converted image/frame into numbered/named structures (segment::SegmentMap), so a particular region can be bolded, colored, or animated (segment::SegmentStyle::Animation) on its own while the rest of the frame renders normally. segment::SequenceStyles extends this across a whole sequence of frames, keyed by (frame, segment id).
  • dither — Floyd–Steinberg/Atkinson error diffusion and Bayer ordered dithering, applied in character-grid space via Config::dither — mainly useful for reducing banding at iascii::render::ColorDepth::Ansi16/Ansi256.
  • script — ready-made non-Latin character ramps (script::Script: Cyrillic, CJK, Devanagari, Braille, block/shade, …) for ConfigBuilder::script, alongside iascii’s own Latin ramps.
  • illusions — procedurally generated optical-illusion source art (café wall, Hermann grid, twisted cord, and the animated “rotating rings” motion illusion), rendered through the same pipeline as any other image.
  • [wasm] (requires the wasm feature, target_arch = "wasm32" only) — a thin wasm-bindgen wrapper around the terminal-independent parts of the pipeline, for rendering ASCII art in a browser.
  • error — unified EgerError / Result.

video also gains GIF playback ([video::play_gif]), and image gains synchronous GIF decoding (image::gif_to_lines) available without the video feature.

§Feature flags

  • video (off by default) — pulls in tokio and enables the video module (which additionally requires ffmpeg/ffprobe on PATH at runtime), plus the async (_async) variants of the image API and render::dispatch_async/render::play_terminal, since they share the same Tokio runtime dependency.
  • wasm (off by default) — pulls in wasm-bindgen and enables the [wasm] module. Only meaningful when targeting wasm32; mutually exclusive with video in practice, since tokio/ffmpeg/real terminals don’t exist in a browser.

§Example

use eger::prelude::*;

let config = Config::builder(MediaType::Image)
    .from_file("cat.png")
    .max_width(120)
    .color_depth(ColorDepth::TrueColor)
    .build()?;
let ascii = eger::image::image_to_string(std::path::Path::new("cat.png"), &config)?;
println!("{ascii}");

Re-exports§

pub use crate::banner::banner_frames;
pub use crate::banner::banner_lines;
pub use crate::color::ColorTransform;
pub use crate::colorize::colorize_frames;
pub use crate::colorize::colorize_grid;
pub use crate::colorize::colorize_grid_frames;
pub use crate::colorize::colorize_joined_sequence;
pub use crate::colorize::colorize_lines;
pub use crate::colorize::colorize_sequence;
pub use crate::colorize::ColorFn;
pub use crate::colorize::PixelAnimation;
pub use crate::config::Config;
pub use crate::config::ConfigBuilder;
pub use crate::config::MediaType;
pub use crate::dither::DitherMethod;
pub use crate::dither::DitherOptions;
pub use crate::error::EgerError;
pub use crate::error::Result;
pub use crate::illusions::generate as generate_illusion;
pub use crate::illusions::render_illusion;
pub use crate::illusions::Illusion;
pub use crate::image::gif_to_lines;
pub use crate::image::image_to_file;
pub use crate::image::image_to_lines;
pub use crate::image::image_to_string;
pub use crate::image::render_batch_parallel;
pub use crate::image::render_dynamic_image;
pub use crate::image::render_image_file;
pub use crate::render::detect_render_depth;
pub use crate::render::terminal_size;
pub use crate::render::DiffGranularity;
pub use crate::render::RenderOutput;
pub use crate::render::RenderTarget;
pub use crate::script::Script;
pub use crate::segment::Rect;
pub use crate::segment::Segment;
pub use crate::segment::SegmentMap;
pub use crate::segment::SegmentOptions;
pub use crate::segment::SegmentStyle;
pub use crate::segment::SegmentStyles;
pub use crate::segment::SequenceStyles;
pub use crate::text::play_text;
pub use crate::text::text_frames;
pub use crate::text::CustomAnimation;
pub use crate::text::Rgb;
pub use crate::text::TextAnimOptions;
pub use crate::text::TextAnimation;

Modules§

banner
Multi-line “big text” banners — a small built-in 5×7 block font plus the existing crate::text animation styles, for animated banners instead of just single colored lines.
color
Reusable color transforms, shared by crate::dither (applied to a cell’s color before quantization/diffusion — see crate::dither::render_ansi_dithered_transformed), crate::colorize (crate::colorize::PixelAnimation::Transformed wraps any other animation and applies one of these on top of it), and [crate::wasm] (exposed directly for browser callers that just want to post-process already-rendered art, e.g. a “grayscale preview” toggle).
colorize
Per-cell (pixel-level) ANSI coloring and animation for any already rendered block of ASCII text — a static image conversion, a decoded GIF/video frame, or plain block-letter banner text — as opposed to crate::text/crate::banner, which only color a single line or a banner’s own generated glyphs.
config
Fluent configuration for eger’s image/video → ASCII pipelines.
dither
Dithering for eger’s color output.
error
Error types for eger.
illusions
Procedurally generated optical-illusion source art.
image
Image → ASCII rendering, with single-file, Rayon-parallel batch, and Tokio-async entry points.
prelude
Everything needed to configure and drive eger in one use.
render
Output targets for rendered ASCII art: stdout, a file, an owned String, or a Vec<String> — plus terminal playback for frame sequences.
script
Multi-script character ramps.
segment
Named/numbered structure extraction and per-structure styling.
text
Text → ANSI rendering and animation.