Skip to main content

Color palette is a python library for working with

Project description

Color palette is a python library for working with various color formats such as RGB and HEX. This project is currently under development, but you can already use this library to work with colors. So far, color_palette supports only HEX and RGB, but other formats will be added in the future.


PyPi - https://pypi.org/project/cpalette/
GitHub - https://github.com/chebupelka8/color_palette

Download

pip install cpalette

Wiki

HEX

HEX("ffffff") -> HEX(color="#FFFFFF")
HEX("#FFFFFF").to_rgb() -> (255, 255, 255)
HEX("#3e3d3d").color -> '#3E3D3D'
HEX("#xxx") -> ValueError: Wrong color at '#xxx'
HEX("#QQQQQQ") -> ValueError: Wrong color at '#QQQQQQ'

RGB

RGB(0, 0, 0) -> RGB(r=0, g=0, b=0)
RGB(255, 255, 255).to_hex(upper=True, hashtag=False) -> FFFFFF
RGB(30, 30, 30).color -> (30, 30, 30)
RGB(256, -2, 400) -> ValueError: Wrong color at (r=256, g=-2, b=400)
RGB(100, 100, 100) + RGB(30, 30, 30) -> RGB(r=65, g=65, b=65) # WARNING!!! Don't use this if you have more than 2 color

ColorConverter.mix_rgb(RGB(100, 100, 100), RGB(30, 30, 30), RGB(255, 255, 255)) -> RGB(r=128, g=128, b=128) # If you have more than 2 colors, use this.

Examples

Preview color

from color_palette import Previewer, RGB

Previewer.preview(RGB(30, 30, 30))

Convert colors

from color_palette import RGB, HEX, ColorConverter

print(ColorConverter.hex_to_rgb(HEX("#dd33bd"))) # RGB(r=221, g=51, b=189)
print(ColorConverter.rgb_to_hex(RGB(156, 48, 39))) # HEX(color=#9C3027)

Mix colors

from color_palette import RGB, ColorConverter

print(ColorConverter.mix_rgb(RGB(100, 100, 100), RGB(255, 55, 88), RGB(79, 23, 54))) # RGB(r=144, g=59, b=80)

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

cpalette-1.0.4.tar.gz (5.0 kB view details)

Uploaded Source

File details

Details for the file cpalette-1.0.4.tar.gz.

File metadata

  • Download URL: cpalette-1.0.4.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.12.0rc1

File hashes

Hashes for cpalette-1.0.4.tar.gz
Algorithm Hash digest
SHA256 1791d19e518127138638afe053fd0dd850c92e7160dc9d61c434a947a0e5c386
MD5 b370f1b85beccaaa17bd68097f31fe6e
BLAKE2b-256 a28b3cc4cbe5197e9e9b97be58400a0e5b37c9041bd0ec430b789c7f9775be95

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