#pack #rect #stb #abstraction #interface #generated #bindgen

stb_rect_pack

Wrapper over stb_rect_pack_sys, offering a cleaner abstraction than the bindgen generated interface

3 releases (breaking)

0.3.0 Mar 4, 2024
0.2.0 Mar 31, 2023
0.1.0 Oct 17, 2022

#869 in Algorithms

Download history 36/week @ 2024-07-26 4/week @ 2024-08-02

1,275 downloads per month

MIT/Apache

7KB
94 lines

stb_rect_pack

Wrapper over stb_rect_pack_sys, offering a cleaner abstraction than the bindgen generated interface.

stb

Example

let mut rects = vec![Rect::new(1280, 720); 4];

pack(&mut rects, 2560, 1440).unwrap();

assert_eq!(rects[0].packed_top_left_x, 1280);
assert_eq!(rects[0].packed_top_left_y, 720);

assert_eq!(rects[1].packed_top_left_x, 0);
assert_eq!(rects[1].packed_top_left_y, 0);

assert_eq!(rects[2].packed_top_left_x, 1280);
assert_eq!(rects[2].packed_top_left_y, 0);

assert_eq!(rects[3].packed_top_left_x, 0);
assert_eq!(rects[3].packed_top_left_y, 720);

Dependencies

~0.3–2.7MB
~56K SLoC