Skip to content

Commit

Permalink
Improve readability.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaanauati committed Dec 24, 2024
1 parent c925a53 commit 5ca0b58
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions wezterm-gui/src/termwindow/background.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,20 +489,22 @@ impl crate::TermWindow {
((pixel_height * aspect).floor(), pixel_height)
};

let computed_background_height = match layer.def.height {
BackgroundSize::Cover => match layer.def.width {
BackgroundSize::Dimension(n) => (n.evaluate_as_pixels(h_context) / aspect) as f32,
_ => min_aspect_height,
}
_ => min_aspect_height,
// Compute image height preserving aspect ratio.
let computed_background_height = if let (
BackgroundSize::Cover, BackgroundSize::Dimension(width)
) = (layer.def.height, layer.def.width) {
(width.evaluate_as_pixels(h_context) / aspect).floor()
} else {
min_aspect_height
};

let computed_background_width = match layer.def.width {
BackgroundSize::Cover => match layer.def.height {
BackgroundSize::Dimension(n) => (n.evaluate_as_pixels(v_context) * aspect).floor(),
_ => min_aspect_width,
}
_ => min_aspect_width,
// Compute width preserving aspect ratio.
let computed_background_width = if let (
BackgroundSize::Cover, BackgroundSize::Dimension(height)
) = (layer.def.width, layer.def.height) {
(height.evaluate_as_pixels(h_context) * aspect).floor()
} else {
min_aspect_width
};

let width = match layer.def.width {
Expand Down

0 comments on commit 5ca0b58

Please sign in to comment.