pub struct RawDistancePixel(/* private fields */);Expand description
A raw pixel in a 2D image
This is either a single distance value or a description of a fill; both
cases are packed into an f32 (using NaN-boxing in the latter case).
The NaN-boxing is transparent to the user; for the curious, it is
implemented by splitting the mantissa into three components:
- Bit 0 indicates the sign of the fill (1 for inside, 0 for outside)
- Bits 1-9 indicate the depth at which evaluation terminated, which is useful for certain debug visualizations
- Bits 10-17 are a fixed bit pattern, which both ensures that the value is
treated as
NaNin the[empty, depth 0]case (rather than infinity) and distinguishes fromNaNvalues generated during normal evaluation
Implementations§
Source§impl RawDistancePixel
impl RawDistancePixel
Sourcepub fn inside(self) -> bool
pub fn inside(self) -> bool
Checks whether the pixel is inside or outside the model
Distances of exactly 0.0 and non-boxed NaN values are treated as
outside (i.e. returning false).
Sourcepub fn is_distance(self) -> bool
pub fn is_distance(self) -> bool
Checks whether this is a distance point sample
Sourcepub fn unpack(self) -> DistancePixel
pub fn unpack(self) -> DistancePixel
Unpacks into a DistancePixel
Sourcepub fn distance(self) -> Option<f32>
pub fn distance(self) -> Option<f32>
Returns the distance value if this is a DistancePixel::Value
Trait Implementations§
Source§impl Clone for RawDistancePixel
impl Clone for RawDistancePixel
impl Copy for RawDistancePixel
Source§impl Debug for RawDistancePixel
impl Debug for RawDistancePixel
Source§impl Default for RawDistancePixel
impl Default for RawDistancePixel
Source§impl From<DistancePixel> for RawDistancePixel
impl From<DistancePixel> for RawDistancePixel
Source§fn from(p: DistancePixel) -> Self
fn from(p: DistancePixel) -> Self
Converts to this type from the input type.
Source§impl From<f32> for RawDistancePixel
impl From<f32> for RawDistancePixel
Source§impl FromBytes for RawDistancePixel
impl FromBytes for RawDistancePixel
Source§impl FromZeros for RawDistancePixel
impl FromZeros for RawDistancePixel
impl Immutable for RawDistancePixel
Source§impl IntoBytes for RawDistancePixel
impl IntoBytes for RawDistancePixel
Source§fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
fn as_mut_bytes(&mut self) -> &mut [u8] ⓘwhere
Self: FromBytes,
Gets the bytes of this value mutably. Read more
Source§fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
fn write_to(&self, dst: &mut [u8]) -> Result<(), SizeError<&Self, &mut [u8]>>where
Self: Immutable,
Source§impl TryFromBytes for RawDistancePixelwhere
f32: TryFromBytes,
impl TryFromBytes for RawDistancePixelwhere
f32: TryFromBytes,
Source§fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_bytes(
source: &[u8],
) -> Result<Self, ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_prefix(
source: &[u8],
) -> Result<(Self, &[u8]), ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Source§fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
fn try_read_from_suffix(
source: &[u8],
) -> Result<(&[u8], Self), ConvertError<!, SizeError<&[u8], Self>, ValidityError<&[u8], Self>>>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for RawDistancePixel
impl RefUnwindSafe for RawDistancePixel
impl Send for RawDistancePixel
impl Sync for RawDistancePixel
impl Unpin for RawDistancePixel
impl UnsafeUnpin for RawDistancePixel
impl UnwindSafe for RawDistancePixel
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
Converts
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> ⓘ
Converts
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<A, T> Read<A, BecauseImmutable> for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.