ColorHash is a lightweight Python library for generating deterministic colors from any object. By calculating a color value based on an object's hash, it ensures consistent results: the same input will always yield the same color. It is currently at version 2.3.0 and has an active development cycle, with recent updates focusing on performance and wider Python version compatibility.
pip install colorhashVerified import paths — ran on the pinned version, not inferred.
Initialize ColorHash with any object (typically a string) and retrieve its deterministic color in HSL, RGB, or hexadecimal format. You can also customize the lightness, saturation, or hue ranges during initialization to influence the generated colors.
Review the documentation for `ColorHash` constructor parameters (`lightness`, `saturation`, `min_h`, `max_h`) and ensure your inputs conform to the expected types and ranges.
Upgrade your Python environment to version 3.8 or newer to ensure full compatibility and support.
To maximize color variety for distinct inputs, use a wider range of values for `lightness` and `saturation` sequences (e.g., `[0.3, 0.5, 0.7]`) and/or broader `min_h`/`max_h` hue ranges.
Expand the sequences of `lightness` and `saturation` values (e.g., `lightness=[0.2, 0.4, 0.6, 0.8]`), or widen the `min_h`/`max_h` hue range to allow `ColorHash` more options to deterministically select a distinct color.
Use the correct attributes to retrieve the desired color format: `c.hex` for hexadecimal string, `c.rgb` for an RGB tuple, or `c.hsl` for an HSL tuple.
No dependency data recorded yet.