diff options
author | Thomas Touhey <thomas@touhey.fr> | 2019-05-10 13:06:26 +0200 |
---|---|---|
committer | Thomas Touhey <thomas@touhey.fr> | 2019-05-10 13:06:26 +0200 |
commit | eeca42ae43dd37e6835bb01e62070f103b331f27 (patch) | |
tree | 1d1a01aa89adf2fd1134f005b2553a14d95633ad /README.rst | |
parent | 14901ebf4da4e8c790d90d971216d867064cb25f (diff) |
Version 0.3 is out!0.3
Diffstat (limited to 'README.rst')
-rw-r--r-- | README.rst | 58 |
1 files changed, 54 insertions, 4 deletions
@@ -1,7 +1,57 @@ -thcolor -- switch between color formats -======================================= +thcolor -- the touhey color management module +============================================= -This module defines the ``Color`` primitive. For more information, read the -documentation accessible on `the official website`_. +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: + +.. code-block:: python + + 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: + +.. code-block:: python + + 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: + +.. code-block:: python + + 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: + +.. code-block:: python + + from thcolor import Color + + color = Color.from_text("gray(red( #123456 )/0.2/)") + for repres in color.css(): + print(f"color: {repres}") + +.. _Thomas Touhey: https://thomas.touhey.fr/ +.. _textoutpc: https://textout.touhey.pro/ .. _the official website: https://thcolor.touhey.pro/ |