{"id":5958,"library":"hsluv","title":"HSLuv: Human-friendly HSL Color Space","description":"HSLuv is a Python implementation of a human-friendly HSL (Hue, Saturation, Lightness) color space, which is an alternative to standard HSL. It's built upon CIELUV, a perceptually uniform color space, extending it with a saturation component that allows spanning all available chroma as a percentage. The library, currently at version 5.0.4, provides functions for converting between HSLuv, HPLuv (pastel variant), RGB, and hexadecimal color representations. It maintains an active development status with periodic updates.","status":"active","version":"5.0.4","language":"en","source_language":"en","source_url":"https://github.com/hsluv/hsluv-python","tags":["color","hsl","hsluv","hpluv","color-space","color-conversion"],"install":[{"cmd":"pip install hsluv","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"hsluv_to_hex","correct":"from hsluv import hsluv_to_hex"},{"symbol":"hex_to_hsluv","correct":"from hsluv import hex_to_hsluv"},{"symbol":"rgb_to_hsluv","correct":"from hsluv import rgb_to_hsluv"},{"symbol":"hsluv_to_rgb","correct":"from hsluv import hsluv_to_rgb"},{"symbol":"hpluv_to_hex","correct":"from hsluv import hpluv_to_hex"},{"symbol":"hex_to_hpluv","correct":"from hsluv import hex_to_hpluv"}],"quickstart":{"code":"from hsluv import hsluv_to_hex, hex_to_hsluv, rgb_to_hsluv, hsluv_to_rgb\n\n# Convert HSLuv to Hex\nhsluv_color = [240.0, 100.0, 50.0]  # Blue color (Hue, Saturation, Lightness)\nhex_code = hsluv_to_hex(hsluv_color)\nprint(f\"HSLuv {hsluv_color} -> Hex: {hex_code}\")\n\n# Convert Hex to HSLuv\nparsed_hsluv = hex_to_hsluv(\"#0000FF\") # Pure Blue\nprint(f\"Hex #0000FF -> HSLuv: {parsed_hsluv}\")\n\n# Convert RGB to HSLuv (RGB values 0-1)\nrgb_color = [0.0, 0.0, 1.0] # Pure Blue\nconverted_hsluv = rgb_to_hsluv(rgb_color)\nprint(f\"RGB {rgb_color} -> HSLuv: {converted_hsluv}\")\n\n# Convert HSLuv to RGB (RGB values 0-1)\nhsluv_to_rgb_example = [240.0, 100.0, 50.0] # Blue\nconverted_rgb = hsluv_to_rgb(hsluv_to_rgb_example)\nprint(f\"HSLuv {hsluv_to_rgb_example} -> RGB: {converted_rgb}\")","lang":"python","description":"This quickstart demonstrates how to use the core conversion functions of the `hsluv` library to transform colors between HSLuv, hexadecimal, and RGB formats. HSLuv takes hue (0-360), saturation (0-100), and lightness (0-100). RGB input/output values are floats between 0 and 1."},"warnings":[{"fix":"Upgrade to Python 3.7+ or pin `hsluv` to a version compatible with Python 2 (e.g., `pip install hsluv==5.0.0`).","message":"Version 5.x and later require Python 3.7 or newer. Python 2 users must install `hsluv==5.0.0` or earlier versions for compatibility.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"For display or strict validation, consider rounding the output values to a desired precision or clamping them to their expected ranges after conversion.","message":"The library does not 'clamp' floating point errors, meaning output values for color components might be slightly outside their expected ranges (e.g., RGB values slightly less than 0 or greater than 1, or HSLuv components slightly out of range).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Always refer to the function signatures and documentation to provide inputs in the correct format and range.","message":"Ensure input types match function expectations. For example, `hsluv_to_rgb` expects hue (0-360), saturation (0-100), and lightness (0-100) as floats. `rgb_to_hsluv` expects R, G, B as floats between 0 and 1. Mis-matched types could lead to unexpected results or `TypeError`s.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-14T00:00:00.000Z","next_check":"2026-07-13T00:00:00.000Z"}