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 TransformOrigin for brushes #15037

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

Gillibald
Copy link
Contributor

@Gillibald Gillibald commented Mar 19, 2024

What does the pull request do?

What is the current behavior?

What is the updated/expected behavior with this PR?

How was the solution implemented (if it's not obvious)?

Checklist

Breaking changes

Obsoletions / Deprecations

Fixed issues

@Gillibald Gillibald requested a review from kekekeks March 19, 2024 11:18
@avaloniaui-bot
Copy link

You can test this PR using the following package version. 11.2.999-cibuild0046368-alpha. (feed url: https://nuget-feed-all.avaloniaui.net/v3/index.json) [PRBUILDID]

@maxkatz6 maxkatz6 added the backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch label Mar 19, 2024
@maxkatz6 maxkatz6 added this pull request to the merge queue Mar 19, 2024
Merged via the queue into AvaloniaUI:master with commit 4f8f46c Mar 19, 2024
6 checks passed
var transformOrigin = content.TransformOrigin.ToPixels(targetRect);
var offset = Matrix.CreateTranslation(transformOrigin);

transform *= -offset * content.Transform.Value * offset;
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this actually work? I think -offset also flips X and Y coordinates, but the test images won't catch this because they are symmetric in X and Y.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TransformOrigin mainly used to move the origin to some rotation point

The math is correct here

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, only noticed now that -offset actually means the inverse of offset. I think it would be more efficient to CreateTranslation(-transformOrigin), but performance is probably not a problem here.

@Gillibald Gillibald deleted the fixes/drawingBrushTransform branch March 20, 2024 05:57
Gillibald added a commit that referenced this pull request Mar 27, 2024
maxkatz6 pushed a commit that referenced this pull request Apr 6, 2024
@maxkatz6 maxkatz6 added backported-11.1.x and removed backport-candidate-11.1.x Consider this PR for backporting to 11.1 branch labels Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants