Skip to content

Render: tiled picture fills keep their size in scaled groups and upright tiles - #1693

Merged
h-a-n-a-s-h-i merged 3 commits into
storytold:mainfrom
leobasilio:fix/tiled-fill-in-scaled-groups
Nov 3, 2026
Merged

h-a-n-a-s-h-i merged 3 commits into
storytold:mainfrom
leobasilio:fix/tiled-fill-in-scaled-groups

Conversation

@leobasilio

@leobasilio leobasilio commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

A tiled picture fill (a:blipFill with a:tile) on a shape inside a group whose child space differs from its box was drawn with a tile far larger or smaller than PowerPoint draws it. Textured shapes in decks with a "legacy" child space (the child rectangle ~1800 times smaller than the group's box, as old PowerPoint files write them) showed one flat texel of their texture instead of the texture.

Problem

paint::picture sizes a tile as natural size * 0.75 * sx in the shape's own units. Outside a group those units are points. Inside a group they are child-space units, so:

  • in a legacy-scale group (child 3840 x 2084 units for a 552 x 325 pt box) one tile covered hundreds of boxes and the fill was a single flat colour; a hatch fill came out as a grey block;
  • in a group that stretches x and y differently the tile was stretched with it;
  • tiles with rotWithShape="0" on a turned shape are drawn on the slide's axes in device pixels, and were sized in pixels too, so their size on the slide followed the zoom (even outside groups) and, in a group, the child scale as well.

What PowerPoint does

Observed in PowerPoint's own PNG export of a synthetic probe deck (our own images, raw OOXML, six slides): the tile keeps its size, offset, anchor and mirroring in slide points, whatever the group's scale: uniform (1, 4, 0.25, 1800, 0.05), stretched unevenly (x2/y0.5, x0.5/y2, x4, x1800, y1800), nested, flipped, or turned; sx/sy, tx/ty, algn and flip all behave as in the ungrouped control; the tile of a 75 dpi picture is 115.2 pt wide and of a 150 dpi one 57.6 pt, also in groups; a group's own tile fill (grpFill members) tiles from the group's corner at the same absolute size; with rotWithShape="0" the tiles stay upright at their absolute size. (The PowerPoint screenshots are not part of this PR, per AGENTS.md section 1.1.)

Solution

  • Renderer::per_point_xy gives the shape units per point along the shape's x and y axes (the existing per_point is the isotropic version, used for 3-D sizes). paint::tiled_per_point converts a tiled picture's sx, sy, tx and ty from points to those units before painting, so the tile comes out in slide points on both axes. fill_geometry applies it to shape fills.
  • The whole-device-pixel snapping of a tile in paint::picture is now per axis; one scale would round a stretched tile to the wrong size.
  • The rotWithShape="0" path in paint::fill_path, which paints in device pixels, sizes the tile to pixels with the same helper using the matrix's per-axis scale.

Note the last point changes drawing outside groups too: an upright tile in a turned shape used to be 90 px wide at any zoom and is now 90 pt (120 px at 1.333 px/pt), as in PowerPoint.

Before / after

Renders of the probe decks with deckcraft-cli render, upstream main (0d45a64) against this branch:

pr-A-uniform-scales pr-B-uneven-scales pr-D-rotation-upright pr-venn-legacy

Verification

  • New tests in crates/render/src/tests_wild.rs:
    • a_tile_keeps_its_size_in_a_group_with_scaled_child_coordinates: a wide and a tall tile in groups of seven scales, uniform and uneven (1, 1600, 0.25, 2x0.5, 0.5x2, 1800x1, 1x1800). It fails without the change (a flat purple pixel in the 1600 group).
    • an_upright_tile_in_a_turned_shape_keeps_its_size_in_points_at_any_zoom: the same turned shape at zoom 1 and 2, ungrouped and in a 0.25 group. It fails without the rotWithShape="0" change (122 of 312 samples agree).
  • Measured against PowerPoint's export of the probe deck (1280 x 720, mean absolute grey difference per case; the ungrouped control itself sits at ~13/255 from resampling): the grouped cases were 51 to 168 before (31 to 35 for the rotated ones) and are 12 to 16 now (about 3 for the rotated ones, which are mostly background). Two cases stay slightly above that floor, flipH on a group (16) and a 75 dpi tile with no group (19); the tile sizes look equal side by side, so I take it as sub-pixel phase or rounding, but I did not measure the phase.
  • cargo xtask ci: all eight steps pass on this branch rebased onto main at 0d45a64.
  • ROADMAP.md progress log and revision history have an entry. I left its stale "Last updated" header lines alone.

Not covered

  • Tiled fills in table cells, charts and the fill overlay of an effect inside a scaled group: not checked, not changed.
  • A group with a shear (more than scale, rotation and flip) is approximated by its per-axis scales.
  • Only the renderer was tested, not the running app.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Tiled picture fills now maintain consistent sizing and placement within scaled groups, including fills inherited by group members and fills on picture shapes.
    • Upright tiled fills retain their point size across zoom levels when shapes are rotated.
    • Tile dimensions are aligned to output pixels independently on each axis for more consistent rendering.

… upright tiles

A tiled picture fill (a:blipFill with a:tile) was sized in the shape's own
units. Inside a group whose child space differs from its box (old decks write
child spaces ~1800 times smaller) one tile covered hundreds of boxes, so the
fill showed a single flat texel instead of the texture.

PowerPoint's own PNG export of a synthetic probe deck shows the tile keeps its
size, offset, anchor and mirroring in slide points whatever the group's scale,
uniform or stretched unevenly, nested or flipped. The tile is now converted
from points to shape units per axis (Renderer::per_point_xy, paint::
tiled_per_point), and snapped to whole device pixels per axis.

Tiles with rotWithShape="0" are drawn in device pixels and were sized in
pixels, ignoring the zoom (even outside groups); they are now sized to pixels
first.

Tests: a tile in groups of seven scales (uniform and uneven, wide and tall
tile), and an upright tile in a turned shape at zoom 1 and 2.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
Commits

Reviewing files that changed from the base of the PR and between 9e59b5f and e90e7f6.

Files selected for processing: 3
  • ROADMAP.md
  • crates/render/src/renderer.rs
  • crates/render/src/tests_wild.rs
Files skipped from review as they are similar to previous changes: 1
  • ROADMAP.md

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

Walkthrough

Tiled picture fills now use separate x- and y-axis scales during rendering. The changes cover fills in scaled groups, including inherited group fills and picture shapes, and upright tiled fills on rotated shapes. Tests check tile dimensions and sampled colors across group scales and zoom levels.

Changes: Tiled picture fills

Layer / File(s) Summary
Per-point tile scaling
crates/render/src/renderer.rs, crates/render/src/paint.rs, crates/render/src/tests_wild.rs, ROADMAP.md, docs/parity-checklist.md
The renderer calculates separate point scales for each axis and applies them to tiled picture fills and picture content. Tests cover group scales, inherited group fills, picture shapes, and reflections. The roadmap and parity checklist record the update.
Upright tile drawing
crates/render/src/paint.rs, crates/render/src/tests_wild.rs
Upright tiled fills in turned shapes use transform scales when drawing. Tile dimensions snap to whole output pixels per axis. Tests compare tile patterns across zoom levels.

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

Change: Bug fix

Possibly related issues

Suggested reviewers: echelon, dylanmtaylor

Merge Risk: Low · up to e90e7

Upright tiled fills in rotated, scaled tables or charts can render at the wrong size. The visual impact is bounded, so the change is mergeable with that limitation understood.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documenta… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title names the main change: tiled picture fills keep their size in scaled groups and stay upright on turned shapes. The changeset adds per-axis scaling of tiled-picture parameters in paint.rs and…
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.
Full details: Title check

Explanation

The title names the main change: tiled picture fills keep their size in scaled groups and stay upright on turned shapes. The changeset adds per-axis scaling of tiled-picture parameters in paint.rs and renderer.rs, adds render tests for scaled groups and upright tiles, and updates the parity checklist and roadmap. The title matches the PR objectives, which describe the same goals.

Full details: Docstring Coverage

Explanation

Docstring coverage is 30.77% which is insufficient. 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 13 functions across 3 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate unit tests (beta)
  • Create a new PR
  • 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

@coderabbitai coderabbitai Bot 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.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread crates/render/src/renderer.rs Resolved
Comment thread crates/render/src/renderer.rs Resolved
Comment thread ROADMAP.md Resolved
…n points too

Review of storytold#1693 found two more places that drew a tiled picture fill in the
shape's own (child-space) units inside a scaled group.

A group nested in a scaled group stored its own tiled fill unconverted, so the
members that take it (grpFill) got oversized tiles. The owning group now
converts the fill with per_point_xy when it stores it, so inheriting members,
directly or through a chain of grpFill groups, get the converted tile.

A picture shape (p:pic) whose blip fill is a tile passed its own fill straight
to paint::picture. It now goes through paint::tiled_picture_per_point, which
tiled_per_point also uses.

Tests: a group's tile passed to its members and a picture shape's own tile, each
in outer groups scaled 1, 0.25, 1600 and 2x0.5; both fail without the change.

Docs: the Picture and texture fill checklist row is re-assessed (remains P) with
its status line and revision history, and the ROADMAP progress log row mentions
both cases.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

@coderabbitai coderabbitai Bot 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.

  • Fix comments: Fix CodeRabbit comments on this PR

Comment thread crates/render/src/renderer.rs Resolved
…ints too

Review of storytold#1693 found that cast_effects built the picture content that a shadow,
a glow and a reflection are drawn from without converting a tiled fill to
points, so inside a scaled group the reflection of a tiled picture showed
child-space tiles while its face showed the right ones.

The content now goes through paint::tiled_picture_per_point with per_point_xy,
as the face does.

Test: a tiled picture's reflection in groups scaled 0.25, 1600 and 2x0.5 shows
the same colours as in an unscaled group; it fails without the change.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@h-a-n-a-s-h-i
h-a-n-a-s-h-i merged commit 3c8dc6b into storytold:main Nov 3, 2026
7 checks passed
@echelon

echelon commented Nov 3, 2026

Copy link
Copy Markdown
Member

Landed on main, thank you @leobasilio for the contribution! If you haven't already, come join us on Discord: https://discord.gg/artcraft

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