diff --git a/docs/changelog.md b/docs/changelog.md index cf0f1b3f7..f559c09bf 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -17,6 +17,7 @@ As features stabilize some brief notes about them will accumulate here. * Fixed: `wezterm cli split-pane` didn't use the current working dir of the source pane. [#766](https://github.com/wez/wezterm/issues/766) * Fixed: double-click-drag selection could panic when crossing line boundaries [#762](https://github.com/wez/wezterm/issues/762) * Fixed: wrong scaling for ligatures in Recursive Mono font [#699](https://github.com/wez/wezterm/issues/699) +* Fixed: incorrect Sixel HLS hue handling [#775](https://github.com/wez/wezterm/issues/775) ### 20210502-154244-3f7122cb diff --git a/term/src/terminalstate.rs b/term/src/terminalstate.rs index 10ec961d4..3eadd442b 100644 --- a/term/src/terminalstate.rs +++ b/term/src/terminalstate.rs @@ -1500,13 +1500,19 @@ impl TerminalState { lightness, } => { use palette::encoding::pixel::Pixel; - let hue = palette::RgbHue::from_degrees(*hue_angle as f32); + // Sixel's hue angles are: blue=0, red=120, green=240, + // whereas Hsl has red=0, green=120, blue=240. + // Looking at red, we need to rotate left by 120 to + // go from sixel red to palette::RgbHue red. + // Negative values wrap around the circle. + // https://github.com/wez/wezterm/issues/775 + let angle = (*hue_angle as f32) - 120.0; + let angle = if angle < 0. { 360.0 + angle } else { angle }; + let hue = palette::RgbHue::from_degrees(angle); let hsl = palette::Hsl::new(hue, *saturation as f32 / 100., *lightness as f32 / 100.); let rgb: palette::Srgb = hsl.into(); - let rgb: [u8; 3] = palette::Srgb::from_linear(rgb.into_linear()) - .into_format() - .into_raw(); + let rgb: [u8; 3] = rgb.into_linear().into_format().into_raw(); color_map.insert(*color_number, RgbColor::new(rgb[0], rgb[1], rgb[2])); }