mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-11 22:22:25 +00:00
.ai import: an Art brush with neither form's count of numbers isn't read
An Art brush object whose last field had neither 15 numbers nor the older form's 8 came in with default settings. It is now left out like other brushes whose values can't be read. An older-form Art brush keeps the Art brush's default colorization, as the note says.
This commit is contained in:
@@ -334,10 +334,13 @@ pub(super) fn parse_tool_object(kind: Tool, name: &str, params: &str) -> Result<
|
||||
}
|
||||
Tool::Art => {
|
||||
// The older form's 8 numbers aren't known: its brush keeps the defaults and its
|
||||
// paths their drawn look.
|
||||
let (colorization, plain) = match <&[f64; 15]>::try_from(n.as_slice()) {
|
||||
Ok(n15) => (if n15[1] == 1.0 { Colorization::Tints } else { Colorization::None }, art_is_plain(n15)),
|
||||
Err(_) => (Colorization::None, false),
|
||||
// paths their drawn look. Any other count isn't a form this reads.
|
||||
let (colorization, plain) = if let Ok(n15) = <&[f64; 15]>::try_from(n.as_slice()) {
|
||||
(if n15[1] == 1.0 { Colorization::Tints } else { Colorization::None }, art_is_plain(n15))
|
||||
} else if n.len() == 8 {
|
||||
(ArtBrush::default().colorization, false)
|
||||
} else {
|
||||
return Err(BrushError::Values);
|
||||
};
|
||||
DraftKind::Art { brush: ArtBrush { colorization, ..ArtBrush::default() }, art: art()?, plain }
|
||||
}
|
||||
|
||||
@@ -7791,6 +7791,12 @@ fn an_older_art_brush_comes_in_with_its_art() {
|
||||
const OLD_RIBBON: &str = "1 / Ribbon art/ / / / / 0 1 / 1 0 1 0 1 0 0 0";
|
||||
let d = brush::parse_tool_object(brush::Tool::Art, "Ribbon", OLD_RIBBON).unwrap();
|
||||
assert!(matches!(d.kind, brush::DraftKind::Art { ref art, plain: false, .. } if art == "Ribbon art"), "{d:?}");
|
||||
let brush::DraftKind::Art { ref brush, .. } = d.kind else { panic!("art") };
|
||||
assert_eq!(brush.colorization, vectorcraft_brush::ArtBrush::default().colorization, "the default colorization");
|
||||
// A count of numbers neither form has isn't read.
|
||||
for bad in ["1 / Ribbon art/ / / / / 0 1 / 1 0 1 0 1 0 0", "1 / Ribbon art/ / / / / 0 1 / 1 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0"] {
|
||||
assert_eq!(brush::parse_tool_object(brush::Tool::Art, "Ribbon", bad), Err(brush::BrushError::Values), "{bad}");
|
||||
}
|
||||
assert_eq!(brush::parse_tool_object(brush::Tool::Scatter, "Spray", "1 /Dot art/ 0 1 / 1 0 1 0 1 0 0 0"), Err(brush::BrushError::Values));
|
||||
let objects = [plugin_object(ART_BRUSH, "Ribbon", OLD_RIBBON), plugin_object(ART_BRUSH, "Bare", "1 / / / / / / 0 1 / 1 0 1 0 1 0 0 0")].concat();
|
||||
let r = read_ok(&format!("{}{objects}{}", brush_art("Ribbon art", 4.0), layer("")));
|
||||
|
||||
Reference in New Issue
Block a user