From 4c81f4d2860f6075fe57d2f3b835a3a104865eb2 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Sun, 9 Jan 2022 16:42:38 -0800 Subject: [PATCH] image: Use clearer ratio names `ratio` and `pic_ratio` were confusing names. Rename them to `widget_ratio` and `texture_ratio` to be more clear. --- src/widgets/image.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/widgets/image.rs b/src/widgets/image.rs index 3fa4efa..62d5b40 100644 --- a/src/widgets/image.rs +++ b/src/widgets/image.rs @@ -98,17 +98,17 @@ mod imp { if let Some(texture) = self.texture.borrow().as_ref() { let width = widget.width() as f64; let height = widget.height() as f64; - let ratio = texture.intrinsic_aspect_ratio(); + let texture_ratio = texture.intrinsic_aspect_ratio(); - if ratio == 0.0 { + if texture_ratio == 0.0 { texture.snapshot(snapshot.upcast_ref(), width, height); } else { - let pic_ratio = width / height; + let widget_ratio = width / height; - let (snapshot_width, snapshot_height) = if ratio > pic_ratio { - (width, width / ratio) + let (snapshot_width, snapshot_height) = if texture_ratio > widget_ratio { + (width, width / texture_ratio) } else { - (height * ratio, height) + (height * texture_ratio, height) }; let x = (width - snapshot_width.ceil()) / 2.0;