VectorCraft: An open-source, vector art tool written by scratch in pure Rust
Reset stroke weight to zero when the stroke colour is removed
NetterSilver6259448c3912
diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rsindex 2c527a820..f6e555892 100644--- a/crates/engine/src/cmd/paint.rs+++ b/crates/engine/src/cmd/paint.rs@@ -504,6 +504,13 @@ fn apply_paint(s: &mut Session, p: &Value, paint: Paint, fill: bool) -> Result<Vlet 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| {diff --git a/crates/engine/tests/it/stroke_visibility.rs b/crates/engine/tests/it/stroke_visibility.rsindex 8f9ecdff0..310770c39 100644--- a/crates/engine/tests/it/stroke_visibility.rs+++ b/crates/engine/tests/it/stroke_visibility.rs@@ -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);+}