Struct zng_layout::unit::Factor
source · #[repr(transparent)]pub struct Factor(pub f32);
Expand description
Normalized multiplication factor.
Values of this type are normalized to generally be in between 0.0
and 1.0
to indicate a fraction
of a unit. However, values are not clamped to this range, Factor(2.0)
is a valid value and so are
negative values.
§Equality
Equality is determined to within 0.00001
epsilon.
Tuple Fields§
§0: f32
Implementations§
source§impl Factor
impl Factor
sourcepub fn clamp_range(self) -> Factor
pub fn clamp_range(self) -> Factor
Clamp factor to [0.0..=1.0]
range.
sourcepub fn clamp(self, min: impl Into<Factor>, max: impl Into<Factor>) -> Factor
pub fn clamp(self, min: impl Into<Factor>, max: impl Into<Factor>) -> Factor
Returns self
if min <= self <= max
, returns min
if self < min
or returns max
if self > max
.
sourcepub fn pct(self) -> FactorPercent
pub fn pct(self) -> FactorPercent
Factor as percentage.
Trait Implementations§
source§impl AddAssign for Factor
impl AddAssign for Factor
source§fn add_assign(&mut self, rhs: Factor)
fn add_assign(&mut self, rhs: Factor)
Performs the
+=
operation. Read moresource§impl<'de> Deserialize<'de> for Factor
impl<'de> Deserialize<'de> for Factor
source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Factor, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Factor, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Div<Factor> for FactorPercent
impl Div<Factor> for FactorPercent
source§type Output = FactorPercent
type Output = FactorPercent
The resulting type after applying the
/
operator.source§impl DivAssign<Factor> for Dip
impl DivAssign<Factor> for Dip
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Factor2d
impl DivAssign<Factor> for Factor2d
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for FactorPercent
impl DivAssign<Factor> for FactorPercent
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Point2D<Dip, Dip>
impl DivAssign<Factor> for Point2D<Dip, Dip>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Point2D<Px, Px>
impl DivAssign<Factor> for Point2D<Px, Px>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Point2D<f32, Px>
impl DivAssign<Factor> for Point2D<f32, Px>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Px
impl DivAssign<Factor> for Px
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Rect<Dip, Dip>
impl DivAssign<Factor> for Rect<Dip, Dip>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Rect<Px, Px>
impl DivAssign<Factor> for Rect<Px, Px>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Size2D<Dip, Dip>
impl DivAssign<Factor> for Size2D<Dip, Dip>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Size2D<Px, Px>
impl DivAssign<Factor> for Size2D<Px, Px>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Size2D<f32, Px>
impl DivAssign<Factor> for Size2D<f32, Px>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Vector2D<Dip, Dip>
impl DivAssign<Factor> for Vector2D<Dip, Dip>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign<Factor> for Vector2D<Px, Px>
impl DivAssign<Factor> for Vector2D<Px, Px>
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl DivAssign for Factor
impl DivAssign for Factor
source§fn div_assign(&mut self, rhs: Factor)
fn div_assign(&mut self, rhs: Factor)
Performs the
/=
operation. Read moresource§impl From<Factor> for FactorPercent
impl From<Factor> for FactorPercent
source§fn from(value: Factor) -> FactorPercent
fn from(value: Factor) -> FactorPercent
Converts to this type from the input type.
source§impl From<Factor> for GridSpacing
impl From<Factor> for GridSpacing
source§impl From<Factor> for RgbaComponent
impl From<Factor> for RgbaComponent
Color channel value is in the [0..=1] range.
source§fn from(f: Factor) -> RgbaComponent
fn from(f: Factor) -> RgbaComponent
Converts to this type from the input type.
source§impl From<Factor> for SideOffsets
impl From<Factor> for SideOffsets
source§impl From<Factor> for Vector
impl From<Factor> for Vector
source§fn from(norm: Factor) -> Self
fn from(norm: Factor) -> Self
Conversion to Length::Factor
then to vector.
source§impl From<FactorPercent> for Factor
impl From<FactorPercent> for Factor
source§fn from(value: FactorPercent) -> Factor
fn from(value: FactorPercent) -> Factor
Converts to this type from the input type.
source§impl IntoVar<EasingTime> for Factor
impl IntoVar<EasingTime> for Factor
source§fn into_var(self) -> <Factor as IntoVar<EasingTime>>::Var
fn into_var(self) -> <Factor as IntoVar<EasingTime>>::Var
Converts the source value into a var.
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
Converts into
BoxedVar<T>
. Read moresource§impl IntoVar<Factor> for FactorPercent
impl IntoVar<Factor> for FactorPercent
source§impl IntoVar<FactorPercent> for Factor
impl IntoVar<FactorPercent> for Factor
source§fn into_var(self) -> <Factor as IntoVar<FactorPercent>>::Var
fn into_var(self) -> <Factor as IntoVar<FactorPercent>>::Var
Converts the source value into a var.
source§fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
fn into_boxed_var(self) -> Box<dyn VarBoxed<T>>where
Self: Sized,
Converts into
BoxedVar<T>
. Read moresource§impl IntoVar<FactorSideOffsets> for Factor
impl IntoVar<FactorSideOffsets> for Factor
source§impl IntoVar<GridSpacing> for Factor
impl IntoVar<GridSpacing> for Factor
source§impl IntoVar<SideOffsets> for Factor
impl IntoVar<SideOffsets> for Factor
source§impl Mul<Factor> for FactorPercent
impl Mul<Factor> for FactorPercent
source§type Output = FactorPercent
type Output = FactorPercent
The resulting type after applying the
*
operator.source§impl MulAssign<Factor> for Dip
impl MulAssign<Factor> for Dip
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Factor2d
impl MulAssign<Factor> for Factor2d
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for FactorPercent
impl MulAssign<Factor> for FactorPercent
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Point2D<Dip, Dip>
impl MulAssign<Factor> for Point2D<Dip, Dip>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Point2D<Px, Px>
impl MulAssign<Factor> for Point2D<Px, Px>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Point2D<f32, Px>
impl MulAssign<Factor> for Point2D<f32, Px>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Px
impl MulAssign<Factor> for Px
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Rect<Dip, Dip>
impl MulAssign<Factor> for Rect<Dip, Dip>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Rect<Px, Px>
impl MulAssign<Factor> for Rect<Px, Px>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Size2D<Dip, Dip>
impl MulAssign<Factor> for Size2D<Dip, Dip>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Size2D<Px, Px>
impl MulAssign<Factor> for Size2D<Px, Px>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Size2D<f32, Px>
impl MulAssign<Factor> for Size2D<f32, Px>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Vector2D<Dip, Dip>
impl MulAssign<Factor> for Vector2D<Dip, Dip>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign<Factor> for Vector2D<Px, Px>
impl MulAssign<Factor> for Vector2D<Px, Px>
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl MulAssign for Factor
impl MulAssign for Factor
source§fn mul_assign(&mut self, rhs: Factor)
fn mul_assign(&mut self, rhs: Factor)
Performs the
*=
operation. Read moresource§impl PartialOrd for Factor
impl PartialOrd for Factor
source§impl Serialize for Factor
impl Serialize for Factor
source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl SubAssign for Factor
impl SubAssign for Factor
source§fn sub_assign(&mut self, rhs: Factor)
fn sub_assign(&mut self, rhs: Factor)
Performs the
-=
operation. Read moresource§impl Transitionable for Factor
impl Transitionable for Factor
impl Copy for Factor
impl IntoValue<Align> for Factor
impl IntoValue<EasingTime> for Factor
impl IntoValue<Factor> for FactorPercent
impl IntoValue<Factor2d> for Factor
impl IntoValue<FactorPercent> for Factor
impl IntoValue<FactorSideOffsets> for Factor
impl IntoValue<GridSpacing> for Factor
impl IntoValue<Length> for Factor
impl IntoValue<Point> for Factor
impl IntoValue<SideOffsets> for Factor
impl IntoValue<Size> for Factor
impl IntoValue<Vector> for Factor
impl Pod for Factor
Auto Trait Implementations§
impl Freeze for Factor
impl RefUnwindSafe for Factor
impl Send for Factor
impl Sync for Factor
impl Unpin for Factor
impl UnwindSafe for Factor
Blanket Implementations§
source§impl<T> AnyVarValue for Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Access to mut
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
Clone the value.
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
Clone the value into a new boxed
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
Gets if
self
equals other
.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<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
impl<T> CheckedBitPattern for Twhere
T: AnyBitPattern,
§type Bits = T
type Bits = T
Self
must have the same layout as the specified Bits
except for
the possible invalid bit patterns being checked during
is_valid_bit_pattern
.§fn is_valid_bit_pattern(_bits: &T) -> bool
fn is_valid_bit_pattern(_bits: &T) -> bool
If this function returns true, then it must be valid to reinterpret
bits
as &Self
.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 more