#[repr(C)]pub struct Clip {
pub rect: Rect,
pub radius: [f32; 4],
}Expand description
The clip a node inherits: a rect, and the radii to round its corners by.
A node that clips (clip, scroll_x, scroll_y) and has a radius
rounds what it clips — the way CSS rounds overflow: hidden under a
border-radius — so the children of a rounded card stay inside its
corners instead of poking out of them. Nothing declares this: the radii
are the clipping node’s own.
One rounded rect cannot name the intersection of two, so nesting is
approximated by Clip::intersect, which says what it gives up.
Fields§
§rect: Rect§radius: [f32; 4]Clockwise from the top-left: [tl, tr, br, bl]. All zero = a plain
rect clip.
Implementations§
Source§impl Clip
impl Clip
Sourcepub fn intersect(&self, box_rect: Rect, box_radius: [f32; 4]) -> Clip
pub fn intersect(&self, box_rect: Rect, box_radius: [f32; 4]) -> Clip
This clip narrowed by a clipping node’s box and that node’s radii.
The rect is the plain intersection, as it has always been. The radii are decided per corner: a corner takes whichever of the two shapes rounds it more (the intersection of two rounded corners is the tighter one), and only while that corner of the result is still the same point as that corner of the shape it came from — a corner an ancestor’s straight edge has already cut away is square, which is what that ancestor made it.
The one case it approximates: an ancestor edge that cuts partway into a rounded corner moves that corner, so its radius drops to zero and a sliver at the very corner goes unclipped. A second clipper offset from the first, both rounded, is the shape that does it.
Trait Implementations§
impl Copy for Clip
impl StructuralPartialEq for Clip
Auto Trait Implementations§
impl Freeze for Clip
impl RefUnwindSafe for Clip
impl Send for Clip
impl Sync for Clip
impl Unpin for Clip
impl UnsafeUnpin for Clip
impl UnwindSafe for Clip
Blanket Implementations§
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.