0

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?

Community
  • 1
  • 1
Bastiaan
  • 686
  • 1
  • 8
  • 20

1 Answers1

2

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" .../>
Clemens
  • 123,504
  • 12
  • 155
  • 268
  • I was completely thinking in pixels instead of pixels as the result of my line. Thanks for this perfect answer Clemens, the picture makes it soo much better! – Bastiaan Sep 30 '15 at 14:45