From fac481c0a5ffcab74262b7c3fe228ae8784d2a3e Mon Sep 17 00:00:00 2001 From: Greg Shuflin Date: Mon, 20 Sep 2021 23:56:43 -0700 Subject: [PATCH] Fix stroke --- iced-tetris/src/main.rs | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) 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()]