Skip to main content

Px

Struct Px 

Source
#[repr(transparent)]
pub struct Px(pub f32);
Expand description

Physical pixels. Paint/input/raster boundaries take this.

NOTE: Compose has no Px scalar type (px are bare Float); this newtype exists so f32 return/param positions are unambiguous in repose.

Tuple Fields§

§0: f32

Implementations§

Source§

impl Px

Source

pub const ZERO: Px

Source

pub const INFINITY: Px

Source

pub const UNSPECIFIED: Px

Source

pub const fn value(self) -> f32

Source

pub fn is_specified(self) -> bool

Source

pub fn is_finite(self) -> bool

Source

pub fn abs(self) -> Px

Absolute value (mirrors f32::abs).

Source

pub fn min(self, other: Px) -> Px

Minimum of two Pxs (mirrors f32::min).

Source

pub fn max(self, other: Px) -> Px

Maximum of two Pxs (mirrors f32::max).

Source

pub fn to_dp(self) -> Dp

Convert to dp with the ambient Density * UiScale.

Source

pub fn to_dp_with_scale(self, scale: f32) -> Dp

Convert to dp with an explicit scale.

Source

pub fn to_sp(self) -> Sp

Convert a px value to Sp (px → dp → sp).

Trait Implementations§

Source§

impl Add for Px

Source§

type Output = Px

The resulting type after applying the + operator.
Source§

fn add(self, other: Px) -> Px

Performs the + operation. Read more
Source§

impl Clone for Px

Source§

fn clone(&self) -> Px

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Copy for Px

Source§

impl Debug for Px

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Px

Source§

fn default() -> Px

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

impl Display for Px

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Div for Px

Source§

type Output = f32

The resulting type after applying the / operator.
Source§

fn div(self, other: Px) -> f32

Performs the / operation. Read more
Source§

impl Div<f32> for Px

Source§

type Output = Px

The resulting type after applying the / operator.
Source§

fn div(self, other: f32) -> Px

Performs the / operation. Read more
Source§

impl From<Px> for f32

Source§

fn from(v: Px) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Px

Source§

fn from(v: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Px

Source§

fn from(v: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Px

Source§

fn from(v: i32) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Px

Source§

fn from(v: u32) -> Self

Converts to this type from the input type.
Source§

impl Hash for Px

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl Mul<Px> for f32

Source§

type Output = Px

The resulting type after applying the * operator.
Source§

fn mul(self, other: Px) -> Px

Performs the * operation. Read more
Source§

impl Mul<f32> for Px

Source§

type Output = Px

The resulting type after applying the * operator.
Source§

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

Performs the * operation. Read more
Source§

impl Neg for Px

Source§

type Output = Px

The resulting type after applying the - operator.
Source§

fn neg(self) -> Px

Performs the unary - operation. Read more
Source§

impl PartialEq for Px

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl PartialOrd for Px

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

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

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

impl StructuralPartialEq for Px

Source§

impl Sub for Px

Source§

type Output = Px

The resulting type after applying the - operator.
Source§

fn sub(self, other: Px) -> Px

Performs the - operation. Read more

Auto Trait Implementations§

§

impl Freeze for Px

§

impl RefUnwindSafe for Px

§

impl Send for Px

§

impl Sync for Px

§

impl Unpin for Px

§

impl UnsafeUnpin for Px

§

impl UnwindSafe for Px

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
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
Source§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.