diff --git a/iced-tetris/src/main.rs b/iced-tetris/src/main.rs index dd0bedf..237eabb 100644 --- a/iced-tetris/src/main.rs +++ b/iced-tetris/src/main.rs @@ -1,4 +1,4 @@ -use iced::widget::canvas::{self, Path}; +use iced::widget::canvas::{self, Path, Stroke}; use iced::{ executor, keyboard, time, Application, Color, Command, Element, Length, Point, Rectangle, Settings, Size, Subscription, @@ -129,8 +129,20 @@ impl<'a> canvas::Program for Tetris { ); let block = Path::rectangle(point, block_size); let color = tetronimo.color(); - let color = Color::from_rgb8(color.0, color.1, color.2); - frame.fill(&block, color); + let fill_color = Color::from_rgb8(color.0, color.1, color.2); + frame.fill(&block, fill_color); + + let stroke_color = Color::from_rgb8( + color.0.checked_sub(20).unwrap_or(0), + color.1.checked_sub(20).unwrap_or(0), + color.2.checked_sub(20).unwrap_or(0), + ); + let stroke = Stroke { + width: 3.0, + color: stroke_color, + ..Stroke::default() + }; + frame.stroke(&block, stroke); } vec![background, frame.into_geometry()]