Skip to main content

Generate a color based on a value

Project description

This module generates a color based on an object, by calculating a color value based on the object’s hash value (by default the result of Python’s built-in hash function). This means the result is deterministic: the same value will always result in the same color.

This module is a port of the ‘color-hash’ Javascript library. It supports Python 2.6, 2.7, and 3.3+.

Quick Start

>>> from colorhash import ColorHash
>>> c = ColorHash('Hello World')
>>> c.hsl
(227, 0.35, 0.65)
>>> c.rgb
(135, 148, 197)
>>> c.hex
'#8794c5'

Changelog

  • color-hash 1.0.0 (2016-07-07) - Initial port.

License

Copyright (c) 2016 Felix Krull <f_krull@gmx.de>

This is a port of the ‘color-hash’ Javascript library which is:

Copyright (c) 2015 Zeno Zeng

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

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

Source Distributions

colorhash-1.0.0.zip (8.9 kB view details)

Uploaded Source

colorhash-1.0.0.tar.bz2 (4.9 kB view details)

Uploaded Source

Built Distribution

colorhash-1.0.0-py2.py3-none-any.whl (5.6 kB view details)

Uploaded Python 2Python 3

File details

Details for the file colorhash-1.0.0.zip.

File metadata

  • Download URL: colorhash-1.0.0.zip
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for colorhash-1.0.0.zip
Algorithm Hash digest
SHA256 603aa373eb7685ade4333a93ef71aed72ba1297fd208086fdad813ecb177f367
MD5 c244dbc2200d43d9b53a607b2476593b
BLAKE2b-256 0c7b8da4ccff1d0894652d15841fa1b7ab57b5f98b2e3c0184be496a15bda522

See more details on using hashes here.

File details

Details for the file colorhash-1.0.0.tar.bz2.

File metadata

  • Download URL: colorhash-1.0.0.tar.bz2
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for colorhash-1.0.0.tar.bz2
Algorithm Hash digest
SHA256 137ba40fa1111e50550224b261d1a869b490a4eb198c251e0274ef05c90fbd50
MD5 3728ec91b36a27fd2405709bbe1a769c
BLAKE2b-256 6a12d03c4d77750193872430d72a10a283cad74083a1b817e968e096b251adaa

See more details on using hashes here.

File details

Details for the file colorhash-1.0.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for colorhash-1.0.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 f841c8942aa249f281941c883b32388024859efbb0bc98c77463fad82c2b9b87
MD5 1aa582ca923b4d8119abda73ed12ae86
BLAKE2b-256 4b245b78cdadc9bcb72b24b5365634f113ca244d0aabdd332fc626ceeec4a69c

See more details on using hashes here.

Supported by

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