Skip to main content

A color library that supports RGB with swizzling and will support hex and hsv in the future

Project description

PandaColor

A lightweight and extensible Python color library.

PandaColor provides a unified interface for working with colors in multiple formats (RGB, Hex, HSV, HSL, etc.).
It supports GLSL-style swizzling, conversions between color spaces, and convenient utilities for manipulation such as lighten, darken, invert, grayscale, and saturation adjustments.


Features

  • RGB support with:
    • Initialization from ints, strings, or iterables
    • GLSL-style swizzling (color.rgb, color.rg, color.gbr, etc.)
  • Conversions between:
    • RGB ↔ Hex
    • RGB ↔ HSV
    • RGB ↔ HSL
  • Manipulation methods:
    • lighten, darken, invert, grayscale
    • saturate, desaturate, adjust_hue
  • Utilities:
    • to_tuple(), to_list(), to_dict()
    • CSS output (css_rgb(), css_rgba())
    • Normalized floats [0.0, 1.0]

Installation

Install from PyPI:

pip install pandacolor

Or install from source:

git clone https://github.com/ColinThePanda/pandacolor.git
cd pandacolor
pip install .

Usage

from pandacolor import RGB

# Initialize with ints
c1 = RGB(255, 128, 0)

# Initialize from iterable
c2 = RGB([0, 255, 128])

# Initialize from string
c3 = RGB("64, 128, 255")

# Swizzling
print(c1.r)      # 255
print(c1.g)      # 128
print(c1.rgb)    # (255, 128, 0)
print(c1.rg)     # (255, 128)

# Convert to Hex
print(c1.to_hex())  # Hex(#ff8000)

# Manipulation
lighter = c1.lighten(0.3)
darker = c1.darken(0.5)
inverted = c1.invert()

# CSS format
print(c1.css_rgb())       # rgb(255, 128, 0)
print(c1.css_rgba(0.5))   # rgba(255, 128, 0, 0.5)


Roadmap

  • Hex, HSV, HSL support
  • Auto generated color palletes
  • Added support for use with opengl and shaders

License

MIT © 2025 Colin Politi See LICENSE for details.

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

panda_color-0.1.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

panda_color-0.1.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file panda_color-0.1.1.tar.gz.

File metadata

  • Download URL: panda_color-0.1.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for panda_color-0.1.1.tar.gz
Algorithm Hash digest
SHA256 e5e7a6dcd21051d9a9dbbc535b88adc031d3def31676ce1925e6b0a18dc1113f
MD5 25d960eec7b758ec9165f09b39d47ac1
BLAKE2b-256 d7b0b9a010e5f3ea247916ac34a28652f3173585d78bee3e2ac5d66b6d35c2d1

See more details on using hashes here.

File details

Details for the file panda_color-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: panda_color-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 10.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.6

File hashes

Hashes for panda_color-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 81f0890daf2d3beb4bfe8c7f0d6fb4f1a7c9eb8404200447a317f8b242057305
MD5 2b8fb589b3e02a7d41f04288973b7cb4
BLAKE2b-256 f1b0b09b593e6389cf942f8d981e24310a73a85728137e8d0b4ac5e7a661bb0e

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