diff options
Diffstat (limited to 'graphics/src')
-rw-r--r-- | graphics/src/widget/canvas/frame.rs | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/graphics/src/widget/canvas/frame.rs b/graphics/src/widget/canvas/frame.rs index 4873e7fb..01b27451 100644 --- a/graphics/src/widget/canvas/frame.rs +++ b/graphics/src/widget/canvas/frame.rs @@ -244,6 +244,30 @@ impl Frame { self.transforms.current = self.transforms.previous.pop().unwrap(); } + /// TODO... + #[inline] + pub fn with_clip( + &mut self, + translation: Vector, + size: Size, + f: impl FnOnce(&mut Frame), + ) { + let mut frame = Frame::new(self.size()); + frame.translate(translation); + + f(&mut frame); + + self.primitives.push(Primitive::Clip { + bounds: Rectangle { + x: translation.x, + y: translation.y, + width: size.width, + height: size.height, + }, + content: Box::new(frame.into_geometry().into_primitive()), + }); + } + /// Applies a translation to the current transform of the [`Frame`]. #[inline] pub fn translate(&mut self, translation: Vector) { |