Add support for asymmetrical padding

This commit is contained in:
Ben LeFevre 2020-11-23 17:19:21 +00:00 committed by Héctor Ramón
parent a9eb591628
commit fe0a27c56d
27 changed files with 339 additions and 195 deletions

View file

@ -1,4 +1,4 @@
use crate::Vector;
use crate::{Padding, Vector};
use std::f32;
/// An amount of space in 2 dimensions.
@ -28,10 +28,10 @@ impl Size {
pub const INFINITY: Size = Size::new(f32::INFINITY, f32::INFINITY);
/// Increments the [`Size`] to account for the given padding.
pub fn pad(&self, padding: f32) -> Self {
pub fn pad(&self, padding: Padding) -> Self {
Size {
width: self.width + padding * 2.0,
height: self.height + padding * 2.0,
width: self.width + (padding.left + padding.right) as f32,
height: self.height + (padding.top + padding.bottom) as f32,
}
}
}