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.0.tar.gz (10.1 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.0-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: panda_color-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 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.0.tar.gz
Algorithm Hash digest
SHA256 bc536fd81b26ba31346d143d407452a2db67afa887bcc15bc12f77c67aa75817
MD5 a8ae01c66a5813d317bbd2ea7c324880
BLAKE2b-256 a9b6fbac6cc85f315787b09fa2b707df0acfc0a543c1d8916ceeb8c2e99dc8cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panda_color-0.1.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1277654e965a3624fad1ee1b481de92e50cc7a69832f287c2c1db19a01b27c87
MD5 b2f4053273a80daeba588a0d28b2d705
BLAKE2b-256 3940b00a41b95937902f7e9fcf72078deeae2e30739e814e547094e1a053c713

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