Closed elbaro closed 2 years ago
use piet::{kurbo::Rect, Color, RenderContext}; fn main() { let mut device = piet_common::Device::new().unwrap(); let mut bitmap: piet_common::BitmapTarget = device.bitmap_target(400, 400, 1.0).unwrap(); let mut rc = bitmap.render_context(); rc.clip(Rect::new(100.0, 100.0, 200.0, 200.0)); rc.clear(None, Color::AQUA); bitmap.save_to_file("test.png").unwrap(); }
RenderContext::clear() does not respect RenderContext::clip() and clears the entire target.
RenderContext::clear()
RenderContext::clip()
This is not a bug; see the docs (including the note) for more explanation.
For an alternative that respects clipping, you can use fill, passing a rectangle the same size as your drawing context. :)
fill
RenderContext::clear()
does not respectRenderContext::clip()
and clears the entire target.