-
Notifications
You must be signed in to change notification settings - Fork 279
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: bounding boxes and points for rotated rects #1600
Merged
Merged
Conversation
This file contains 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
± Registry diff
📊 PerformanceKeyNote that each bar component rounds up to the nearest 100ms, so each full bar is an overestimate by up to 400ms.
If a row has only one bar instead of four, that means it's not a trio and the bar just shows the total time spent for that example, again rounded up to the nearest 100ms. Data
|
Deploying with Cloudflare Pages
|
wodeni
approved these changes
Aug 4, 2023
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.
Description
Resolves #1595.
The way we handle rotated rectlike shapes has a few problems.
Rectangle
shape, thebboxFromRect
function computes the bounding box. But it ignores therotation
field. There already exists a functionbboxFromRotatedRect
(which is used to handle other rect-like shapes such asText
andImage
) which we can use.bboxFromRotatedRect
is also implemented incorrectly since it uses the wrong anchor for rotation. Rotation of rectlike shapes is rendered with respect to the center of the shape, butbboxFromRotatedRect
uses the top-left corner as the anchor which is inconsistent.rectPts
uses the same internal algorithm asbboxFromRotatedRect
, which has the same error.See example at code:
Implementation strategy and design decisions
I changed three things.
rectPts
now runs the correct algorithm that bases its rotation on the center of the shape.bboxFromRotatedRect
now runsrectPts
and constructs a bounding box from these points.bboxFromRect
now callsbboxFromRotatedRect
.Examples with steps to reproduce them
https://bboxrot.penrose-72l.pages.dev/try/?gist=d24def0664273563a9d5360289b6b6d7
The example above now behaves correctly.
Checklist