2024-05-17 22:37 UTC
  • Xyne


Description: An extension of the standard colorsys module with support for CMYK, terminal colors, ANSI and more.
Latest Version: 2021.11
Source Code: src/
  • any
  • python3
Build Dependencies:
  • python-setuptools
Arch Repositories:
  • [xyne-any]
  • [xyne-i686]
  • [xyne-x86_64]
AUR Page: python3-colorsysplus
Arch Forum Thread: 151196


Colorsysplus is a extension of the standard colorsys module. It provides RGB conversion functions for

  • hexadecimal color codes
  • CMYK
  • terminal and ANSI colors (ANSI to RGB is incomplete)
  • Xonotic color codes
  • visible wavelengths (only wavelength to RGB is supported)

The module is a receptacle for color conversion functions that I frequently found myself copying or rewriting. I will continue to add to it and improve it. If you have suggestions of what to include, please let me know.


The source code is reasonably documented and straight-forward. The default main routine provides a simple example of converting HSV values to the nearest ANSI escape codes.

Additional Modules


The package also includes the ColorizedText module that provides a class of the same name for working with colorized text. Text is stored as a list of chunks with associated RGB values that can be easily manipulated in an output-agnostic way.

The class includes methods for converting to and from the following formats:

  • HTML
  • BBCode
  • ANSI1
  • Xonotic

It also includes some convenience functions for applying gradients of different types.



A command line pipe converter that can convert colorized text between different types. This can be useful for posting colorized command-line output online, for example. See the help message below.


The code for retrieving RGB values for ANSI escape codes in the running terminal was adapted from code posted by Lux Perpetua on the Arch Linux forum


The example output of the module when run as a script.




  • Fix pylint warnings.
  • Update copyright headers.
  • Remove function vector_distance_squared.
  • Removed redundant encoding comments.
  • Completely changed formatter classes (not backwards-compatible).

The previous formatter classes were hacks that used placeholder fields to insert colors at arbitrary points in the format and template strings. The new classes instead add a custom color specification to the different format specifications as the color is an aspect of each field’s formatting.


  • Converted to PEP8 formatting and fixed most warnings.
  • Added module to support colors in format, percent-style and template strings: colorsysplus.format.
  • Restructured modules in package: ColorizedText -> colorsysplus.text, ColorizedLog -> colorsysplus.Log.


  • Added colorlog module with code from pacboy project. The configure_logging function can be used to colorize the output of the standard logging module.


  • Merged ANSI functions from XCGF module.
  • Reworked ANSI SGR parsing.
  • Simplified color projection code for standard 256 terminal colors.
  • Changed terminal and ANSI color functions.
  • Added rgb_to_ansi and ansi_to_rgb.
  • Miscellaneous other changes (sorry).
  • Added ctconv.


  • Added ColorizedText module.
echo | sed 's/\./@/'
XHTML 1.0 Strict CSS level 3 Atom 1.0