pub trait Clipped: Sized + Clipped {
// Required methods
fn push_clip(&mut self, clip: Rect<UPx>);
fn pop_clip(&mut self);
// Provided method
fn clipped_to(&mut self, clip: Rect<UPx>) -> ClipGuard<'_, Self> { ... }
}
Expand description
A graphics context that has been clipped.
Required Methods§
sourcefn push_clip(&mut self, clip: Rect<UPx>)
fn push_clip(&mut self, clip: Rect<UPx>)
Pushes a new clipping state to the clipping stack.
This function causes this type to act as if the origin of the context is
clip.origin
, and the size of the context is clip.size
. This means
that rendering at 0,0 will actually render at the effective clip rect’s
origin.
clip
is relative to the current clip rect and cannot extend the
current clipping rectangle.
To restore the clipping rect to the state it was before this function
was called, use Clipped::pop_clip()
.
sourcefn pop_clip(&mut self)
fn pop_clip(&mut self)
Restores the clipping rect to the previous state before the last call to
Clipped::push_clip()
.
§Panics
This function will panic if it is called more times than
Clipped::push_clip()
.
Provided Methods§
sourcefn clipped_to(&mut self, clip: Rect<UPx>) -> ClipGuard<'_, Self>
fn clipped_to(&mut self, clip: Rect<UPx>) -> ClipGuard<'_, Self>
Returns a ClipGuard
that causes all drawing operations to be offset
and clipped to clip
until it is dropped.
This function causes this type to act as if the origin of the context is
clip.origin
, and the size of the context is clip.size
. This means
that rendering at 0,0 will actually render at the effective clip rect’s
origin.
clip
is relative to the current clip rect and cannot extend the
current clipping rectangle.