Skip to content

.ai import: images, meshes, blends and styled objects keep the knockout shape flag - #5978

Merged
bflatastic merged 3 commits into
storytold:mainfrom
dotCooCoo:fix/ai-image-knockout-shape
Nov 7, 2026
Merged

bflatastic merged 3 commits into
storytold:mainfrom
dotCooCoo:fix/ai-image-knockout-shape

Conversation

@dotCooCoo

@dotCooCoo dotCooCoo commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

What and why

Part of #637.

When it opened an .ai file's editing data, the reader dropped the Opacity & Mask Define Knockout Shape flag on several kinds of object. An image saved with the flag on (embedded or linked) came back without it, and no warning was shown. The same thing happened to gradient meshes, blends, styled objects whose flag is written on their drawn look, text objects with a look, and a compound path made of several clipping paths.

The writer writes the flag as the shape operand of Xy (crates/eps/src/ai_editing/writer.rs:75), set before an image at crates/eps/src/ai_editing/writer/images.rs:118. The reader now keeps that operand:

  • An image or a gradient mesh (one mesh or a group of patches) takes the flag from an Xy written before it.
  • A mesh or a blend takes the flag from an Xy written right after its end. When that Xy is the layer's, the reader puts the object's own flag back, as it already did for opacity and blend mode. A live blend takes the flag from its drawn steps.
  • A styled object takes the flag written on its drawn look. A text object takes it when its look draws only the type; otherwise the group that holds the look and the type takes it.
  • The compound path made of several clipping paths has the flag when every clipping path has it.

Changes in how existing files open: images, meshes, blends, styled objects and these compound clipping paths that carry the flag now keep it, so inside a knockout group they knock out by their shape instead of by their opacity. An opaque text look that draws more than the type and sets the flag now goes into a group with the type, which holds the flag.

How it was tested

New tests in vectorcraft-eps:

  • ai_editing::tests::an_images_knockout_shape_comes_back: an embedded and a linked image with the flag are written and read back with it; the image between them and the layer do not take it.
  • import::ai::tests::a_gradient_mesh_keeps_its_knockout_shape: an Xy before a mesh and after its end, as one mesh and as a group of patches, and an Xy that is the layer's.
  • import::ai::tests::a_blend_keeps_its_knockout_shape: a live blend, its drawn steps, an Xy before the record, and an Xy that is the layer's.
  • import::ai::tests::a_text_objects_look_gives_it_the_knockout_shape: a look that draws only the type, and a look that draws more, transparent and opaque.
  • import::ai::tests::the_compound_of_clipping_paths_keeps_their_knockout_shape: the flag on every clipping path, on none, on one only, and with opacities that differ.
  • import::ai::tests::a_styled_object_keeps_the_transparency_written_on_its_look now also checks the flag.

Each new test fails on main at 36ef34dfdd.

Commands run on 5089dc91eb:

  • cargo fmt --all -- --check
  • cargo clippy -p vectorcraft-eps --all-targets -- -D warnings
  • cargo test -p vectorcraft-eps: 983 tests, 0 failed
  • cargo test -p vectorcraft-engine --lib -- ai: 478 tests, 0 failed
  • cargo test -p vectorcraft-engine --test import_fuzz: 190 tests, 0 failed
  • cargo xtask brands, cargo xtask layers (28 crates), cargo xtask assets (334 files)

cargo xtask ci passed in this pull request's CI run on 5089dc91eb: https://github.com/storytold/vectorcraft/actions/runs/42295756949/job/128160427908

Checklist

  • cargo xtask ci passes (fmt, clippy, tests, assets, brands, layers, wasm).
  • No panics in shipped code: no unwrap(), expect(), panic!, unreachable!, todo! or
    unimplemented! outside tests, and no unchecked indexing on data from files, parameters or
    messages. Errors are returned as Result and shown to the user
    (why and how).
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code (AGENTS.md).
  • Every new asset has a row in ASSETS.md.

Summary by CodeRabbit

  • Bug Fixes
    • Preserved knockout-shape settings when importing artwork, including images, meshes, clipping paths, blends, groups, and styled text.
    • Improved handling of transparency settings so object and layer states remain distinct.
  • Tests
    • Added coverage for knockout-shape settings across imported artwork and image read-back.

@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Caution

Review failed

The pull request is closed.

No actionable comments were generated in the recent review.

Walkthrough

AI import now preserves knockout_shape across images, meshes, styled and text objects, clipping compounds, blends, and layer state. Tests check object-versus-layer state and image read-back expectations.

Changes: AI Import State

Layer / File(s) Summary
Propagate state to imported objects
crates/eps/src/import/ai/read.rs, crates/eps/src/import/ai/read/art.rs, crates/eps/src/import/ai/read/ops.rs, crates/eps/src/import/ai/tests.rs, crates/eps/src/ai_editing/tests.rs
Mesh, image, styled-object, and text import paths propagate knockout_shape with other transparency state. Tests cover these object states and image read-back.
Preserve state on compounds and blends
crates/eps/src/import/ai/read/containers.rs, crates/eps/src/import/ai/tests.rs
Clipping compounds, restored layer mesh state, and live blends preserve knockout_shape. Tests check clipping-path agreement and blend state assignment.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: mockydevs

Merge Risk: Minimal · previous review 5089d

No actionable merge-blocking issue is established for the knockout-shape import change. Merge after the project's normal checks.

Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title clearly identifies the main change: preserving the knockout shape flag during .ai import.
Docstring Coverage Passed Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentati…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed The description includes all required sections. It explains the changes, links an issue, lists tests and results, and completes the checklist.
Full details: Docstring Coverage

Explanation

Docstring coverage is 90.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 10 functions across 6 files.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 36ef34d and 5089dc9.

Files selected for processing: 6

  • crates/eps/src/ai_editing/tests.rs
  • crates/eps/src/import/ai/read.rs
  • crates/eps/src/import/ai/read/art.rs
  • crates/eps/src/import/ai/read/containers.rs
  • crates/eps/src/import/ai/read/ops.rs
  • crates/eps/src/import/ai/tests.rs

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

dotCooCoo and others added 3 commits November 7, 2026 05:15
An `Xy` whose shape operand is set now reaches an image (embedded or
linked) and a gradient mesh when it is written before the object, and a
mesh or blend when it is written after the object's end. A live blend
takes the flag from its drawn steps. Before, the reader dropped the flag
on these objects, so an image saved with Opacity & Mask Define Knockout
Shape lost it on reopening, with no warning.

A styled object takes the flag written on its drawn look. For a text
object, the flag goes to the object when the look draws only its type,
and otherwise to the group that holds the look and the type. An opaque
look that draws more than the type and sets the flag now goes into that
group as well.
Clipping paths in a compound path that holds a drawn look become one
compound path. It took the paths' shared stroke, opacity and blend mode
but dropped the knockout shape flag. It now has the flag when every
clipping path has it.
@bflatastic
bflatastic force-pushed the fix/ai-image-knockout-shape branch from 5089dc9 to ccdccb1 Compare November 7, 2026 01:10
@bflatastic
bflatastic merged commit 60f1bff into storytold:main Nov 7, 2026
3 checks passed
@bflatastic

Copy link
Copy Markdown
Member

Merged, thanks @dotCooCoo! Images, meshes, blends and styled objects now keep the knockout shape flag on .ai import.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants