Microsoft.Maui.Graphics
Microsoft.Maui.Graphics copied to clipboard
ScalingCanvas - Path is scaled only with ScaleX
Path operations: DrawPath, FillPath, ClipPath are only using Scale X for transformation, Scale Y is ignored:
var scaledPath = path.AsScaledPath(_scaleX);
Method AsScaledPath is creating transform as uniform scale:
var transform = Matrix3x2.CreateScale(scale);
scaledPath.Transform(transform);
Hi @mgierlasinski, thanks for noting this! I think I resolved this issue in #305 and I'm looking forward to feedback over there.
Adding details to this issue, the problem is that ScalingCanvas methods DrawPath, FillPath, and ClipPath only use the X scale, and that calling AsScaledPath() with a single value results in that scale being applied in both X and Y directions
https://github.com/dotnet/Microsoft.Maui.Graphics/blob/8b0dbfcb0e6a3b80f025e33412911aa5e2a53bc7/src/Microsoft.Maui.Graphics/ScalingCanvas.cs#L176-L180
https://github.com/dotnet/Microsoft.Maui.Graphics/blob/8b0dbfcb0e6a3b80f025e33412911aa5e2a53bc7/src/Microsoft.Maui.Graphics/ScalingCanvas.cs#L182-L186
https://github.com/dotnet/Microsoft.Maui.Graphics/blob/8b0dbfcb0e6a3b80f025e33412911aa5e2a53bc7/src/Microsoft.Maui.Graphics/ScalingCanvas.cs#L188-L192
The reason for this limitation is because AsScaledPath() only accepts a single number and scales both X and Y by that value:
https://github.com/dotnet/Microsoft.Maui.Graphics/blob/5410757e44e4c6a40c18691dc3c6b1e15a6897a9/src/Microsoft.Maui.Graphics/PathExtensions.cs#L66-L74
https://docs.microsoft.com/en-us/dotnet/api/system.numerics.matrix3x2.createscale
I resolve this in #305 by adding an overload that accepts distinct X and Y scales, then updating all the methods above to use it.
Hi @swharden, that was blazing fast :astonished: Thanks for that, that's exactly what I needed :blush: