Skip to main content

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

Reason this release was yanked:

Критическая ошибка

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.4.0.tar.gz (3.4 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.4.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ripix-2.4.0.tar.gz
  • Upload date:
  • Size: 3.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ripix-2.4.0.tar.gz
Algorithm Hash digest
SHA256 d7e5fb52f60eb90ed454c48265ce602e2a586b65face9207b75c4d9aeb5fe7ea
MD5 9f150e0916359f90e9cd6d2b3d61165a
BLAKE2b-256 7de21a74f41e2cef4cafe712ef547f71a58bed08e5cc2c3324060293913ad7db

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ripix-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.13

File hashes

Hashes for ripix-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5dcbb448f22bdfc3ad737886a9d2b25c4e0aa388ff008b32f230c6b6a29f03f3
MD5 83463976de90bcb5467832fd78df98d5
BLAKE2b-256 9c3b6919f1983a3dfcba8630b1768356c83b7188b86665fa5da4ec2503a0af13

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