unoplatform / uno.extensions

Libraries to ease common developer tasks associated with building multi-platform mobile, desktop and web applications using Uno Platform or WinAppSDK.
https://platform.uno/
Other
73 stars 47 forks source link

Rectangle draws too big shape (in C# markup) #2232

Closed kucint closed 6 months ago

kucint commented 7 months ago

Current behavior

Following code should draw a rectangle of size 10x6

new Rectangle()
    .Width(10)
    .Height(6)
    .StrokeThickness(1)
    .Stroke(Colors.Black)

but it draws a rectangle of size 13x8 (anti-aliased inner rectangle has size 11x6)

This is original screenshot: image

This is the same screenshot zoomed in Paint:

image

Expected behavior

The code should draw a rectangle of size 10x6

How to reproduce it (as minimally and precisely as possible)

STEPS TO REPRODUCE

MINIMAL REPRO PROJECT

Environment

{
  "msbuild-sdks": {
    "Uno.Sdk": "5.1.104",
    "Microsoft.Build.NoTargets": "3.7.56"
  }
}

Nuget Package (s):

<Project ToolsVersion="15.0">
  <ItemGroup>
    <PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" />
    <PackageVersion Include="Microsoft.Windows.SDK.BuildTools" Version="10.0.22621.2428" />
    <PackageVersion Include="Microsoft.WindowsAppSDK" Version="1.4.231219000" />
    <PackageVersion Include="Uno.Core.Extensions.Logging.Singleton" Version="4.0.1" />
    <PackageVersion Include="Uno.Extensions.Core.WinUI" Version="4.0.0" />
    <PackageVersion Include="Uno.Extensions.Hosting" Version="4.0.0" />
    <PackageVersion Include="Uno.Extensions.Hosting.WinUI" Version="4.0.0" />
    <PackageVersion Include="Uno.Extensions.Logging.WinUI" Version="4.0.0" />
    <PackageVersion Include="Uno.Extensions.Reactive" Version="4.0.0" />
    <PackageVersion Include="Uno.Extensions.Reactive.WinUI" Version="4.0.0" />
    <PackageVersion Include="Uno.Toolkit.WinUI" Version="5.1.7" />
    <PackageVersion Include="Uno.Resizetizer" Version="1.4.0" />
    <PackageVersion Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" Version="$(UnoVersion)" />
    <PackageVersion Include="Uno.UniversalImageLoader" Version="1.9.36" />
    <PackageVersion Include="Uno.WinUI" Version="$(UnoVersion)" />
    <PackageVersion Include="Uno.WinUI.Lottie" Version="$(UnoVersion)" />
    <PackageVersion Include="Uno.WinUI.Markup" Version="5.1.5" />
    <PackageVersion Include="Uno.Extensions.Markup.Generators" Version="5.1.5" />
    <PackageVersion Include="Uno.Toolkit.WinUI.Markup" Version="5.1.3" />
    <PackageVersion Include="Uno.Extensions.Reactive.WinUI.Markup" Version="4.0.0" />
    <PackageVersion Include="Uno.Themes.WinUI.Markup" Version="4.1.1" />
    <PackageVersion Include="Uno.WinUI.DevServer" Version="$(UnoVersion)" />
  </ItemGroup>
</Project>

Affected platform(s):

Visual Studio:

Relevant plugins:

Anything else we need to know?

checked only on windows. Other platforms - behavior unknown.

Youssef1313 commented 6 months ago

Maybe there is DPI scaling?

kucint commented 6 months ago

oh gosh! you are perfectly right! this is due to dpi scaling... Thanks for the hint!