Skip to main content

ArtSI

ArtSI is a python module for drawing in the terminal using ansi escape codes.

Installation:

pip install artsi or uv add artsi

Getting Started:

ANSI escape codes are special characters that many terminal emulators support which change things like the position of the cursor and the color being drawn.

ArtSI abstracts the actual codes away when using the Canvas class. when drawing with ArtSI is the Canvas class. You can set it's background color and draw rectangles on it.

# Rectangle Drawing
from artsi import Canvas

Canvas.clear()
Canvas.set_background_color("blue")
Canvas.draw_rectangle(1, 1, 3, 4, "white")
Canvas.show(home_=False)

rect-image

Coordinates are (x, y) and the origin (0, 0) is located at the top left of the Canvas.

Animations

With a bit of creativity and a loop you can also make animations with ArtSI.
A bouncing rectangle animation is included which also counts how often the rectangle hits a corner as it runs.

# ArtSI hello world
from artsi import Canvas

Canvas.hello_canvas()

hello_canvas-gif

Games

It is also possible to make games with ArtSI as your display framework. I've made a few games like pong and snake this way using pynput to handle keyboard input.

pong-ss

Drawing

Currently rectangles are the only thing you can draw. It is of course possible to make other shapes by layering these on top of each other but that is left as an exercise for the reader.

Supported Colors

ArtSI currently uses the most basic 8-16 color terminal codes. These are defined by your terminal but the names are: black, red, green, yellow, blue, magenta, cyan, white, default.

API Reference

Color Codes

Colors.get_code(color_: str, bg_: bool = True) -> str
"""given the name of a color, returns it's escape code"""

Special Characters

Special.reset() -> str
"""returns the reset escape code"""

Special.home() -> str
"""returns the home escape code"""

Special.clear() -> str
"""returns the clear escape code"""

Canvas

Canvas.clear() -> None
"""clears the terminal and homes the cursor"""

Canvas.reset() -> None
"""resets the internal data of the Canvas"""

Canvas.set_background_color(color_: str) -> None
"""changes the background color of the Canvas given the name of a color"""

Canvas.get_shape() -> tuple[int, int]
"""returns the current width and height of the Canvas"""

Canvas.get_width() -> int
"""returns the current width of the Canvas"""

Canvas.get_height() -> int
"""returns the current height of the Canvas"""

Canvas.set_width(new_width_: int) -> None
"""sets the width of the Canvas"""

Canvas.set_height(new_height_: int) -> None
"""sets the height of the Canvas"""

Canvas.draw_rectangle(x_: float, y_: float, width_: int, height_: int, color_: str = "red") -> None
"""marks the cells of the Canvas's buffer with the given color at the given rectangle area"""

Canvas.show(home_: bool = True) -> None
"""converts the Canvas's buffer into a printable string and displays it in the terminal"""

Canvas.hello_canvas() -> None
"""runs the demo bouncing box animation"""

Contribution:

If you would like to see features added feel free to fork the repo or reach out over email.

Metadata

Release files for artsi 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for artsi 1.0.0
File Size Uploaded Provenance
artsi-1.0.0.tar.gz 1.6 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for artsi 1.0.0
File Interpreter ABI Platform
artsi-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 1.6 MB

Release files / artsi-1.0.0.tar.gz

Download URL artsi-1.0.0.tar.gz
Size 1.6 MB
Tags Source
SHA-256 checksum
How to use checksums
576b036359b03eb17ab3498aa2a5465a0c23584f35f5333e3496b4e81ed26dad
BLAKE2b-256 checksum
How to use checksums
543156760903d27ad595cbd2f7b0b6fd32cdf4c713fa2e03b1ea0a85de7be9f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Release files / artsi-1.0.0-py3-none-any.whl

Download URL artsi-1.0.0-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b1eedb486b93984f28fd52ff0ddf6426acc9b38626d13afc427ddc4037fde744
BLAKE2b-256 checksum
How to use checksums
dd15c7becd3ab4eee53e5bb93e3629cadd2afabe5de7e860f9de43069b28f7db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.6

Security for artsi 1.0.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page