Skip to main content

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}")

Download files

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

Source Distribution

thcolor-0.3.1.tar.gz (18.3 kB view details)

Uploaded Source

File details

Details for the file thcolor-0.3.1.tar.gz.

File metadata

  • Download URL: thcolor-0.3.1.tar.gz
  • Upload date:
  • Size: 18.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.21.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.2

File hashes

Hashes for thcolor-0.3.1.tar.gz
Algorithm Hash digest
SHA256 a93a535f7f81b5e38460531b5731f0fa8c4b30b2a63d1fe763c2ac15e37df8b7
MD5 386803effb7c26941b6adf95f84d5403
BLAKE2b-256 769a62deb9c5fb4c1a27f79cc3cd5c7abe92d8d55cd0f99845945295075224ce

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4

1 file

This release

0.3.1 This release

1 file

0.3

1 file

0.2.2

1 file

0.2.1

1 file

0.2

1 file

0.1

1 file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page