From f1e20a61f16388ed4d2dac734bab30d67bbd84b3 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 9 Feb 2020 03:25:13 +0100 Subject: Allow `iced_wgpu` to render to any `TextureView` --- wgpu/src/viewport.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 wgpu/src/viewport.rs (limited to 'wgpu/src/viewport.rs') diff --git a/wgpu/src/viewport.rs b/wgpu/src/viewport.rs new file mode 100644 index 00000000..a4bcb704 --- /dev/null +++ b/wgpu/src/viewport.rs @@ -0,0 +1,32 @@ +use crate::Transformation; + +#[derive(Debug)] +pub struct Viewport { + width: u32, + height: u32, + scale_factor: f32, + transformation: Transformation, +} + +impl Viewport { + pub fn new(width: u32, height: u32, scale_factor: f64) -> Viewport { + Viewport { + width, + height, + scale_factor: scale_factor as f32, + transformation: Transformation::orthographic(width, height), + } + } + + pub fn dimensions(&self) -> (u32, u32) { + (self.width, self.height) + } + + pub fn scale_factor(&self) -> f32 { + self.scale_factor + } + + pub(crate) fn transformation(&self) -> Transformation { + self.transformation + } +} -- cgit From 8f0b59a4b28bee028a879b0705eeeaa0b2e82df6 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Sun, 9 Feb 2020 03:36:59 +0100 Subject: Remove `scale_factor` from `iced_wgpu::Viewport` --- wgpu/src/viewport.rs | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'wgpu/src/viewport.rs') diff --git a/wgpu/src/viewport.rs b/wgpu/src/viewport.rs index a4bcb704..66242468 100644 --- a/wgpu/src/viewport.rs +++ b/wgpu/src/viewport.rs @@ -1,31 +1,28 @@ use crate::Transformation; +/// A viewing region for displaying computer graphics. #[derive(Debug)] pub struct Viewport { width: u32, height: u32, - scale_factor: f32, transformation: Transformation, } impl Viewport { - pub fn new(width: u32, height: u32, scale_factor: f64) -> Viewport { + /// Creates a new [`Viewport`] with the given dimensions. + pub fn new(width: u32, height: u32) -> Viewport { Viewport { width, height, - scale_factor: scale_factor as f32, transformation: Transformation::orthographic(width, height), } } + /// Returns the dimensions of the [`Viewport`]. pub fn dimensions(&self) -> (u32, u32) { (self.width, self.height) } - pub fn scale_factor(&self) -> f32 { - self.scale_factor - } - pub(crate) fn transformation(&self) -> Transformation { self.transformation } -- cgit