Trait kludgine::Clipped

source ·
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§

source

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

source

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§

source

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.

Object Safety§

This trait is not object safe.

Implementors§