#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

#1233 in Algorithms

Download history 27/week @ 2024-07-23 13/week @ 2024-07-30 10/week @ 2024-09-24 26/week @ 2024-10-01

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.2–2.7MB
~57K SLoC