summaryrefslogtreecommitdiffstats
path: root/glow/src/viewport.rs
diff options
context:
space:
mode:
authorLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-19 14:23:28 +0200
committerLibravatar Héctor Ramón Jiménez <hector0193@gmail.com>2020-05-19 14:23:28 +0200
commitd4743183d40c6044ce6fa39e2a52919a32912cda (patch)
treed2dec81cd9b419262cf2aa57ad793895ccacb320 /glow/src/viewport.rs
parent33448508a524db6447b380cc236be6f0d5ca8a86 (diff)
downloadiced-d4743183d40c6044ce6fa39e2a52919a32912cda.tar.gz
iced-d4743183d40c6044ce6fa39e2a52919a32912cda.tar.bz2
iced-d4743183d40c6044ce6fa39e2a52919a32912cda.zip
Draft first working version of `iced_glow` :tada:
Diffstat (limited to 'glow/src/viewport.rs')
-rw-r--r--glow/src/viewport.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/glow/src/viewport.rs b/glow/src/viewport.rs
new file mode 100644
index 00000000..c1afee87
--- /dev/null
+++ b/glow/src/viewport.rs
@@ -0,0 +1,33 @@
+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),
+ }
+ }
+
+ pub fn height(&self) -> u32 {
+ self.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
+ }
+}