Skip to main content

🎨 Named colors in Python 🎨

Project description

🎨 nc: Named colors in Python 🎨

--

The module nc collects named colors in Python.

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), or from custom color schemes created by the user.

There is also a collection of color swatches for the default color collection.

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

API Documentation

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-1.1.0.tar.gz (27.3 kB view details)

Uploaded Source

Built Distribution

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

nc-1.1.0-py3-none-any.whl (36.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nc-1.1.0.tar.gz
  • Upload date:
  • Size: 27.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nc-1.1.0.tar.gz
Algorithm Hash digest
SHA256 57c57064d0ec0fe23d5b44be380a9d747e8d22685719abaf4c968bfe4cd01a52
MD5 22d454d60a3232e91fad15738665b07d
BLAKE2b-256 13ac55726480736b5edca3ca84e45c2363f7afe44de09d833ad6959dd83ba974

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nc-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 36.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.28 {"installer":{"name":"uv","version":"0.9.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for nc-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 13a532a492c9f086e3fb34caf1d76e074f009401a5c1fef6131cf6e48d89d0f5
MD5 dbebba04f8e7ea8d8e22fca71c54a1b2
BLAKE2b-256 026e7f3f15a7c195866511f19f904be11ea58bd1a9dcf02be89625b0ee63ee72

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