Refactor Viewport and Compositor

This commit is contained in:
Héctor Ramón Jiménez 2020-05-20 20:28:35 +02:00
parent 720e7756f2
commit a1a5fcfd46
24 changed files with 202 additions and 278 deletions

View file

@ -2,11 +2,20 @@ use std::f32;
/// An amount of space in 2 dimensions.
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Size {
pub struct Size<T = f32> {
/// The width.
pub width: f32,
pub width: T,
/// The height.
pub height: f32,
pub height: T,
}
impl<T> Size<T> {
/// Creates a new [`Size`] with the given width and height.
///
/// [`Size`]: struct.Size.html
pub const fn new(width: T, height: T) -> Self {
Size { width, height }
}
}
impl Size {
@ -25,13 +34,6 @@ impl Size {
/// [`Size`]: struct.Size.html
pub const INFINITY: Size = Size::new(f32::INFINITY, f32::INFINITY);
/// Creates a new [`Size`] with the given width and height.
///
/// [`Size`]: struct.Size.html
pub const fn new(width: f32, height: f32) -> Self {
Size { width, height }
}
/// Increments the [`Size`] to account for the given padding.
///
/// [`Size`]: struct.Size.html