Skip to content
Snippets Groups Projects

Use a more random hash to generate user colors

Merged Nicolas Werner requested to merge more-random-colors into master
+ 3
1
@@ -656,7 +656,9 @@ utils::generateContrastingHexColor(const QString &input, const QColor &backgroun
auto hash = hashQString(input);
// create a hue value based on the hash of the input.
// Adapted to make Nico blue
auto userHue = static_cast<int>((hash - static_cast<uint32_t>(45)) % 360);
auto userHue =
static_cast<int>(static_cast<double>(hash - static_cast<uint32_t>(0x60'00'00'00)) /
std::numeric_limits<uint32_t>::max() * 360.);
// start with moderate saturation and lightness values.
auto sat = 230;
auto lightness = 125;
Loading