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

Uploaded Python 3

File details

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

File metadata

  • Download URL: panda_color-0.1.2.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.tar.gz
Algorithm Hash digest
SHA256 28c6e2f71024cd433f3ebd84f079553af795ff5b60c9a900a0f52d5584e0e1d0
MD5 08ac7ffed1171bdfe5d28616a3aba4b4
BLAKE2b-256 f9b40e3a520f4ddbc65b733cfc929dfbeb8344f342e45fcfafebcc2bc3b1621c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: panda_color-0.1.2-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-py3-none-any.whl
Algorithm Hash digest
SHA256 e48911d1764ee5ea8b367471f9260491e01d00e0c47596655f20406c4c765eb7
MD5 b5505656e78489d78b6a4232bbed9e8b
BLAKE2b-256 9110a957528e7efdce7a0acaaf1c3e17d99f4ab0063b49d6545016276cb9e35f

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