Enum vizia::style::LengthValue

pub enum LengthValue {
Show 15 variants Px(f32), In(f32), Cm(f32), Mm(f32), Q(f32), Pt(f32), Pc(f32), Em(f32), Ex(f32), Ch(f32), Rem(f32), Vw(f32), Vh(f32), Vmin(f32), Vmax(f32),
}
Expand description

A length value.

Variants§

§

Px(f32)

Pixels.

A pixel is the smallest viewable unit. The length of a pixel depends on the used device.

§

In(f32)

Inches.

An inch is roughly 96 pixels or about 2.54cm.

§

Cm(f32)

Centimeters.

A centimeter is roughly 37.8 pixels.

§

Mm(f32)

Millimeters.

A millimeter is roughly 3.78 pixels or 1/10th of a centimeter.

§

Q(f32)

Quarter.

A quarter of a millimeter is roughly 1/40th of 1cm.

§

Pt(f32)

Points.

A point is roughly 1.3333 pixels or 1/72th of an inch.

§

Pc(f32)

Picas.

A pica is roughly 16 pixels or 1/6th of an inch.

§

Em(f32)

em.

An em is equal to the computed font-size property of the element on which it is used.

§

Ex(f32)

ex.

An ex is the height of the letter x of the font, or 0.5em.

§

Ch(f32)

Character unit.

A character unit is defined as the width of the character 0 of the font.

§

Rem(f32)

Root em.

An rem is equal to the computed font-size property of the root of the document. For websites the root of the document is the <html> element.

§

Vw(f32)

View width.

A length equal to 1% of the width of the viewport.

§

Vh(f32)

View height.

A length equal to 1% of the height of the viewport.

§

Vmin(f32)

Viewport minimum.

A viewport minimum is equal to 1% of the viewport’s smallest dimension. For example 1vmin is equal to 6px on a browser window that is 1200px wide and 600px high.

§

Vmax(f32)

Viewport maximum.

A viewport maximum is equal to 1% of the viewport’s largest dimension. For example 1vmax is equal to 12px on a browser window that is 1200px wide and 600px high.

Implementations§

§

impl LengthValue

pub const PX_PER_IN: f32 = 96f32

The amount of pixels per inch.

pub const PX_PER_CM: f32 = 37.7952766f32

The amount of pixels per centimeter.

pub const PX_PER_MM: f32 = 3.77952766f32

The amount of pixels per millimeter.

pub const PX_PER_Q: f32 = 0.944881916f32

The amount of pixels per quarter-millimeter.

pub const PX_PER_PT: f32 = 1.33333337f32

The amount of pixels per point.

pub const PX_PER_PC: f32 = 16f32

The amount of pixels per pica.

pub fn to_px(&self) -> Option<f32>

Returns the amount of pixels of the length if calculateable.

pub fn to_unit_value(&self) -> (f32, &str)

Trait Implementations§

§

impl Clone for LengthValue

§

fn clone(&self) -> LengthValue

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for LengthValue

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for LengthValue

§

fn default() -> LengthValue

Returns the “default value” for a type. Read more
§

impl From<LengthValue> for LengthOrPercentage

§

fn from(value: LengthValue) -> LengthOrPercentage

Converts to this type from the input type.
§

impl Mul<f32> for LengthValue

§

type Output = LengthValue

The resulting type after applying the * operator.
§

fn mul(self, other: f32) -> LengthValue

Performs the * operation. Read more
§

impl<'i> Parse<'i> for LengthValue

§

fn parse<'t>( input: &mut Parser<'i, 't> ) -> Result<LengthValue, ParseError<'i, CustomParseError<'i>>>

§

impl PartialEq<f32> for LengthValue

§

fn eq(&self, other: &f32) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialEq for LengthValue

§

fn eq(&self, other: &LengthValue) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd<f32> for LengthValue

§

fn partial_cmp(&self, other: &f32) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl PartialOrd for LengthValue

§

fn partial_cmp(&self, other: &LengthValue) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Res<LengthValue> for LengthValue

source§

fn set_or_bind<F>(self, cx: &mut Context, entity: Entity, closure: F)
where Self: Sized, F: 'static + Clone + Fn(&mut Context, Self),

source§

impl ResGet<LengthValue> for LengthValue

source§

fn get_ref<'a>( &self, _: &impl DataContext ) -> Option<LensValue<'_, LengthValue>>

source§

fn get(&self, _: &impl DataContext) -> LengthValue

§

impl TryAdd<LengthValue> for LengthValue

§

fn try_add(&self, other: &LengthValue) -> Option<LengthValue>

§

impl Copy for LengthValue

§

impl StructuralPartialEq for LengthValue

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast for T
where T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert 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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
§

impl<T> DowncastSync for T
where T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Sync + Send>

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more