PitchHut logo
ASCII-Block
Transform text into stunning binary art with ease.
Pitch

ASCII-Block is a Python script that converts text into binary art using a customizable font. By rendering the text onto a Pillow canvas, this tool creates a character grid where each character represents the text or fills the background. Perfect for creating unique visual representations of text, with flexible options for output.

Description

ASCII-Block

ASCII-Block is a powerful Python script designed to transform text into stunning binary art using real fonts. Each character in the output represents a pixel drawn on a Pillow canvas, providing a unique aesthetic for textual representation.

Key Features

  • Customizable Output: Specify output dimensions, foreground and background characters, and even padding to shape the presentation.
  • Font Integration: Utilizes your system's TrueType or OpenType fonts, with support for auto-detection of common fonts like DejaVu Sans Bold and Helvetica.
  • ANSI Escape Codes: Enables colored terminal output through ANSI escape codes for both foreground and background characters.
  • Multiple Output Formats: Options to generate outputs as plain text or SVG, making it versatile for various applications.

Requirements

  • Python version 3.10 or higher
  • Pillow library installed via pip

Usage

To run the script, use the command:

python generate.py [options] [TEXT]

Where the default TEXT is set to CODE.

Options

ShortLongDefaultDescription
-w--widthterminal widthSpecify the output width in characters.
-h--heightwidth / 4Specify the output height in characters
-f--foreground0Characters used for the text pixels. Supports ANSI codes.
-b--background1Characters for the background pixels. Supports ANSI codes.
-p--padding0Padding in characters around the text.
-x--fontauto-detectProvide the path to a desired font file.
-o--outputstdoutSpecify where to write output (default is stdout).
--formattextChoose between text or svg output formats.
--fcolor#000000Foreground character color in SVG (hex code).
--bcolor#ccccccBackground character color in SVG (hex code).
--svg-background#ffffffSVG rectangle background color (hex code).
--helpDisplay a help message.

Example Scenarios

  • Basic Usage: Generate default output with:

    python generate.py
    
  • Custom Characters: Change text and background with:

    python generate.py -f '#' -b '.' HELLO
    
  • Coloured Output: Create red text on a grey background:

    python generate.py -f '\033[31m0\033[0m' -b '\033[90m1\033[0m'
    
  • SVG Generation: Output your art as an SVG file:

    python generate.py --format svg -o output.svg CODE
    

ASCII-Block brings a creative approach to turning text into art, leveraging Python's capabilities for users looking for unique visual expressions.

0 comments

No comments yet.

Sign in to be the first to comment.