Expand description
eger — a high-level, parallel ASCII-art media pipeline built on top
of iascii.
config— fluentConfig/ConfigBuilderdescribing input, output, sizing, and parallelism.style— one-knob color treatments: basic uncolored ASCII (Style::Plain), full color (Style::Full), black-and-white grayscale (Style::Gray), a single color of your choice (Style::Mono), or 1-bit bilevel (Style::BlackWhite) — set viaConfigBuilder::styleand honored by the image, batch, GIF, and video pipelines.image— single-image and Rayon-parallel batch image → ASCII rendering. Always available.video(requires thevideofeature) — video → ASCII frame-sequence rendering, streamed throughffmpegwith chunked Rayon-parallel conversion, plus terminal playback.render— output targets: stdout, file,String, orVec<String>, plus terminal-size detection (render::terminal_size) and cursor-addressed diffed playback (render::diff_frame,render::play_terminal_diffed, the latter behind thevideofeature) 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 (novideofeature needed, except for the asyncplay_text_async/stream_text_framesvariants).banner— multi-line “big text” banners: the same animation styles astext, rendered as block letters instead of a single line.colorize— per-cell (as opposed totext/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 — includingcolorize::PixelAnimation::Customfor fully custom, mathematically-defined coloring functions.color— reusablecolor::ColorTransforms (grayscale, invert, sepia, brightness/contrast/saturation, hue rotation, tinting) shared bydither(transform-then-quantize),colorize(colorize::PixelAnimation::Transformedlayers one on top of any other animation), andwasm(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::SequenceStylesextends 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 viaConfig::dither— mainly useful for reducing banding atiascii::render::ColorDepth::Ansi16/Ansi256.system— system-aware resource scaling: detected CPUs size thread pools, detected RAM sizes decode-chunk buffering (both manually overridable, both conservative when detection fails).canvas— efficient frame building/presentation, usable on its own (dashboards, monitors, custom renderers): a flat, clippingCanvasof coloredcanvas::Cells with damage tracking (dirty rows, render cache, cell-snapshot dedupe), zero-allocation frame paths (Canvas::write_into/Canvas::write_dirty_into), and cursor-addressed patch-only presentation (Canvas::present_dirty_into). Plus multi-frameSprites from text, pictures, or any rendered frame, andrender::diff_frame-basedcanvas::present_diff/canvas::screenhelpers.game— realtime game loop layer on top ofcanvas(which it re-exports): backend-freeInput,Camera,rects_overlap, fixed-stepTickClock, theGametrait with a headless runner for tests/bots/replays, and thejump_arc/perspective_scale/shake_offseteffect helpers.script— ready-made non-Latin character ramps (script::Script: Cyrillic, CJK, Devanagari, Braille, block/shade, …) forConfigBuilder::script, alongsideiascii’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 thewasmfeature,target_arch = "wasm32"only) — a thinwasm-bindgenwrapper around the terminal-independent parts of the pipeline, for rendering ASCII art in a browser.error— unifiedEgerError/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
Modules are opt-out, not clubbed together. default = ["standard"]
matches the historical build (everything below except video/wasm);
standard pulls one feature per module (image, text, banner,
color, colorize, dither, segment, script, illusions,
canvas, game) so you can drop what you don’t ship. With
default-features = false you get the lean core — grid rendering,
Config, Style, system detection, raw-buffer conversion — with
no image decoders and no extra modules:
[dependencies]
eger = { version = "1", default-features = false } # core only
eger = { version = "1", default-features = false, features = ["image", "dither"] }standard(on by default) — all modules exceptvideo/wasm.full—standard+video+wasm(everything).video(off by default) — pulls intokio(plusimage,colorize, andtext, which the pipeline is built on) and enables thevideomodule (which additionally requiresffmpeg/ffprobeonPATHat runtime), plus the async (_async) variants of the image API andrender::dispatch_async/render::play_terminal.wasm(off by default) — pulls inwasm-bindgen(plusimage,banner,color,colorize,dither,script,text, andillusions) and enables thewasmmodule. Only meaningful when targetingwasm32; mutually exclusive withvideoin practice, sincetokio/ffmpeg/real terminals don’t exist in a browser.parallel(off by default) — row-level split within a single image/frame conversion (viaiascii/parallel’sconvert_with_pool); across-file/frame batching is always on.- Granular module features:
image(file/GIF decoding via theimagecrate — buffer APIs stay in the core),text,banner(impliestext),color,colorize,dither,segment(impliescolorize),script,illusions(impliesimage+colorize),canvas(efficient frame building/presentation, usable standalone),game(impliescanvas— onlyCanvas::apply_animationneedscolorize).
Always-on substrate (small, pure-Rust, no system services): iascii,
rayon (shared thread pool), regex (directory input patterns),
thiserror, terminal_size.
§Example
use eger::prelude::*;
// Core-only: no image decoders, no extra modules. A raw RGB8
// framebuffer (screencap, game frame, camera feed) straight to ASCII.
let config = Config::builder(MediaType::Image)
.from_file("cat.png") // placeholder source; the buffer below is authoritative
.max_width(120)
.style(Style::Plain) // basic ASCII, zero escapes
.build()?;
let rgb = vec![128u8; 64 * 32 * 3]; // your pixels here
let ascii = eger::image::rgb_buffer_to_string(64, 32, &rgb, &config)?;
println!("{ascii}");Re-exports§
pub use crate::canvas::present_diff;pub use crate::canvas::screen;pub use crate::canvas::Canvas;pub use crate::canvas::Cell as GameCell;pub use crate::canvas::Sprite;pub use crate::color::ColorTransform;pub use crate::colorize::animation_color;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::game::jump_arc;pub use crate::game::perspective_scale;pub use crate::game::rects_overlap;pub use crate::game::run_headless;pub use crate::game::shake_offset;pub use crate::game::Camera;pub use crate::game::Control;pub use crate::game::Game;pub use crate::game::Input;pub use crate::game::Key;pub use crate::game::TickClock;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::image::render_rgb_buffer;pub use crate::image::rgb_buffer_to_string;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::rgb::Rgb;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::style::Style;pub use crate::system::SystemSpecs;pub use crate::text::play_text;pub use crate::text::text_frames;pub use crate::text::CustomAnimation;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::textanimation styles, for animated banners instead of just single colored lines. - canvas
- Efficient ASCII frame building and presentation: a flat
Canvasof coloredCells with damage tracking, multi-frameSprites, and three present paths (full, incremental, patch-only). - color
- Reusable color transforms, shared by
crate::dither(applied to a cell’s color before quantization/diffusion — seecrate::dither::render_ansi_dithered_transformed),crate::colorize(crate::colorize::PixelAnimation::Transformedwraps any other animation and applies one of these on top of it), andwasm(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 single-line text animations or block-letter banners, 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. - game
- Realtime ASCII game layer: input, a fixed-timestep clock, the
Gametrait, and a headless runner — the loop side of building an ASCII game on top of this crate’s rendering. - 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
egerin oneuse. - render
- Output targets for rendered ASCII art: stdout, a file, an owned
String, or aVec<String>— plus terminal playback for frame sequences. - rgb
- Core color vocabulary:
Rgband HSV conversion. - script
- Multi-script character ramps.
- segment
- Named/numbered structure extraction and per-structure styling.
- style
- One-knob color treatments for ASCII rendering.
- system
- System-aware resource scaling: detect what the machine has, size every pool/buffer/chunk from it, and stay conservative whenever detection or the numbers look wrong.
- text
- Text → ANSI rendering and animation.