Skip to main content

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 to use 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
  • Colors

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(surface: engine.Canvas) method that allows for easy drawing on a surface

Metadata

Release files for TermGFX 0.2.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 TermGFX 0.2.0
File Size Uploaded
TermGFX-0.2.0.tar.gz 9.5 kB Details

Built distribution (wheel)

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

Total release size: 19.1 kB

Release files / TermGFX-0.2.0.tar.gz

Download URL TermGFX-0.2.0.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
8e9b8fc5033e4809d8c776c55f4958a2922134a03681c9f4fc79ab9d84639198
BLAKE2b-256 checksum
How to use checksums
b7ef20189930807d74cf427328e5cf9d3397bd4840c769a63a83bc74131c619c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release files / TermGFX-0.2.0-py3-none-any.whl

Download URL TermGFX-0.2.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
457166717f70c809607bf22593d889ecfdda293a7ca9b483284ee04a26108a17
BLAKE2b-256 checksum
How to use checksums
1d477aac3347236faf8c8567efc26533f0664cbed2066d915c5a260683544d89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.0 CPython/3.10.4

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.0

2 release files

0.0.2

2 release files

0.0.1

2 release files

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