Bastiaan
Bastiaan

Reputation: 736

WPF - Simple path not producing expected result

I am trying to replicate a very simple image using a path in WPF, but somehow the path does not produce the results I expect.

This is the Image I want

enter image description here

This is the Path I use

<Path Stroke="Black" StrokeThickness="1" Data="M0,2 L2,4 L6,0"
   SnapsToDevicePixels="True" RenderOptions.EdgeMode="Aliased" />

This gets returned

enter image description here

How is this possible?

Upvotes: 0

Views: 50

Answers (1)

Clemens
Clemens

Reputation: 128136

I've added a green line through the coordinates you are drawing, which makes it obvious why you get that output.

enter image description here

You should draw the lower point at the center of a pixel, e.g. like this:

<Path Data="M0,2 L2.5,4.5 L7,0" .../>

Upvotes: 2

Related Questions