Skip to main content

A Rich-compatible library for writing pixel images and ASCII art to the terminal.

Project description

Ripix

A Rich-compatible library for writing pixel images and other colourful grids to the terminal.

Installation

Get ripix from PyPI.

pip install ripix

Basic Usage

Images

Image from a file

You can load an image file from a path using from_image_path:

from ripix import Pixels
from rich.console import Console

console = Console()
pixels = Pixels.from_image_path("pokemon/bulbasaur.png")
console.print(pixels)

Pillow image object

You can create a PIL image object yourself and pass it in to from_image.

from ripix import Pixels
from rich.console import Console
from PIL import Image

console = Console()

with Image.open("path/to/image.png") as image:
    pixels = Pixels.from_image(image)

console.print(pixels)

Using this approach means you can modify your PIL Image beforehard.

ASCII Art

You can quickly build shapes using a tool like asciiflow, and apply styles the ASCII characters. This provides a quick way of sketching out shapes.

from ripix import Pixels
from rich.console import Console

console = Console()

# Draw your shapes using any character you want
grid = """\
     xx   xx
     ox   ox
     Ox   Ox
xx             xx
xxxxxxxxxxxxxxxxx
"""

# Map characters to different characters/styles
mapping = {
    "x": Segment(" ", Style.parse("yellow on yellow")),
    "o": Segment(" ", Style.parse("on white")),
    "O": Segment(" ", Style.parse("on blue")),
}

pixels = Pixels.from_ascii(grid, mapping)
console.print(pixels)

Using with Textual

Pixels can be integrated into Textual applications just like any other Rich renderable.

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

ripix-2.2.0.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

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

ripix-2.2.0-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file ripix-2.2.0.tar.gz.

File metadata

  • Download URL: ripix-2.2.0.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.9

File hashes

Hashes for ripix-2.2.0.tar.gz
Algorithm Hash digest
SHA256 0af8e16f037377813d31ee19a038bc6251f7ec019aa2aec1d4d84a0b4d2ec57d
MD5 7a2c40a36a1225104531ef576bc58d96
BLAKE2b-256 b50fb72edaa5d7384f888a4b50e66f3f3db4fbebc4101bc8f336c072503c0ded

See more details on using hashes here.

File details

Details for the file ripix-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: ripix-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.9

File hashes

Hashes for ripix-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5dc4360b81c05ede1324c052eda3559278030bcb7252f6229281154900bb1dc8
MD5 a4554f1c0ddbe31a1d9881df55c3a47d
BLAKE2b-256 6d890190e725b2ae06f51fe6c2861d3a4683a9a7c3c0494258e147813b00a625

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