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

Uploaded Source

File details

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

File metadata

  • Download URL: thcolor-0.3.tar.gz
  • Upload date:
  • Size: 18.1 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.tar.gz
Algorithm Hash digest
SHA256 e65dc86c256ccda94184f90abd8369021b3fb6a01ccfe657394fc4b41a889f12
MD5 5aa9cb09010baaa760d60928f34e6919
BLAKE2b-256 4f1ce437d319872484d2e55a13e23c8e6e2a8bfdf885f9309323c997485ed457

See more details on using hashes here.

Release history Release notifications | RSS feed

0.4

1 file

0.3.1

1 file

This release

0.3 This release

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