Skip to content

g-laliotis/ascii-art

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

54 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ASCII-Art

Transform your text into beautiful ASCII art

CI License: MIT Go Report Card Makefile

ASCII-Art is a command-line tool that converts regular text into stylized ASCII art using predefined banner templates. Perfect for creating eye-catching headers, banners, or just having fun with text!

🌐 Try the Live Demo

✨ Features

  • 🎨 ASCII art using standard banner style (with shadow and thinkertoy support planned)
  • 🌈 Color support - colorize entire output or specific substrings with ANSI colors
  • πŸ“ Support for letters, numbers, spaces, and special characters
  • πŸ”„ Multi-line output with \n support
  • πŸ“± Automatic terminal width detection and wrapping - adapts to any screen size
  • ⚑ Fast and lightweight - uses only Go standard library
  • 🎯 Simple command-line interface

πŸš€ Quick Start

# Clone the repository
git clone https://github.com/g-laliotis/ascii-art.git
cd ascii-art

# Run directly
go run ./cmd/ascii-art "Hello World"

# Or use Makefile
make run

πŸ“ Example Output

$ go run ./cmd/ascii-art "Hello"
$
 _    _          _   _          $
| |  | |        | | | |         $
| |__| |   ___  | | | |   ___   $
|  __  |  / _ \ | | | |  / _ \  $
| |  | | |  __/ | | | | | (_) | $
|_|  |_|  \___| |_| |_|  \___/  $
                                $

πŸ› οΈ Installation

Prerequisites

  • Go 1.19 or higher

Using Makefile

# Build executable
make build

# Run tests
make test

# Install to GOPATH/bin
make install

# See all available commands
make help

Manual Build

# Build executable
go build -o ascii-art ./cmd/ascii-art

# Run all tests
go test -v ./...

πŸ“š Usage

# Basic text
go run ./cmd/ascii-art "Hello"

# Multi-line text
go run ./cmd/ascii-art "Hello\nWorld"

# Special characters and numbers
go run ./cmd/ascii-art "Hello There! 123"

# Color entire output
go run ./cmd/ascii-art --color=red "Hello"

# Color specific substring
go run ./cmd/ascii-art --color=blue kit "a king kitten have kit"

# Available colors: red, green, yellow, blue, magenta, cyan, white, orange

# Empty string (prints nothing)
go run ./cmd/ascii-art ""

# Long text (automatically wraps to terminal width)
go run ./cmd/ascii-art "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

πŸ“± Terminal Width Adaptation

The program automatically detects your terminal width and wraps long text accordingly:

  • Smart wrapping: Automatically breaks long text at character boundaries
  • Any terminal size: Works on narrow mobile terminals to wide desktop screens
  • Preserves formatting: Each wrapped section maintains proper ASCII art structure
  • Fallback support: Uses COLUMNS environment variable or defaults to 80 characters

πŸ“ Project Structure

ascii-art/
β”œβ”€β”€ cmd/ascii-art/main.go      # Entry point
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ ascii/                 # Core ASCII generation logic
β”‚   β”‚   β”œβ”€β”€ art.go            # ASCII art generation functions
β”‚   β”‚   β”œβ”€β”€ banner.go         # Banner file loading and parsing
β”‚   β”‚   β”œβ”€β”€ color.go          # Color support with ANSI codes
β”‚   β”‚   β”œβ”€β”€ art_test.go       # Unit tests for art generation
β”‚   β”‚   β”œβ”€β”€ banner_test.go    # Unit tests for banner loading
β”‚   β”‚   └── color_test.go     # Unit tests for color functionality
β”‚   └── version/
β”‚       └── version.go        # Version information
β”œβ”€β”€ assets/
β”‚   └── standard.txt          # Standard banner template (8 lines per character)
β”œβ”€β”€ docs/
β”‚   └── index.html           # GitHub Pages website with live demo
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml           # GitHub Actions CI/CD pipeline
β”œβ”€β”€ main_test.go             # Integration tests using exec.Command
β”œβ”€β”€ edge_cases_test.go       # Comprehensive edge case tests
β”œβ”€β”€ go.mod                   # Go module definition
β”œβ”€β”€ Makefile                 # Build automation (build, test, install)
β”œβ”€β”€ README.md                # Project documentation
β”œβ”€β”€ CHANGELOG.md             # Version history and changes
β”œβ”€β”€ CONTRIBUTING.md          # Contribution guidelines
└── LICENSE                  # MIT License

πŸ“– How It Works

  1. Input: Takes a string as command-line argument
  2. Terminal Detection: Automatically detects terminal width using system calls
  3. Processing: Maps each character to its 8-line ASCII representation
  4. Smart Wrapping: Calculates character widths and wraps when exceeding terminal width
  5. Output: Combines characters horizontally with automatic line breaks
  6. Format: Each character is exactly 8 lines tall
  7. Support: ASCII characters 32-126 (printable characters)
  8. Adaptive Width: Characters have variable widths, automatically handled

🀝 Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

This project follows Go best practices:

  • Standard Go formatting (go fmt)
  • Comprehensive unit tests (100% coverage)
  • Clean, readable code structure
  • Proper error handling
  • CI/CD with GitHub Actions

πŸ‘₯ Authors

  • Giorgos Laliotis
  • Stavros Gkraikas

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“‹ Changelog

See CHANGELOG.md for a detailed history of changes, new features, and bug fixes.

🌟 Links

πŸŽ“ Acknowledgments

This project is part of the Zone01 curriculum and is now open-source for the community.

About

Regular text into stylized ASCII art converter

Resources

License

Contributing

Stars

Watchers

Forks

Packages

No packages published