Skip to content

feat: additional texture fit modes - #75

Merged
antouhou merged 1 commit into
mainfrom
feat-additional-texture-fit-modes
Sep 3, 2026
Merged

feat: additional texture fit modes#75
antouhou merged 1 commit into
mainfrom
feat-additional-texture-fit-modes

Conversation

@antouhou

@antouhou antouhou commented Sep 3, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added Cover and Contain texture-fit modes for shapes.
    • Improved texture placement with aspect-ratio preservation, centered scaling, and correct handling of cropped or letterboxed areas.
  • Bug Fixes

    • Corrected texture compositing so pixels outside valid texture bounds no longer contribute unintended colors.
  • Tests

    • Added visual coverage verifying Cover and Contain behavior.
  • Chores

    • Updated the package version to 0.19.0.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Team

Run ID: 963eb7b9-b8a0-495d-97e5-b64ac11a68ad

📥 Commits

Reviewing files that changed from the base of the PR and between 74de285 and 5b83309.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (9)
  • Cargo.toml
  • src/renderer.rs
  • src/renderer/draw_queue.rs
  • src/renderer/preparation.rs
  • src/renderer/shape_effects.rs
  • src/shaders/shader.wgsl
  • src/shape.rs
  • src/vertex.rs
  • tests/visual_regression.rs

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The renderer adds Cover and Contain texture fitting. UV data now carries scale and offset values through instance metadata and vertex buffers. Shaders apply the transforms and suppress samples outside the texture footprint. Visual regression coverage verifies both modes.

Changes

Texture fit rendering

Layer / File(s) Summary
Texture fit and transform contract
src/shape.rs, src/vertex.rs, src/renderer.rs
Adds Cover and Contain. Defines TextureUvTransform and updates instance metadata and vertex attributes to use scale and offset values.
CPU transform calculation and propagation
src/renderer/draw_queue.rs, src/renderer/preparation.rs, src/renderer/shape_effects.rs
Computes centered transforms for Cover and Contain, then forwards them through instance texture data.
Shader rendering and regression validation
src/shaders/shader.wgsl, tests/visual_regression.rs, Cargo.toml
Applies UV transforms in both vertex shaders, masks out-of-footprint texture samples, adds Cover and Contain assertions, and bumps the crate version to 0.19.0.

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

Merge Risk: ⚪ Minimal · up to 5b833

This change adds aspect-ratio-preserving Cover and Contain texture fitting, including cropping or transparent out-of-footprint areas as appropriate. The rendering path and regression coverage support the intended behavior, with no current merge-blocking risk identified.

Sequence Diagram(s)

sequenceDiagram
  participant Shape
  participant Renderer
  participant VertexShader
  participant FragmentShader
  participant RegressionTest
  Shape->>Renderer: select Cover or Contain
  Renderer->>Renderer: compute UV scale and offset
  Renderer->>VertexShader: upload TextureUvTransform
  VertexShader->>FragmentShader: pass transformed coordinates
  FragmentShader->>RegressionTest: render fitted texture
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 7 files. (2 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 clearly identifies the main change: adding additional texture fit modes, including Cover and Contain.
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: Docstring Coverage

Explanation

Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 15 functions across 7 files. (2 skipped: 2 unsupported.)

  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat-additional-texture-fit-modes

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

Comment @coderabbitai help to get the list of available commands.

@antouhou
antouhou merged commit 139d81a into main Sep 3, 2026
5 checks passed
@antouhou
antouhou deleted the feat-additional-texture-fit-modes branch September 3, 2026 16:22
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.

1 participant