Skip to main content

Terminal graphics with zero deps

Project description

TermGFX

A yet another terminal graphics library written in Python.

Why tho?

The idea behind this project is to allow simple yet extensible graphics processing in the terminal. I'm a videogames enjoyer and I have used libraries such as PyGame, so it was an inspiration for me to write my own graphics lib. I decided using a terminal/TTY as canvas, because I spend a lot of time sitting at it as a Linux user. Moreover, it felt like something a bit more unique (even though there were a bunch of such project already, shh)

What it can

Draw

  • Dots
  • Lines

What's planned

  • Cirle shapes
  • Arbitrary shapes (with straight sides)

Installation

Prerequisites

In order to use the package, you need Python 3

  • Python (3.6+)* (Some examples use 3.10, though)

* If incorrect, please report (too lazy to figure out actual range of versions needed)

pip

You can use pip or pip3 to install TermGFX by executing

pip --user install termgfx

Note: you can omit --user, but it's not recommended (see [why][https://stackoverflow.com/questions/42988977/what-is-the-purpose-of-pip-install-user])

From source

The source code is located in <project root>/src/TermGFX/, so, in order to use it, you might just copy the file onto yout project directory, though it's not recommended (pip is a better option)

Usage

To get more information on project usage, you can view examples located in <project root>/examples/

Here's an overview: First, import the Canvas

from TermGFX.engine import Canvas

Then, create a Canvas instance

window_size = (20, 10)  # Size of the canvas

canvas = Canvas(window_size)  # Instantiate a canvas with the size of (20, 10)

Pixels

Now you can set "pixels" on the canvas

char = "O"  # A character to be displayed

canvas.set((0, 0), char)  # Set (0, 0) pixel to "O" 

And draw the canvas on the "screen"

canvas.draw()

Shapes

For all shapes, see shapes.py Example: Drawing a rectangle filled with "$" chars:

from TermGFX.engine import Canvas
from TermGFX.shapes import FilledRect

canvas = Canvas((20, 10))
rect = FilledRect((5, 2), "$")

rect.draw(canvas)
canvas.draw()

Tip: shapes usually have a draw method that allows for easy drawing on a surface

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

TermGFX-0.1.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

TermGFX-0.1.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file TermGFX-0.1.0.tar.gz.

File metadata

  • Download URL: TermGFX-0.1.0.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for TermGFX-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6c8716c948f2d84b3022e7ea225b97b40739c86aeae1f02b390d9af88cd3e109
MD5 4c6d21d8de90b0b76d2e33685e613c50
BLAKE2b-256 64e2027c09aa15692db39ecb52558f2e578869347452941042339603a28a16b6

See more details on using hashes here.

File details

Details for the file TermGFX-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: TermGFX-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.4

File hashes

Hashes for TermGFX-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 244f97cc820900ca86e8a45dee8a890b90c776755a1d3a80cb6df2192f0cc647
MD5 35fc9749d3650edde3fe48dcff34bafd
BLAKE2b-256 9b8fe5ea4950eee777be27a31d7f15acd0086a60327dc75beea3a2eb2aaf5e14

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