Skip to content

Commit

Permalink
more spelling and style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-ilesik committed Oct 5, 2023
1 parent 965b002 commit f3ccf27
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 9 deletions.
8 changes: 4 additions & 4 deletions include/dpp/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
20 changes: 15 additions & 5 deletions src/dpp/utility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down

0 comments on commit f3ccf27

Please sign in to comment.