summaryrefslogtreecommitdiff
path: root/src/color.rs
diff options
context:
space:
mode:
authorIvan Potiienko <[email protected]>2026-08-31 22:07:34 +0200
committerIvan Potiienko <[email protected]>2026-08-31 22:07:34 +0200
commit531480d8983d063b982968ad199ae0b959d903df (patch)
tree3c9ebed481e6854d5065d7e3de07dc521b003916 /src/color.rs
parent3e964f98da759c438e6d3a0467df346de7a3d236 (diff)
downloadmikusays-c-531480d8983d063b982968ad199ae0b959d903df.tar.gz
mikusays-c-531480d8983d063b982968ad199ae0b959d903df.zip
Prepare v0.1.5 release
Diffstat (limited to 'src/color.rs')
-rw-r--r--src/color.rs26
1 files changed, 8 insertions, 18 deletions
diff --git a/src/color.rs b/src/color.rs
index 548c222..74497ab 100644
--- a/src/color.rs
+++ b/src/color.rs
@@ -301,14 +301,8 @@ fn hsl_to_rgb(h: u16, s: u8, l: u8) -> (u8, u8, u8) {
let s = s as f32 / 100.0;
let l = l as f32 / 100.0;
- let r;
- let g;
- let b;
-
- if s == 0.0 {
- r = l;
- g = l;
- b = l;
+ let (r, g, b) = if s == 0.0 {
+ (l, l, l)
} else {
let hue_to_rgb = |p: f32, q: f32, t: f32| -> f32 {
let mut t = t;
@@ -337,10 +331,12 @@ fn hsl_to_rgb(h: u16, s: u8, l: u8) -> (u8, u8, u8) {
};
let p = 2.0 * l - q;
- r = hue_to_rgb(p, q, h + 1.0 / 3.0);
- g = hue_to_rgb(p, q, h);
- b = hue_to_rgb(p, q, h - 1.0 / 3.0);
- }
+ (
+ hue_to_rgb(p, q, h + 1.0 / 3.0),
+ hue_to_rgb(p, q, h),
+ hue_to_rgb(p, q, h - 1.0 / 3.0),
+ )
+ };
(
(r * 255.0).round() as u8,
@@ -493,12 +489,6 @@ pub fn detect_windows_shell() -> Option<String> {
None
}
-/// Convert Color to a crossterm Color (helper for use across platforms)
-pub fn to_crossterm_color(color: &Color) -> crossterm::style::Color {
- let (r, g, b) = color.to_rgb();
- crossterm::style::Color::Rgb { r, g, b }
-}
-
/// Detect the parent shell name on Windows, using the sysinfo crate.
pub fn detect_color_mode() -> ColorMode {
if std::env::var("NO_COLOR").is_ok() {