Find the nearest W3C/X11 named colors to a given color
Project description
Nearest Colours
Find the nearest W3C/X11 named colors to a given color.
This module, nearest_colour, provides two functions:
from typing import List, Literal, Union
from colour import Color
ColorSpace = Literal["hsv", "rgb", "yiq", "hls"]
def nearest_x11(color: Union[Color, str], n: int = 1, space: ColorSpace = "hls") -> List[Color]:
pass
def nearest_w3c(color: Union[Color, str], n: int = 1, space: ColorSpace = "hls") -> List[Color]:
pass
Each will return the n colors that are closest (Euclidean distance) to color in the specified color-space from either the set of W3C web colors or the set of Unix X11 colors.
Web colors are standardized by W3C, whereas Unix X11 colors are defined in the X11 source-code.
Note: these two sets of colors are almost entirely overlapping, but not completely.
Colors may be provided as either colour Color objects, or as W3C colors strings.
The default color-space for distance computation is HSL, which is perceptually uniform and therefore returns colors which are perceptually closer to the given color.
A list is always returned, even if n == 1, and the ordering is from most similar to least similar.
If you pass a large wnough integer (say, 256), you'll get the ranking for all colors in the respective set.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nearest-colour-1.0.0.tar.gz.
File metadata
- Download URL: nearest-colour-1.0.0.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.11.0-44-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46e7c1078968c4a890f877dd48b5cc8328a8ff9d3acf67360b8e53ba38b2007a
|
|
| MD5 |
bee63a9a45099c633f0ead20cefc7eff
|
|
| BLAKE2b-256 |
acb9d1a8954c4d96f0bfd8a6a753c2f5a029f2461f4d7b90bb2c94d1f3ac3159
|
File details
Details for the file nearest_colour-1.0.0-py3-none-any.whl.
File metadata
- Download URL: nearest_colour-1.0.0-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.9.7 Linux/5.11.0-44-generic
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1decafd407dd3f396a3560f1ca5bbc929dd4e900588b51e6124ed915168b3b0e
|
|
| MD5 |
0cc8ad24c8f350f273a2c92421166559
|
|
| BLAKE2b-256 |
1ad7ebd68cee3f4bd841bb610adc7b3acc04c3f7f4cd85bd09e0162d9e7128cc
|