Skip to main content

color management module

Project description

This module is a color management module made by Thomas Touhey (th is for touhey) for the textoutpc project, a BBCode to HTML translation module. It provides the following features:

  • color management and conversions between formats (RGB, HSL, HWB, NCol, …).
  • text-to-color using close-to-CSS format.

For more information, consult the official website.

Examples

Converting an RGB color to HSL:

from thcolor import Color

color = Color(Color.Type.RGB, 55, 23, 224)
print(color.hsl())

Converting a HSL color to RGB with an alpha value:

from thcolor import Color, Angle

alpha = 0.75
color = Color(Color.Type.HSL, Angle(Angle.Type.DEG, 180), 0.5, 1.0, alpha)
print(color.rgba())

Converting a textual representation to the RGBA color components:

from thcolor import Color

color = Color.from_text("darker(10%,  hsl(0, 1, 50.0%))")
print(color.rgba())

Getting the CSS color representations (with compatibility for earlier CSS versions) from a textual representation:

from thcolor import Color

color = Color.from_text("gray(red( #123456 )/0.2/)")
for repres in color.css():
        print(f"color: {repres}")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for thcolor, version 0.3.1
Filename, size File type Python version Upload date Hashes
Filename, size thcolor-0.3.1.tar.gz (18.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page