Fix RoundRect radius clamping and containsRectangle API#1327
Merged
Conversation
- Width/height setters now re-clamp radius (prevents invalid vertices when dimensions shrink below 2*radius) - Radius setter clamps negative values to 0 - containsRectangle accepts any object with left/right/top/bottom (not just RoundRect, preserving Rect compatibility) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes RoundRect radius handling to prevent invalid vertex generation when dimensions shrink, and widens the containsRectangle API to accept Rect and other rectangle-like objects.
Changes:
- Re-clamp
radius(via theradiussetter) whenwidth/heightare updated to smaller values. - Clamp negative
radiusvalues to0in theradiussetter. - Update
containsRectangleto accept any object withleft/right/top/bottom, and add tests covering these behaviors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/melonjs/src/geometries/roundrect.ts | Re-clamps radius on dimension changes, clamps negative radius, and broadens containsRectangle parameter type. |
| packages/melonjs/tests/roundrect.spec.ts | Adds tests for setter-based re-clamping, negative radius clamping, and containsRectangle structural typing (including Rect). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
Addresses Copilot review feedback from PR #1326:
left/right/top/bottom(not justRoundRect), preservingRectcompatibilityTest plan
🤖 Generated with Claude Code