ANSI Art Editor
Create ANSI art with box-drawing characters, 16-color palette, drawing tools, and export to ANSI escape sequences or plain text.
About
ANSI art encodes visual information within the constraints of monospaced character grids and a fixed 16-color palette defined by ECMA-48 / ISO 6429. A single misplaced escape sequence renders the entire downstream output as garbage in most terminal emulators. This editor operates on a cols × rows grid where each cell stores a character, a foreground color index, and a background color index. It implements Bresenham's line algorithm for precise diagonal strokes and iterative BFS flood fill to avoid recursion limits on large canvases. Export produces optimized ANSI escape sequences that only emit color-change codes when the palette actually shifts between adjacent cells, reducing output size by roughly 40% compared to naive per-cell encoding.
The tool assumes a standard 80×24 terminal geometry by default. Grids exceeding 200 columns may render incorrectly in terminals that do not support line wrapping suppression. Box-drawing characters (U+2500 block) require a font with complete Unicode coverage. Pro tip: test your exported art in at least two terminal emulators - rendering of block elements like ▄ and █ varies between xterm, iTerm2, and Windows Terminal.
Formulas
The line tool uses Bresenham's algorithm to determine which grid cells to fill between two endpoints. Given start cell (x0, y0) and end cell (x1, y1):
At each step, the error term err is tested. If 2err ≥ dy, advance horizontally and add dy to err. If 2err ≤ dx, advance vertically and add dx to err. This yields an integer-only, branch-minimal rasterization with O(max(dx, |dy|)) time complexity.
ANSI export uses SGR (Select Graphic Rendition) sequences:
Where fg and bg are integers 0 - 15 corresponding to the standard ANSI color indices. The optimizer tracks the previous cell's colors and only emits a new SGR sequence when either fg or bg differs from the predecessor, reducing byte count significantly for regions of uniform color.
Reference Data
| Character | Unicode | Name | Usage |
|---|---|---|---|
| ─ | U+2500 | Box Light Horizontal | Horizontal lines |
| │ | U+2502 | Box Light Vertical | Vertical lines |
| ┌ | U+250C | Box Light Down Right | Top-left corner |
| ┐ | U+2510 | Box Light Down Left | Top-right corner |
| └ | U+2514 | Box Light Up Right | Bottom-left corner |
| ┘ | U+2518 | Box Light Up Left | Bottom-right corner |
| ├ | U+251C | Box Light Vertical Right | Left T-junction |
| ┤ | U+2524 | Box Light Vertical Left | Right T-junction |
| ┬ | U+252C | Box Light Down Horizontal | Top T-junction |
| ┴ | U+2534 | Box Light Up Horizontal | Bottom T-junction |
| ┼ | U+253C | Box Light Vertical Horizontal | Cross junction |
| ═ | U+2550 | Box Double Horizontal | Double horizontal line |
| ║ | U+2551 | Box Double Vertical | Double vertical line |
| ╔ | U+2554 | Box Double Down Right | Double top-left corner |
| ╗ | U+2557 | Box Double Down Left | Double top-right corner |
| ╚ | U+255A | Box Double Up Right | Double bottom-left corner |
| ╝ | U+255D | Box Double Up Left | Double bottom-right corner |
| █ | U+2588 | Full Block | Solid fill, pixel art |
| ▓ | U+2593 | Dark Shade | 75% density shading |
| ▒ | U+2592 | Medium Shade | 50% density shading |
| ░ | U+2591 | Light Shade | 25% density shading |
| ▄ | U+2584 | Lower Half Block | Sub-cell vertical resolution |
| ▀ | U+2580 | Upper Half Block | Sub-cell vertical resolution |
| ▌ | U+258C | Left Half Block | Sub-cell horizontal resolution |
| ▐ | U+2590 | Right Half Block | Sub-cell horizontal resolution |
| ● | U+25CF | Black Circle | Decorative, bullets |
| ○ | U+25CB | White Circle | Decorative, status indicators |
| ♦ | U+2666 | Black Diamond | Decorative elements |
| ★ | U+2605 | Black Star | Rating, decoration |
| ♠ | U+2660 | Black Spade | Card art, decoration |
| ♥ | U+2665 | Black Heart | Card art, decoration |