Repository navigation
Make drawRoundedImage keep aspect ratio with centered cover fit - #65
Merged
Merged
Conversation
The image is scaled uniformly to cover the destination rect, centered, and the overflow is cropped instead of stretching. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Follow-up to #64 — this commit was pushed to the
rounded-imagebranch just after that PR merged, so it never landed.drawRoundedImagenow keeps the image's aspect ratio instead of stretching: the image is scaled uniformly to cover the destination rect, centered, and the overflow is cropped (CSSobject-fit: coverbehavior).How
Only the UV mapping changes; the nine-piece geometry is untouched. A uniform cover scale (
max(size.x / imgW, size.y / imgH)) shifts the UV origin to a centered, aspect-matched sub-rect of the atlas entry, and all rect and fan vertices map through that shared sub-rect, so UVs stay continuous across pieces.Verified
Framebuffer captures via
tests/manual_rounded_image.nim --screenshot: a wide 300x200 rect crops the source's top/bottom rows, a tall 150x400 rect crops the left/right columns, and in both the color-block proportions match the original 48x48debug.9patch.🤖 Generated with Claude Code