Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Draw not blurred path

Tags:

c#

uwp

I have a path that maybe makes not much sense without some context, but I need it that way

<Path StrokeThickness="2" Stroke="Blue" >
        <Path.Data>
            <PathGeometry>
                <PathFigure StartPoint="-10000,20">
                    <BezierSegment Point1="100,100" 
                                   Point2="120,120" 
                                   Point3="350, 350" />
                    <BezierSegment Point1="400,400" 
                                   Point2="450, 450" 
                                   Point3="200, 600" />
                </PathFigure>
            </PathGeometry>
        </Path.Data>
    </Path>

I've noticed that when I have a long path UWP by default optimizes the draw, my path gets pixelated

enter image description here

I don't want this behavior, is there any way to disable it? I really need a path like this, I can't change the length of it to get a better quality.

In WPF I get what I need:

enter image description here

like image 881
bto.rdz Avatar asked Mar 10 '23 20:03

bto.rdz


1 Answers

The reason for why you get the Blurry Lines in your XAML is because that you have used this StartPoint="-10000,20". Our WinRT has an issue rendering large polylines when the Polyline has any two points that are more than 2048 pixels apart it scales the polyline rather than rendering it normally.

The following explaination is quoted from Brendan Clark - MSFT in this thread:

In WinRT the size of each shape is limited by the hardware you're running your app on. The lowest common denominator is 2048 x 2048. This is large enough that everything will look sharp as long as you keep each component of your UI at roughly the same scale as a typical screen. As soon as you try to draw things that are significantly larger than the screen, the shapes will be clamped to the maximum size supported on your hardware, and will be scaled up from that point to the size you requested. Since the shape is clamped to a lower resolution than what you requested, scaling it up causes it to look blurry.

So if you change the StartPoint="-10000,20" to StartPoint="100,20", you will see it work fine.

Based on your description, I know that you do not want to change your path data, the only way to workaround this issue is to manually clip the Polyline based on the size of the viewing area, for more information, please check this code sample.

like image 90
Amy Peng - MSFT Avatar answered Mar 23 '23 19:03

Amy Peng - MSFT