Skip to main content

Bounds

Struct Bounds 

Source
#[repr(C)]
pub struct Bounds<T: Clone + Debug + Default + PartialEq> { pub origin: Point<T>, pub size: Size<T>, }
Expand description

A rectangle, defined by its top left corner and its size.

The rectangle covers the area from origin to the bottom right corner. Bounds::contains treats the left and top edges as inside and the right and bottom edges as outside, so adjacent bounds don’t overlap. Elements receive their bounds in logical pixels when they are laid out and painted. See layout and style.

§Examples

use gpui::{Bounds, Point, Size};

let bounds = Bounds::new(Point { x: 10, y: 20 }, Size { width: 30, height: 40 });
assert_eq!(bounds.right(), 40);
assert_eq!(bounds.bottom(), 60);

Fields§

§origin: Point<T>

The top left corner of the rectangle.

§size: Size<T>

The width and height of the rectangle.

Implementations§

Source§

impl Bounds<Pixels>

Source

pub fn centered( display_id: Option<DisplayId>, size: Size<Pixels>, cx: &App, ) -> Self

Returns bounds of size centered on a display.

Uses the display with display_id, or the primary display if display_id is None or doesn’t match a connected display. If there is no display at all, the bounds start at (0, 0).

§Examples
app.read(|cx| {
    // The test platform has one 1920 by 1080 display.
    let window = Bounds::centered(None, size(px(800.), px(600.)), cx);
    assert_eq!(window, bounds(point(px(560.), px(240.)), size(px(800.), px(600.))));
});
Source

pub fn maximized(display_id: Option<DisplayId>, cx: &App) -> Self

Returns bounds that cover a display.

Uses the display with display_id, or the primary display if display_id is None or doesn’t match a connected display. If there is no display at all, returns 1024 by 768 pixels at (0, 0).

§Examples
app.read(|cx| {
    // The test platform has one 1920 by 1080 display.
    let screen = Bounds::maximized(None, cx);
    assert_eq!(screen, bounds(point(px(0.), px(0.)), size(px(1920.), px(1080.))));
});
Source§

impl<T> Bounds<T>
where T: Clone + Debug + Default + PartialEq,

Source

pub fn new(origin: Point<T>, size: Size<T>) -> Self

Creates bounds from an origin and a size. Same as bounds.

§Examples
let b = Bounds::new(Point { x: 0, y: 0 }, Size { width: 10, height: 20 });
assert_eq!(b.size.height, 20);
Source§

impl<T> Bounds<T>
where T: Sub<Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn from_corners(top_left: Point<T>, bottom_right: Point<T>) -> Self

Creates bounds from its top left and bottom right corners.

The size is bottom_right - top_left and is not clamped. A bottom_right above or to the left of top_left gives a negative width or height, which Bounds::is_empty reports as empty.

§Examples
let top_left = Point { x: 0, y: 0 };
let bottom_right = Point { x: 10, y: 10 };
let bounds = Bounds::from_corners(top_left, bottom_right);

assert_eq!(bounds.origin, top_left);
assert_eq!(bounds.size.width, 10);
assert_eq!(bounds.size.height, 10);
Source§

impl<T> Bounds<T>
where T: Sub<Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn from_anchor_and_size( corner: Anchor, origin: Point<T>, size: Size<T>, ) -> Bounds<T>

Creates bounds of size whose corner sits at origin.

Use this to place a box by one of its corners or edge centers: the box’s top left corner is origin minus the offset of corner within the size.

§Examples
let b = Bounds::from_anchor_and_size(
    Anchor::BottomRight,
    point(px(10.), px(10.)),
    size(px(4.), px(2.)),
);
assert_eq!(b.origin, point(px(6.), px(8.)));
assert_eq!(b.bottom_right(), point(px(10.), px(10.)));
Source§

impl<T> Bounds<T>
where T: Sub<T, Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn centered_at(center: Point<T>, size: Size<T>) -> Self

Creates bounds of size centered on center.

§Examples
let b = Bounds::centered_at(point(px(50.), px(50.)), size(px(20.), px(10.)));
assert_eq!(b.origin, point(px(40.), px(45.)));
assert_eq!(b.center(), point(px(50.), px(50.)));
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn top_center(&self) -> Point<T>

