Skip to main content

Named colors in Python

Project description

nc names color.

There are two ways to use nc.

The simple way is as an intuitive and forgiving interface to a collection of over 2000 named colors, put together from almost 20 color palettes scraped from the Internet.

In the simplest use, it’s a collection of about 1700 colors, some scraped from the Wikipedia (which includes some very strange colors), with a neat API.

For more precise use, color collections can be put together from schemes built into nc (currently html, juce, pwg, wikipedia, x11), and from custom color schemes created by the user.

Install nc from the command line using pip:

pip3 install nc

EXAMPLES:

import nc

for c in nc.red, nc.light_green, nc.DarkGrey, nc['PUCE']:
    print(c, '=', *c)

# Prints:
#   Red = 255 0 0
#   Light green = 144 238 144
#   Dark grey = 85 85 85
#   Puce = 204 136 153

# Colors have red, green, blue or r, g, b components
assert nc.yellow.red == nc.yellow.r == 0
assert nc.yellow.green == nc.yellow.g == 255
assert nc.yellow.blue == nc.yellow.b == 255

# Lots of ways to reach colors
assert nc.black == nc(0, 0, 0) == nc('0, 0, 0') == nc('(0, 0, 0)') == nc(0)

# ``nc`` looks like a dict
assert nc.red == nc['red'] == nc['RED']
for name, color in nc.items():
    print(name, '=', *color)

# Prints:
#   Absolute Zero = 0 72 186
#   Acid green = 176 191 26
#   Aero = 124 185 232
#   ... many more

# closest() function

from random import randrange
for i in range(8):
    c1 = randrange(256), randrange(256), randrange(256)
    c2 = nc.closest(c1)
    print(c1, 'is closest to', c2, *c2)

# Prints:
#   (193, 207, 185) is closest to Honeydew 3 = 193 205 193
#   (181, 162, 188) is closest to Lilac = 200 162 200
#   (122, 110, 250) is closest to Slate blue 1 = 131 111 255
#   (56, 218, 180) is closest to Turquoise = 64 224 208

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

nc-0.9.5.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

nc-0.9.5-py3-none-any.whl (35.8 kB view details)

Uploaded Python 3

File details

Details for the file nc-0.9.5.tar.gz.

File metadata

  • Download URL: nc-0.9.5.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.6

File hashes

Hashes for nc-0.9.5.tar.gz
Algorithm Hash digest
SHA256 1981bf03839d63e0f0b97d6a0e1fdd2589cfa80bbcc7a3b72cc7d900462dae96
MD5 ad2ccd3a50312bf0412f9f77917c5827
BLAKE2b-256 eb1f900b5523ec6b3c492285225cd5695550c96e3f8d34030aef93eb554655fa

See more details on using hashes here.

File details

Details for the file nc-0.9.5-py3-none-any.whl.

File metadata

  • Download URL: nc-0.9.5-py3-none-any.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.0 requests-toolbelt/0.9.1 tqdm/4.48.0 CPython/3.6.6

File hashes

Hashes for nc-0.9.5-py3-none-any.whl
Algorithm Hash digest
SHA256 070a3a9c1a9d32e92a6cd2904ab42acb61887eaef1c90c648ccbb13de410515d
MD5 86b2b09ec6ed9033d813c82ad2c945cc
BLAKE2b-256 601970b0b1fea10349be89a3d476ddddf06b596c8c2e848b3f11b5da21a836b1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page