Respect emoji when calculating nick hue

This commit is contained in:
Joscha 2023-01-20 19:42:54 +01:00
parent 9324517c56
commit 9f7c1fb9c0
4 changed files with 10 additions and 2 deletions

View file

@ -1,4 +1,8 @@
use crossterm::style::{Color, ContentStyle, Stylize};
use euphoxide::emoji::Emoji;
use once_cell::sync::Lazy;
static EMOJI: Lazy<Emoji> = Lazy::new(Emoji::load);
/// Convert HSL to RGB following [this approach from wikipedia][1].
///
@ -33,8 +37,7 @@ fn hsl_to_rgb(h: f32, s: f32, l: f32) -> (u8, u8, u8) {
}
pub fn nick_color(nick: &str) -> (u8, u8, u8) {
// TODO Use nick hue with emoji (lazy init emoji?)
let hue = euphoxide::nick_hue_without_removing_emoji(nick) as f32;
let hue = euphoxide::nick_hue(&EMOJI, nick) as f32;
hsl_to_rgb(hue, 1.0, 0.72)
}