Skip to main content
Help the Python Software Foundation raise $60,000 USD by December 31st!  Building the PSF Q4 Fundraiser

A short description for your project.

Project description

The :mod:`colortools` defines a :cls:`Color` object that can be used to
represent and manipulate colors in various contexts. It was created with the
:mod:`FGAme` game engine, but it can also be used in other contexts such as
arts and web applications.

Colors can be initialized from the RGB/RGBA components, in which each component
is in the 0-255 range.

>>> w1 = Color(255, 255, 255)
>>> w2 = Color(255, 255, 255, 255)
>>> w1 == w2

The constructor also accepts color names, hex strings or hex numbers.

>>> Color('white') == Color('#FFF') == Color(0xffffff) == Color(255, 255, 255)

All names in CSS3.0 are accepted (see the complete list `here<>`).
It is worth noting that although the *G* in RGB stands for green, the color
with a full green value is called *lime*, while "green" is **#008000** rather than

Usage and API

Color objects are immutable and behave like a tuple of 4 values.

>>> list(Color('green'))
[0, 80, 0, 255]

It also exposes several different representations of a color using the
appropriate attribute.

>>> blue = Color('blue')
>>> blue.rbg
(255, 0, 0)

>>> blue.rgbf
(1.0, 0.0, 0.0)

>>> blue.rgbu

Color objects also implement a few useful transformations

>>> blue.darken(0.1) # darken by 10%
Color(229, 0, 0)

Project details

Download files

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

Files for colortools, version 0.1.2
Filename, size File type Python version Upload date Hashes
Filename, size colortools-0.1.2.tar.gz (7.7 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page