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 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
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file TermGFX-0.2.0.tar.gz.
File metadata
- Download URL: TermGFX-0.2.0.tar.gz
- Upload date:
- Size: 9.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e9b8fc5033e4809d8c776c55f4958a2922134a03681c9f4fc79ab9d84639198
|
|
| MD5 |
40b61dbb9bef1e12365a917578fd6e8b
|
|
| BLAKE2b-256 |
b7ef20189930807d74cf427328e5cf9d3397bd4840c769a63a83bc74131c619c
|
File details
Details for the file TermGFX-0.2.0-py3-none-any.whl.
File metadata
- Download URL: TermGFX-0.2.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
457166717f70c809607bf22593d889ecfdda293a7ca9b483284ee04a26108a17
|
|
| MD5 |
084c9611e7e74c6dc630177f24610da6
|
|
| BLAKE2b-256 |
1d477aac3347236faf8c8567efc26533f0664cbed2066d915c5a260683544d89
|