Skip to main content
File added late

1 file was added to this release more than 14 days after its initial publication. Inspect the release files before installing.

Authors:

Mike Spindel

Version:
0.2

Palette makes it easy to perform simple operations on colors and to convert between different color systems and representations.

Sample Usage

Initialize a color object using whatever representation is convenient:

>>> c = Color("#0a0bcc")
>>> c = Color.from_rgb(255, 255, 255, a=0.5)
>>> c = Color(hls=(0.2, 0.1, 0.1))

Manipulate colors:

>>> a = Color("#aaaa00")
>>> a.lighter()
>>> a.darker(amt=0.4)

Measure Colors:

>>> a = Color("#aaaa00")
>>> b = Color("#000000")
>>> a.w3_contrast_ratio(b)
>>> a.w3_contrast_test(b)
>>> a.luminance

Convert Representations:

>>> a = Color("#aaaa00")
>>> a.rgb8.r
170
>>> a.rgb8.r = 30
>>> tuple(a.rgb8)
(30.0, 170.0, 0.0)
>>> tuple(a.hls)
(0.30392156862745096, 0.3333333333333333, 1.0)
>>> str(a.hls)
'hls(0.30392156862745096, 0.3333333333333333, 1.0)'
>>> a.hex
'#1eaa00'
>>> a.css
'rgb(170, 170, 0)'

Convert sRGB:

>>> a = Color("#aaaa00")
>>> a.workspace
"srgb"
>>> a.rgb == a.srgb
True
>>> a.linear_rgb
{'r': 0.4019777798321958, 'b': 0.0, 'g': 0.4019777798321958}
>>> a.linear_rgb = (.2, .3, .3)
>>> a.rgb
(0.48452920448170694, 0.5838314900602575, 0.5838314900602575)

Where Does Palette Fit In?

There already exist several good python libraries for manipulating color. Perhaps the two most notable are Grapefruit and python-colormath. Palette hopes to fill a niche somewhere between the two.

With respect to grapefruit, palette intends to have:

  • a simpler interface for common tasks

  • more sophistication with respect to RGB working spaces, illuminants, etc.

  • PEP-8 compliance

With respect to python-colormath, palette intends to have:

  • a simpler interface for common tasks; potentially at the expense of deep support for non-RGB colors.

  • more utilities that are primarily useful for web development

  • support for fewer colorspaces. Palette isn’t particularly interested in completionism.

  • no dependency on numpy

Release files for palette 0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

File added late

1 file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release files before installing.

Source distribution (sdist)

Source distribution for palette 0.2
File Size Uploaded
palette-0.2.tar.gz 5.6 kB Details

Release files / palette-0.2.tar.gz

File added late

This file was uploaded more than 14 days after the first file in this release.

While project maintainers occasionally add legitimate files to an existing release, late additions can also indicate a security compromise.

We recommend inspecting the release file before installing.

Download URL palette-0.2.tar.gz
Size 5.6 kB
Tags Source
SHA-256 checksum
How to use checksums
82e28a008b686594b6dd9ee9d6d7d9e7c81ded224b5acccc74a799abc72cf10f
BLAKE2b-256 checksum
How to use checksums
e82ffd242288bcc7d98c829b61b3a281e8562d3bc14c409bae87e1d1cbb32b87
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2 This release

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page