Returns the midpoint of the top edge.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.top_center(), Point { x: 5, y: 0 });
Source

pub fn bottom_center(&self) -> Point<T>

Returns the midpoint of the bottom edge.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.bottom_center(), Point { x: 5, y: 20 });
Source

pub fn left_center(&self) -> Point<T>

Returns the midpoint of the left edge.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.left_center(), Point { x: 0, y: 10 });
Source

pub fn right_center(&self) -> Point<T>

Returns the midpoint of the right edge.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.right_center(), Point { x: 10, y: 10 });
Source§

impl<T> Bounds<T>
where T: PartialOrd + Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn intersects(&self, other: &Bounds<T>) -> bool

Returns true if this rectangle and other share some area.

Bounds that only touch along an edge don’t intersect.

§Examples
let bounds1 = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let bounds2 = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 10, height: 10 },
};
let bounds3 = Bounds {
    origin: Point { x: 20, y: 20 },
    size: Size { width: 10, height: 10 },
};

assert_eq!(bounds1.intersects(&bounds2), true);
assert_eq!(bounds1.intersects(&bounds3), false);
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn center(&self) -> Point<T>

Returns the center point of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.center(), Point { x: 5, y: 10 });
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn half_perimeter(&self) -> T

Returns the width plus the height.

The perimeter of the bounds is twice this value.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.half_perimeter(), 30);
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn dilate(&self, amount: T) -> Bounds<T>

Returns the bounds grown by amount on every side.

The origin moves by -amount and the width and height grow by twice amount, so the center stays in place. A negative amount shrinks the bounds. Use Bounds::inset to shrink by a positive amount.

§Examples
let bounds = Bounds {
    origin: Point { x: 10, y: 10 },
    size: Size { width: 10, height: 10 },
};
assert_eq!(bounds.dilate(5), Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 20, height: 20 },
});
Source

pub fn extend(&self, amount: Edges<T>) -> Bounds<T>

Returns the bounds grown by a different amount on each side.

Each side of amount moves the matching edge outward: top grows upward, right grows to the right, and so on.

§Examples
let bounds = Bounds {
    origin: Point { x: 10, y: 10 },
    size: Size { width: 10, height: 10 },
};
let amount = Edges { top: 1, right: 2, bottom: 3, left: 4 };
assert_eq!(bounds.extend(amount), Bounds {
    origin: Point { x: 6, y: 9 },
    size: Size { width: 16, height: 14 },
});
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Neg<Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn inset(&self, amount: T) -> Self

Returns the bounds shrunk by amount on every side.

Same as Bounds::dilate with amount negated.

§Examples
let bounds = Bounds {
    origin: Point { x: 0.0, y: 0.0 },
    size: Size { width: 10.0, height: 10.0 },
};
assert_eq!(bounds.inset(2.0), Bounds {
    origin: Point { x: 2.0, y: 2.0 },
    size: Size { width: 6.0, height: 6.0 },
});
Source§

impl<T: PartialOrd + Add<T, Output = T> + Sub<Output = T> + Clone + Debug + Default + PartialEq> Bounds<T>

Source

pub fn intersect(&self, other: &Self) -> Self

Returns the area that this rectangle and other share.

If the bounds don’t overlap, the result has zero width or zero height. Its origin is then the larger of the two origins in each coordinate, which may lie outside both bounds.

§Examples
let bounds1 = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let bounds2 = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 10, height: 10 },
};
assert_eq!(bounds1.intersect(&bounds2), Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 5, height: 5 },
});
Source

pub fn union(&self, other: &Self) -> Self

Returns the smallest bounds that contain both rectangles.

§Examples
let bounds1 = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
let bounds2 = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 15, height: 15 },
};
assert_eq!(bounds1.union(&bounds2), Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 20, height: 20 },
});
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn space_within(&self, outer: &Self) -> Edges<T>

Returns the distance from each edge of this rectangle to the matching edge of outer.

A positive value means this rectangle lies inside outer on that side. A negative value means it extends past outer.

§Examples
let outer = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 100, height: 100 },
};
let inner = Bounds {
    origin: Point { x: 10, y: 20 },
    size: Size { width: 30, height: 40 },
};
assert_eq!(inner.space_within(&outer), Edges { top: 20, right: 60, bottom: 40, left: 10 });
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source

