Skip to content

AI import: a pattern fill tiles from its tile's lower left, wherever the definition drew the tile - #2016

Merged
bflatastic merged 1 commit into
storytold:mainfrom
EricKuck:fix/ai-pattern-phase
Oct 15, 2026
Merged

bflatastic merged 1 commit into
storytold:mainfrom
EricKuck:fix/ai-pattern-phase

Conversation

@EricKuck

Copy link
Copy Markdown
Contributor

What and why

A .ai pattern definition (%AI3_BeginPattern) gives its tile as a box in the pattern's own space, (name) llx lly urx ury, and draws its art there. A fill with it (p/P) carries the matrix from the pattern's space to the art. pattern_paint in crates/eps/src/import/ai/read.rs built the fill's transform with an extra translate(origin), the tile's top left, but the renderer already places each tile's art relative to its tile (PatternDef::instance_xf). The tile's position was counted twice, so every fill whose definition drew its tile away from (0, 0) tiled shifted by that position, modulo the tile size.

The fill now places the tile's lower left at the pattern's origin, whatever box the definition drew it in. A tile drawn at (0, 0) tiles exactly as before.

Across the .ai files we own, 410 of 442 pattern definitions draw their tile away from (0, 0). Checked against the files' own PDF pages: a 256-point scale pattern was shifted by (−55, +56) points; it now lands on the page's tiling exactly (cross-correlation peak at zero shift), and the artboard's difference from the page drops from 94 % to 25 % of its pixels (what's left is a separate issue, gradients inside the tiles), and another artboard's from 11.4 % to 2.5 %. Of 73 artboards across 20 files that fill with patterns, those two improve and none get worse.

How it was tested

crates/eps/src/import/ai/tests.rs (hand-written input): a_pattern_tiles_from_its_lower_left_wherever_its_definition_drew_it moves the existing Dots definition's tile and art to 30..38 × 40..48 and checks the fill places the tile where the original at 0..8 × 0..8 does. It fails without the change. patterns_are_pattern_swatches_and_fill_with_them passes unchanged.

cargo test -p vectorcraft-eps (201 tests) passes.

Checklist

  • fmt, clippy (-D warnings; the only hits are pre-existing upstream lints in crates this PR doesn't touch, crates/pdf/src/import_scan.rs among them), the tests above, brands.
  • 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.
  • Clean-room: nothing copied from Adobe products or GPL/AGPL code. The test input is written from scratch.
  • No new assets.

@Messhias Messhias left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo xtask ci is incomplete or unchecked on this PR. Run it end to end (fmt, clippy, tests, assets, brands, layers, wasm), tick the checklist when green, and reply here with the outcome. That is required before any approve from here.

…the definition drew the tile

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bflatastic
bflatastic force-pushed the fix/ai-pattern-phase branch from 1b875c2 to a3081b9 Compare October 15, 2026 19:38
@bflatastic
bflatastic merged commit 01c66e5 into storytold:main Oct 15, 2026
@bflatastic

Copy link
Copy Markdown
Member

Thanks @EricKuck! Merged after a full gate.

@bflatastic

Copy link
Copy Markdown
Member

One note: read.rs had gained the legacy-type fields from #1794 next to pattern_tiles, so I kept both when rebasing.

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.

3 participants