From 7552b7437bbd31a6b8fb184a29001900ef994adb Mon Sep 17 00:00:00 2001 From: Emil Ernerfeldt Date: Mon, 16 Dec 2024 16:46:07 +0100 Subject: [PATCH] Fix zero-width strokes still affecting the feathering color of boxes --- crates/epaint/src/stroke.rs | 13 +++++++++---- crates/epaint/src/tessellator.rs | 4 +++- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/crates/epaint/src/stroke.rs b/crates/epaint/src/stroke.rs index 399a602c259..63412cdc013 100644 --- a/crates/epaint/src/stroke.rs +++ b/crates/epaint/src/stroke.rs @@ -161,10 +161,15 @@ where impl From for PathStroke { fn from(value: Stroke) -> Self { - Self { - width: value.width, - color: ColorMode::Solid(value.color), - kind: StrokeKind::default(), + if value.is_empty() { + // Important, since we use the stroke color when doing feathering of the fill! + Self::NONE + } else { + Self { + width: value.width, + color: ColorMode::Solid(value.color), + kind: StrokeKind::default(), + } } } } diff --git a/crates/epaint/src/tessellator.rs b/crates/epaint/src/tessellator.rs index 0594c8a2aa2..ebd22f55303 100644 --- a/crates/epaint/src/tessellator.rs +++ b/crates/epaint/src/tessellator.rs @@ -502,6 +502,8 @@ impl Path { /// Calling this may reverse the vertices in the path if they are wrong winding order. /// /// The preferred winding order is clockwise. + /// + /// The stroke colors is used for color-correct feathering. pub fn fill(&mut self, feathering: f32, color: Color32, stroke: &PathStroke, out: &mut Mesh) { fill_closed_path(feathering, &mut self.0, color, stroke, out); } @@ -918,7 +920,7 @@ fn stroke_path( ) { let n = path.len() as u32; - if stroke.width <= 0.0 || stroke.color == ColorMode::TRANSPARENT || n < 2 { + if stroke.is_empty() || n < 2 { return; }