Skip to main content

A simple module to handle colors

Project description


PyPI Build Status License: MIT

A simple module to handle colors

Only RGBA colors are supported at the moment.


You need Python>=3.6 to use Verna.

It can be installed from PyPI with pip using

pip install verna


Colors are represented using objects of class Color.

The color value is essentially stored as an integer as the integer attribute.

The following properties can be used to access the different color components.


where color is an instance of Color.

The different color components can be edited with one of the following values

  • a percentage in string form with a '%' at the end (eg: "20%")
  • an integer from 0 to 255 (eg: 0xff, 255)
  • a float from 0.0 to 1.0 (only for alpha property. eg: 0.4)

So, the following are valid:

color = Color(0x00ffff)
color.alpha = 0x80
color.alpha = "50%"
color.alpha = 0.5   # float values can be assigned
                    # only to alpha property = 0xff    # Same as = 255 = "100%" = 217 = "85%" = 0xf5 = "96%"

whereas the following will cause error:

color = Color(0x00ffff)
color.alpha = 0x1ff    # > 0xff
color.alpha = -1       # < 0.0
color.alpha = "120%"   # > 100%
color.alpha = "120"    # No '%' at end
color.alpha = 1.2      # > 1.0
color.alpha = True     # Invalid type: bool = 0.5        # float value accepted only for alpha

A Color object may be created in multiple ways.

By default, alpha value is 0.

From integer color code

For example, cyan (solid), which has color code 0x00ffff can be created like


which is same as

From color name

Color.from_name() can be used to create Color objects from a CSS3 color name.

For example, cyan can be created with

From RGBA values

Color.from_rgba() can be used to create an instance of Color from RGBA values.

Color.from_rgba(255, 255, 0)         # solid yellow
Color.from_rgba(255, 255, 0, 0.5)    # translucent yellow

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 verna, version 0.0.2
Filename, size File type Python version Upload date Hashes
Filename, size verna-0.0.2-py3-none-any.whl (6.4 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size verna-0.0.2.tar.gz (6.6 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