There is a good discussion about getting a widened path geometry on this thread:
Create a polygon around a polyline like a buffer
In my case, I would like to have the resulting outer line not "rounded", but totally flat. Is that Possible?
I tried to change line joins property, but there is no change on the resulting visual.
Here is the code to reproduce the problem:
private void Window_Loaded(object sender, RoutedEventArgs e)
{
StreamGeometry geom = new StreamGeometry();
DrawLines(geom);
Pen p = new Pen(Brushes.Black, 10);
p.LineJoin = PenLineJoin.Miter;
p.EndLineCap = PenLineCap.Flat;
p.StartLineCap = PenLineCap.Flat;
PathGeometry pathGeoWidened = geom.GetWidenedPathGeometry(p);
PathGeometry pathGeom = pathGeoWidened.GetOutlinedPathGeometry();
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.Data = pathGeom;
myCanvas.Children.Add(myPath);
}
private static void DrawLines(StreamGeometry geom)
{
using (var context = geom.Open())
{
context.BeginFigure(new Point(100, 100), true, true);
context.LineTo(new Point(100, 200), true, true);
context.LineTo(new Point(200, 200), true, true);
context.LineTo(new Point(200, 100), true, true);
}
}
Any thoughts?
Igor.