Fix zero-width strokes still affecting the feathering color of boxes (#5485)

This commit is contained in:
Emil Ernerfeldt 2024-12-16 16:54:18 +01:00 committed by GitHub
parent e8029178b6
commit 045ed41efc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 5 deletions

View File

@ -161,6 +161,10 @@ where
impl From<Stroke> for PathStroke { impl From<Stroke> for PathStroke {
fn from(value: Stroke) -> Self { fn from(value: Stroke) -> Self {
if value.is_empty() {
// Important, since we use the stroke color when doing feathering of the fill!
Self::NONE
} else {
Self { Self {
width: value.width, width: value.width,
color: ColorMode::Solid(value.color), color: ColorMode::Solid(value.color),
@ -168,3 +172,4 @@ impl From<Stroke> for PathStroke {
} }
} }
} }
}

View File

@ -502,6 +502,8 @@ impl Path {
/// Calling this may reverse the vertices in the path if they are wrong winding order. /// Calling this may reverse the vertices in the path if they are wrong winding order.
/// ///
/// The preferred winding order is clockwise. /// 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) { pub fn fill(&mut self, feathering: f32, color: Color32, stroke: &PathStroke, out: &mut Mesh) {
fill_closed_path(feathering, &mut self.0, color, stroke, out); fill_closed_path(feathering, &mut self.0, color, stroke, out);
} }
@ -918,7 +920,7 @@ fn stroke_path(
) { ) {
let n = path.len() as u32; let n = path.len() as u32;
if stroke.width <= 0.0 || stroke.color == ColorMode::TRANSPARENT || n < 2 { if stroke.is_empty() || n < 2 {
return; return;
} }