The MAUI ICanvas has several transform methods but is lacking the commonly-found SetTransform or ResetTransform methods. The docs here say:
The only ICanvas method that accepts a Matrix3x2 argument is the ConcatenateTransform method, which combines multiple transforms into a single transform.
This "only" is very unusual. SkiaSharp has both set and reset methods, as does HTML CanvasRenderingContext2D.
Of course ResetTransform is not strictly necessary, you can call SetTransform with identity. But having neither makes it very annoying to get the MAUI Graphics ICanvas back to identity transform without resetting all of its state, or creating a transform to try and cancel-out the current transform. Calling ICanvas.ResetState is unacceptable, as it destroys the Font, colors, alpha, etc.
Public API Changes
ICanvas.SetTransform(Matrix3x2 matrix); // Replaces the ICanvas current matrix values with the supplied matrix
ICanvas.ResetTransform(); // Resets the ICanvas current matrix to identity
Intended Use-Case
I author JS and C# Diagramming libraries, and am in the process of updating the C# one that uses GDI+, which is terribly slow, to MAUI/Skia, which is nice and fast. My code uses a lot of transforms and something like SetTransform is very useful when drawing persistent objects that maintain their own coordinates in the visual tree.
Description
The MAUI
ICanvas
has several transform methods but is lacking the commonly-foundSetTransform
orResetTransform
methods. The docs here say:This "only" is very unusual. SkiaSharp has both set and reset methods, as does HTML CanvasRenderingContext2D.
Of course
ResetTransform
is not strictly necessary, you can callSetTransform
with identity. But having neither makes it very annoying to get the MAUI Graphics ICanvas back to identity transform without resetting all of its state, or creating a transform to try and cancel-out the current transform. CallingICanvas.ResetState
is unacceptable, as it destroys the Font, colors, alpha, etc.Public API Changes
Intended Use-Case
I author JS and C# Diagramming libraries, and am in the process of updating the C# one that uses GDI+, which is terribly slow, to MAUI/Skia, which is nice and fast. My code uses a lot of transforms and something like
SetTransform
is very useful when drawing persistent objects that maintain their own coordinates in the visual tree.