pub fn top(&self) -> T

Returns the y coordinate of the top edge.

Source

pub fn bottom(&self) -> T

Returns the y coordinate of the bottom edge, which is outside the bounds.

Source

pub fn left(&self) -> T

Returns the x coordinate of the left edge.

Source

pub fn right(&self) -> T

Returns the x coordinate of the right edge, which is outside the bounds.

Source

pub fn top_right(&self) -> Point<T>

Returns the top right corner point of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.top_right(), Point { x: 10, y: 0 });
Source

pub fn bottom_right(&self) -> Point<T>

Returns the bottom right corner point of the bounds.

This point is outside the bounds: Bounds::contains returns false for it.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.bottom_right(), Point { x: 10, y: 20 });
Source

pub fn bottom_left(&self) -> Point<T>

Returns the bottom left corner point of the bounds.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.bottom_left(), Point { x: 0, y: 20 });
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Half + Clone + Debug + Default + PartialEq,

Source

pub fn corner(&self, corner: Anchor) -> Point<T>

Returns the point at corner on this rectangle.

Accepts the four corners and the four edge midpoints.

§Examples
use gpui::{Anchor, Bounds, Point, Size};
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 20 },
};
assert_eq!(bounds.corner(Anchor::BottomLeft), Point { x: 0, y: 20 });
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + PartialOrd + Clone + Debug + Default + PartialEq,

Source

pub fn contains(&self, point: &Point<T>) -> bool

Returns true if point lies inside the bounds.

The left and top edges are inside, and the right and bottom edges are outside. A point at (right, y) or (x, bottom) returns false. With integer coordinates, a rectangle of width 10 at x = 0 contains x = 0 through x = 9 only.

§Examples
let bounds = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 10 },
};
assert!(bounds.contains(&Point { x: 5, y: 5 }));
assert!(bounds.contains(&Point { x: 0, y: 0 }));
assert!(!bounds.contains(&Point { x: 10, y: 5 }));
assert!(!bounds.contains(&Point { x: 15, y: 15 }));
Source

pub fn is_contained_within(&self, other: &Self) -> bool

Returns true if this rectangle lies entirely inside other.

Checks that the top left and bottom right corners of this rectangle are inside other, using the rules of Bounds::contains.

§Examples
let outer = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 20, height: 20 },
};
let inner = Bounds {
    origin: Point { x: 5, y: 5 },
    size: Size { width: 10, height: 10 },
};
let overlapping = Bounds {
    origin: Point { x: 15, y: 15 },
    size: Size { width: 10, height: 10 },
};

assert!(inner.is_contained_within(&outer));
assert!(!overlapping.is_contained_within(&outer));
Source

pub fn map<U>(&self, f: impl Fn(T) -> U) -> Bounds<U>
where U: Clone + Debug + Default + PartialEq,

Returns bounds with f applied to the origin and the size, converting T to U.

§Examples
let bounds = Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 10.0, height: 20.0 },
};
let new_bounds = bounds.map(|value| value as f64 * 1.5);

assert_eq!(new_bounds, Bounds {
    origin: Point { x: 15.0, y: 15.0 },
    size: Size { width: 15.0, height: 30.0 },
});
Source

pub fn map_origin(self, f: impl Fn(T) -> T) -> Bounds<T>

Returns bounds with f applied to each coordinate of the origin. The size is unchanged.

§Examples
let bounds = Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 10.0, height: 20.0 },
};
let new_bounds = bounds.map_origin(|value| value * 1.5);

assert_eq!(new_bounds, Bounds {
    origin: Point { x: 15.0, y: 15.0 },
    size: Size { width: 10.0, height: 20.0 },
});
Source

pub fn map_size(self, f: impl Fn(T) -> T) -> Bounds<T>

Returns bounds with f applied to the width and the height. The origin is unchanged.

§Examples
let bounds = Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 10.0, height: 20.0 },
};
let new_bounds = bounds.map_size(|value| value * 1.5);

assert_eq!(new_bounds, Bounds {
    origin: Point { x: 10.0, y: 10.0 },
    size: Size { width: 15.0, height: 30.0 },
});
Source§

impl<T> Bounds<T>
where T: Add<T, Output = T> + Sub<T, Output = T> + PartialOrd + Clone + Debug + Default + PartialEq,

