[]Struct piet_common::kurbo::Size

pub struct Size {
    pub width: f64,
    pub height: f64,
}

A 2d size.

Fields

width: f64

The width.

height: f64

The height.

Methods

impl Size

pub const ZERO: Size

A size with zero width or height.

pub const fn new(width: f64, height: f64) -> Size

Create a new Size with the provided width and height.

pub fn clamp(self, min: Size, max: Size) -> Size

Returns a new size bounded by min and max.

Examples

use kurbo::Size;

let this = Size::new(0., 100.);
let min = Size::new(10., 10.,);
let max = Size::new(50., 50.);
assert_eq!(this.clamp(min, max), Size::new(10., 50.))

pub fn to_vec2(self) -> Vec2

Convert this size into a Vec2, with width mapped to x and height mapped to y.

pub fn round(self) -> Size

A new Size, with each of width and height rounded to the nearest integer value.

Trait Implementations

impl From<(f64, f64)> for Size

impl PartialEq<Size> for Size

impl Display for Size

impl Copy for Size

impl Default for Size

impl Debug for Size

impl Clone for Size

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

Auto Trait Implementations

impl Sync for Size

impl Send for Size

impl Unpin for Size

impl RefUnwindSafe for Size

impl UnwindSafe for Size

Blanket Implementations

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> RoundFrom<T> for T[src]

impl<T, U> RoundInto<U> for T where
    U: RoundFrom<T>, 
[src]