FerroUI/ docs

Search guides, controls, Rust APIs, and XAML.

    GitHub ↗

    PixelSize

    struct · ferroui-base · v0.5.0

    struct PixelSize
    

    Represents a size in device pixels.

    Conversions from floating point saturate at the i32 range (NaN becomes 0).

    View source

    Members

    width

    width: i32
    

    The width.

    Source

    height

    height: i32
    

    The height.

    Source

    EMPTY

    const EMPTY: PixelSize
    

    A size representing zero.

    Source

    new

    const fn new(width: i32, height: i32) -> Self
    

    Initializes a new instance of the PixelSize structure.

    Source

    aspect_ratio

    fn aspect_ratio(self: &Self) -> f64
    

    Gets the aspect ratio of the size.

    Source

    parse

    fn parse(s: &str) -> Result<Self, FormatError>
    

    Parses a PixelSize string ("width, height").

    Source

    try_parse

    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).

    Source

    equals

    const fn equals(self: &Self, other: PixelSize) -> bool
    

    Returns a boolean indicating whether the size is equal to the other given size.

    Source

    with_width

    const fn with_width(self: &Self, width: i32) -> PixelSize
    

    Returns a new PixelSize with the same height and the specified width.

    Source

    with_height

    const fn with_height(self: &Self, height: i32) -> PixelSize
    

    Returns a new PixelSize with the same width and the specified height.

    Source

    to_size

    fn to_size(self: &Self, scale: f64) -> Size
    

    Converts the PixelSize to a device-independent Size using the specified scaling factor.

    Source

    to_size_vector

    fn to_size_vector(self: &Self, scale: Vector) -> Size
    

    Converts the PixelSize to a device-independent Size using the specified per-axis scaling factor.

    Source

    to_size_with_dpi

    fn to_size_with_dpi(self: &Self, dpi: f64) -> Size
    

    Converts the PixelSize to a device-independent Size using the specified dots per inch (DPI).

    Source

    to_size_with_dpi_vector

    fn to_size_with_dpi_vector(self: &Self, dpi: Vector) -> Size
    

    Converts the PixelSize to a device-independent Size using the specified per-axis dots per inch (DPI).

    Source

    from_size

    fn from_size(size: Size, scale: f64) -> PixelSize
    

    Converts a Size to device pixels using the specified scaling factor, rounding up.

    Source

    from_size_ceiling

    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.

    Source

    from_size_vector

    fn from_size_vector(size: Size, scale: Vector) -> PixelSize
    

    Converts a Size to device pixels using the specified per-axis scaling factor, rounding up.

    Source

    from_size_with_dpi

    fn from_size_with_dpi(size: Size, dpi: f64) -> PixelSize
    

    Converts a Size to device pixels using the specified dots per inch (DPI).

    Source

    from_size_with_dpi_vector

    fn from_size_with_dpi_vector(size: Size, dpi: Vector) -> PixelSize
    

    Converts a Size to device pixels using the specified per-axis dots per inch (DPI).

    Source

    Trait implementations

    Availability

    Extracted for aarch64-apple-darwin. Cargo features are listed in the crate index.