[librsvg/rustify-rsvg-convert: 29/78] rsvg-convert: Rename Zoom struct to Scale
- From: Sven Neumann <sneumann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/rustify-rsvg-convert: 29/78] rsvg-convert: Rename Zoom struct to Scale
- Date: Wed, 3 Feb 2021 10:18:30 +0000 (UTC)
commit ae1fa975749669213a0cb2073d7e20be41837f1d
Author: Sven Neumann <sven svenfoo org>
Date: Fri Nov 6 16:04:36 2020 +0100
rsvg-convert: Rename Zoom struct to Scale
src/bin/rsvg-convert/cli.rs | 12 ++++++------
src/bin/rsvg-convert/main.rs | 8 ++++----
src/bin/rsvg-convert/size.rs | 8 ++++----
3 files changed, 14 insertions(+), 14 deletions(-)
---
diff --git a/src/bin/rsvg-convert/cli.rs b/src/bin/rsvg-convert/cli.rs
index e59822ed..86a78a85 100644
--- a/src/bin/rsvg-convert/cli.rs
+++ b/src/bin/rsvg-convert/cli.rs
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use librsvg::{Color, Parse};
use crate::input::Input;
-use crate::size::{Dpi, Zoom};
+use crate::size::{Dpi, Scale};
arg_enum! {
#[derive(Clone, Copy, Debug)]
@@ -256,12 +256,12 @@ impl Args {
Input::new(&self.input)
}
- pub fn zoom(&self) -> Zoom {
+ pub fn zoom(&self) -> Scale {
match (self.zoom_x, self.zoom_y) {
- (None, None) => Zoom { x: 1.0, y: 1.0 },
- (Some(x), None) => Zoom { x, y: x },
- (None, Some(y)) => Zoom { x: y, y },
- (Some(x), Some(y)) => Zoom { x, y },
+ (None, None) => Scale { x: 1.0, y: 1.0 },
+ (Some(x), None) => Scale { x, y: x },
+ (None, Some(y)) => Scale { x: y, y },
+ (Some(x), Some(y)) => Scale { x, y },
}
}
}
diff --git a/src/bin/rsvg-convert/main.rs b/src/bin/rsvg-convert/main.rs
index c250287d..89250d40 100644
--- a/src/bin/rsvg-convert/main.rs
+++ b/src/bin/rsvg-convert/main.rs
@@ -40,8 +40,8 @@ fn load_stylesheet(args: &Args) -> std::io::Result<Option<String>> {
}
fn get_size(_handle: &SvgHandle, renderer: &CairoRenderer, args: &Args) -> Option<Size> {
- // TODO
- renderer
+
+ match renderer
.intrinsic_size_in_pixels()
.map(|(w, h)| Size::new(w, h).scale(args.zoom()))
}
@@ -97,8 +97,8 @@ fn main() {
);
}
- let zoom = args.zoom();
- cr.scale(zoom.x, zoom.y);
+ let scale = args.zoom();
+ cr.scale(scale.x, scale.y);
surface
.render(&renderer, &cr, args.export_id())
diff --git a/src/bin/rsvg-convert/size.rs b/src/bin/rsvg-convert/size.rs
index 5b86481d..94ff5def 100644
--- a/src/bin/rsvg-convert/size.rs
+++ b/src/bin/rsvg-convert/size.rs
@@ -4,7 +4,7 @@ pub struct Dpi {
pub y: f64,
}
-pub struct Zoom {
+pub struct Scale {
pub x: f64,
pub y: f64,
}
@@ -20,10 +20,10 @@ impl Size {
Self { w, h }
}
- pub fn scale(&self, zoom: Zoom) -> Self {
+ pub fn scale(&self, scale: Scale) -> Self {
Self {
- w: self.w * zoom.x,
- h: self.h * zoom.y,
+ w: self.w * scale.x,
+ h: self.h * scale.y,
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]