Skip to content

🎨 A versatile Go CLI tool that converts text into ASCII art with multiple fonts, color support, text alignment options, and file output capabilities.

Notifications You must be signed in to change notification settings

TanakAiko/ascii-art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

17 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Go Linux Git

ASCII Art Generator

A versatile Go application that converts text into ASCII art using various stylized fonts with support for colors, alignment options, and file output.

✨ Features

  • Multiple Font Styles: Choose from standard, shadow, or thinkertoy ASCII art fonts
  • Color Support: Add colors to your ASCII art with various color formats
  • Text Alignment: Align your text with left, right, center, or justify options
  • File Output: Save your ASCII art directly to text files
  • Input Validation: Handles only printable ASCII characters (32-126)
  • Newline Support: Process text with \n for multi-line ASCII art

πŸ“‹ Requirements

  • Go 1.20 or later
  • Unix-like environment (for terminal size detection in alignment features)

πŸ› οΈ Installation

  1. Clone the repository:
git clone <repository-url>
cd ascii-art
  1. Ensure you have Go 1.20 or later installed:
go version
  1. Run the application:
go run .

πŸ“– Usage

  • Basic Usage

Generate ASCII art with default settings:

go run . "Hello World"

Specify a banner style:

go run . "Hello World" standard
go run . "Hello World" shadow
go run . "Hello World" thinkertoy
  • Color Options

Basic Colors

go run . --color=red "Hello World"
go run . --color=blue "Hello World"

Available colors: red, green, blue, yellow, purple, orange, pink, cyan, magenta, gray

Color Specific Characters

Color only specific letters:

go run . --color=red "el" "Hello World"

Advanced Color Formats

RGB Format:

go run . --color=rgb(255,0,0) "Hello World"

Hexadecimal Format:

go run . --color=#FF0000 "Hello World"

HSL Format:

go run . --color=hsl(0,100%,50%) "Hello World"

Color Mixing:

go run . --color=red,blue "Hello World"
  • Alignment Options

Left Alignment (default)

go run . --align=left "Hello World" standard

Right Alignment

go run . --align=right "Hello World" standard

Center Alignment

go run . --align=center "Hello World" standard
  • Justify Alignment

go run . --align=justify "Hello World" standard
  • File Output

Save ASCII art to a file:

go run . --output=result.txt "Hello World" standard
  • Multi-line Text

Use \n for line breaks:

go run . "Hello\nWorld" standard

πŸ’‘ Examples

Basic ASCII Art

go run . "Hello" standard

Output:

 _    _          _   _        
| |  | |        | | | |       
| |__| |   ___  | | | |   ___ 
|  __  |  / _ \ | | | |  / _ \
| |  | | |  __/ | | | | | (_) |
|_|  |_|  \___| |_| |_|  \___/ 

Basic ASCII Art

go run . "Hello" thinkertoy

Output:

o  o     o o     
|  |     | |     
O--O o-o | | o-o 
|  | |-' | | | | 
o  o o-o o o o-o               
                 

Colored ASCII Art

go run . --color=blue "Hello" 

Aligned ASCII Art

go run . --align=center "Hello"

File Output

go run . --output=my_art.txt "Hello World"

πŸ“ Project Structure

ascii-art/
β”œβ”€β”€ main.go              # Main application entry point
β”œβ”€β”€ go.mod              # Go module file
β”œβ”€β”€ tools/              # Package containing core functionality
β”‚   β”œβ”€β”€ colorCode.go    # Color processing functions
β”‚   β”œβ”€β”€ getTxt.go       # File reading utilities
β”‚   β”œβ”€β”€ isvalid.go      # Input validation
β”‚   β”œβ”€β”€ justify.go      # Text alignment functions
β”‚   β”œβ”€β”€ printascii.go   # ASCII art generation
β”‚   β”œβ”€β”€ recognize.go    # Color format recognition
β”‚   └── Recuperation.go # Character retrieval from banners
β”œβ”€β”€ banners/            # ASCII art font files
β”‚   β”œβ”€β”€ standard.txt    # Standard font
β”‚   β”œβ”€β”€ shadow.txt      # Shadow font
β”‚   └── thinkertoy.txt  # Thinkertoy font
└── README.md           # This file

⚠️ Error Handling

The application provides clear error messages for common issues:

  • Invalid arguments: Shows proper usage format
  • Unsupported characters: Only ASCII characters (32-126) are supported
  • Invalid color formats: Validates color syntax
  • Missing files: Checks for banner file existence

πŸ§ͺ Testing

Run the included tests:

go test

The project includes comprehensive tests for:

  • Basic ASCII art generation
  • Different banner styles
  • File output functionality

🎨 Color Format Reference

Supported Color Formats

  1. Named Colors: red, green, blue, yellow, purple, orange, pink, cyan, magenta, gray
  2. RGB: rgb(255,0,0) - Values from 0-255
  3. Hexadecimal: #FF0000 - 6-digit hex values
  4. HSL: hsl(0,100%,50%) - Hue (0-360), Saturation & Lightness (0-100%)
  5. Color Mixing: red,blue - Mix two colors

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

πŸ“ Notes

  • The application automatically detects terminal width for proper text alignment
  • Color output requires a terminal that supports ANSI color codes
  • Banner files must be in the correct format for proper character rendering

⭐ Star this repository if you found it helpful! ⭐

Made with ❀️ from πŸ‡ΈπŸ‡³

About

🎨 A versatile Go CLI tool that converts text into ASCII art with multiple fonts, color support, text alignment options, and file output capabilities.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •