A simple module to handle colors
Project description
Verna
A simple module to handle colors
Only RGBA colors are supported at the moment.
Installation
You need Python>=3.6 to use Verna.
It can be installed from PyPI with pip using
pip install verna
Usage
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.
color.alpha
color.red
color.green
color.blue
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
color.red = 0xff # Same as color.red = 255
color.red = "100%"
color.green = 217
color.green = "85%"
color.blue = 0xf5
color.blue = "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
color.red = 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
Color(0x00ffff)
which is same as
Color(65535)
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
Color.from_name('cyan')
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file verna-0.0.2.tar.gz
.
File metadata
- Download URL: verna-0.0.2.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 81e420c82dce2316a70d7547f2e8f935fb60332a1836f2462ff67fcfef537651 |
|
MD5 | 86f15cc0901e31dfdc74335db4c622cc |
|
BLAKE2b-256 | 3bd5ada42226920dd0f0ef758b18a52c81e496a49477748d73f24b3a987d61da |
File details
Details for the file verna-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: verna-0.0.2-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d6b13c70aac865529587f7625ad10dd96fda92a67b9dea7b49ca0a8b8efcc0b |
|
MD5 | 6a9654adf751807a4fbf9af2b04108ae |
|
BLAKE2b-256 | 18d78c3634b7c477576c3d07881dac9649f4a51fe33798ca56684d4be3fc011d |