mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 10:47:11 -06:00
Merge pull request #4132 from Silvertree2010/fix/4109-stroked-paths-issue
Reset stroke weight to zero when the stroke colour is removed
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user