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

[BUG] SKMatrix.MapRect method standardizes the output rectangle. #2997

Open
1 task done
TormodS opened this issue Sep 13, 2024 · 0 comments
Open
1 task done

[BUG] SKMatrix.MapRect method standardizes the output rectangle. #2997

TormodS opened this issue Sep 13, 2024 · 0 comments
Labels

Comments

@TormodS
Copy link

TormodS commented Sep 13, 2024

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

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

  • I agree to follow this project's Code of Conduct
@TormodS TormodS changed the title [BUG] SKMatrix.MapRect method standardizes the X coordinates of the rectangle. [BUG] SKMatrix.MapRect method standardizes the output rectangle. Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant