From d56c5d1229bd1addf9a61deab438105b44e34ac9 Mon Sep 17 00:00:00 2001 From: Yu Chen Date: Tue, 3 Jan 2023 18:34:45 +0800 Subject: [PATCH] update move_rect Fn --- os/src/gui/paint.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/os/src/gui/paint.rs b/os/src/gui/paint.rs index 0cdf60d3..b96d187b 100644 --- a/os/src/gui/paint.rs +++ b/os/src/gui/paint.rs @@ -28,7 +28,14 @@ impl DrawingBoard { .draw(&mut self.graphics) .ok(); } + fn unpaint(&mut self) { + Rectangle::with_center(self.latest_pos, Size::new(RECT_SIZE, RECT_SIZE)) + .into_styled(PrimitiveStyle::with_stroke(Rgb888::BLACK, 1)) + .draw(&mut self.graphics) + .ok(); + } pub fn move_rect(&mut self, dx: i32, dy: i32) { + self.unpaint(); self.latest_pos.x += dx; self.latest_pos.y += dy; self.paint();