A module to print a strings in a given colour, with a given colour background
Project description
Polychromy
Description
Polychromy is a Python script to manipulate the colors of a text.
Features
- Function
colorate
prints text of a specified colour in a specified colour background. - Function
show
prints out color details such as Hex and RGB values of a given colour in a square of the given colour.
Latest Version 1.1.0
Table of Contents
Getting Started
Prerequisites
This script relies on the Python standard library, and the libraries requests
and textlinebreaker
.
Installation
- Install the package with pip
pip install polychromy
- Import the selected package in your program
from polychromy import colorate
or
from polychromy import show
Usage
Calling the function show
your program will print a square of the selected color with details about it.
Calling the function colorate
inside your program will return a printable string of the desired color.
Parameters
The function accept most color names, RGB values [0-255];[0-255];[0-255]
, Hex values #[00-FF][00-FF][00-FF]
, xterm color number in the format x[0-255]
, and ANSI codes.[^Note]
[^Note]: The output color might differ from the desired one depending on terminal used.
Examples
Here are some examples of how to use polychromy.
Show
Using the function show
you can print out color details such as Hex and RGB values of a given colour in a square of the given colour.
import sys
from polychromy import show
# If you run this program without any argument it asks you for a color and prints it out to the screen.
if len(sys.argv) == 1:
color_in = input("Enter a colour: ")
show(color_in)
# Giving a color as argument it prints it out directly to the screen
# Accepted values are: Name colors, HEX and RGB values.
else:
show()
Output 1
Colorate
Using the function colorate
you can print text of a specified colour in a specified colour background.
from polychromy import colorate
# Texts to print
text1 = "There are only 10 kinds of people in this world:"
text2 = "Those who know binary and Those who don't."
# Foreground (text) coors
foreground_1 = "#F5F5F5"
foreground_2 = 90
# Background colors
background_1 = "0;128;128"
background_2 = "Cosmic Latte"
print(colorate(text1,foreground_1,background_1))
print(colorate(text2,foreground_2,background_2))
Output 2
Contributing
If you'd like to contribute to this project, please follow these steps:
- Fork the repository on GitHub.
- Clone the fork to your local machine.
- Create a new branch for your feature or bug fix.
- Make your changes and commit them.
- Push the changes to your fork on GitHub.
- Create a pull request to the original repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
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
Built Distribution
File details
Details for the file polychromy-1.1.0.tar.gz
.
File metadata
- Download URL: polychromy-1.1.0.tar.gz
- Upload date:
- Size: 16.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 122c45fd6a758f6d418ee581330366616d8cdfbfec5b52b902d6770a1b5aaf58 |
|
MD5 | f1e0ef58945b96cb783e0bdb33e9a01a |
|
BLAKE2b-256 | 682c0b5da5b733c0e376b9c55ded00428071cf62f14e49fb421ea65318d9111e |
File details
Details for the file polychromy-1.1.0-py3-none-any.whl
.
File metadata
- Download URL: polychromy-1.1.0-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1592d157f9ccddbf622bccabc768139e6f791a01d94c6ccb22d6bd0d4b5b967 |
|
MD5 | 0278dda8491e3f87c2bac94c939f937a |
|
BLAKE2b-256 | 5b37ab22b1eed146a47238e3aa5f13f3d14657e8e2a94b981eb42a7cb72a0253 |