1
1
mirror of https://github.com/wez/wezterm.git synced 2024-09-21 11:50:42 +03:00

gui: add Linear gradient

This commit is contained in:
Erlend Lind Madsen 2022-05-26 15:39:00 +02:00 committed by Wez Furlong
parent 4e00b24dbf
commit c3ea11487c
2 changed files with 18 additions and 0 deletions

View File

@ -32,6 +32,9 @@ impl Default for BlendMode {
pub enum GradientOrientation {
Horizontal,
Vertical,
Linear {
angle: Option<f64>,
},
Radial {
radius: Option<f64>,
cx: Option<f64>,

View File

@ -594,6 +594,21 @@ fn load_background_image(config: &ConfigHandle, dimensions: &Dimensions) -> Opti
)));
}
}
GradientOrientation::Linear { angle } => {
let angle = angle.unwrap_or(0.0).to_radians();
for (x, y, pixel) in imgbuf.enumerate_pixels_mut() {
let (x, y) = (x as f64, y as f64);
let (x, y) = (x - fw / 2., y - fh / 2.);
let t = x * f64::cos(angle) - y * f64::sin(angle);
*pixel = to_pixel(grad.at(remap(
t + noise(&rng, noise_amount),
-fw / 2.,
fw / 2.,
dmin,
dmax,
)));
}
}
GradientOrientation::Radial { radius, cx, cy } => {
let radius = fw * radius.unwrap_or(0.5);
let cx = fw * cx.unwrap_or(0.5);