Source

pub fn localize(&self, point: &Point<T>) -> Option<Point<T>>

Returns point relative to the origin of this rectangle, or None if point is outside.

Use it to turn a window position into a position inside an element. The result follows the rules of Bounds::contains.

§Examples
let panel = bounds(point(px(100.), px(50.)), size(px(200.), px(100.)));
assert_eq!(panel.localize(&point(px(110.), px(60.))), Some(point(px(10.), px(10.))));
assert_eq!(panel.localize(&point(px(10.), px(10.))), None);
Source§

impl<T: PartialOrd + Clone + Debug + Default + PartialEq> Bounds<T>

Source

pub fn is_empty(&self) -> bool

Returns true if the width or the height is zero or less.

§Examples
let empty = Bounds {
    origin: Point { x: 0, y: 0 },
    size: Size { width: 10, height: 0 },
};
assert!(empty.is_empty());
Source§

impl Bounds<Pixels>

Source

pub fn scale(&self, factor: f32) -> Bounds<ScaledPixels>

Multiplies the origin and the size by factor, producing ScaledPixels.

Pass the display’s scale factor to convert logical bounds into the scaled space. The values aren’t rounded: use Bounds::to_device_pixels to get whole device pixels.

§Examples
let bounds = Bounds {
    origin: Point { x: Pixels::from(10.0), y: Pixels::from(20.0) },
    size: Size { width: Pixels::from(30.0), height: Pixels::from(40.0) },
};
let scaled_bounds = bounds.scale(2.0);
assert_eq!(scaled_bounds, Bounds {
    origin: Point {
        x: ScaledPixels::from(20.0),
        y: ScaledPixels::from(40.0),
    },
    size: Size {
        width: ScaledPixels::from(60.0),
        height: ScaledPixels::from(80.0)
    },
});
Source

pub fn to_device_pixels(self, factor: f32) -> Bounds<DevicePixels>

Converts these logical bounds to device pixels.

Multiplies each coordinate and size by factor, rounding each to the nearest whole device pixel. The origin and the size are rounded separately, so the bottom right corner can differ by one pixel from rounding the corner directly.

§Examples
let logical = bounds(point(px(10.), px(20.)), size(px(30.), px(40.)));
assert_eq!(
    logical.to_device_pixels(1.5),
    bounds(point(DevicePixels(15), DevicePixels(30)), size(DevicePixels(45), DevicePixels(60))),
);
Source§

impl Bounds<DevicePixels>

Source

pub fn to_pixels(self, scale_factor: f32) -> Bounds<Pixels>

Converts these device pixel bounds to logical pixels by dividing by scale_factor.

§Examples
let device = bounds(point(DevicePixels(200), DevicePixels(100)), size(DevicePixels(400), DevicePixels(300)));
assert_eq!(device.to_pixels(2.), bounds(point(px(100.), px(50.)), size(px(200.), px(150.))));

Trait Implementations§

Source§

impl<T> Add<Point<T>> for Bounds<T>
where T: Add<T, Output = T> + Clone + Debug + Default + PartialEq,

Source§

type Output = Bounds<T>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Point<T>) -> Self

Performs the + operation. Read more
Source§

impl<T: Clone + Clone + Debug + Default + PartialEq> Clone for Bounds<T>

Source§

fn clone(&self) -> Self

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<T: Copy + Clone + Debug + Default + PartialEq> Copy for Bounds<T>

Source§

impl<T: Debug + Clone + Debug + Default + PartialEq> Debug for Bounds<T>

Source§

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

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

impl<T: Default + Clone + Debug + Default + PartialEq> Default for Bounds<T>

Source§

fn default() -> Self

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

impl<'de, T> Deserialize<'de> for Bounds<T>
where T: Deserialize<'de> + Clone + Debug + Default + PartialEq,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Clone + Debug + Default + PartialEq + Display + Add<T, Output = T>> Display for Bounds<T>

Source§

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

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

impl<T, S> Div<S> for Bounds<T>
where Size<T>: Div<S, Output = Size<T>>, T: Div<S, Output = T> + Clone + Debug + Default + PartialEq, S: Clone,

Source§

type Output = Bounds<T>

The resulting type after applying the / operator.
Source§

fn div(self, rhs: S) -> Self

