Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nearest-colour-1.0.0.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nearest_colour-1.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

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

Hashes for nearest-colour-1.0.0.tar.gz
Algorithm Hash digest
SHA256 46e7c1078968c4a890f877dd48b5cc8328a8ff9d3acf67360b8e53ba38b2007a
MD5 bee63a9a45099c633f0ead20cefc7eff
BLAKE2b-256 acb9d1a8954c4d96f0bfd8a6a753c2f5a029f2461f4d7b90bb2c94d1f3ac3159

See more details on using hashes here.

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

Hashes for nearest_colour-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1decafd407dd3f396a3560f1ca5bbc929dd4e900588b51e6124ed915168b3b0e
MD5 0cc8ad24c8f350f273a2c92421166559
BLAKE2b-256 1ad7ebd68cee3f4bd841bb610adc7b3acc04c3f7f4cd85bd09e0162d9e7128cc

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