pub struct PixelSize {
pub width: i32,
pub height: i32,
}Expand description
Represents a size in device pixels.
Conversions from floating point saturate at the i32 range (NaN becomes 0).
Fields§
§width: i32The width.
height: i32The height.
Implementations§
Source§impl PixelSize
impl PixelSize
Sourcepub const fn new(width: i32, height: i32) -> Self
pub const fn new(width: i32, height: i32) -> Self
Initializes a new instance of the PixelSize structure.
Sourcepub fn aspect_ratio(&self) -> f64
pub fn aspect_ratio(&self) -> f64
Gets the aspect ratio of the size.
Sourcepub fn parse(s: &str) -> Result<Self, FormatError>
pub fn parse(s: &str) -> Result<Self, FormatError>
Parses a PixelSize string ("width, height").
Sourcepub fn try_parse(source: &str) -> Option<Self>
pub fn try_parse(source: &str) -> Option<Self>
Tries to parse a PixelSize string. Every kind of malformed input yields
None (the reference implementation raises a format error for some of them,
e.g. trailing tokens; there is no such distinction here).
Sourcepub const fn equals(&self, other: PixelSize) -> bool
pub const fn equals(&self, other: PixelSize) -> bool
Returns a boolean indicating whether the size is equal to the other given size.
Sourcepub const fn with_width(&self, width: i32) -> PixelSize
pub const fn with_width(&self, width: i32) -> PixelSize
Returns a new PixelSize with the same height and the specified width.
Sourcepub const fn with_height(&self, height: i32) -> PixelSize
pub const fn with_height(&self, height: i32) -> PixelSize
Returns a new PixelSize with the same width and the specified height.
Sourcepub fn to_size_vector(&self, scale: Vector) -> Size
pub fn to_size_vector(&self, scale: Vector) -> Size
Sourcepub fn to_size_with_dpi(&self, dpi: f64) -> Size
pub fn to_size_with_dpi(&self, dpi: f64) -> Size
Sourcepub fn to_size_with_dpi_vector(&self, dpi: Vector) -> Size
pub fn to_size_with_dpi_vector(&self, dpi: Vector) -> Size
Sourcepub fn from_size(size: Size, scale: f64) -> PixelSize
pub fn from_size(size: Size, scale: f64) -> PixelSize
Converts a Size to device pixels using the specified scaling factor,
rounding up.
Sourcepub fn from_size_ceiling(size: Size, scale: f64) -> PixelSize
pub fn from_size_ceiling(size: Size, scale: f64) -> PixelSize
A tolerant ceiling variant of from_size: a value within
1e-6 of an integer snaps to that integer, otherwise it is rounded up.
This prevents floating-point artifacts (e.g. 24.0000001) from producing an
extra pixel while still guaranteeing the pixel size covers the logical size.
Sourcepub fn from_size_vector(size: Size, scale: Vector) -> PixelSize
pub fn from_size_vector(size: Size, scale: Vector) -> PixelSize
Converts a Size to device pixels using the specified per-axis scaling
factor, rounding up.
Trait Implementations§
impl Copy for PixelSize
impl Eq for PixelSize
Source§impl MarkupTyped for PixelSize
impl MarkupTyped for PixelSize
Source§const MARKUP: &'static MarkupType
const MARKUP: &'static MarkupType
impl StructuralPartialEq for PixelSize
Auto Trait Implementations§
impl Freeze for PixelSize
impl RefUnwindSafe for PixelSize
impl Send for PixelSize
impl Sync for PixelSize
impl Unpin for PixelSize
impl UnsafeUnpin for PixelSize
impl UnwindSafe for PixelSize
Blanket Implementations§
Source§impl<T> AnyValue for Twhere
T: PartialEq + 'static,
impl<T> AnyValue for Twhere
T: PartialEq + 'static,
fn any_value_as_any(&self) -> &(dyn Any + 'static)
fn any_value_eq(&self, other: &(dyn AnyValue + 'static)) -> bool
fn any_value_type_name(&self) -> &'static str
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> ClassDefaults for Twhere
T: ?Sized,
impl<T> ClassDefaults for Twhere
T: ?Sized,
Source§fn static_constructor()
fn static_constructor()
affects_render, metadata
overrides). Read more