Terminal painter
Project description
TerminalPainter
A Python library for drawing on the terminal.
Installation
To install the library, run the following command:
pip install terminalpainter
Usage
Main Functions
- Painter: The main class for drawing on the terminal.
- Canvas: A class for creating and managing a canvas.
- Colors: A class for working with colors.
Examples
Drawing Text
from terminalpainter import Painter
canvas = Canvas((10, 10))
painter = Painter()
painter.paint_text("Hello, World!")
canvas.paint()
Drawing Shapes
from terminalpainter import Canvas, Colors
canvas = Canvas((10, 10))
canvas.draw_rectangle((1, 1), (8, 8), Colors.RED)
canvas.draw_circle((5, 5), 3, Colors.BLUE)
canvas.paint()
Working with Colors
from terminalpainter import Painter, Canvas, Colors, ColorBlendMode
import os
color_red = Colors.to_rgba(Colors.RED, 128)
color_green = Colors.to_rgba(Colors.GREEN, 128)
color_blue = Colors.to_rgba(Colors.BLUE, 128)
os.system('cls' if os.name == 'nt' else 'clear')
canvas = Canvas((36, 36))
canvas.blend_mode = ColorBlendMode.ADD
painter = Painter()
painter.paint_circle(canvas, 17, 10, 10, color_red)
painter.paint_circle(canvas, 10, 24, 10, color_green)
painter.paint_circle(canvas, 24, 24, 10, color_blue)
canvas.paint()
Documentation
Painter:
paint_rectangle: Draws a rectangle on the canvas.paint_circle: Draws a circle on the canvas.paint_text: Draws text on the canvas.paint_image: Draws an image on the canvas.paint_line: Draws a line on the canvas.paint_pieslice: Draws a pie slice on the canvas.fill: Fills the canvas with a color.
Canvas:
blend_mode: The blend mode to use when blending colors.resize: Resizes the canvas.paint: Paints the canvas to the terminal.clear: Clears the canvas.set_pixel: Sets a pixel on the canvas.set_char: Sets a character on the canvas.get_pixel: Gets a pixel from the canvas.
Colors:
to_rgb: Converts a color to RGB format.to_rgba: Converts a color to RGBA format.blend: Blends two colors together.
ColorBlendMode:
ADD: Adds two colors together.MIX: Mixes two colors together.SUB: Subtracts two colors.MAX: Takes the maximum of two colors.MIN: Takes the minimum of two colors.
Authors
professionsalincpp
License
The library is distributed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
terminalpainter-1.0.0.tar.gz
(7.7 kB
view details)
File details
Details for the file terminalpainter-1.0.0.tar.gz.
File metadata
- Download URL: terminalpainter-1.0.0.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fbf9a03fc5a473e08dc71c4fb4980e6e30d5ecdabacc9640c5b8750e72722d2d
|
|
| MD5 |
ce3178ee0d813522ecd600df77d0398e
|
|
| BLAKE2b-256 |
1e5f4983417e63101b6237c8036bfa51575aca7c3f0726a187c92e1e3343e24b
|