Skip to main content

A Python library for enhanced terminal display.

Project description

cobra-color

Build PyPI version Python Versions License Pull Requests Welcome Github stars

About

A lightweight Python library for enhanced terminal display: simple text color/style conventions and image-to-terminal rendering.

  • Python: 3.9+
  • Runtime deps: Pillow (>=9,<11), NumPy (>=1.21,<2)

Features

  • :rocket: Concise color/style names for terminal text.
  • :rocket: Image rendering in multiple modes: ASCII, color, half-color, gray, half-gray.
  • :rocket: Minimal dependencies and easy integration.

Installation

Stable (once published):

pip install cobra-color

Quick Start

  • Render a text in the terminal:

    from cobra_color import ctext
    
    print(ctext("Hello World!", fg="r", styles=["bold"]))
    
  • Render an image in the terminal:

    from cobra_color.draw import fmt_image
    
    # ASCII art
    print(fmt_image("example.jpg", width=80, mode="ascii"))
    
    # Half-block color (recommended for truecolor terminals)
    print(fmt_image("example.jpg", width=80, mode="half-color"))
    
  • Render some text with fonts in the terminal:

    from cobra_color.draw import fmt_font, FontName
    
    # Borderless grayscale font
    print(fmt_font("Hello World!", font=FontName.LLDISCO,, mode="half-gray", trim_border=True))
    

Image Modes

  • ascii: monochrome ASCII using a density charset.
  • color: colorized character fill.
  • half-color: half-block characters with color (higher density, good visual quality).
  • gray: grayscale characters.
  • half-gray: half-block grayscale.

Tip: For best results, use a TrueColor-capable terminal and a monospaced font.

Requirements

  • Python >= 3.9
  • Pillow >= 9.0, < 11
  • NumPy >= 1.21, < 2.0

License

See LICENSE in the repository.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cobra_color-0.2.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cobra_color-0.2.0-py3-none-any.whl (15.0 kB view details)

Uploaded Python 3

File details

Details for the file cobra_color-0.2.0.tar.gz.

File metadata

  • Download URL: cobra_color-0.2.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for cobra_color-0.2.0.tar.gz
Algorithm Hash digest
SHA256 101f82f1abec8e90c3f9a9f04ebca7a679db7462305a908ac0f0e278857b59c8
MD5 c9819f651af30bfccfe99d09a87bf501
BLAKE2b-256 983d869e6b8f598e95ea6c29f8173a7edae4fc41d614a8040eff51f475247f9a

See more details on using hashes here.

File details

Details for the file cobra_color-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cobra_color-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for cobra_color-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9b26d75fd5cfc5afa593a70236e22a7920de013da508b8bbd413924b2648711d
MD5 58188ec2411cd5830aa7cd89e474eb2d
BLAKE2b-256 df7f033c2bf2de94639f6371133468370ddf026d4b7323762069c3dec68a67eb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page