MCPcopy Create free account
hub / github.com/17cupsofcoffee/nova / insert

Method insert

src/graphics/packer.rs:37–55  ·  view source on GitHub ↗

Tries to insert RGBA data into the atlas, and returns the position. If the data will not fit into the remaining space, `None` will be returned.

(
        &mut self,
        data: &[u8],
        width: i32,
        height: i32,
        padding: i32,
    )

Source from the content-addressed store, hash-verified

35 ///
36 /// If the data will not fit into the remaining space, `None` will be returned.
37 pub fn insert(
38 &mut self,
39 data: &[u8],
40 width: i32,
41 height: i32,
42 padding: i32,
43 ) -> Option<IRectangle> {
44 let padded_width = width + padding * 2;
45 let padded_height = height + padding * 2;
46
47 let space = self.find_space(padded_width, padded_height);
48
49 if let Some(s) = space {
50 self.texture
51 .set_region(s.x + padding, s.y + padding, width, height, data);
52 }
53
54 space
55 }
56
57 /// Finds a space in the atlas that can fit a sprite of the specified width and height,
58 /// and returns the position.

Callers 5

eventMethod · 0.80
set_downMethod · 0.80
set_upMethod · 0.80
set_valueMethod · 0.80
newMethod · 0.80

Calls 2

find_spaceMethod · 0.80
set_regionMethod · 0.80

Tested by

no test coverage detected