mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-17 05:35:52 +00:00
Graphs: Default Fill and Stroke on an axis line stores the default rows for its kind
Default Fill and Stroke on an axis line, tick mark or radar ring that already shows the default paint now stores the default fill and stroke rows for every line of its kind, so a stroke the kind kept from another line no longer comes back when the graph is drawn again. The object opacity and blend mode the kind keeps stay as they are.
This commit is contained in:
@@ -6753,6 +6753,23 @@ fn default_fill_and_stroke_and_fill_to_stroke_on_an_axis_line_are_kept() {
|
||||
assert!(redrawn_line_looks(&mut s, id).iter().all(|l| l.0 == "#0000ff"), "the blue fill on the stroke");
|
||||
}
|
||||
|
||||
/// Default Fill and Stroke on an axis line that already shows the default paint is kept for every axis line, in place of
|
||||
/// the stroke the kind keeps from another line, and leaves the object opacity the kind keeps from another line.
|
||||
#[test]
|
||||
fn default_fill_and_stroke_on_an_axis_line_that_shows_it_is_kept() {
|
||||
let mut s = Session::new();
|
||||
s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap();
|
||||
let id = graph(&mut s, "column");
|
||||
let lines = line_nodes(&s, id);
|
||||
s.execute("paint.default", &json!({"ids": [lines[0].id.0]})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"ids": [lines[1].id.0], "color": "#ff0000"})).unwrap();
|
||||
s.execute("object.setProps", &json!({"ids": [lines[1].id.0], "opacity": 50})).unwrap();
|
||||
s.execute("paint.default", &json!({"ids": [lines[0].id.0]})).unwrap();
|
||||
let looks = redrawn_line_looks(&mut s, id);
|
||||
assert!(looks.iter().all(|l| (l.0.as_str(), l.1) == ("#000000", 1.0)), "the 1 pt black default stroke: {looks:?}");
|
||||
assert!(looks.iter().all(|l| (l.2 - 0.5).abs() < 1e-6), "the kind keeps its 50% opacity: {looks:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pie_names_and_wedge_labels_keep_their_style() {
|
||||
let mut s = Session::new();
|
||||
|
||||
@@ -1020,7 +1020,10 @@ fn default_paint(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
}
|
||||
let kept = super::appearance::capture_series_writes(&before, d, &ids, (true, true), (true, true), false, false);
|
||||
let labels = super::graph::capture_label_changes(&before, d, &ids, false, None);
|
||||
Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels))
|
||||
// The graph keeps the default fill and stroke rows for every line of a kind it reached, also when one already
|
||||
// showed them; the object opacity the kind keeps stays.
|
||||
let lines = super::graph::capture_line_fill_stroke_rows(d, &ids);
|
||||
Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels || lines))
|
||||
})?;
|
||||
}
|
||||
super::newart::reset(s);
|
||||
|
||||
+2
-1
@@ -899,7 +899,8 @@ line's rows even when the line already showed them. The other commands, an `appe
|
||||
included, store only what they change on a line's rows; the kind keeps its other attributes, also when the line still
|
||||
shows different ones until the graph is drawn again. An `appearance.copyFrom` that does not apply the object's
|
||||
transparency, and `graphicStyle.apply` with `add`, leave the object opacity and blend mode a kind keeps as they are,
|
||||
also when the line still shows other ones. Rows equal to a kind's default stroke (0.5 pt black for axis lines and tick
|
||||
also when the line still shows other ones. `paint.default` stores the default fill and stroke rows for a line's kind
|
||||
even when the line already showed them, and leaves the object opacity and blend mode the kind keeps. Rows equal to a kind's default stroke (0.5 pt black for axis lines and tick
|
||||
marks, 0.25 pt gray for rings) are not saved. When one command reaches several lines of one kind, the frontmost line in
|
||||
paint order sets what the kind keeps, whatever order the `ids` are in. A gradient is stored without its placement, and
|
||||
each line fits it when the graph is drawn again. The graph saves the rows as `axisRows` and `ringRows` in its label
|
||||
|
||||
Reference in New Issue
Block a user