Reset stroke weight to zero when the stroke colour is removed

Fixes #4109

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
NetterSilver
2026-10-26 08:18:32 +07:00
committed by bflatastic
co-authored by Claude Haiku 5.5
parent aa7f6bb31d
commit 6259448c39
2 changed files with 19 additions and 0 deletions
+7
View File
@@ -504,6 +504,13 @@ fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool) -> Result<V
let new_paint = keep_pattern_xf(&paint, p, n.appearance.paint_at(index, fill));
let placed = place_paint(&new_paint, p, item_paint_bounds(n, index, fill));
n.appearance.set_paint_at(index, fill, placed);
if !fill
&& paint.is_none()
&& let Some(stroke) = n.appearance.stroke_at_mut(index)
{
// A stroke without paint has no weight; painting it again restores the 1 pt default.
stroke.width = 0.0;
}
Ok(())
},
|d, changed| {
@@ -116,3 +116,15 @@ fn appearance_panel_stroke_colour_restores_an_unpainted_zero_width_stroke() {
s.execute("appearance.setItem", &json!({"index": 1, "color": "#0000ff"})).unwrap();
assert_eq!(width(&s, id), 0.0, "a painted stroke keeps an explicit zero width");
}
#[test]
fn removing_the_stroke_colour_resets_the_weight_to_zero() {
let (mut s, id) = fixture();
s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap();
s.execute("stroke.set", &json!({"weight": 10})).unwrap();
s.execute("paint.setStroke", &json!({"none": true})).unwrap();
assert_eq!(width(&s, id), 0.0);
assert_eq!(s.shown_stroke().unwrap().width, 0.0);
s.execute("paint.setStroke", &json!({"color": "#ee2222"})).unwrap();
assert_eq!(width(&s, id), 1.0);
}