dotnet / dotnet-api-docs

.NET API reference documentation (.NET 5+, .NET Core, .NET Framework)
https://docs.microsoft.com/dotnet/api/
Other
701 stars 1.55k forks source link

Wrong description for the parameters at Windows.Foundation.Rect Constructor #10230

Open eliyahuA opened 1 month ago

eliyahuA commented 1 month ago

Type of issue

Missing information

Description

For

Rect(Double, Double, Double, Double)

Constructor is specifies for the x and y parameters that they are coordinates for the top-left corner. But it is wrong, in-fact they are the coordinates for the bottom-left corner.

A simple app that demonstrates is available at this gist: https://gist.github.com/eliyahuA/83d2eb8a1e493a1abf07881ddece2879

Therefor I propose to change the written description accordingly

Page URL

https://learn.microsoft.com/en-us/dotnet/api/windows.foundation.rect.-ctor?view=dotnet-uwp-10.0#windows-foundation-rect-ctor(system-double-system-double-system-double-system-double)

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/Windows.Foundation/Rect.xml

Document Version Independent Id

d56ccb8d-f2ef-88e6-2ac4-7efe9278b029

Article author

@dotnet-bot

rzikm commented 3 weeks ago

I think the documentation is correct, if I use your example and change the FourPointsString to log the following

        public static string FourPointsString(this Rect rect, string string_format)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("4 Points as (x,y):");
            sb.AppendLine($"Top: {rect.Top}");
            sb.AppendLine($"Bottom: {rect.Bottom}");
            sb.AppendLine($"Left: {rect.Left}");
            sb.AppendLine($"Right: {rect.Right}");
            sb.AppendLine($"X: {rect.X}");
            sb.AppendLine($"Y: {rect.Y}");

            return sb.ToString();
        }

Then the result is image

So the X,Y coordinates are indeed the coordinates of the top left corner.

eliyahuA commented 2 weeks ago

@rzikm I think the misunderstanding originates from not clear definition of what is bottom and what is top.

traditional x,y coordinates If I reference a traditional x,y coordinates, then all points listed will be above (0,0) and therefore I would expect higher Y to be above smaller Y. So the line (500,600):(700,600) should be called top and not bottom, and (500,500):(700,500) should be called bottom and not top

placing objects on a canvas

If I need to provide coordinates for the SetLeft and SetTop methods of Canvas Class Then my 0,0 is the top left corner of the canvas. Then indeed the reference point of what is top and what is bottom is reversed and higher Y values will be below lower Y values. Then rectangle coordinates do make sense.

However, not every one who uses Rect struct will use it to place UI shapes on a canvas, I think there is a room for more clear explanation of what is the reference point for the discussed coordinates.

rzikm commented 2 weeks ago

However, not every one who uses Rect struct will use it to place UI shapes on a canvas, I think there is a room for more clear explanation of what is the reference point for the discussed coordinates.

The type is in the Windows.Foundation namespace, and is expected to be used with other types within that namespace. Is there any such type that uses different coordinate system such that it would have different meaning of top vs bottom?

I think the misunderstanding originates from not clear definition of what is bottom and what is top.

Feel free to suggest changes to the documentation that would make this clearer.

eliyahuA commented 2 weeks ago

The type is in the Windows.Foundation namespace, and is expected to be used with other types within that namespace. Is there any such type that uses different coordinate system such that it would have different meaning of top vs bottom?

This is valid point, I guess that would be my take from researching this

Feel free to suggest changes to the documentation that would make this clearer.

I need to give it more thought about the exact wording, but what comes to mind is to use the term Window Coordinate System and reference this page