Performs the / operation. Read more
Source§

impl<T: Eq + Clone + Debug + Default + PartialEq> Eq for Bounds<T>

Source§

impl<T: Clone + Debug + Default + PartialEq> From<BoundsRefinement<T>> for Bounds<T>
where Option<Point<T>>: Clone, Option<Size<T>>: Clone,

Source§

fn from(value: BoundsRefinement<T>) -> Self

Converts to this type from the input type.
Source§

impl<T: Hash + Clone + Debug + Default + PartialEq> Hash for Bounds<T>

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<T: IsZero + Clone + Debug + Default + PartialEq> IsZero for Bounds<T>

Source§

fn is_zero(&self) -> bool

Returns true if this value is zero.
Source§

impl<T: Lerp + Clone + Debug + Default + PartialEq> Lerp for Bounds<T>

Source§

fn lerp(&self, to: &Self, delta: f32) -> Self

Returns the value delta of the way from self to to.
Source§

impl<T, Rhs> Mul<Rhs> for Bounds<T>
where T: Mul<Rhs, Output = Rhs> + Clone + Debug + Default + PartialEq, Point<T>: Mul<Rhs, Output = Point<Rhs>>, Rhs: Clone + Debug + Default + PartialEq,

Source§

type Output = Bounds<Rhs>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Rhs) -> Self::Output

Performs the * operation. Read more
Source§

impl<T, S> MulAssign<S> for Bounds<T>
where T: Mul<S, Output = T> + Clone + Debug + Default + PartialEq, S: Clone,

Source§

fn mul_assign(&mut self, rhs: S)

Performs the *= operation. Read more
Source§

impl<T: PartialEq + Clone + Debug + Default + PartialEq> PartialEq for Bounds<T>

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl<T: Clone + Debug + Default + PartialEq> Refineable for Bounds<T>
where Option<Point<T>>: Clone, Option<Size<T>>: Clone,

Source§

type Refinement = BoundsRefinement<T>

Source§

fn refine(&mut self, refinement: &Self::Refinement)

Applies the given refinement to this instance, modifying it in place. Read more
Source§

fn refined(self, refinement: Self::Refinement) -> Self

Returns a new instance with the refinement applied, equivalent to cloning self and calling refine on it.
Source§

fn is_superset_of(&self, refinement: &Self::Refinement) -> bool

Returns true if this instance would contain all values from the refinement. Read more
Source§

fn subtract(&self, refinement: &Self::Refinement) -> Self::Refinement

Returns a refinement that represents the difference between this instance and the given refinement. Read more
Source§

fn from_cascade(cascade: &Cascade<Self>) -> Self
where Self: Sized + Default,

Creates an instance from a cascade by merging all refinements atop the default value.
Source§

impl<T> Serialize for Bounds<T>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq + Clone + Debug + Default + PartialEq> StructuralPartialEq for Bounds<T>

Source§

impl<T> Sub<Point<T>> for Bounds<T>
where T: Sub<T, Output = T> + Clone + Debug + Default + PartialEq,

Source§

type Output = Bounds<T>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: Point<T>) -> Self

Performs the - operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Bounds<T>
where Point<T>: Freeze, Size<T>: Freeze,

§

impl<T> RefUnwindSafe for Bounds<T>

§

impl<T> Send for Bounds<T>
where Point<T>: Send, Size<T>: Send,

§

impl<T> Sync for Bounds<T>
where Point<T>: Sync, Size<T>: Sync,

§

impl<T> Unpin for Bounds<T>
where Point<T>: Unpin, Size<T>: Unpin,

§

impl<T> UnsafeUnpin for Bounds<T>

§

impl<T> UnwindSafe for Bounds<T>

Blanket Implementations§

Source§

impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
where T: Real + Zero + Arithmetics + Clone, Swp: WhitePoint<T>, Dwp: WhitePoint<T>, D: AdaptFrom<S, Swp, Dwp, T>,

Source§

fn adapt_into_using<M>(self, method: M) -> D
where M: TransformMatrix<T>,

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the specified method.
Source§

fn adapt_into(self) -> D

👎Deprecated since 0.7.7:

replaced by palette::chromatic_adaptation::AdaptIntoUnclamped

Convert the source color to the destination color using the bradford method by default.
Source§

