Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Control): corner coords definition order #9884

Merged
merged 2 commits into from
May 18, 2024

Conversation

jiayihu
Copy link
Contributor

@jiayihu jiayihu commented May 15, 2024

Control.calcCornerCoords returns corners in an order which make them an incorrect polygon, whereas it should just be a rect. That's because bl is defined before br.

Since ES2015 object keys are returned in insertion-order by spec (https://stackoverflow.com/a/23202095/6860493) so I believe we should fix this in calcCornerCoords instead of manually sorting the coords before calling Intersection.isPointInPolygon. That's more convenient and it works correctly out-of-the-box.

If you revert the fix, you'll see the test failing.

Copy link

codesandbox bot commented May 15, 2024

Review or Edit in CodeSandbox

Open the branch in Web EditorVS CodeInsiders

Open Preview

@asturur
Copy link
Member

asturur commented May 18, 2024

I think this is good, it also somehow aligns it with getCoords that returns an array in the same 'order'

@asturur asturur merged commit 938eae8 into fabricjs:master May 18, 2024
7 of 9 checks passed
@jiayihu jiayihu deleted the fix/calccornercoords-order branch May 19, 2024 10:18
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.

None yet

2 participants