Skip to content

Commit

Permalink
Expose methods on PackedLocation
Browse files Browse the repository at this point in the history
  • Loading branch information
chinedufn committed Mar 9, 2020
1 parent 52146a9 commit 361f699
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rectangle-pack"
version = "0.1.2"
version = "0.1.3"
authors = ["Chinedu Francis Nwafili <[email protected]>"]
edition = "2018"
keywords = ["texture", "atlas", "bin", "box", "packer"]
Expand Down
21 changes: 2 additions & 19 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ use crate::width_height_depth::WidthHeightDepth;

pub use self::box_size_heuristics::{volume_heuristic, BoxSizeHeuristicFn};
pub use self::rect_to_insert::RectToInsert;
pub use crate::packed_location::PackedLocation;

mod bin_section;
mod grouped_rects_to_place;

mod packed_location;
mod rect_to_insert;
mod target_bin;
mod width_height_depth;
Expand Down Expand Up @@ -261,25 +263,6 @@ fn sort_groups_largest_to_smallest<GroupId, RectToPlaceId>(
});
}

/// Describes how and where an incoming rectangle was packed into the target bins
#[derive(Debug, PartialEq)]
pub struct PackedLocation {
x: u32,
y: u32,
z: u32,
whd: WidthHeightDepth,
x_axis_rotation: RotatedBy,
y_axis_rotation: RotatedBy,
z_axis_rotation: RotatedBy,
}

#[derive(Debug, PartialEq)]
#[allow(unused)] // TODO: Implement rotations
enum RotatedBy {
ZeroDegrees,
NinetyDegrees,
}

#[cfg(test)]
mod tests {
use std::collections::HashMap;
Expand Down
47 changes: 47 additions & 0 deletions src/packed_location.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
use crate::width_height_depth::WidthHeightDepth;

/// Describes how and where an incoming rectangle was packed into the target bins
#[derive(Debug, PartialEq)]
pub struct PackedLocation {
x: u32,
y: u32,
z: u32,
whd: WidthHeightDepth,
x_axis_rotation: RotatedBy,
y_axis_rotation: RotatedBy,
z_axis_rotation: RotatedBy,
}

#[derive(Debug, PartialEq)]
#[allow(unused)] // TODO: Implement rotations
enum RotatedBy {
ZeroDegrees,
NinetyDegrees,
}

#[allow(missing_docs)]
impl PackedLocation {
pub fn x(&self) -> u32 {
self.x
}

pub fn y(&self) -> u32 {
self.y
}

pub fn z(&self) -> u32 {
self.z
}

pub fn width(&self) -> u32 {
self.whd.width
}

pub fn height(&self) -> u32 {
self.whd.height
}

pub fn depth(&self) -> u32 {
self.whd.depth
}
}

0 comments on commit 361f699

Please sign in to comment.