impl<T, C> AdaptIntoUnclamped<T> for C
where T: AdaptFromUnclamped<C>,

Source§

type Scalar = <T as AdaptFromUnclamped<C>>::Scalar

The number type that’s used as the color’s components.
Source§

fn adapt_into_unclamped_with<M>(self) -> T

Adapt a color of type Self into a color of type T, using the custom matrix M. Read more
Source§

fn adapt_into_unclamped(self) -> T
where Bradford: LmsToXyz<Self::Scalar> + XyzToLms<Self::Scalar>,

Adapt a color of type Self into a color of type T, using the Bradford matrix. Read more
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, C> ArraysFrom<C> for T
where C: IntoArrays<T>,

Source§

fn arrays_from(colors: C) -> T

Cast a collection of colors into a collection of arrays.
Source§

impl<T, C> ArraysInto<C> for T
where C: FromArrays<T>,

Source§

fn arrays_into(self) -> C

Cast this collection of arrays into a collection of colors.
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<WpParam, T, U> Cam16IntoUnclamped<WpParam, T> for U
where T: FromCam16Unclamped<WpParam, U>,

Source§

type Scalar = <T as FromCam16Unclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn cam16_into_unclamped( self, parameters: BakedParameters<WpParam, <U as Cam16IntoUnclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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, C> ComponentsFrom<C> for T
where C: IntoComponents<T>,

Source§

fn components_from(colors: C) -> T

Cast a collection of colors into a collection of color components.
Source§

impl<T, C> ComponentsInto<C> for T

Source§

fn components_into(self) -> C

Cast this collection of color components into a collection of colors. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromAngle<T> for T

Source§

fn from_angle(angle: T) -> T

Performs a conversion from angle.
Source§

impl<T, U> FromStimulus<U> for T
where U: IntoStimulus<T>,

Source§

fn from_stimulus(other: U) -> T

Converts other into Self, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Instrument for T

Source§

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

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

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, U> IntoAngle<U> for T
where U: FromAngle<T>,

Source§

fn into_angle(self) -> U

Performs a conversion into T.
Source§

impl<WpParam, T, U> IntoCam16Unclamped<WpParam, T> for U
where T: Cam16FromUnclamped<WpParam, U>,

Source§

type Scalar = <T as Cam16FromUnclamped<WpParam, U>>::Scalar

The number type that’s used in parameters when converting.
Source§

fn into_cam16_unclamped( self, parameters: BakedParameters<WpParam, <U as IntoCam16Unclamped<WpParam, T>>::Scalar>, ) -> T

Converts self into C, using the provided parameters.
Source§

impl<T, U> IntoColor<U> for T
where U: FromColor<T>,

Source§

fn into_color(self) -> U

Convert into T with values clamped to the color defined bounds Read more
Source§

impl<T, U> IntoColorUnclamped<U> for T
where U: FromColorUnclamped<T>,

Source§

fn into_color_unclamped(self) -> U

Convert into T. The resulting color might be invalid in its color space Read more
Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoStimulus<T> for T

Source§

fn into_stimulus(self) -> T

Converts self into T, while performing the appropriate scaling, rounding and clamping.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Serialize for T
where T: Serialize + ?Sized,

Source§

fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>

Source§

fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>

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

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, C> TryComponentsInto<C> for T
where C: TryFromComponents<T>,

Source§

type Error = <C as TryFromComponents<T>>::Error

The error for when try_into_colors fails to cast.
Source§

fn try_components_into(self) -> Result<C, <T as TryComponentsInto<C>>::Error>

Try to cast this collection of color components into a collection of colors. 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.
Source§

impl<T, U> TryIntoColor<U> for T
where U: TryFromColor<T>,

Source§

fn try_into_color(self) -> Result<U, OutOfBounds<U>>

Convert into T, returning ok if the color is inside of its defined range, otherwise an OutOfBounds error is returned which contains the unclamped color. Read more
Source§

impl<C, U> UintsFrom<C> for U
where C: IntoUints<U>,

Source§

fn uints_from(colors: C) -> U

Cast a collection of colors into a collection of unsigned integers.
Source§

impl<C, U> UintsInto<C> for U
where C: FromUints<U>,

Source§

fn uints_into(self) -> C

Cast this collection of unsigned integers into a collection of colors.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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