You are not logged in.

#1 2012-10-22 07:49:10

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

colorsysplus: Python 3 color conversion module

Project page: http://xyne.archlinux.ca/projects/python3-colorsysplus/

Over time I've written a lot of code to manage color conversions between different formats (hexadecimal, terminal, ANSI, CMYK, etc). Some of it has found its way into some of my projects (e.g. pychrom and tiv, both of which were written as afterthoughts from messing around with colors), but it's never really been directly accessible.

I finally got tired of cannibalizing my own code whenever I needed some conversion functions so I put everything in a single module and packaged it.

The source code is reasonably documented and relatively straight-forward, so it should be easy to use.

Anyone interested in this may also be interested in Lux Perpetua's script from which some of the code was adapted/cannibalized.

If you have any suggestions for additional functionality or ways that the existing code could be improved, let me know.

edit: screenshot
python3-colorsysplus_01.png

Last edited by Xyne (2012-10-22 07:50:07)

Offline

#2 2012-10-22 23:15:40

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: colorsysplus: Python 3 color conversion module

The package now contains a supplementary module for working with colorized text. It can convert to and from HTML, BBCode, ANSI, etc. and provides some functions for applying custom gradients and other fun stuff. This text was generated with the code. It could have just as easily been display in a compatible terminal.

Yes, I am aware that I appear to have too much time on my hands. In fact, the opposite is true. This is the result of procrastination and escapism.

But hey, look at the pretty colors! No, not the clock, the colors!

Offline

#3 2015-12-23 06:27:15

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: colorsysplus: Python 3 color conversion module

Shameless self-bump to say that I have moved the ANSI functions from python3-xcgf to python3-colorsysplus in case anyone needs some simple python functions for displaying colored terminal text with other common ANSI select graphics rendition options (bold, blink, negative).

Example:

#!/usr/bin/env python
from colorsysplus import ansi_sgr
s = ansi_sgr(fg='red', bold=True, blink=True) + \
    'BLINKING TERMINAL TEXT IS ANNOYING, ISN\'T IT?' + \
    ansi_sgr(reset=True)
print(s)

Offline

#4 2015-12-23 15:18:16

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 12,935

Re: colorsysplus: Python 3 color conversion module

I had forgotten about this Xyne.  Made my day big_smile


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Like you, I have no idea what you are doing, but I am pretty sure it is wrong...Jasonwryan
----
How to Ask Questions the Smart Way

Offline

#5 2015-12-23 21:52:26

Xyne
Moderator/TU
Registered: 2008-08-03
Posts: 5,688
Website

Re: colorsysplus: Python 3 color conversion module

big_smile

Added a command-line utility for piping fun:

pacman --color always -Ss colorsys | ctconv ansi bbcode

xyne-x86_64/python3-colorsysplus 2013-5 [installed: 2015.12-1]
    An extension of the standard colorsys module with support for CMYK, terminal colors, ANSI and more.

Offline

Board footer

Powered by FluxBB