Skip to main content

Unversal polymorph color class

Project description

UniversalColor

Simple lightweight polymorph color class for python 3.10+

Features

  • Can store colors with or without an alpha channel in RGB, HSL, and HSV formats.
  • Easily converts between formats, understands #HEX, CSS (rgb, hsl, color names), and LSL.

Install

pip install universalcolor

or

https://github.com/erfeatux/UniversalColor.git

Usage

from universalcolor import Color

Color(red=255, green=0, blue=0)
# Color(RGB(red=1.0, green=0.0, blue=0.0, alpha=None))

Color(hlsHue=360, hslSat=1.0, hslLight=0.5)
# Color(HSL(hue=0.0, sat=1.0, light=0.5, alpha=None))

Color(hlsHue=360, hslSat=1.0, hsvValue=1.0, alpha=0.5)
# Color(HSL(hue=0.0, sat=1.0, light=0.5, alpha=0.5))

Color('#ff0000')
# Color(RGB(red=1.0, green=0.0, blue=0.0, alpha=None))

Color('rgb(255, 0, 0)')
# Color(RGB(red=1.0, green=0.0, blue=0.0, alpha=None))

Color('hsla(360, 100%, 50%, 0.5)')
# Color(HSL(hue=1.0, sat=1.0, light=0.5, alpha=0.5))

Color('<1.0, 0.0, 0.0>', alpha = 1.0).asName()
# 'red'

Color(hslHue=360).asRGB()
# RGB(red=1.0, green=0.0, blue=0.0, alpha=None)

Color('red').asHSV()
#HSV(hue=0.0, sat=1.0, value=1.0, alpha=None)

Color('green').asHEX()
# '#008000'

Color('aqua').asCSSHSL()
# 'hsl(180, 100%, 50%)'

Color(hslHue=120).red
# 0

Color(hslHue=120).green
# 255

Color(hslHue=120).blue
# 0

Color(hslHue=120).hslHue
#120

Color(hslHue=120).hslSat
# 100

Color(hslHue=120).hslLight
# 50

Color(hslHue=120).hsvHue
# 120

Color(hslHue=120).hsvSat
# 100

Color(hslHue=120).hsvValue
# 100

Project details


Download files

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

Source Distribution

universalcolor-24.7.1.tar.gz (10.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

universalcolor-24.7.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file universalcolor-24.7.1.tar.gz.

File metadata

  • Download URL: universalcolor-24.7.1.tar.gz
  • Upload date:
  • Size: 10.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-15-generic

File hashes

Hashes for universalcolor-24.7.1.tar.gz
Algorithm Hash digest
SHA256 c6926173e9fa1a6752160175ccdd29accd9a57f0be23cf2f30de5c5fca8d4fbb
MD5 f323dd8852ee95e3908a5a470bfaedac
BLAKE2b-256 929be61f8489cbc26c562c51b0c97ffb7db2df33cb435d77e04e2f07657a1268

See more details on using hashes here.

File details

Details for the file universalcolor-24.7.1-py3-none-any.whl.

File metadata

  • Download URL: universalcolor-24.7.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-15-generic

File hashes

Hashes for universalcolor-24.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f9d01872bee3862c196cf70bc5176c9bc3c0db3ad96ed6771d8611ffd8e9f7e
MD5 da860238c47246488eed1fdb4f40e966
BLAKE2b-256 096c1011b9b561ab9dd22e704d7b08a0be683ec01c8fc855e86a6369d9eed6fc

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page