pub struct BoxStyle { /* private fields */ }Expand description
Set of blocks used to draw 3D boxes of any size, allowing corners and edges to have different blocks than faces and the interior.
Boxes have walls exactly 1 cube thick. Thus, a BoxStyle has 64 parts (blocks),
identified by the BoxPart type:
- interior volume,
- 6 faces,
- 12 edges,
- 8 corners, and
- 38 more parts for the case where the box to be drawn is only one block thick, thus requiring a block to be both faces simultaneously on one or more axes.
Each part of the box can be absent (None), which means that when drawn, the existing
block in that place is unchanged.
This can be considered a 3-dimensional analogue of the “9-patch image” concept, or as a voxel “tile set” (but one with no “inside corner” pieces).
BoxStyle’s data is kept behind a reference-counted pointer,
so BoxStyle is small and cheap to clone.
Implementations§
Source§impl BoxStyle
impl BoxStyle
Sourcepub fn from_fn<F>(f: F) -> BoxStyle
pub fn from_fn<F>(f: F) -> BoxStyle
Construct a BoxStyle by asking a function for each part.
The order of calls to the function is unspecified and subject to change.
Sourcepub fn from_nine_and_thin(multiblock: &Block) -> BoxStyle
pub fn from_nine_and_thin(multiblock: &Block) -> BoxStyle
Construct a BoxStyle from a 2D 4×4×1 multiblock whose components on each axis
are in the order [lower, middle, upper, lower & upper]; that is, this layout
of blocks:
┊ ┏━━━━━━━━━━━━━┓┏━━━┓
3 ┃ ┃┃ ┃
┊ ┗━━━━━━━━━━━━━┛┗━━━┛
┃ ┏━━━━━━━━━━━━━┓┏━━━┓
2 ┃ ┃┃ ┃
┃ ┃ ┃┃ ┃
┊ ┃ ┃┃ ┃
1 ┃ ┃┃ ┃
┊ ┃ ┃┃ ┃
┃ ┃ ┃┃ ┃
0 ┃ ┃┃ ┃
┃ ┗━━━━━━━━━━━━━┛┗━━━┛
━━0━━┈┈1┈┈━━2━━┈┈3┈┈The resolution is one quarter of the input. The Z axis is filled with all the same blocks. TODO: Make it sensitive to the input dimensions as defined by multiblock metadata instead.
Sourcepub fn from_composited_corner_and_edge(
corner_block: Block,
line_section_block: Block,
) -> BoxStyle
pub fn from_composited_corner_and_edge( corner_block: Block, line_section_block: Block, ) -> BoxStyle
Construct a BoxStyle made up of one type of corner block and one type of edge
block.
corner_blockwill be composited with the line sections at all eight corners of the box. It should be oriented as thelower_boundscorner of the box; the other seven corners will be mirrored across the relevant axis.line_section_blockshould be a block which is a line segment at the origin and extending in the+Zdirection. It should be symmetric about the X-Y=0 plane, and will be rotated and mirrored to make the other forms.
Sourcepub fn with(self, part: BoxPart, block: Option<Block>) -> BoxStyle
pub fn with(self, part: BoxPart, block: Option<Block>) -> BoxStyle
Replace a single part of this and return the modified style.
Sourcepub fn map(self, block_fn: impl FnMut(BoxPart, Block) -> Block) -> BoxStyle
pub fn map(self, block_fn: impl FnMut(BoxPart, Block) -> Block) -> BoxStyle
Applies the given function to every block present in this. Does not affect absent blocks.
Sourcepub fn create_box(&self, bounds: GridAab) -> SpaceTransaction
pub fn create_box(&self, bounds: GridAab) -> SpaceTransaction
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BoxStyle
impl RefUnwindSafe for BoxStyle
impl Send for BoxStyle
impl Sync for BoxStyle
impl Unpin for BoxStyle
impl UnwindSafe for BoxStyle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
Source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
Source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more