mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-27 16:42:44 +00:00
Merge main into fix/fileinfo-control-characters-message
This commit is contained in:
@@ -163,6 +163,61 @@ fn reverse_path_direction_on_and_off_set_the_winding() {
|
||||
assert!(s.execute("path.reverse", &json!({})).is_err(), "nothing to reverse");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reverse_path_direction_turns_the_width_profile_and_pen_records_with_the_path() {
|
||||
use vectorcraft_doc::{AngleProfile, PressureProfile, WidthProfile};
|
||||
let mut s = session();
|
||||
let open =
|
||||
NodeId(run(&mut s, "path.create", json!({"anchors": [{"x": 0, "y": 50}, {"x": 40, "y": 50}, {"x": 100, "y": 50}]}))["id"].as_u64().unwrap());
|
||||
let closed = rect(&mut s, 10.0);
|
||||
let profile = WidthProfile { points: vec![(0.0, 0.2, 0.6), (0.3, 1.0, 0.4), (1.0, 0.5, 0.9)] };
|
||||
let pressure = PressureProfile { points: vec![(0.0, 0.1), (0.25, 0.9), (1.0, 0.4)] };
|
||||
let bearing = AngleProfile { points: vec![(0.0, 10.0), (0.6, 80.0), (1.0, 170.0)] };
|
||||
s.edit("set", |d, _| {
|
||||
for id in [open, closed] {
|
||||
let st = d.node_mut(id).unwrap().appearance.stroke_mut().unwrap();
|
||||
st.profile = Some(profile.clone());
|
||||
st.pressure = Some(pressure.clone());
|
||||
st.tilt = Some(pressure.clone());
|
||||
st.bearing = Some(bearing.clone());
|
||||
st.rotation = Some(bearing.clone());
|
||||
}
|
||||
Ok(())
|
||||
})
|
||||
.unwrap();
|
||||
// (anchor point, its fraction of the path's length) for each anchor.
|
||||
let along = |s: &Session, id: NodeId| {
|
||||
let sp = s.doc().unwrap().doc.node(id).unwrap().path_data().unwrap().subpaths[0].clone();
|
||||
let pos = sp.anchor_arc_positions();
|
||||
let total = *pos.last().unwrap();
|
||||
sp.anchors.iter().zip(pos).map(|(a, at)| (a.p, at / total)).collect::<Vec<_>>()
|
||||
};
|
||||
let before = [along(&s, open), along(&s, closed)];
|
||||
run(&mut s, "select.set", json!({"ids": [open.0, closed.0]}));
|
||||
assert_eq!(run(&mut s, "path.reverse", json!({}))["changed"], 2);
|
||||
for ((id, before), closed) in [open, closed].into_iter().zip(before).zip([false, true]) {
|
||||
let after = along(&s, id);
|
||||
let st = s.doc().unwrap().doc.node(id).unwrap().appearance.stroke().unwrap().clone();
|
||||
// Each anchor keeps the widths it had (its sides swapped, as the path runs the other way)
|
||||
// and what the pen recorded there. (A closed path's start is where its profile steps.) A
|
||||
// closed path now starts part way along a span of the width profile, which is resampled
|
||||
// there, so its smooth curve moves a little.
|
||||
let near = if closed { 0.02 } else { 1e-6 };
|
||||
for (p, t) in before.iter().filter(|(_, t)| !closed || *t > 0.0) {
|
||||
let u = after.iter().find(|(q, _)| q.distance(*p) < 1e-9).unwrap().1;
|
||||
let (l, r) = profile.at(*t);
|
||||
let (l2, r2) = st.profile.as_ref().unwrap().at(u);
|
||||
assert!((l - r2).abs() < near && (r - l2).abs() < near, "{id:?} at {p:?}: {:?} then {:?}", (l, r), (l2, r2));
|
||||
for got in [&st.pressure, &st.tilt] {
|
||||
assert!((pressure.at(*t) - got.as_ref().unwrap().at(u)).abs() < 1e-6, "{id:?} pressure at {p:?}");
|
||||
}
|
||||
for got in [&st.bearing, &st.rotation] {
|
||||
assert!((bearing.at(*t) - got.as_ref().unwrap().at(u)).abs() < 1e-6, "{id:?} bearing at {p:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn attributes_survive_a_native_round_trip() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -3878,6 +3878,37 @@ fn live_paint_bucket_alt_shift_gradient_samples_active_stroke_only() {
|
||||
assert!(matches!(node(&s, src).appearance.fill_paint(), Paint::Gradient(_)));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_paint_selection_double_click_selects_the_faces_no_stroked_edge_parts() {
|
||||
let mut s = session();
|
||||
let g = live(&mut s);
|
||||
// The edge between the middle and right faces draws no stroke.
|
||||
s.execute("livePaint.strokeEdge", &json!({"group": g.0, "point": [100.0, 50.0], "none": true})).unwrap();
|
||||
let v = ViewInfo::default();
|
||||
s.select_tool("livePaintSelection", v).unwrap();
|
||||
let gn = node(&s, g);
|
||||
let face = |x: f64| vectorcraft_tools::builder::face_at(&gn, Point::new(x, 50.0)).unwrap().id;
|
||||
let before = s.doc().unwrap().doc.clone();
|
||||
let double_click = |s: &mut Session, x: f64, m: Mods| {
|
||||
for kind in [PointerKind::Down, PointerKind::Up, PointerKind::Down, PointerKind::Up, PointerKind::DoubleClick] {
|
||||
s.pointer(&PointerEvent::new(kind, x, 50.0).with_mods(m), v).unwrap();
|
||||
}
|
||||
let mut ids = s.doc().unwrap().selection.objects.clone();
|
||||
ids.sort();
|
||||
ids
|
||||
};
|
||||
let sorted = |mut ids: Vec<NodeId>| {
|
||||
ids.sort();
|
||||
ids
|
||||
};
|
||||
assert_eq!(double_click(&mut s, 125.0, Mods::default()), sorted(vec![face(75.0), face(125.0)]));
|
||||
// The stroked edge at x = 50 parts the left face from the others.
|
||||
assert_eq!(double_click(&mut s, 25.0, Mods::default()), vec![face(25.0)]);
|
||||
// Shift-double-click adds the faces reached to the selection.
|
||||
assert_eq!(double_click(&mut s, 75.0, Mods { shift: true, ..Default::default() }), sorted(vec![face(25.0), face(75.0), face(125.0)]));
|
||||
assert_eq!(s.doc().unwrap().doc, before, "selecting changes no paint");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn live_paint_selection_marquee_selects_what_it_touches() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -16,7 +16,10 @@ use crate::*;
|
||||
/// Every test here reads or changes the process-wide proof view or colour settings: one at a time.
|
||||
/// Tests that switch the Color Settings away from the defaults live in `tests/color_settings.rs`
|
||||
/// (their own process): every colour shown or rendered goes through them, so no lock could cover
|
||||
/// all the tests that would see the change.
|
||||
/// all the tests that would see the change. A unit test that assigns its front document a profile
|
||||
/// other than the working space changes the active settings the same way until another document
|
||||
/// comes to the front: it starts with `crate::tests::in_own_process`, which runs it again in a
|
||||
/// child process.
|
||||
pub(crate) static GLOBAL: Mutex<()> = Mutex::new(());
|
||||
|
||||
fn session() -> Session {
|
||||
|
||||
@@ -5269,6 +5269,47 @@ fn pencil_extend_closes_within_400_pt_at_any_fidelity() {
|
||||
}
|
||||
}
|
||||
|
||||
/// `closed`, when given, decides whether a stroke continuing an open path closes it (the tools
|
||||
/// send it by Close Paths When Ends Are Within): false leaves it open even ending on the other end;
|
||||
/// true closes one ending 50 pt away with a straight segment back, the stroke's end kept, and one
|
||||
/// ending 2 pt away on the other end itself.
|
||||
#[test]
|
||||
fn pencil_extend_closes_as_closed_says() {
|
||||
let mut s = session();
|
||||
for (end, closed, ends_on_start) in [([0i32, 0], false, false), ([0, 50], true, false), ([0, 2], true, true)] {
|
||||
let l = line(&mut s, 0.0, 0.0, 200.0, 0.0);
|
||||
let points = json!([[200, 0], [200, 100], [100, 150], end]);
|
||||
let p = json!({"points": points, "fidelity": 1.5, "closed": closed, "extend": {"id": l.0}, "keepSelected": false});
|
||||
s.execute("path.freehand", &p).unwrap();
|
||||
let pd = path(&s, l);
|
||||
let sp = &pd.subpaths[0];
|
||||
assert_eq!(sp.closed, closed, "ending at {end:?}");
|
||||
if closed {
|
||||
let stroke_end = Point::new(f64::from(end[0]), f64::from(end[1]));
|
||||
let kept = sp.anchors.iter().any(|a| a.p.distance(stroke_end) < 1e-6);
|
||||
assert_eq!(kept, !ends_on_start, "ending at {end:?}: {:?}", sp.anchors);
|
||||
let on_start = sp.anchors.iter().filter(|a| a.p.distance(Point::new(0.0, 0.0)) < 1e-6).count();
|
||||
assert_eq!((sp.anchors[0].p, on_start), (Point::new(0.0, 0.0), 1), "ending at {end:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// A continued path closed from away from its other end closes with a straight segment, even when
|
||||
/// that end carries a handle the open path didn't use.
|
||||
#[test]
|
||||
fn pencil_extend_closes_far_away_with_a_straight_segment() {
|
||||
let mut s = session();
|
||||
let anchors = json!([{"x": 0, "y": 0, "in": [-40, 30]}, {"x": 200, "y": 0}]);
|
||||
let l = NodeId(s.execute("path.create", &json!({"anchors": anchors})).unwrap()["id"].as_u64().unwrap());
|
||||
let points = json!([[200, 0], [200, 100], [100, 150], [0, 50]]);
|
||||
let p = json!({"points": points, "fidelity": 1.5, "closed": true, "extend": {"id": l.0}, "keepSelected": false});
|
||||
s.execute("path.freehand", &p).unwrap();
|
||||
let sp = path(&s, l).subpaths[0].clone();
|
||||
assert!(sp.closed);
|
||||
let (first, last) = (sp.anchors[0], sp.anchors[sp.anchors.len() - 1]);
|
||||
assert_eq!((first.h_in, last.h_out), (first.p, last.p), "the closing segment has no handles: {:?}", sp.anchors);
|
||||
}
|
||||
|
||||
/// At Fidelity 0.01 short, one-point and repeated-point strokes still draw or are refused, never
|
||||
/// crash, and what they draw has finite anchors.
|
||||
#[test]
|
||||
|
||||
@@ -683,6 +683,9 @@ fn the_new_document_links_from_the_profile_file() {
|
||||
/// is a warning.
|
||||
#[test]
|
||||
fn a_profile_brings_the_color_profile_its_file_carries() {
|
||||
if !super::in_own_process("tests::newdoc::a_profile_brings_the_color_profile_its_file_carries") {
|
||||
return;
|
||||
}
|
||||
use vectorcraft_color::cms;
|
||||
let (mut s, dir) = with_profiles("icc");
|
||||
let builtin = cms::profiles().into_iter().find(|p| p.kind == cms::ProfileKind::Rgb && p.builtin && p.name != cms::SRGB).unwrap();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
//! as images of the effected object.
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::cms;
|
||||
use vectorcraft_doc::NodeKind;
|
||||
use vectorcraft_geom::Rect;
|
||||
use vectorcraft_render::{Rendered, Renderer};
|
||||
@@ -173,16 +174,22 @@ fn each_effect_changes_the_canvas_and_draws_the_same_twice() {
|
||||
EFFECTS.into_iter().chain(ARTISTIC).chain(BRUSH_STROKES).chain(DISTORT).chain(PIXELATE).chain(SKETCH).chain(TEXTURE).chain(VIDEO)
|
||||
{
|
||||
let (mut s, g) = striped();
|
||||
// Every color drawn goes through the process-wide color settings. A test that changes them
|
||||
// runs in a process of its own (`crate::tests::in_own_process`).
|
||||
let colors = cms::active();
|
||||
assert_eq!(cms::active_settings(), cms::ColorSettings::default(), "{id}: another test left the color settings changed");
|
||||
let plain = render(&s);
|
||||
let params: Value = serde_json::from_str(params).unwrap();
|
||||
s.execute("effect.apply", &json!({"effect": id, "ids": [g], "params": params})).unwrap();
|
||||
let a = render(&s);
|
||||
assert!(mean_diff(&plain, &a) > 0.0005, "{id} shows: {}", mean_diff(&plain, &a));
|
||||
assert_eq!(a.pixels, render(&s).pixels, "{id} is deterministic");
|
||||
let again = render(&s);
|
||||
// The multithreaded pipeline draws the same.
|
||||
let mut mt = Renderer::new();
|
||||
mt.threads = 4;
|
||||
let b = mt.render_region(&s.doc().unwrap().doc, Rect::new(0.0, 0.0, 200.0, 200.0), 1.0, true);
|
||||
assert!(std::sync::Arc::ptr_eq(&colors, &cms::active()), "{id}: another test changed the color settings while this one drew");
|
||||
assert!(mean_diff(&plain, &a) > 0.0005, "{id} shows: {}", mean_diff(&plain, &a));
|
||||
assert_eq!(a.pixels, again.pixels, "{id} is deterministic");
|
||||
assert!(mean_diff(&a, &b) < 0.002, "{id}: multithreaded differs by {}", mean_diff(&a, &b));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -112,6 +112,9 @@ fn a_linked_pngs_bytes_are_embedded() {
|
||||
|
||||
#[test]
|
||||
fn an_embedded_profile_is_restored() {
|
||||
if !super::in_own_process("tests::saveoptions::an_embedded_profile_is_restored") {
|
||||
return;
|
||||
}
|
||||
let builtin = cms::profiles().into_iter().find(|p| p.kind == cms::ProfileKind::Rgb && p.builtin && p.name != cms::SRGB).unwrap();
|
||||
let icc = cms::icc_bytes(&builtin.name).unwrap();
|
||||
let name = format!("Studio RGB {}", std::process::id());
|
||||
|
||||
@@ -68,6 +68,49 @@ fn type_placed_on_an_artboard_edge_takes_that_artboards_frame() {
|
||||
}
|
||||
}
|
||||
|
||||
/// `text` as UTF-16 without a byte-order mark, little-endian when `le` is set.
|
||||
fn utf16(text: &str, le: bool) -> Vec<u8> {
|
||||
text.encode_utf16().flat_map(|u| if le { u.to_le_bytes() } else { u.to_be_bytes() }).collect()
|
||||
}
|
||||
|
||||
/// Unicode text in UTF-16 without a byte-order mark is read as UTF-16 when at least half of its
|
||||
/// two-byte units hold a NUL byte, in the byte order that reads a line break, or for one line, the
|
||||
/// order its NUL bytes give. Other bytes keep today's reading.
|
||||
#[test]
|
||||
fn utf16_without_a_byte_order_mark_places_by_its_nul_bytes_and_line_breaks() {
|
||||
let mut s = session();
|
||||
for le in [true, false] {
|
||||
let r = place_text(&mut s, &utf16("Hello, 世界 café!\r\nSecond line", le), json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "Hello, 世界 café!\nSecond line", "little-endian: {le}");
|
||||
let r = place_text(&mut s, &utf16("One line, 世界", le), json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "One line, 世界", "little-endian: {le}");
|
||||
}
|
||||
// One line with NUL bytes in both places (U+4E00 ends in a zero byte) takes the order more of
|
||||
// its units give, and a tie is little-endian.
|
||||
let r = place_text(&mut s, &utf16("一AB", false), json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "一AB");
|
||||
let r = place_text(&mut s, &utf16("一A", true), json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "一A");
|
||||
// Not read as UTF-16, so read as UTF-8 or else Windows-1252 with NUL bytes dropped: an odd
|
||||
// length, an unpaired surrogate, a NUL character, and line breaks in both byte orders (U+0A00).
|
||||
let r = place_text(&mut s, b"A\0B", json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "AB");
|
||||
let r = place_text(&mut s, b"\0a\0b\xd8\0", json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "abØ");
|
||||
let r = place_text(&mut s, b"\0\0\xc3\xa9", json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "é");
|
||||
let r = place_text(&mut s, &utf16("A\u{0A00}\nB", true), json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "A\n\nB");
|
||||
// Fewer than half of the two-byte units hold a NUL byte: UTF-8, and Windows-1252.
|
||||
let r = place_text(&mut s, "Fünf\0 Zeilen!".as_bytes(), json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "Fünf Zeilen!");
|
||||
let r = place_text(&mut s, b"caf\xe9\0x", json!({}));
|
||||
assert_eq!(placed(&s, &r).0, "caféx");
|
||||
// ANSI reads each byte as a character of the 8-bit set; NUL and other control bytes are dropped.
|
||||
let r = place_text(&mut s, &utf16("Hi, 世界", true), json!({"text": {"characterSet": "ansi"}}));
|
||||
assert_eq!(placed(&s, &r).0, "Hi, NLu");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn text_files_report_and_queue_with_their_options() {
|
||||
let mut s = session();
|
||||
|
||||
@@ -2201,6 +2201,16 @@ fn datasets_csv_reads_utf16_files_without_a_byte_order_mark() {
|
||||
let e = import(&mut s, &bytes).unwrap_err().to_string();
|
||||
assert!(e.contains("CSV has a header but no data rows"), "{e}");
|
||||
}
|
||||
// With no line break, the side of each unit that holds the NUL byte gives the byte order, and a
|
||||
// tie is little-endian.
|
||||
let order = crate::cmd::utf16_order_without_mark;
|
||||
assert_eq!(order(&utf16("City", false)), Some(false));
|
||||
assert_eq!(order(&utf16("City", true)), Some(true));
|
||||
assert_eq!(order(b"\0aa\0"), Some(true));
|
||||
assert_eq!(order(&[utf16("City\n", false), vec![0x0A]].concat()), Some(false), "an odd last byte is left out");
|
||||
// Read big-endian, this one-line file ends in an unpaired surrogate.
|
||||
let e = import(&mut s, b"\0a\0b\xd8\0").unwrap_err().to_string();
|
||||
assert!(e.contains("CSV holds NUL bytes"), "{e}");
|
||||
import(&mut s, &utf16("City\tName\n一二三丁目\tKai\n", true)).unwrap();
|
||||
assert_eq!(value(&s, "Data Set 1"), text_value("一二三丁目"));
|
||||
// Most units hold their NUL byte where a big-endian file would (U+4E00); the line breaks
|
||||
|
||||
@@ -1115,6 +1115,92 @@ fn lasso_picks_gradient_mesh_points() {
|
||||
assert_eq!(red, top, "only the points inside the loop are recoloured");
|
||||
}
|
||||
|
||||
/// With gradient mesh points picked, the Fill proxy (and the Color panel that edits it) shows
|
||||
/// the color a solid fill gives them, not the mesh object's own fill: "?" when the picked
|
||||
/// points' colors differ, the object's fill again once no point is picked.
|
||||
#[test]
|
||||
fn the_fill_proxy_shows_the_picked_mesh_points_color() {
|
||||
let mut s = session();
|
||||
let a = rect(&mut s, 100.0, 100.0, 100.0, 100.0);
|
||||
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff8500"})).unwrap();
|
||||
s.execute("object.mesh.create", &json!({"rows": 2, "cols": 2})).unwrap();
|
||||
let object_fill = s.proxy_paints().0;
|
||||
// Round the top row of points.
|
||||
gesture(&mut s, "lasso", &[(90.0, 90.0), (210.0, 90.0), (210.0, 110.0), (90.0, 110.0), (90.0, 110.0)], Mods::default());
|
||||
s.execute("paint.setFill", &json!({"color": "#3366ff"})).unwrap();
|
||||
let shown = s.execute("paint.proxies", &json!({})).unwrap();
|
||||
assert_eq!(s.proxy_paints().0.color().map(|c| c.to_hex()), Some("#3366ff".into()), "the picked points' color: {shown}");
|
||||
assert_eq!(shown["fillMixed"], json!(false));
|
||||
assert_eq!(shown["fill"], json!(s.proxy_paints().0));
|
||||
// One picked point takes another color: the points differ.
|
||||
let Some(NodeKind::Mesh(m)) = s.doc().unwrap().doc.node(a).map(|n| &n.kind) else { panic!("still a gradient mesh") };
|
||||
let first = m.idx(0, 0);
|
||||
s.execute("object.mesh.setPointColor", &json!({"id": a.0, "index": first, "color": "#00ff00"})).unwrap();
|
||||
assert!(s.proxy_mixed().0, "the picked points' colors differ");
|
||||
// Picking none (the Selection tool) shows the object's fill again.
|
||||
s.select_tool("selection", ViewInfo::default()).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
|
||||
assert_eq!(s.proxy_paints().0, object_fill);
|
||||
assert!(!s.proxy_mixed().0);
|
||||
}
|
||||
|
||||
/// With the Appearance panel's stroke row active, a solid fill still recolors the picked mesh
|
||||
/// points, so the Fill proxy shows them; with its fill row active, the fill goes to that row, and
|
||||
/// the proxy shows the row.
|
||||
#[test]
|
||||
fn the_fill_proxy_follows_where_the_fill_goes_with_an_appearance_row_active() {
|
||||
let mut s = session();
|
||||
let a = rect(&mut s, 100.0, 100.0, 100.0, 100.0);
|
||||
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
|
||||
s.execute("object.mesh.create", &json!({"rows": 2, "cols": 2})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#ff8500"})).unwrap();
|
||||
s.execute("paint.setStroke", &json!({"color": "#000000"})).unwrap();
|
||||
let items = &s.doc().unwrap().doc.node(a).unwrap().appearance.items;
|
||||
let fill_row = items.iter().position(|it| it.is_fill()).expect("a fill row");
|
||||
let stroke_row = items.iter().position(|it| !it.is_fill()).expect("a stroke row");
|
||||
gesture(&mut s, "lasso", &[(90.0, 90.0), (210.0, 90.0), (210.0, 110.0), (90.0, 110.0), (90.0, 110.0)], Mods::default());
|
||||
assert_eq!(s.fill_mesh_points().first().map(|(_, v)| v.len()), Some(3), "the top row is picked");
|
||||
let point_color = |s: &Session| {
|
||||
let Some(NodeKind::Mesh(m)) = s.doc().unwrap().doc.node(a).map(|n| &n.kind) else { panic!("still a gradient mesh") };
|
||||
m.points[m.idx(0, 0)].color.to_hex()
|
||||
};
|
||||
|
||||
s.execute("appearance.setActiveItem", &json!({"index": stroke_row})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"color": "#3366ff"})).unwrap();
|
||||
assert_eq!(point_color(&s), "#3366ff", "the stroke row leaves the fill on the picked points");
|
||||
assert_eq!(s.proxy_paints().0.color().map(|c| c.to_hex()), Some("#3366ff".into()));
|
||||
assert!(!s.proxy_mixed().0);
|
||||
|
||||
s.execute("appearance.setActiveItem", &json!({"index": fill_row})).unwrap();
|
||||
assert!(s.fill_mesh_points().is_empty());
|
||||
s.execute("paint.setFill", &json!({"color": "#00ff00"})).unwrap();
|
||||
assert_eq!(point_color(&s), "#3366ff", "the fill row takes the fill");
|
||||
assert_eq!(s.proxy_paints().0.color().map(|c| c.to_hex()), Some("#00ff00".into()));
|
||||
}
|
||||
|
||||
/// A gradient mesh with points picked selected with another object: a solid fill recolors the
|
||||
/// points and fills the other object, and the Fill proxy and its "?" count the points' colors.
|
||||
#[test]
|
||||
fn the_fill_proxy_counts_picked_mesh_points_beside_other_objects() {
|
||||
let mut s = session();
|
||||
let a = rect(&mut s, 100.0, 100.0, 100.0, 100.0);
|
||||
let b = rect(&mut s, 300.0, 300.0, 50.0, 50.0);
|
||||
s.execute("select.set", &json!({"ids": [a.0]})).unwrap();
|
||||
s.execute("object.mesh.create", &json!({"rows": 2, "cols": 2})).unwrap();
|
||||
gesture(&mut s, "lasso", &[(90.0, 90.0), (210.0, 90.0), (210.0, 110.0), (90.0, 110.0), (90.0, 110.0)], Mods::default());
|
||||
s.execute("select.add", &json!({"ids": [b.0]})).unwrap();
|
||||
assert_eq!(s.doc().unwrap().selection.objects, vec![a, b]);
|
||||
assert_eq!(s.fill_mesh_points().first().map(|(id, v)| (*id, v.len())), Some((a, 3)), "the top row is still picked");
|
||||
s.execute("paint.setFill", &json!({"color": "#3366ff"})).unwrap();
|
||||
let Some(NodeKind::Mesh(m)) = s.doc().unwrap().doc.node(a).map(|n| &n.kind) else { panic!("still a gradient mesh") };
|
||||
assert_eq!(m.points[m.idx(0, 0)].color.to_hex(), "#3366ff");
|
||||
assert_eq!(s.proxy_paints().0.color().map(|c| c.to_hex()), Some("#3366ff".into()));
|
||||
assert!(!s.proxy_mixed().0, "the points and the other object are the same color");
|
||||
s.execute("paint.setFill", &json!({"ids": [b.0], "color": "#00ff00"})).unwrap();
|
||||
assert!(s.proxy_mixed().0, "the picked points and the other object's fill differ");
|
||||
}
|
||||
|
||||
/// Shift-drag a marquee with the Selection tool (#483): the selected objects it reaches are
|
||||
/// deselected and the others selected, the rest of the selection staying as it was.
|
||||
#[test]
|
||||
|
||||
Reference in New Issue
Block a user