2020-02-09 03:25:13 +01:00
|
|
|
use crate::Transformation;
|
|
|
|
|
|
2020-02-09 03:36:59 +01:00
|
|
|
/// A viewing region for displaying computer graphics.
|
2020-02-09 03:25:13 +01:00
|
|
|
#[derive(Debug)]
|
|
|
|
|
pub struct Viewport {
|
|
|
|
|
width: u32,
|
|
|
|
|
height: u32,
|
|
|
|
|
transformation: Transformation,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Viewport {
|
2020-02-09 03:36:59 +01:00
|
|
|
/// Creates a new [`Viewport`] with the given dimensions.
|
|
|
|
|
pub fn new(width: u32, height: u32) -> Viewport {
|
2020-02-09 03:25:13 +01:00
|
|
|
Viewport {
|
|
|
|
|
width,
|
|
|
|
|
height,
|
|
|
|
|
transformation: Transformation::orthographic(width, height),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-09 03:36:59 +01:00
|
|
|
/// Returns the dimensions of the [`Viewport`].
|
2020-02-09 03:25:13 +01:00
|
|
|
pub fn dimensions(&self) -> (u32, u32) {
|
|
|
|
|
(self.width, self.height)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub(crate) fn transformation(&self) -> Transformation {
|
|
|
|
|
self.transformation
|
|
|
|
|
}
|
|
|
|
|
}
|