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

@ -14,6 +14,9 @@ Procedure when bumping the version number:
## Unreleased ## Unreleased
### Changed
- Respect colon-delimited emoji when calculating nick hue
## v0.5.2 - 2023-01-14 ## v0.5.2 - 2023-01-14
### Added ### Added

1
Cargo.lock generated
View file

@ -179,6 +179,7 @@ dependencies = [
"euphoxide", "euphoxide",
"linkify", "linkify",
"log", "log",
"once_cell",
"open", "open",
"parking_lot", "parking_lot",
"rusqlite", "rusqlite",

View file

@ -13,6 +13,7 @@ directories = "4.0.1"
edit = "0.1.4" edit = "0.1.4"
linkify = "0.9.0" linkify = "0.9.0"
log = { version = "0.4.17", features = ["std"] } log = { version = "0.4.17", features = ["std"] }
once_cell = "1.17.0"
open = "3.2.0" open = "3.2.0"
parking_lot = "0.12.1" parking_lot = "0.12.1"
rusqlite = { version = "0.28.0", features = ["bundled", "time"] } rusqlite = { version = "0.28.0", features = ["bundled", "time"] }

View file

@ -1,4 +1,8 @@
use crossterm::style::{Color, ContentStyle, Stylize}; 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]. /// 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) { pub fn nick_color(nick: &str) -> (u8, u8, u8) {
// TODO Use nick hue with emoji (lazy init emoji?) let hue = euphoxide::nick_hue(&EMOJI, nick) as f32;
let hue = euphoxide::nick_hue_without_removing_emoji(nick) as f32;
hsl_to_rgb(hue, 1.0, 0.72) hsl_to_rgb(hue, 1.0, 0.72)
} }