Skip to content

Commit

Permalink
fix(renderer): Fix tile mode for landscape images
Browse files Browse the repository at this point in the history
  • Loading branch information
danyspin97 committed Jun 18, 2024
1 parent 6cc4e12 commit cf662e5
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions daemon/src/render/renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -175,27 +175,26 @@ impl Renderer {
]
}
BackgroundMode::Tile => {
let width_proportion = display_width / image_width * display_ratio;
let height_proportion = display_height / image_height * display_ratio;
if display_ratio > image_ratio {
// Portrait mode
let height =
(display_height / image_height / (display_height / display_width))
.max(1.0);
if height == 1.0 {
if height_proportion.max(1.0) == 1.0 {
// Same as Fit
let width = display_height * image_ratio;
[display_width / width, 1.0]
} else {
[
(display_width / image_width / (display_height / display_width)),
height,
]
[width_proportion, height_proportion]
}
} else {
// Landscape mode
[
(display_width / image_width).max(1.0),
(display_height / image_height),
]
if width_proportion.max(1.0) == 1.0 {
// Same as Fit
let height = display_width / image_ratio;
[1.0, display_height / height]
} else {
[width_proportion, height_proportion]
}
}
}
})
Expand Down

0 comments on commit cf662e5

Please sign in to comment.