pub struct MaxRectsBin { /* private fields */ }Expand description
A two-dimensional rectangle bin packer using the MAXRECTS data structure and different bin packing algorithms that use this structure.
It can be used to pack multiple rectangles of arbitrary size into a “bin” of rectangular shape with the goal to add as many rectangles as possible into the bin.
Implementations§
Source§impl MaxRectsBin
impl MaxRectsBin
Sourcepub fn new(width: i32, height: i32) -> Self
pub fn new(width: i32, height: i32) -> Self
Creates an empty bin of the given size.
Minimum width and height of a bin is 1.
Sourcepub fn with_capacity(width: i32, height: i32, capacity: usize) -> Self
pub fn with_capacity(width: i32, height: i32, capacity: usize) -> Self
Creates an empty bin of the given size and reserves space for at least capacity number
of mapped rectangle to improve performance.
Minimum width and height of a bin is 1.
Sourcepub fn default_rule(&self) -> Heuristic
pub fn default_rule(&self) -> Heuristic
Returns the default Heuristic rule, which is used by the BinPacker trait’s
insert and insert_list methods.
Sourcepub fn set_default_rule(&mut self, rule: Heuristic)
pub fn set_default_rule(&mut self, rule: Heuristic)
Can be used to override the default Heuristic rule, which is used by the BinPacker
trait’s insert and insert_list methods.
Sourcepub fn insert_list(
&mut self,
nodes: &[Dimension],
rule: Heuristic,
) -> (Vec<Rectangle>, Vec<Dimension>)
pub fn insert_list( &mut self, nodes: &[Dimension], rule: Heuristic, ) -> (Vec<Rectangle>, Vec<Dimension>)
Attempts to insert the given list of Dimension objects into the bin.
nodes specifies the list of Dimension objects to insert. All successfully inserted
objects will be removed from the list in the process.
rule specifies the rectangle placement rule to use for the packing operations.
Returns a list with all successfully inserted Rectangle objects.
This method performs slower than insert, but may result in more tightly
packed bins for greater numbers of dimension objects.
Trait Implementations§
Source§impl BinPacker for MaxRectsBin
impl BinPacker for MaxRectsBin
Source§fn clear_with(&mut self, capacity: usize)
fn clear_with(&mut self, capacity: usize)
clear, this method removes all mapped rectangle from the bin, but
also sets initial capacity of the internal rectangle lists to improve performance.Source§fn grow(&mut self, dw: u32, dh: u32)
fn grow(&mut self, dw: u32, dh: u32)
Source§fn occupancy(&self) -> f32
fn occupancy(&self) -> f32
[0.0, 1.0].Source§fn as_slice(&self) -> &[Rectangle]
fn as_slice(&self) -> &[Rectangle]
Source§fn find_by_id(&self, id: isize) -> Option<Rectangle>
fn find_by_id(&self, id: isize) -> Option<Rectangle>
None otherwise.Source§impl Clone for MaxRectsBin
impl Clone for MaxRectsBin
Source§fn clone(&self) -> MaxRectsBin
fn clone(&self) -> MaxRectsBin
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MaxRectsBin
impl Debug for MaxRectsBin
Source§impl Display for MaxRectsBin
impl Display for MaxRectsBin
Source§impl<Idx> Index<Idx> for MaxRectsBinwhere
Idx: SliceIndex<[Rectangle]>,
impl<Idx> Index<Idx> for MaxRectsBinwhere
Idx: SliceIndex<[Rectangle]>,
Source§impl PartialEq for MaxRectsBin
impl PartialEq for MaxRectsBin
Source§fn eq(&self, other: &MaxRectsBin) -> bool
fn eq(&self, other: &MaxRectsBin) -> bool
self and other values to be equal, and is used by ==.