Skip to main content

🎨 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

Metadata

Release files for nc 1.2.0

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

Source distribution (sdist)

Source distribution for nc 1.2.0
File Size Uploaded
nc-1.2.0.tar.gz 733.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for nc 1.2.0
File Interpreter ABI Platform
nc-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 769.9 kB

Release files / nc-1.2.0.tar.gz

Download URL nc-1.2.0.tar.gz
Size 733.4 kB
Tags Source
SHA-256 checksum
How to use checksums
4f07647e5096b81fc4dab1e79fe69c690a202205f1882b574cf3e5bf3e2bed6d
BLAKE2b-256 checksum
How to use checksums
1cab6fb8117b3a5d469d8ef5942cef9eccc2094a54f93b3f97cfdbd7f00de341
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}

Release files / nc-1.2.0-py3-none-any.whl

Download URL nc-1.2.0-py3-none-any.whl
Size 36.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3de6f8e65370a0d4e533df5243764cae1285295146b4baec1cef515130f25bdf
BLAKE2b-256 checksum
How to use checksums
834faa83ae1eab79055b43936e49d40e380801c6762a8a347cb34a6d2ed877a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","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}

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.0

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.9.5

2 release files

0.9.4

2 release files

0.9.3

2 release files

0.9.2

1 release file

0.9.1

1 release file

0.9.0

1 release file

0.8.3

1 release file

0.8.2

1 release file

0.8.1

1 release file

0.8.0

1 release file

0.0.8

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