diff options
author | 2020-02-09 03:25:13 +0100 | |
---|---|---|
committer | 2020-02-09 03:25:13 +0100 | |
commit | f1e20a61f16388ed4d2dac734bab30d67bbd84b3 (patch) | |
tree | e4112411df1b0493ecb34aa75ecd04e92e9a82af /wgpu/src/viewport.rs | |
parent | 95880ca74bddb6a23774621ef766b91956d40a61 (diff) | |
download | iced-f1e20a61f16388ed4d2dac734bab30d67bbd84b3.tar.gz iced-f1e20a61f16388ed4d2dac734bab30d67bbd84b3.tar.bz2 iced-f1e20a61f16388ed4d2dac734bab30d67bbd84b3.zip |
Allow `iced_wgpu` to render to any `TextureView`
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/viewport.rs | 32 |
1 files changed, 32 insertions, 0 deletions
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 + } +} |