public void AddEllipse(RectangleF rect)
{
const float C1 = 0.552285f;
const float C2 = 0.552285f;
float rx = rect.Width / 2;
float ry = rect.Height / 2;
float cx = rect.X + rx;
float cy = rect.Y + ry;
if (!isReverseWindingOnFill) {
/* origin */
Append (cx + rx, cy, PathPointType.Start, false);
/* quadrant I */
AppendBezier (cx + rx, cy - C1 * ry,
cx + C1 * rx, cy - ry,
cx, cy - ry);
/* quadrant II */
AppendBezier (cx - C1 * rx, cy - ry,
cx - rx, cy - C1 * ry,
cx - rx, cy);
/* quadrant III */
AppendBezier (cx - rx, cy + C1 * ry,
cx - C1 * rx, cy + ry,
cx, cy + ry);
/* quadrant IV */
AppendBezier (cx + C1 * rx, cy + ry,
cx + rx, cy + C1 * ry,
cx + rx, cy);
}
else
{
// We need to reverse the drawing of the ellipse so that the
// winding is taken into account to not leave holes.
/* origin */
Append (cx + rx, cy, PathPointType.Start, false);
/* quadrant IV */
AppendBezier (cx + C1 * rx, cy + ry,
cx + rx, cy + C1 * ry,
cx + rx, cy);
/* quadrant I */
AppendBezier (cx + rx, cy - C1 * ry,
cx + C1 * rx, cy - ry,
cx, cy - ry);
/* quadrant II */
AppendBezier (cx - C1 * rx, cy - ry,
cx - rx, cy - C1 * ry,
cx - rx, cy);
/* quadrant III */
AppendBezier (cx - rx, cy + C1 * ry,
cx - C1 * rx, cy + ry,
cx, cy + ry);
}
CloseFigure ();
}
GraphicsPath::AddEllipse ( Rectangle rect ) : void | |
GraphicsPath::AddEllipse ( float x, float y, float width, float height ) : void | |
GraphicsPath::AddEllipse ( int x, int y, int width, int height ) : void |
public static void RenderEllipseGlass(Graphics g, Rectangle ownerRect, GlassPosition position, float positionFactor, Color glassColor, int alphaCenter, int alphaSurround) { if (!(positionFactor > 0 && positionFactor < 1)) throw new ArgumentException("positionFactor must be between 0 and 1, but not include 0 and 1. ", "positionFactor"); ownerRect.Height--; ownerRect.Width--; if (ownerRect.Width < 1 || ownerRect.Height < 1) return; using (GraphicsPath gp = new GraphicsPath()) { gp.AddEllipse(ownerRect); using (PathGradientBrush pb = new PathGradientBrush(gp)) { pb.CenterPoint = GetEllipseGlassCenterPoint(ownerRect, position, positionFactor); pb.CenterColor = Color.FromArgb(alphaCenter, glassColor); pb.SurroundColors = new Color[] { Color.FromArgb(alphaSurround, glassColor) }; using (NewSmoothModeGraphics ng = new NewSmoothModeGraphics(g, SmoothingMode.AntiAlias)) { g.FillPath(pb, gp); } } } }