Crate streemap[−][src]
Set of tree map algorithms
Algorithms:
- Slice and Dice 😵.
- Binary.
- Squarified by Bruls, Mark; Huizing, Kees; van Wijk, Jarke J. (2000).
Example:
use streemap::Rect; const R0: Rect<f32> = Rect { x: 0., y: 0., w: 0., h: 0. }; let mut slice = [(6., R0), (6., R0), (4., R0), (3., R0), (2., R0), (2., R0), (1., R0)]; streemap::squarify( Rect { x: 0., y: 0., w: 6., h: 4. }, &mut slice[..], |&(n, _)| n, // map item to item size |(_, item_r), r| *item_r = r, // set item distributed rect ); assert_eq!( slice, [ (6.0, Rect { x: 0.0, y: 0.0, w: 3.0, h: 2.0 }), (6.0, Rect { x: 0.0, y: 2.0, w: 3.0, h: 2.0 }), (4.0, Rect { x: 3.0, y: 0.0, w: 1.7142857, h: 2.3333333 }), (3.0, Rect { x: 4.714286, y: 0.0, w: 1.2857141, h: 2.3333333 }), (2.0, Rect { x: 3.0, y: 2.3333333, w: 1.1999999, h: 1.6666667 }), (2.0, Rect { x: 4.2, y: 2.3333333, w: 1.1999999, h: 1.6666667 }), (1.0, Rect { x: 5.3999996, y: 2.3333333, w: 0.60000014, h: 1.6666667 }) ] ); streemap::binary( Rect { x: 0., y: 0., w: 6., h: 4. }, &mut slice[..], |&(n, _)| n, // map item to item size |(_, item_r), r| *item_r = r, // set item distributed rect ); assert_eq!( slice, [ (6.0, Rect { x: 0.0, y: 0.0, w: 3.0, h: 2.0 }), (6.0, Rect { x: 0.0, y: 2.0, w: 3.0, h: 2.0 }), (4.0, Rect { x: 3.0, y: 0.0, w: 3.0, h: 1.3333334 }), (3.0, Rect { x: 3.0, y: 1.3333334, w: 1.125, h: 2.6666665 }), (2.0, Rect { x: 4.125, y: 1.3333334, w: 1.875, h: 1.0666667 }), (2.0, Rect { x: 4.125, y: 2.4, w: 1.25, h: 1.5999999 }), (1.0, Rect { x: 5.375, y: 2.4, w: 0.625, h: 1.5999999 }) ] );
Structs
Rect | A simple rect |
Functions
binary | Distribute |
dice | Distribute |
ordered_pivot_by_middle | Distribute |
ordered_pivot_by_size | Distribute |
slice | Distribute |
squarify | Distribute |