pub struct Dimension { /* private fields */ }Expand description
The Dimension struct stores information about width, height and optional padding of an object.
Padding can be used to ensure that rectangles are placed into bins with spacing to each other.
An identifier is provided for custom identification purposes.
Implementations§
Source§impl Dimension
impl Dimension
Sourcepub fn with_padding(width: i32, height: i32, padding: i32) -> Self
pub fn with_padding(width: i32, height: i32, padding: i32) -> Self
Creates a new Dimension object with the specified dimensions, an auto-generated
identifier and optional padding.
Negative values for width, height and padding are capped at 0.
Note: Auto-generated identifiers can be considered unique, as long as they are not
duplicated by with_id, set_id or cloning.
Sourcepub fn with_id(id: isize, width: i32, height: i32, padding: i32) -> Self
pub fn with_id(id: isize, width: i32, height: i32, padding: i32) -> Self
Creates a new Dimension object with the specified dimension, identifier and
optional padding.
Negative values for width, height and padding are capped at 0.
Sourcepub fn set_width(&mut self, value: i32)
pub fn set_width(&mut self, value: i32)
Sets width of the Dimension to the specified value.
A negative value for width is capped at 0.
Sourcepub fn set_height(&mut self, value: i32)
pub fn set_height(&mut self, value: i32)
Sets height of the Dimension to the specified value.
A negative value for height is capped at 0.
Sourcepub fn set_dimension(&mut self, width: i32, height: i32)
pub fn set_dimension(&mut self, width: i32, height: i32)
Sets both width and height of the Dimension.
Negative values for width and height are capped at 0.
Sourcepub fn set_padding(&mut self, value: i32)
pub fn set_padding(&mut self, value: i32)
Sets padding of the Dimension to the specified value.
A negative value for padding is capped at 0.
Sourcepub fn to_flipped(&self) -> Self
pub fn to_flipped(&self) -> Self
Creates a new Dimension from the current instance, which is flipped by 90 degrees.