mirror of
https://github.com/wez/wezterm.git
synced 2024-12-24 22:01:47 +03:00
gui: introduce foreground_text_hsb transform
This allows explicitly manipulating the hue, saturation, brightness
of the text rendered in the terminal, allowing users to dial in
the accidental effect that was introduced by
d886de8300
For example, this will punch up the brightness:
```
foreground_text_hsb = {
hue = 1.0,
saturation = 1.0,
brightness = 1.5,
},
```
refs: https://github.com/wez/wezterm/issues/491
This commit is contained in:
parent
651e536d87
commit
08b6043166
@ -3,7 +3,7 @@ use luahelper::impl_lua_conversion;
|
||||
use termwiz::cell::CellAttributes;
|
||||
use termwiz::color::{ColorSpec, RgbColor};
|
||||
|
||||
#[derive(Debug, Default, Copy, Deserialize, Serialize, Clone)]
|
||||
#[derive(Debug, Copy, Deserialize, Serialize, Clone)]
|
||||
pub struct HsbTransform {
|
||||
#[serde(default = "default_one_point_oh")]
|
||||
pub hue: f32,
|
||||
@ -13,6 +13,16 @@ pub struct HsbTransform {
|
||||
pub brightness: f32,
|
||||
}
|
||||
|
||||
impl Default for HsbTransform {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
hue: 1.,
|
||||
saturation: 1.,
|
||||
brightness: 1.,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Deserialize, Serialize, Clone)]
|
||||
pub struct Palette {
|
||||
/// The text color to use when the attributes are reset to default
|
||||
|
@ -734,6 +734,8 @@ pub struct Config {
|
||||
pub window_background_image: Option<PathBuf>,
|
||||
#[serde(default)]
|
||||
pub window_background_image_hsb: Option<HsbTransform>,
|
||||
#[serde(default)]
|
||||
pub foreground_text_hsb: HsbTransform,
|
||||
|
||||
/// Specifies the alpha value to use when rendering the background
|
||||
/// of the window. The background is taken either from the
|
||||
|
@ -18,6 +18,8 @@ uniform bool has_background_image;
|
||||
uniform sampler2D atlas_nearest_sampler;
|
||||
uniform sampler2D atlas_linear_sampler;
|
||||
|
||||
uniform vec3 foreground_text_hsb;
|
||||
|
||||
out vec4 color;
|
||||
|
||||
float multiply_one(float src, float dst, float inv_dst_alpha, float inv_src_alpha) {
|
||||
@ -88,7 +90,7 @@ vec4 colorize(vec4 glyph, vec4 color) {
|
||||
vec4 colorize_hsv(vec4 glyph, vec4 color) {
|
||||
vec3 hsv = rgb2hsv(color.rgb);
|
||||
hsv.b *= glyph.a;
|
||||
return vec4(hsv2rgb(hsv), glyph.a);
|
||||
return vec4(hsv2rgb(hsv * foreground_text_hsb), glyph.a);
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
@ -2776,6 +2776,13 @@ impl TermWindow {
|
||||
|
||||
let has_background_image = self.window_background.is_some();
|
||||
|
||||
let foreground_text_hsb = configuration().foreground_text_hsb;
|
||||
let foreground_text_hsb = (
|
||||
foreground_text_hsb.hue,
|
||||
foreground_text_hsb.saturation,
|
||||
foreground_text_hsb.brightness,
|
||||
);
|
||||
|
||||
// Pass 1: Draw backgrounds
|
||||
frame.draw(
|
||||
&*vb,
|
||||
@ -2788,6 +2795,7 @@ impl TermWindow {
|
||||
window_bg_layer: true,
|
||||
bg_and_line_layer: false,
|
||||
has_background_image: has_background_image,
|
||||
foreground_text_hsb: foreground_text_hsb,
|
||||
},
|
||||
&alpha_blending,
|
||||
)?;
|
||||
@ -2804,6 +2812,7 @@ impl TermWindow {
|
||||
window_bg_layer: false,
|
||||
bg_and_line_layer: true,
|
||||
has_background_image: has_background_image,
|
||||
foreground_text_hsb: foreground_text_hsb,
|
||||
},
|
||||
&alpha_blending,
|
||||
)?;
|
||||
@ -2860,6 +2869,7 @@ impl TermWindow {
|
||||
window_bg_layer: false,
|
||||
bg_and_line_layer: false,
|
||||
has_background_image: has_background_image,
|
||||
foreground_text_hsb: foreground_text_hsb,
|
||||
},
|
||||
&blend_but_set_alpha_to_one,
|
||||
)?;
|
||||
|
Loading…
Reference in New Issue
Block a user