Skip to main content

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


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.1.tar.gz (7.8 kB view details)

Uploaded Source

File details

Details for the file terminalpainter-1.0.1.tar.gz.

File metadata

  • Download URL: terminalpainter-1.0.1.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.1

File hashes

Hashes for terminalpainter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 33ac5726ad101f8dbf728759cf5d3b38d89f60463b99992023d3703f2e80ec58
MD5 ac77b100f59f0e4168efd97998ca1297
BLAKE2b-256 23d492e9844d4879f8da9adfe6479f82097cd2049e710abfb0d85537c4a9537f

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