diff options
author | 2020-02-10 19:49:08 +0100 | |
---|---|---|
committer | 2020-02-10 19:49:08 +0100 | |
commit | 5d16f431b3088189579cf096b3abf89578cc73f6 (patch) | |
tree | c7efea00fabd87133a59760e902548d39822a844 /wgpu/src/viewport.rs | |
parent | 95880ca74bddb6a23774621ef766b91956d40a61 (diff) | |
parent | 4337daddb2a02a2c60dfc5beb896e3059588312a (diff) | |
download | iced-5d16f431b3088189579cf096b3abf89578cc73f6.tar.gz iced-5d16f431b3088189579cf096b3abf89578cc73f6.tar.bz2 iced-5d16f431b3088189579cf096b3abf89578cc73f6.zip |
Merge pull request #183 from hecrj/feature/wgpu-integration
Integration with existing `wgpu` projects
Diffstat (limited to '')
-rw-r--r-- | wgpu/src/viewport.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/wgpu/src/viewport.rs b/wgpu/src/viewport.rs new file mode 100644 index 00000000..66242468 --- /dev/null +++ b/wgpu/src/viewport.rs @@ -0,0 +1,29 @@ +use crate::Transformation; + +/// A viewing region for displaying computer graphics. +#[derive(Debug)] +pub struct Viewport { + width: u32, + height: u32, + transformation: Transformation, +} + +impl Viewport { + /// Creates a new [`Viewport`] with the given dimensions. + pub fn new(width: u32, height: u32) -> Viewport { + Viewport { + width, + height, + transformation: Transformation::orthographic(width, height), + } + } + + /// Returns the dimensions of the [`Viewport`]. + pub fn dimensions(&self) -> (u32, u32) { + (self.width, self.height) + } + + pub(crate) fn transformation(&self) -> Transformation { + self.transformation + } +} |