Crates.io | asg |
lib.rs | asg |
version | 0.1.0 |
created_at | 2025-08-29 09:34:55.725158+00 |
updated_at | 2025-08-29 09:34:55.725158+00 |
description | Asciinema SVG Generator - Convert .cast files to animated SVG |
homepage | https://github.com/kingsword09/asg |
repository | https://github.com/kingsword09/asg |
max_upload_size | |
id | 1815605 |
size | 119,378 |
A Rust CLI that converts Asciinema cast files (.cast
) into animated SVG.
Chinese documentation: README_ZH.md
vte
# Clone the repository
git clone https://github.com/kingsword09/asg.git
cd asg
# Build release
cargo build --release
# Install to system (optional)
cargo install --path .
# Convert a local .cast file
asg demo.cast demo.svg
# Specify output file name (second positional arg)
asg demo.cast output.svg
# Download from asciinema.org by recording ID and convert
asg 113643 output.svg
# Use a custom font stack
asg demo.cast output.svg --font-family "JetBrains Mono,Monaco,Consolas,Liberation Mono,Menlo,monospace"
USAGE:
asg <INPUT> <OUTPUT> [OPTIONS]
ARGS:
<INPUT> Path to .cast file, URL, or remote ID (e.g., '113643')
<OUTPUT> Output SVG file path
OPTIONS:
--theme <THEME> Select color theme (or provide comma-separated hex colors)
--speed <SPEED> Adjust playback speed [default: 1.0]
--fps <FPS> Frames per second [default: 30]
--font-family <FONT_FAMILY> Font family for the terminal text
[default: JetBrains Mono,Monaco,Consolas,Liberation Mono,Menlo,monospace]
--font-size <PX> Font size in pixels [default: 14]
-i, --idle-time-limit <SECS> Idle time limit in seconds
--cols <COLS> Override terminal width (columns)
--rows <ROWS> Override terminal height (rows)
--font-dir <DIR> Path to a directory containing font files
--no-loop Disable animation loop
--line-height <FLOAT> Line height [default: 1.4]
--at <SECS> Timestamp of frame to render (static image)
--from <SECS> Lower range of timeline to render
--to <SECS> Upper range of timeline to render
--no-cursor Disable cursor rendering
--window Render with window decorations
--padding <PX> Distance between text and image bounds [default: 10]
--padding-x <PX> Override padding on x axis
--padding-y <PX> Override padding on y axis
--timeline <MODE> Timeline mode: original|fixed [default: original]
-v, --verbose Verbose output (-v, -vv, -vvv)
-h, --help Print help information
ASG uses a modular architecture consisting of these primary modules:
src/input.rs
— Input layer for local files, URLs, and remote IDssrc/asciicast.rs
— Asciicast v2 parsersrc/terminal.rs
— VTE-based terminal emulator (parses ANSI/SGR, produces frames)src/renderer.rs
— SVG generation and CSS animationsrc/main.rs
— CLI entrypoint and orchestrationInput (file/URL/ID)
↓
Input reader
↓
.cast NDJSON stream
↓
Asciicast parser
↓
Terminal emulator (VTE)
↓
Frame sequence (cells with fg/bg and styles)
↓
SVG renderer
↓
Animated SVG file
vte
<rect>
to reduce element countfont-weight
/font-style
/text-decoration
# Record a terminal session
asciinema rec demo.cast
# Convert to SVG
asg demo.cast demo.svg
# Open in a browser
open demo.svg
# Fetch from asciinema.org and convert
asg 113643 terminal-demo.svg
Issues and pull requests are welcome!
# Run tests
cargo test
# Lint code
cargo clippy
# Format code
cargo fmt
Apache-2.0 License
Kingsword kingsword09@gmail.com