Skip to content
This repository was archived by the owner on Apr 29, 2022. It is now read-only.

Conversation

@bdero
Copy link
Member

@bdero bdero commented Apr 7, 2022

Add an explicit Vector2 scale override in Matrix and Canvas.

So I ran into some confusion while adding imgui elements to the test for flutter/flutter#101330. I set the canvas scale with canvas.Scale({3, 3}), which scaled everything correctly. However, to my dismay, canvas.GetCurrentTransformation().Invert() produced an identity matrix. The problem was that canvas.Scale({x, y}) matches Canvas::Scale(Vector3{x, y}), and so the Z component of the Z basis vector gets set to zero, which means the determinant ends up being zero, which makes computing the inverse nonsensical. Having this explicit override makes this mistake much less likely.

(Also, drive-by fix: Move the text contents color premultiply into the render method for consistency with other contents)

@bdero bdero requested review from chinmaygarde and dnfield April 7, 2022 04:19
@bdero bdero changed the title Add explicit scaling methods for Point/Vector2 Add explicit Point/Vector2 scaling methods to Matrix and Canvas Apr 7, 2022
@bdero bdero merged commit 58ef66b into flutter:main Apr 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants