Posted 18 July 2018, 4:25 am EST
Hi again,
Attached is a modified Shapes sample, it adds a MakeRoundRect method that creates an IPath describing the specified round rectangle, and draws one on the first page. The actual code is this:
private IPath MakeRoundRect(GcGraphics g, RectangleF rc, float rx, float ry)
{
var path = g.CreatePath();
var sz = new SizeF(rx, ry);
// start from horizontal top left
path.BeginFigure(new PointF(rc.Left + rx, rc.Top));
path.AddLine(new PointF(rc.Right - rx, rc.Top));
path.AddArc(new ArcSegment() { Point = new PointF(rc.Right, rc.Top + ry), SweepDirection = SweepDirection.Clockwise, Size = sz });
path.AddLine(new PointF(rc.Right, rc.Bottom - ry));
path.AddArc(new ArcSegment() { Point = new PointF(rc.Right - rx, rc.Bottom), SweepDirection = SweepDirection.Clockwise, Size = sz });
path.AddLine(new PointF(rc.Left + rx, rc.Bottom));
path.AddArc(new ArcSegment() { Point = new PointF(rc.Left, rc.Bottom - ry), SweepDirection = SweepDirection.Clockwise, Size = sz });
path.AddLine(new PointF(rc.Left, rc.Top + ry));
path.AddArc(new ArcSegment() { Point = new PointF(rc.Left + rx, rc.Top), SweepDirection = SweepDirection.Clockwise, Size = sz });
path.EndFigure(FigureEnd.Closed);
return path;
}
and it can be used as follows:
RectangleF rc = new RectangleF(72, 72, 72 * 4, 72 * 2);
IPath path = MakeRoundRect(g, rc, 36, 24);
g.FillPath(path, Color.Purple);
g.DrawPath(path, new Pen(Color.Red, 4));
Hope this works for you. I am not sure I understand correctly what the other issue you mention is, if you still have that problem please provide a sample code and/or the (wrong) result.
Thanks.
RoundRect.zip