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.2.1.tar.gz (10.6 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.2.1-py3-none-any.whl (12.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panda_color-0.1.2.1.tar.gz
  • Upload date:
  • Size: 10.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for panda_color-0.1.2.1.tar.gz
Algorithm Hash digest
SHA256 89b03518f7890f285720de027a1b1d0e7ac31d24d57f1358ad14cf1f9489f361
MD5 c1c552cd65980ae50d782acb69b569f7
BLAKE2b-256 e66d55cfe839b9d7fbce134d330f66c6dfb7f260616730de1b5e4f31bbc811ab

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panda_color-0.1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for panda_color-0.1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 237bfbba639b5a068b5707bb7c213dfcf158661c214125f51a89c2056cbfc072
MD5 9283f7688862f0180dbf3b98d30195d0
BLAKE2b-256 291966923b45c32824335959e6d0625c4b15794423927272085140b9e047acab

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