mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-14 15:57:49 +00:00
.ai import: Art brush guides match as fractions of the art too
A path's guide lengths matched the brush's within 0.001, so on very short art guides at 30% and 35% of the art matched. The guides now also match as fractions of the art's length.
This commit is contained in:
@@ -291,9 +291,16 @@ pub(super) fn draws_as(draft: &BrushDraft, settings: &PathBrush, bending: &HashM
|
||||
&& d.modes() == c.modes()
|
||||
}
|
||||
(DraftKind::Art { settings: Some(d), art: name, .. }, PathBrush::Art(s)) => {
|
||||
drawn(d).iter().zip(drawn(s)).all(|(a, b)| close(*a, b))
|
||||
&& art_options(s).is_some()
|
||||
&& bending.get(name).is_some_and(|length| opens_live(d, *length) && opens_live(s, *length))
|
||||
let (dd, ds) = (drawn(d), drawn(s));
|
||||
art_options(s).is_some()
|
||||
&& bending.get(name).is_some_and(|length| {
|
||||
// The guides match as lengths and as fractions of the art's length, so they differ
|
||||
// neither on short art nor near the ends of long art.
|
||||
dd.iter().zip(ds).all(|(a, b)| close(*a, b))
|
||||
&& [11, 12].iter().all(|&i| close(dd[i] / length, ds[i] / length))
|
||||
&& opens_live(d, *length)
|
||||
&& opens_live(s, *length)
|
||||
})
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
||||
@@ -10650,6 +10650,10 @@ fn an_art_brushed_path_the_brush_cant_draw_keeps_its_drawn_look() {
|
||||
// The brush's guides leave art between them, and the path's, close to them, leave none.
|
||||
let (def, style) = ribbon_with(&[(10, "1"), (11, "20"), (12, "19.99")]);
|
||||
cases.push(("path guides close to the brush's that leave no art between them", def, style.replace("19.99 /", "20 /")));
|
||||
// On art 0.01 long, a guide at 0.0035 is 35% of the way along it, and the brush's at 0.003 is 30%.
|
||||
let (def, style) = ribbon_with(&[(10, "1"), (11, "0.003"), (12, "0.002")]);
|
||||
let short = format!("%AI8_BeginBrushPattern\n(Ribbon art)\n0 A\n0 g\n{}f\n%AI8_EndBrushPattern\n", rect_path(0.0, 0.0, 0.01, 4.0));
|
||||
cases.push(("path guides elsewhere on short art", def.replace(&lopsided_art("Ribbon art"), &short), style.replace("0.003 /", "0.0035 /")));
|
||||
let mut wrong = vec![];
|
||||
for (why, def, style) in cases {
|
||||
let r = read_ok(&format!("{def}{style}{}", layer(&brushed_path())));
|
||||
|
||||
Reference in New Issue
Block a user