.ai editing data: Scatter and Art brushes keep their art's opacity masks

A Scatter or Art brush whose art holds an opacity mask was left out of the
Brushes panel in the editing data with the brushes warning. The writer now
writes such a brush when each mask's art passes the same check as the
brush's art, in the form define_brush_art in
crates/eps/src/import/ai/read/directives.rs reads: the mask's art between
X= and X+ in the object's art dictionary, with its Clip, Invert Mask,
disabled and linked options. Masks may sit up to seven deep in one
another's art. Masks on a compound path's members, gradient masks and mask
art past the reader's limits still leave the brush out with the warning.

- The reader turns an Art brush's art over with the art of masks that
  don't move with their objects, so such a mask stays over the part of
  the object it was over.
- A brush's mask art is written as the brush holds it, not as an object
  of the layers' mask art that has the same id and keeps an art style.
This commit is contained in:
dotCooCoo
2026-11-13 17:09:49 -08:00
parent 71cef8ac8d
commit 7402ca4fd8
8 changed files with 263 additions and 14 deletions
+167 -2
View File
@@ -8085,7 +8085,8 @@ fn brushes_document() -> Document {
}
/// Brush art `n` as a tree to compare with [`same_tree`]: each object's kind, its anchors and handles,
/// the fills and strokes that paint (a stroke with its width), and its members in order.
/// the fills and strokes that paint (a stroke with its width), its members in order, and its opacity
/// mask's art and options when it has one.
fn art_tree(n: &Node) -> serde_json::Value {
let kind = match &n.kind {
NodeKind::Path { .. } => "path",
@@ -8110,7 +8111,11 @@ fn art_tree(n: &Node) -> serde_json::Value {
})
.collect();
let members: Vec<serde_json::Value> = n.children().map(|c| c.iter().map(|m| art_tree(m)).collect()).unwrap_or_default();
serde_json::json!({"kind": kind, "anchors": anchors, "paints": paints, "members": members})
let mut tree = serde_json::json!({"kind": kind, "anchors": anchors, "paints": paints, "members": members});
if let Some(m) = &n.extras().mask {
tree["mask"] = serde_json::json!({"art": art_tree(&m.art), "options": [m.clip, m.invert, m.disabled, m.linked]});
}
tree
}
/// Are trees `a` and `b` ([`art_tree`]) the same but for numbers within the written numbers'
@@ -8253,6 +8258,166 @@ fn an_art_brush_whose_art_doesnt_bend_keeps_its_paths_look() {
assert!(same_tree(&art_tree(&got.art), &art_tree(&want.art)), "{:#?}", got.art);
}
/// An opacity mask whose art is rectangle `r` filled in `paint`, with the options given.
fn rect_mask(id: u64, r: Rect, paint: Paint, clip: bool, invert: bool, linked: bool) -> OpacityMask {
let art = Node::path(vectorcraft_doc::NodeId(id), shapes::rectangle(r), Appearance::basic(paint, Paint::None, 0.0));
OpacityMask { art: Arc::new(art), clip, invert, disabled: false, linked }
}
/// `levels` white rectangle masks that clip, each but the last holding the next in its art.
fn mask_chain(levels: u32) -> Option<Box<OpacityMask>> {
(0..levels).fold(None, |inner, i| {
let mut m = rect_mask(100 + u64::from(i), Rect::new(0.0, 0.0, 30.0 - f64::from(i), 8.0), solid(Color::WHITE), true, false, true);
Arc::make_mut(&mut m.art).extras_mut().mask = inner;
Some(Box::new(m))
})
}
/// [`brush_art_node`] with opacity masks: on the group, a mid-gray rectangle that clips; on the wide
/// block, a white rectangle inverted without clipping. Both masks are `linked` or not.
fn masked_brush_art(linked: bool) -> Node {
let mut art = brush_art_node();
if let Some(c) = art.children_mut() {
let wide = rect_mask(10, Rect::new(0.0, 0.0, 20.0, 4.0), solid(Color::WHITE), false, true, linked);
Arc::make_mut(&mut c[0]).extras_mut().mask = Some(Box::new(wide));
}
art.extras_mut().mask = Some(Box::new(rect_mask(11, Rect::new(0.0, 0.0, 30.0, 8.0), solid(Color::rgb(0.5, 0.5, 0.5)), true, false, linked)));
art
}
/// Scatter and Art brushes whose art holds opacity masks come back in the Brushes panel with their
/// settings, the masks' art in place with its paint, and the masks' options: masks on the art and on
/// a member, masks that don't move with their objects, and masks seven deep in one another's art. A
/// path with the masked Art brush comes back as its drawn look, with the stroke warning.
#[test]
fn scatter_and_art_brush_mask_art_round_trips() {
use vectorcraft_brush::{ArtBrush, Brush, BrushKind, Scatter};
let mut deep = brush_art_node();
deep.extras_mut().mask = mask_chain(7);
let lib = vec![
Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(true), ..Scatter::default() }) },
Brush { name: "Masked ribbon".into(), kind: BrushKind::Art(ArtBrush { art: masked_brush_art(true), ..ArtBrush::default() }) },
Brush { name: "Unlinked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(false), ..Scatter::default() }) },
Brush { name: "Unlinked ribbon".into(), kind: BrushKind::Art(ArtBrush { art: masked_brush_art(false), ..ArtBrush::default() }) },
Brush { name: "Deep spray".into(), kind: BrushKind::Scatter(Scatter { art: deep.clone(), ..Scatter::default() }) },
Brush { name: "Deep ribbon".into(), kind: BrushKind::Art(ArtBrush { art: deep, ..ArtBrush::default() }) },
];
let mut doc = Document::new(300.0, 200.0);
vectorcraft_brush::store(&mut doc, &lib);
brushed(&mut doc, "Masked ribbon", (20.0, 120.0), (280.0, 150.0), 1.0);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(!out.warnings.iter().any(|w| w == writer::BRUSHES || w == writer::DEEP_MASKS), "{:?}", out.warnings);
assert!(out.warnings.iter().any(|w| w == writer::STROKES), "{:?}", out.warnings);
assert_eq!(program(&doc).matches("%AI8_BeginBrushPattern").count(), lib.len());
let back = read_back(&doc);
assert!(matches!(back.layers[0].children().unwrap()[0].kind, NodeKind::Group { .. }), "the path's drawn look");
let got = vectorcraft_brush::library(&back);
assert_eq!(got.iter().map(|b| b.name.as_str()).collect::<Vec<_>>(), lib.iter().map(|b| b.name.as_str()).collect::<Vec<_>>());
let none = || Node::group(vectorcraft_doc::NodeId(0), vec![]);
for (g, w) in got.iter().zip(&lib) {
let name = &w.name;
let (ga, wa) = match (&g.kind, &w.kind) {
(BrushKind::Scatter(gs), BrushKind::Scatter(ws)) => {
let settings = |s: &Scatter| Scatter { art: none(), modes: Some(s.modes()), ..s.clone() };
assert_eq!(settings(gs), settings(ws), "{name}");
(&gs.art, &ws.art)
}
(BrushKind::Art(ga), BrushKind::Art(wa)) => {
assert_eq!(ArtBrushOptions::of(ga), ArtBrushOptions::of(wa), "{name}");
(&ga.art, &wa.art)
}
_ => panic!("{name}: {g:?}"),
};
let (gt, wt) = (art_tree(ga), art_tree(wa));
assert!(same_tree(&gt, &wt), "{name}: {gt:#} for {wt:#}");
}
}
/// Brushes whose mask art the reader wouldn't read back as it is are left out with a warning, beside
/// a brush that comes back: a Scatter brush whose art's mask is a gradient, one whose art holds
/// masks eight deep in one another's art (deeper than the editing data writes masks), one whose
/// mask's art is a compound path of 26,500 members of two squares each, which the reader reads as
/// 53,000 paths, more art than it copies into one file's brushes, and one whose art is a compound
/// path with a mask on a member (a compound path is written as one path, without its members' masks).
#[test]
fn brushes_whose_mask_art_isnt_read_back_are_left_out() {
use vectorcraft_brush::{Brush, BrushKind, Scatter};
let keep = Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(true), ..Scatter::default() }) };
let mut gradient = brush_art_node();
let ramp = gradient_paint(sunset(), None, None);
gradient.extras_mut().mask = Some(Box::new(rect_mask(11, Rect::new(0.0, 0.0, 30.0, 8.0), ramp, true, false, true)));
let mut deep = brush_art_node();
deep.extras_mut().mask = mask_chain(8);
let square = |i: u32| {
let (x, y) = (f64::from(i % 400) * 2.0, f64::from(i / 400) * 2.0);
shapes::rectangle(Rect::new(x, y, x + 1.0, y + 1.0)).subpaths
};
let members = (0..26_500)
.map(|m| {
let path = PathData::new((0..2).flat_map(|k| square(m * 2 + k)).collect());
Arc::new(Node::path(vectorcraft_doc::NodeId(21), path, Appearance::basic(solid(Color::WHITE), Paint::None, 0.0)))
})
.collect();
let mut squares = Node::path(vectorcraft_doc::NodeId(20), PathData::default(), Appearance::basic(solid(Color::WHITE), Paint::None, 0.0));
squares.kind = NodeKind::Compound { children: members, rule: FillRule::NonZero };
let mut heavy = brush_art_node();
heavy.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(squares), clip: true, invert: false, disabled: false, linked: true }));
let mut member = brush_art_node();
member.kind = match member.kind {
NodeKind::Group { mut children, .. } => {
let mask = rect_mask(10, Rect::new(0.0, 0.0, 20.0, 4.0), solid(Color::WHITE), true, false, true);
Arc::make_mut(&mut children[0]).extras_mut().mask = Some(Box::new(mask));
NodeKind::Compound { children, rule: FillRule::NonZero }
}
kind => kind,
};
member.appearance = Appearance::basic(black_fill(), Paint::None, 0.0).into();
let cases = [
("gradient mask", gradient),
("masks eight deep", deep),
("mask art past the reader's limit", heavy),
("mask on a compound path's member", member),
];
for (why, art) in cases {
let mut doc = Document::new(300.0, 200.0);
let lib = vec![keep.clone(), Brush { name: why.into(), kind: BrushKind::Scatter(Scatter { art, ..Scatter::default() }) }];
vectorcraft_brush::store(&mut doc, &lib);
let out = export_ai_editing(&doc, &opts()).unwrap();
assert!(out.warnings.iter().any(|w| w == writer::BRUSHES), "{why}: {:?}", out.warnings);
assert!(!out.warnings.iter().any(|w| w == writer::DEEP_MASKS), "{why}: {:?}", out.warnings);
let names: Vec<String> = vectorcraft_brush::library(&read_back(&doc)).into_iter().map(|b| b.name).collect();
assert_eq!(names, ["Masked spray"], "{why}");
assert_eq!(program(&doc).matches("%AI8_BeginBrushPattern").count(), 1, "{why}");
}
}
/// A brush's mask art is written as the brush holds it when an object of the layers' mask art with
/// the same id keeps a live effect as an art style: the brush's mask comes back as its own plain
/// rectangle, without the layers' object's effect or geometry.
#[test]
fn a_brushs_mask_art_isnt_written_as_a_styled_object_with_its_id() {
use vectorcraft_brush::{Brush, BrushKind, Scatter};
let offset = fx("path.offsetPath", serde_json::json!({"offset": 8.0, "joins": "miter", "miterLimit": 4.0}));
let mut id = None;
let mut doc = masked_image(|doc| {
let grown = styled_rect(doc, "Grown", Rect::new(60.0, 30.0, 110.0, 70.0), solid(Color::rgb(0.0, 0.0, 0.0)), Paint::None, vec![offset]);
id = Some(grown.id);
grown
});
let id = id.expect("the mask's art");
let mut art = brush_art_node();
art.extras_mut().mask = Some(Box::new(rect_mask(id.0, Rect::new(0.0, 0.0, 30.0, 8.0), solid(Color::WHITE), true, false, true)));
let lib = vec![Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art, ..Scatter::default() }) }];
vectorcraft_brush::store(&mut doc, &lib);
let got = vectorcraft_brush::library(&read_back(&doc));
let [Brush { kind: BrushKind::Scatter(s), .. }] = got.as_slice() else { panic!("{got:?}") };
let BrushKind::Scatter(want) = &lib[0].kind else { panic!("a Scatter brush") };
let m = s.art.extras().mask.as_deref().unwrap_or_else(|| panic!("the mask is read: {:#?}", s.art));
assert!(m.art.appearance.effects.is_empty(), "{:?}", m.art.appearance.effects);
let (gt, wt) = (art_tree(&s.art), art_tree(&want.art));
assert!(same_tree(&gt, &wt), "{gt:#} for {wt:#}");
}
/// Settings the other tests don't use come back: a Calligraphic brush varying with tilt and bearing,
/// a Scatter brush keeping its art's colors whose rotation doesn't follow the path, and brushes whose
/// modes aren't given (the reader gives them, the same ones).
+38 -8
View File
@@ -23,7 +23,7 @@ use super::{Writer, Xy};
use crate::ai_ops;
use crate::ps;
pub(in crate::ai_editing) const BRUSHES: &str = "Pattern and Bristle brushes, Art brushes that don't stretch their art along the path from left to right at 100% unflipped without overlap, Scatter and Art brushes in Tints and Shades or Hue Shift, brushes whose art holds an empty path or group or more than paths, compound paths and groups with one solid fill and one plain stroke each, brushes whose names hold a slash or repeat an earlier brush's name, brushes that would open with other settings, brushes past the number or the amount of art one file's brushes can hold, and every brush on a large canvas are left out of the Brushes panel in the editing data for other apps";
pub(in crate::ai_editing) const BRUSHES: &str = "Pattern and Bristle brushes, Art brushes that don't stretch their art along the path from left to right at 100% unflipped without overlap, Scatter and Art brushes in Tints and Shades or Hue Shift, brushes whose art or its opacity masks' art holds an empty path or group or more than paths, compound paths and groups with one solid fill and one plain stroke each, or opacity masks on a compound path's members or more than seven deep in one another's art, brushes whose names hold a slash or repeat an earlier brush's name, brushes that would open with other settings, brushes past the number or the amount of art one file's brushes can hold, and every brush on a large canvas are left out of the Brushes panel in the editing data for other apps";
/// Most brushes written (the reader's limit).
const MAX_BRUSHES: usize = 4096;
@@ -164,17 +164,38 @@ fn art_params(a: &ArtBrush, art: &str) -> Option<String> {
Some(format!("2 / {art}/ / / / / 0 0/ 5 0 0 0 / {}", nums6(&numbers)))
}
/// Most opacity masks in one another's art in a brush's art: a brush's art section writes its art
/// one level inside, and masks at [`super::MAX_NEST`] levels are left out ([`super::DEEP_MASKS`]).
const MAX_MASK_NEST: u32 = super::MAX_NEST - 1;
/// Is `art` written as the reader reads it back, within a brush: paths and compound paths with
/// points and groups with members (not clipping, without paint of their own), each opaque in the
/// normal blending mode, without effects or opacity masks, with at most one fill and one plain
/// stroke (no brush, width profile, arrowheads, alignment off the path or dashes fitted to corners)
/// over it, each in a color or none? A path without points isn't written ([`Writer::plain_object`]).
/// normal blending mode, without effects, with at most one fill and one plain stroke (no brush,
/// width profile, arrowheads, alignment off the path or dashes fitted to corners) over it, each in a
/// color or none, and opacity masks whose art is such art too, at most [`MAX_MASK_NEST`] deep and
/// none on a compound path's members? A path without points isn't written
/// ([`Writer::plain_object`]).
fn plain_art(art: &Node) -> bool {
plain_within(art, MAX_MASK_NEST)
}
/// Does no object of `art` have an opacity mask?
fn unmasked(art: &Node) -> bool {
let mut unmasked = true;
art.walk(&mut |n| unmasked &= n.extras().mask.is_none());
unmasked
}
/// [`plain_art`] with at most `masks` opacity masks in one another's art.
fn plain_within(art: &Node, masks: u32) -> bool {
let mut plain = true;
art.walk(&mut |n| {
let kind = match &n.kind {
NodeKind::Path { path, guide: false, clipping: false, .. } => path.subpaths.iter().any(|sp| !sp.anchors.is_empty()),
NodeKind::Compound { .. } => super::compound_path(n).subpaths.iter().any(|sp| !sp.anchors.is_empty()),
// A compound path is written as one path of its members' subpaths, without their masks.
NodeKind::Compound { children, .. } => {
children.iter().all(|c| unmasked(c)) && super::compound_path(n).subpaths.iter().any(|sp| !sp.anchors.is_empty())
}
NodeKind::Group { children, clip: false } => !children.is_empty(),
_ => false,
};
@@ -198,7 +219,7 @@ fn plain_art(art: &Node) -> bool {
&& order
&& quiet
&& n.appearance.effects.is_empty()
&& n.extras().mask.is_none()
&& n.extras().mask.as_deref().is_none_or(|m| masks > 0 && plain_within(&m.art, masks - 1))
&& n.opacity >= 1.0
&& n.blend == BlendMode::Normal;
});
@@ -209,8 +230,13 @@ fn plain_art(art: &Node) -> bool {
/// compound path with the subpaths of all its members as one path ([`super::compound_path`]), is
/// written as one path when it has one subpath with points and as a compound path when it has more
/// ([`Writer::plain_object`]); the reader reads that compound path as one path for each subpath,
/// each with the object's paint.
/// each with the object's paint. An opacity mask's art is written shown ([`Writer::mask`]).
fn as_read(art: &mut Node) {
if let Some(m) = art.extras_if_any().and_then(|e| e.mask.as_mut()) {
let mask_art = Arc::make_mut(&mut m.art);
mask_art.visible = true;
as_read(mask_art);
}
let (subpaths, rule) = match &art.kind {
NodeKind::Path { path, rule, .. } => (path.subpaths.clone(), *rule),
NodeKind::Compound { rule, .. } => (super::compound_path(art).subpaths, *rule),
@@ -341,7 +367,7 @@ impl Writer<'_> {
}
let mut read = a.clone();
if *to_section == Affine::IDENTITY {
read.transform(Affine::FLIP_Y, false);
crate::import::turn_brush_art_over(&mut read);
}
as_read(&mut read);
Some(read)
@@ -378,6 +404,9 @@ impl Writer<'_> {
// The art is the brush's own: not on `%_` lines, in a drawn look or in a symbol that
// first uses the brush.
(std::mem::take(&mut self.hidden), std::mem::take(&mut self.in_look), std::mem::take(&mut self.in_symbol)),
// The layers' objects written with art styles, by id: none of them is the brush's art,
// which may hold objects with the same ids.
std::mem::take(&mut self.styled),
);
(self.to_art, self.grad_space, self.canvas, self.block_end) = (to_section, to_section, to_section, usize::MAX);
self.state(false, false);
@@ -413,6 +442,7 @@ impl Writer<'_> {
self.clip,
(self.block_start, self.block_end),
(self.hidden, self.in_look, self.in_symbol),
self.styled,
) = saved;
let text = std::mem::replace(&mut self.body, body);
if !std::mem::replace(&mut self.warnings, warnings).is_empty() {
+1 -1
View File
@@ -90,7 +90,7 @@ pub(crate) use ai::objects_read;
pub(crate) use ai::{
BRUSH_MANAGER, BrushesRead, DEFORM_PLUGIN, EnvelopeGridPoint, MAX_CHECKED as ENVELOPE_CHECKS, MAX_EDITING_OBJECTS, MAX_GRADIENT_STOPS,
MAX_LISTED, MAX_LISTED_NAME, MAX_SYMBOLS, brush_plugin_name, brushes_kept, envelope_outline, envelope_upright, read_art_style, read_brush_object,
read_style_list, style_moves_with, symbol_art_member, warp_number,
read_style_list, style_moves_with, symbol_art_member, turn_brush_art_over, warp_number,
};
pub(crate) use ate::{MAX_BYTES as MAX_TEXT_DOCUMENT, MAX_FRAMES, MAX_SEGMENTS, MAX_STORY, MAX_VALUES as MAX_TEXT_VALUES, record_version};
pub use native::{AiLayers, ai_alone, ai_alone_on_page, ai_alone_with, ai_layers_alone, ai_opened_artboard, is_loss, layered_ai, layered_ai_from};
+3 -1
View File
@@ -34,7 +34,9 @@ use std::io::Read as _;
use super::lex::find;
use crate::ps;
pub(crate) use brush::{BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object};
pub(crate) use brush::{
BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object, turn_over as turn_brush_art_over,
};
pub(crate) use envelope::DRAWN as ENVELOPE_DRAWN;
pub(crate) use envelope::MAX_CHECKED;
pub(crate) use envelope::TYPE_DRAWN as ENVELOPE_TYPE_DRAWN;
+26 -1
View File
@@ -50,6 +50,7 @@
//! at None so the art keeps its own colors.
use std::collections::{HashMap, HashSet};
use std::sync::Arc;
use kurbo::Affine;
use vectorcraft_brush::{ArtBrush, Bristle, Brush, BrushKind, Calligraphic, Colorization, Scatter, Variation};
@@ -377,6 +378,30 @@ pub(super) fn parse_tool_object(kind: Tool, name: &str, params: &str) -> Result<
Ok(BrushDraft { name: name.to_string(), kind })
}
/// Turn `art` over (y for -y) with the art of all its opacity masks, those that don't move with
/// their objects too: the art changes the space it is in, and no object moves over its mask.
pub(crate) fn turn_over(art: &mut Node) {
art.transform(Affine::scale_non_uniform(1.0, -1.0), false);
turn_unlinked_masks(art);
}
/// Turn over the art of the opacity masks in `n` that a transform of `n` leaves in place (the masks
/// that don't move with their objects), in members and in other masks' art too.
fn turn_unlinked_masks(n: &mut Node) {
if let Some(m) = n.extras_if_any().and_then(|e| e.mask.as_mut()) {
let linked = m.linked;
let art = Arc::make_mut(&mut m.art);
if linked {
turn_unlinked_masks(art);
} else {
turn_over(art);
}
}
for c in n.children_mut().into_iter().flatten() {
turn_unlinked_masks(Arc::make_mut(c));
}
}
/// The brushes of `drafts`, their art from the sections `art` (by name), in the brush manager's
/// `order` (brushes it doesn't list after those it does, in the order of their objects), each
/// kept within its ranges → the brushes and how many were left out: those whose art isn't read,
@@ -456,7 +481,7 @@ pub(super) fn finish_brushes_within(
DraftKind::Art { brush, art: name, .. } => copy(&name).map(|mut a| {
// The side of the section with y up draws on the right of the path, and a brush
// draws art's y (down here) on the left of the path.
a.transform(Affine::scale_non_uniform(1.0, -1.0), false);
turn_over(&mut a);
BrushKind::Art(ArtBrush { art: a, ..brush })
}),
DraftKind::Pattern { .. } => None,
+24
View File
@@ -6358,6 +6358,30 @@ fn a_brushs_opacity_mask_art_takes_ids_of_the_document() {
assert_eq!(unique.len(), all.len(), "{all:?}");
}
/// An Art brush's art is turned over with the art of its opacity mask, whether the mask moves with
/// its object or not: the mask's art stays over the part of the object it is over in the section.
#[test]
fn an_art_brushs_opacity_mask_art_turns_over_with_its_object() {
let mut read = vec![];
for linked in [true, false] {
let mask_art: String = format!("1 g\n{}f\n", rect_path(0.0, 0.0, 40.0, 3.0)).lines().map(|l| format!("%_{l}\n")).collect();
let options = format!("%_1 /Bool (Clipping) ,\n%_{} /Bool (Linked) ,\n", u8::from(linked));
let mask = format!("%_/ArtDictionary :\n%_/Mask :\n%_X=\n{mask_art}%_X+\n%_(Art) ,\n{options}%_; (AI9_Mask) ,\n%_;\n");
let section = format!("%AI8_BeginBrushPattern\n(Ribbon art)\n0 A\n0 g\n{}f\n{mask}%AI8_EndBrushPattern\n", rect_path(0.0, 0.0, 40.0, 8.0));
let shape = format!("{RED}{}f\n", rect_path(0.0, 0.0, 10.0, 10.0));
let r = read_ok(&format!("{section}{}{}", plugin_object(ART_BRUSH, "Ribbon", RIBBON), layer(&shape)));
let lib = vectorcraft_brush::library(&r.doc);
let vectorcraft_brush::BrushKind::Art(brush) = brush_named(&lib, "Ribbon") else { panic!("art: {:?}", r.warnings) };
let m = brush.art.extras().mask.as_deref().unwrap_or_else(|| panic!("the mask is read: {:#?}", brush.art));
assert_eq!(m.linked, linked);
let (object, over) = (brush.art.geometric_bounds().unwrap(), m.art.geometric_bounds().unwrap());
assert!((object.height() - 8.0).abs() < 1e-6 && (over.height() - 3.0).abs() < 1e-6, "linked {linked}: {over:?} over {object:?}");
assert!(over.y0 > object.y0 - 1e-6 && over.y1 < object.y1 + 1e-6, "linked {linked}: {over:?} over {object:?}");
read.push((object, over));
}
assert_eq!(read[0], read[1], "a mask is in the same place whether it moves with its object or not");
}
/// An art styles section inside a symbol's, a pattern's or a brush's art is skipped: the file's own
/// art styles still style the layers' objects read after the definition.
#[test]
+3 -1
View File
@@ -118,7 +118,9 @@ private editing data. VectorCraft:
Scatter and Art brushes with their art, are written in its order: Scatter and Art brushes in Tints or keeping their
art's colors, Art brushes that stretch their art along the path from left to right at 100% unflipped without
overlap, and art of paths and compound paths with points and groups with members, with one solid fill and one
plain stroke each. Other brushes,
plain stroke each. Such art may hold opacity masks whose art is of the same kinds, up to seven deep in one
another's art; the masks are written with their options, and an Art brush whose art holds one is written with
its strokes as their drawn look. Other brushes,
Pattern and Bristle brushes among them, and brushes past the number or the art VectorCraft's reader reads are left
out with a warning; no brush is written on a large canvas. A path or compound path with a Calligraphic brush, or
with an Art brush in Tints whose art bends along the path, keeps the brush on its stroke; other brushed strokes are
+1
View File
@@ -1651,6 +1651,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
A `.ai` or EPS whose editing data has brushes opens with the file's Calligraphic, Scatter, Art and Bristle brushes in the Brushes panel in place of the default ones, in the file's order: the Calligraphic size, roundness and angle with their variation, the Scatter size, spacing, scatter and rotation, the Bristle settings, and the Scatter and Art brushes' art (Art brushes in the older and newer forms of their objects). A brush library `.ai` (brushes and no layers) opens from its PDF part with its brushes, so Other Library lists them. An Art brush in Tints keeps that colorization. Pattern brushes and brushes that can't be read are left out with a note. Paths with a Calligraphic brush, and paths with an Art brush in the newer form at 100% in Tints that stretches art of solid-filled paths unflipped, open as the path with the brush on its stroke. Paths with an Art brush in the older form, and other brushed paths, still come in as their drawn look (part of #372 and #637; `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`).
In a `.ai` opened from its editing data, a path or type object with Offset Path, Outline Object or Outline Stroke on the whole object opens as itself with those effects live, in their order and shown or hidden; on a fill or stroke of type they stay on that fill or stroke. Offset Path keeps its Offset, Joins and Miter Limit, and Outline Stroke takes its width from the stroke. An Offset Path with a setting missing, out of range or not read keeps the drawn art, as does a path with a Path effect on one fill or stroke (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`).
In a `.ai` or EPS opened from its editing data, a Scatter brush whose last 15 numbers start with 1 comes into the Brushes panel in Tints, and each brush art section is read without its frame, an unnamed, unpainted rectangle with no settings of its own at the art's bounds (within 1/1000 pt). A wider frame stays in the art, and an art group with a state or look of its own (hidden, locked, isolated, knockout, an opacity, a blend mode, a name, a mask, a note or an appearance) stays a group (`crates/eps/src/import/ai/tests.rs`).
A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes a Scatter or Art brush whose art holds opacity masks to the Brushes panel of its editing copy. This is VectorCraft's own rule for brushes a document already holds. Each mask's art is written in the brush's art section in the form VectorCraft's `.ai` reader reads (`define_brush_art` in `crates/eps/src/import/ai/read/directives.rs`), with the mask's Clip and Invert Mask options, whether it is disabled and whether it moves with its object, for masks up to seven deep in one another's art. A brush whose mask art holds more than paths, compound paths and groups with one solid fill and one plain stroke each is left out with a warning, and a path with an Art brush whose art holds a mask is written as its drawn look. When the reader turns an Art brush's art over, it turns the art of a mask that doesn't move with its object over too (`scatter_and_art_brush_mask_art_round_trips` and `brushes_whose_mask_art_isnt_read_back_are_left_out` in `crates/eps/src/ai_editing/tests.rs`, `an_art_brushs_opacity_mask_art_turns_over_with_its_object` in `crates/eps/src/import/ai/tests.rs`).
In a `.ai` opened from its editing data, type with Warp on the object or on one of its fills or strokes opens as type with the effect live when the live warp draws as the art saved with it. When it draws differently, or when the file's limit of checks has no check left for it, it opens as that art, and one note says how many did. Type stays live without a comparison when the saved art paints nothing or draws type of its own, in frames of threaded type, when a text variable binds it, and when its text object doesn't come in as one text object (`crates/eps/src/import/ai/envelope.rs`, `crates/eps/src/import/tests_native.rs`).
In a `.ai` opened from its editing data, an object with a Tweak that moves nothing or Pucker & Bloat at 0 opens as itself with the effect live. A path, compound path or group whose only effect is Transform without copies, or a Free Distort whose corners make a parallelogram, opens as itself with it live, and so does an object with nothing stroked whose only effect is Twist: a path or compound path with straight segments at up to 180° either way, and another path, compound path or group with no guide in it at up to 90° either way (limits VectorCraft sets); one twisted further keeps the drawn art. A gradient or pattern, an image, type, a clipping group, an opacity mask or effects inside the object, or a stroke with a Transform that scales, rotates or reflects, keep the drawn art (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/ai/read/ops.rs`).
A PDF page whose `UserUnit` (PDF 1.6) is above 1 opens at its size in points, its numbers times the `UserUnit` (one above 75,000 counts as 75,000), and `document.pdfInfo` gives its size and boxes in points too. A `.ai` whose editing data has its artboards in the units of such a page opens from that data at the page's size, with its layers, and when the layers can't be read its pages still take the artboard layout of the data, scaled the same way (part of #1482).