When filling a GraphicsPath, a 1px stroke is also drawn. From the comment and related commits it seems that this behaviour was needed at some stage in the past, but my testing shows that it is no longer correct.
Test case (in Form Paint event):
using (var path = new GraphicsPath()) {
path.AddRectangle(new Rectangle(10, 10, 1, 20));
path.AddString("hi there", new FontFamily("Arial"), (int)FontStyle.Regular, 20, new Point(14, 10), StringFormat.GenericDefault);
e.Graphics.FillPath(Brushes.Blue, path);
}
using (var path = new GraphicsPath()) {
path.AddRectangle(new Rectangle(100, 10, 50, 50));
e.Graphics.FillPath(Brushes.Green, path);
using (var pen = new Pen(Color.FromArgb(128, Color.Red), 2))
e.Graphics.DrawPath(pen, path);
e.Graphics.TranslateTransform(100, 0);
using (var brush = new SolidBrush(Color.FromArgb(128, Color.Red)))
e.Graphics.FillPath(brush, path);
e.Graphics.TranslateTransform(50, 0);
using (var brush = new SolidBrush(Color.FromArgb(128, Color.Green)))
e.Graphics.FillPath(brush, path);
}
Unmodified:
With this change:
For good measure, .Net Framework on Windows 8.1:
As you can see above, it really messes up drawing text or anything narrow via a GraphicsPath.
After this change fill_graphics_with_brush is never called with stroke set to TRUE so I guess the parameter and code for drawing the stroke should be removed, but I didn't want to add that much noise initially.
When filling a
GraphicsPath
, a 1px stroke is also drawn. From the comment and related commits it seems that this behaviour was needed at some stage in the past, but my testing shows that it is no longer correct.Test case (in Form Paint event):
Unmodified:
With this change:
For good measure, .Net Framework on Windows 8.1:
As you can see above, it really messes up drawing text or anything narrow via a
GraphicsPath
.After this change
fill_graphics_with_brush
is never called withstroke
set toTRUE
so I guess the parameter and code for drawing the stroke should be removed, but I didn't want to add that much noise initially.