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

feat: Added transform to Rect #1360

Merged
merged 8 commits into from
Feb 21, 2022
Merged

feat: Added transform to Rect #1360

merged 8 commits into from
Feb 21, 2022

Conversation

wolfenrain
Copy link
Contributor

@wolfenrain wolfenrain commented Feb 7, 2022

Description

Noticed there wasn't a method for transform rects. This method is kinda biased as it will transform from "center".

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the
relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • The title of my PR starts with a Conventional Commit prefix (fix:, feat:, docs: etc).
  • I have read the Contributor Guide and followed the process outlined for submitting PRs.
  • I have updated/added tests for ALL new/updated/fixed functionality.
  • I have updated/added relevant documentation in docs and added dartdoc comments with ///.
  • I have updated/added relevant examples in examples.

Breaking Change

Does your PR require Flame users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change. (Indicate it in the Conventional Commit prefix with a !,
    e.g. feat!:, fix!:).
  • No, this is not a breaking change.

Related Issues

Replace this paragraph with a list of issues related to this PR from the issue database.
Indicate which of these issues are resolved or fixed by this PR, i.e. Fixes #xxxx

@wolfenrain wolfenrain changed the title feat: Added transformRect to Matrix4 feat: Added transform to Rect Feb 8, 2022
/// Transform Rect using the transformation defined by [matrix].
///
/// **Note:** Rotation matrices will increase the size of the [Rect] but they
/// will not rotate it as [Rect] does not have any rotational values.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if it would be best to validate and throw errors for invalid matrixes.

We could (in the future) also have a version that fully works with any matrix and returns a Polygon to represent non-AA rectangles

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could, but not sure how to validate that on a matrix. So if anyone has any pointers, I am all ears!

@@ -36,5 +37,14 @@ void main() {
expect(r2.position.x, r1.left);
expect(r2.position.y, r1.top);
});

test('test transform', () {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we test the edge cases mentioned on the comments?

Copy link
Member

@luanpotter luanpotter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a couple comments

@spydon spydon enabled auto-merge (squash) February 21, 2022 18:58
@spydon spydon merged commit 1818be4 into main Feb 21, 2022
@spydon spydon deleted the feat-implemented-transform-rect branch February 21, 2022 19:01
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.

5 participants