[librsvg/rustify-rsvg-convert: 66/78] rsvg-convert: extract the final_size computation to a function
- From: Sven Neumann <sneumann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustify-rsvg-convert: 66/78] rsvg-convert: extract the final_size computation to a function
- Date: Wed, 3 Feb 2021 10:18:31 +0000 (UTC)
commit 2f1659f24b0ca28451494dd6e7bb65dd301f2548
Author: Federico Mena Quintero <federico gnome org>
Date: Mon Jan 25 15:52:35 2021 -0600
rsvg-convert: extract the final_size computation to a function
src/bin/rsvg-convert.rs | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
---
diff --git a/src/bin/rsvg-convert.rs b/src/bin/rsvg-convert.rs
index fe9c8da5..ac1ec99a 100644
--- a/src/bin/rsvg-convert.rs
+++ b/src/bin/rsvg-convert.rs
@@ -412,6 +412,15 @@ impl Converter {
Size::new(w, h)
}
+ fn final_size(&self, strategy: &ResizeStrategy, natural_size: &Size, input: &Input) -> Size {
+ strategy
+ .apply(
+ Size::new(natural_size.w, natural_size.h),
+ self.keep_aspect_ratio,
+ )
+ .unwrap_or_else(|| exit!("The SVG {} has no dimensions", input))
+ }
+
fn create_surface(&self, renderer: &CairoRenderer, input: &Input) -> Surface {
let natural_size = self.natural_size(renderer, input);
@@ -431,12 +440,7 @@ impl Converter {
_ => ResizeStrategy::FitLargestScale(self.zoom, self.width, self.height),
};
- let final_size = strategy
- .apply(
- Size::new(natural_size.w, natural_size.h),
- self.keep_aspect_ratio,
- )
- .unwrap_or_else(|| exit!("The SVG {} has no dimensions", input));
+ let final_size = self.final_size(&strategy, &natural_size, input);
let output_stream = match self.output {
Output::Stdout => Stdout::stream().upcast::<OutputStream>(),
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]