
Research
/Security News
Contagious Interview Campaign Escalates With 67 Malicious npm Packages and New Malware Loader
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Polychromy is a Python script to manipulate the colors of a text.
colorate
prints text of a specified colour in a specified colour background.show
prints out color details such as Hex and RGB values of a given colour in a square of the given colour.This script relies on the Python standard library, and the libraries requests
and textlinebreaker
.
pip install polychromy
from polychromy import colorate
or
from polychromy import show
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.
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.1
Here are some examples of how to use polychromy.
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()
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))
If you'd like to contribute to this project, please follow these steps:
This project is licensed under the MIT License - see the LICENSE file for details.
The output color might differ from the desired one depending on terminal used. ↩
FAQs
A module to print a strings in a given colour, with a given colour background
We found that polychromy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.
Security News
Meet Socket at Black Hat & DEF CON 2025 for 1:1s, insider security talks at Allegiant Stadium, and a private dinner with top minds in software supply chain security.
Security News
CAI is a new open source AI framework that automates penetration testing tasks like scanning and exploitation up to 3,600× faster than humans.