SkiaSharp is a cross-platform 2D graphics API for .NET platforms based on Google's Skia Graphics Library. It provides a comprehensive 2D API that can be used across mobile, server and desktop models to render images.
MIT License
4.55k
stars
543
forks
source link
[BUG] SKMatrix.MapRect method standardizes the output rectangle. #2997
Due to many various libraries/formats from legacy systems, we deal with various coordinate systems.
The "Top" of an SKRect artifact is not always the smalles Y number" and the Y axis does not always decrease when moving up on the screen.
Similar on the X axis. What the user perceives as the "Left" of a screen artifact may along the way have been higher X coordinate due to the format that it was persisted in.
A use case for me is to draw in any technology specific coordinate system and have a SKMatrix map the points to their corresponding output coordinates.
Having quirks like this inside the library affects the whole concept of matrices since operation1 and operation2 done separately will no longer equal their concatenation if operation1 decides to standardize the intermediate result.
Code
var inputRect = new SKRect();
inputRect.Left =25;
inputRect.Right = 15;
inputRect.Bottom = 2;
inputRect.Top = 10;
// For simplicity, I have entered the described case here. But this test should be for all variations of inputRect.
var resultRect = SKMatrix.CreateIdentity().MapRect(inputRect);
Assert.AreEqual(inputRect.Right,resultRect.Right);
Assert.AreEqual(inputRect.Left,resultRect.Left);
Assert.AreEqual(inputRect.Top,resultRect.Top);
Assert.AreEqual(inputRect.Bottom,resultRect.Bottom);
Expected Behavior
The resultRectangle.Left == inputRectangle.Left
The resultRectangle.Right == inputRectangle.Right
The resultRectangle.Top == inputRectangle.Top
The resultRectangle.Bottom == inputRectangle.Bottom
I expect to use .Standardized property or similarif I want X/Y axis "corrected" (/flipped) in the output rectangle.
Actual Behavior
The resultRectangle.Left == inputRectangle.Right
The resultRectangle.Right == inputRectangle.Left
The resultRectangle.Top == inputRectangle.Bottom
The resultRectangle.Bottom == inputRectangle.Top
Version of SkiaSharp
2.88.3 (Current)
Last Known Good Version of SkiaSharp
2.88.2 (Previous)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
No response
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct
[X] I agree to follow this project's Code of Conduct
Description
Due to many various libraries/formats from legacy systems, we deal with various coordinate systems. The "Top" of an SKRect artifact is not always the smalles Y number" and the Y axis does not always decrease when moving up on the screen. Similar on the X axis. What the user perceives as the "Left" of a screen artifact may along the way have been higher X coordinate due to the format that it was persisted in.
A use case for me is to draw in any technology specific coordinate system and have a SKMatrix map the points to their corresponding output coordinates.
Having quirks like this inside the library affects the whole concept of matrices since operation1 and operation2 done separately will no longer equal their concatenation if operation1 decides to standardize the intermediate result.
Code
Expected Behavior
The resultRectangle.Left == inputRectangle.Left The resultRectangle.Right == inputRectangle.Right The resultRectangle.Top == inputRectangle.Top The resultRectangle.Bottom == inputRectangle.Bottom
I expect to use .Standardized property or similarif I want X/Y axis "corrected" (/flipped) in the output rectangle.
Actual Behavior
The resultRectangle.Left == inputRectangle.Right The resultRectangle.Right == inputRectangle.Left The resultRectangle.Top == inputRectangle.Bottom The resultRectangle.Bottom == inputRectangle.Top
Version of SkiaSharp
2.88.3 (Current)
Last Known Good Version of SkiaSharp
2.88.2 (Previous)
IDE / Editor
Visual Studio (Windows)
Platform / Operating System
Windows
Platform / Operating System Version
No response
Devices
No response
Relevant Screenshots
No response
Relevant Log Output
No response
Code of Conduct