diff --git a/include/dpp/utility.h b/include/dpp/utility.h index 28471779f4..c021af12ba 100644 --- a/include/dpp/utility.h +++ b/include/dpp/utility.h @@ -424,8 +424,8 @@ namespace dpp { * @brief Convert doubles to HSL for sending in embeds * * @param h hue value, between 0 and 1 inclusive - * @param s saturation value in procents, between 0 and 1 inclusive - * @param l lightness value in procents, between 0 and 1 inclusive + * @param s saturation value in percentage , between 0 and 1 inclusive + * @param l lightness value in percentage , between 0 and 1 inclusive * @return uint32_t returned integer colour value */ uint32_t DPP_EXPORT hsl(double h, double s, double l); @@ -434,8 +434,8 @@ namespace dpp { * @brief Convert ints to HSL for sending in embeds * * @param h hue value, between 0 and 360 inclusive - * @param s saturation value in procents, between 0 and 100 inclusive - * @param l lightness value in procents, between 0 and 100 inclusive + * @param s saturation value in percentage , between 0 and 100 inclusive + * @param l lightness value in percentage , between 0 and 100 inclusive * @return uint32_t returned integer colour value */ uint32_t DPP_EXPORT hsl(int h, int s, int l); diff --git a/src/dpp/utility.cpp b/src/dpp/utility.cpp index 42c7aec666..cf52a30710 100644 --- a/src/dpp/utility.cpp +++ b/src/dpp/utility.cpp @@ -310,11 +310,21 @@ namespace dpp { uint32_t hsl(double h, double s, double l) { const auto hue_to_rgb = [](double p, double q, double t){ - if (t < 0) t += 1; - if (t > 1) t -= 1; - if (t < 1.0 / 6.0) return p + (q - p) * 6.0 * t; - if (t < 0.5) return q; - if (t < 2.0 / 3.0) return p + (q - p) * (2.0 / 3.0 - t) * 6.0; + if (t < 0) { + t += 1; + } + if (t > 1) { + t -= 1; + } + if (t < 1.0 / 6.0) { + return p + (q - p) * 6.0 * t; + } + if (t < 0.5) { + return q; + } + if (t < 2.0 / 3.0) { + return p + (q - p) * (2.0 / 3.0 - t) * 6.0; + } return p; };