Hello
I wrote a simple rounded rectangle function I'm having some issues with. It works fine when I don't set the smoothing mode, but if I set SmoothingMode.H ighQuality or AntiAlias it creates small gaps between the arc's I've used for corners. Increasing the size of the filler rectangles creates artifacts if I'm using transparency so thats not an option
See http://img594.imagesha ck.us/i/gaps.png/ for an example of the artifact
Heres the offending code
Hope someone has an idea on how to solve this
I wrote a simple rounded rectangle function I'm having some issues with. It works fine when I don't set the smoothing mode, but if I set SmoothingMode.H ighQuality or AntiAlias it creates small gaps between the arc's I've used for corners. Increasing the size of the filler rectangles creates artifacts if I'm using transparency so thats not an option
See http://img594.imagesha ck.us/i/gaps.png/ for an example of the artifact
Heres the offending code
Code:
private void FillRoundedRectangle(Graphics g, Brush b, Rectangle r, int RoundSize)
{
int rad = RoundSize * 2;
// ----------------------------------------------------------------
// Quality settings
// ----------------------------------------------------------------
g.SmoothingMode = SmoothingMode.HighQuality;
// ----------------------------------------------------------------
// Draw the rounded corners
// ----------------------------------------------------------------
g.FillPie(b, new Rectangle(r.Left, r.Top, rad, rad), 180, 90); // upper left
g.FillPie(b, new Rectangle(r.Left, r.Top + r.Height - rad, rad, rad), 90, 90); // lower left
g.FillPie(b, new Rectangle(r.Left + r.Width - rad, r.Top, rad, rad), 270, 90); // upper right
g.FillPie(b, new Rectangle(r.Left + r.Width - rad, r.Top + r.Height - rad, rad, rad), 0, 90); // lower right
// ----------------------------------------------------------------
// Draw the rest
// ----------------------------------------------------------------
// top
g.FillRectangle(b, new Rectangle(r.Left + RoundSize, r.Top, r.Width - rad, RoundSize));
// bottom
g.FillRectangle(b, new Rectangle(r.Left + RoundSize, r.Top + r.Height - RoundSize, r.Width - rad, RoundSize));
// center
g.FillRectangle(b, new Rectangle(r.Left, r.Top + RoundSize, r.Width, r.Height - rad));
}
Comment