本文整理汇总了C#中GraphicsPath.AddEllipse方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.AddEllipse方法的具体用法?C# GraphicsPath.AddEllipse怎么用?C# GraphicsPath.AddEllipse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.AddEllipse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
GraphicsPath grPath = new GraphicsPath();
grPath.AddEllipse(0, 0, ClientSize.Width, ClientSize.Height);
this.Region = new System.Drawing.Region(grPath);
base.OnPaint(e);
}
示例2: OnResize
protected override void OnResize(EventArgs e)
{
using (var path = new GraphicsPath())
{
path.AddEllipse(new Rectangle(2, 2, this.Width - 4, this.Height - 4));
this.Region = new Region(path);
}
base.OnResize(e);
}
示例3: OnResize
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
using (var gp = new GraphicsPath())
{
gp.AddEllipse(new Rectangle(0, 0, this.Width - 1, this.Height - 1));
this.Region = new Region(gp);
}
}
示例4: Main
public static void Main (string[] args)
{
Bitmap bmp = new Bitmap (600, 600);
Graphics gr = Graphics.FromImage (bmp);
Rectangle rect = new Rectangle (20, 20, 100, 100);
PointF[] polygon_pnts = {new PointF(150.0F, 150.0F),
new PointF(200.0F, 125.0F), new PointF(300.0F, 105.0F),
new PointF(350.0F, 150.0F), new PointF(400.0F, 200.0F),
new PointF(450.0F, 300.0F), new PointF(350.0F, 350.0F) };
// Default Display
gr.DrawRectangle (Pens.Red, rect);
gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Red, 50, 50);
gr.DrawArc (Pens.Red, 30, 30, 60, 60, 0, 180);
gr.DrawPolygon (Pens.Red, polygon_pnts);
// Point
gr.PageUnit = GraphicsUnit.Point;
gr.DrawRectangle (Pens.Yellow, rect);
gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Yellow, 50, 50);
gr.DrawArc (Pens.Yellow, 30, 30, 60, 60, 0, 180);
gr.DrawPolygon (Pens.Yellow, polygon_pnts);
// Document
gr.PageUnit = GraphicsUnit.Document;
gr.DrawRectangle (Pens.Pink, rect);
gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Pink, 50, 50);
gr.DrawArc (Pens.Pink, 30, 30, 60, 60, 0, 180);
gr.DrawPolygon (Pens.Pink, polygon_pnts);
// Inc
gr.PageUnit = GraphicsUnit.Inch;
gr.DrawRectangle (Pens.Blue, 3f, 1f, 1f, 1f);
gr.DrawString ("Unit " + gr.PageUnit, new Font ("Arial", 10), Brushes.Blue, 0.7f, 0.7f);
gr.DrawArc (Pens.Blue, 3f, 3f, 1f, 1f, 0, 180);
bmp.Save ("units1.bmp");
bmp.Dispose ();
gr.Dispose ();
bmp = new Bitmap (600, 600);
gr = Graphics.FromImage (bmp);
GraphicsPath graphPath = new GraphicsPath();
graphPath.AddEllipse (0, 80, 100, 200);
// Default Display
gr.DrawBezier (Pens.Red, new Point (10, 10), new Point (20, 10),
new Point (35, 50), new Point (50, 10));
gr.DrawEllipse (Pens.Red, 10, 50, 30, 50);
gr.DrawPath (Pens.Red, graphPath);
gr.DrawPie (Pens.Red, 150, 20, 60, 60, 100, 140);
gr.DrawCurve (Pens.Red, polygon_pnts, 2, 4, 0.5f);
// Point
gr.PageUnit = GraphicsUnit.Display;
gr.PageUnit = GraphicsUnit.Point;
gr.DrawBezier (Pens.Pink, new Point (10, 10), new Point (20, 10),
new Point (35, 50), new Point (50, 10));
gr.DrawCurve (Pens.Pink, polygon_pnts, 2, 4, 0.5f);
gr.DrawEllipse (Pens.Pink, 10, 50, 30, 50);
gr.DrawPath (Pens.Pink, graphPath);
gr.DrawPie (Pens.Pink, 150, 20, 60, 60, 100, 140);
// Document
gr.PageUnit = GraphicsUnit.Document;
gr.DrawBezier (Pens.Yellow, new Point (10, 10), new Point (20, 10),
new Point (35, 50), new Point (50, 10));
gr.DrawEllipse (Pens.Yellow, 10, 50, 30, 50);
gr.DrawPath (Pens.Yellow, graphPath);
gr.DrawPie (Pens.Yellow, 150, 20, 60, 60, 100, 140);
gr.DrawCurve (Pens.Yellow, polygon_pnts, 2, 4, 0.5f);
// Inc
gr.PageUnit = GraphicsUnit.Inch;
gr.DrawBezier (Pens.Blue, new Point (10, 10), new Point (20, 10),
new Point (35, 50), new Point (50, 10));
gr.DrawEllipse (Pens.Blue, 10, 50, 30, 50);
gr.DrawPath (Pens.Blue, graphPath);
gr.DrawPie (Pens.Blue, 150, 20, 60, 60, 100, 140);
gr.DrawCurve (Pens.Blue, polygon_pnts, 2, 4, 0.5f);
bmp.Save ("units2.bmp");
}
示例5: CreatePath
GraphicsPath CreatePath ()
{
GraphicsPath path = new GraphicsPath ();
path.AddEllipse (new Rectangle (20, 20, 100, 100));
return path;
}
示例6: GetValueRec
public GraphicsPath GetValueRec()
{
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse((float)((.04) * vm.Width), (float)((.04) * vm.Height), (float)(.92) * vm.Width, (float)(.92) * vm.Height);
return gp;
}
示例7: GetValueRec
public Region GetValueRec()
{
Region r;
GraphicsPath gp = new GraphicsPath();
gp.AddEllipse((float)((.05 - vm.CircleWidth / 200f) * vm.Width), (float)((.05 - vm.CircleWidth / 200f) * vm.Height), (float)(.90 + vm.CircleWidth / 100f) * vm.Width, (float)(.90 + vm.CircleWidth / 100f) * vm.Height);
r = new Region(gp);
gp = new GraphicsPath();
gp.AddEllipse((float)((.05 + vm.CircleWidth / 200f) * vm.Width), (float)((.05 + vm.CircleWidth / 200f) * vm.Height), (float)(.90 - vm.CircleWidth / 100f) * vm.Width, (float)(.90 - vm.CircleWidth / 100f) * vm.Height);
r.Xor(gp);
return r;
}
示例8: IsFit
public bool IsFit(Point[] points)
{
// Note: rigorously calculating distance(point,ellipse) is very hard...
// overlay the regions and compare the areas, for now.
using (GraphicsPath polygp = new GraphicsPath())
using (GraphicsPath elligp = new GraphicsPath())
using (Matrix m = new Matrix())
{
// Set up gp for stroke.
polygp.AddPolygon(points);
// Set up gp for ellipse.
elligp.AddEllipse((float)-mj,(float)-mn,(float)mj*2,(float)mn*2);
m.Translate((float)cx,(float)cy);
m.Rotate((float)th);
elligp.Transform(m);
// Prepare regions for area-calculation.
using (Region xor = new Region(elligp))
using (Region isc = new Region(elligp))
{
xor.Xor(polygp);
isc.Intersect(polygp);
float badarea = Geometry.CalculateArea(xor);
float iscarea = Geometry.CalculateArea(isc);
float ratio = iscarea/badarea;
//heuristic: 10.0 seems about right.
return (ratio > 10f);
}
}
}
示例9: ColorWheel
public ColorWheel(Rectangle colorRectangle, Rectangle brightnessRectangle, Rectangle selectedColorRectangle)
{
// Caller must provide locations for color wheel
// (colorRectangle), brightness "strip" (brightnessRectangle)
// and location to display selected color (selectedColorRectangle).
using (GraphicsPath path = new GraphicsPath())
{
// Store away locations for later use.
this.colorRectangle = colorRectangle;
this.brightnessRectangle = brightnessRectangle;
this.selectedColorRectangle = selectedColorRectangle;
//this.selectedColor = Color.FromArgb(RGB.Alpha, RGB.Red, RGB.Green, RGB.Blue);
// Calculate the center of the circle.
// Start with the location, then offset
// the point by the radius.
// Use the smaller of the width and height of
// the colorRectangle value.
this.radius = (int)Math.Min(colorRectangle.Width, colorRectangle.Height) / 2;
this.centerPoint = colorRectangle.Location;
this.centerPoint.Offset(radius, radius);
// Start the pointer in the center.
this.colorPoint = this.centerPoint;
// Create a region corresponding to the color circle.
// Code uses this later to determine if a specified
// point is within the region, using the IsVisible
// method.
path.AddEllipse(colorRectangle);
colorRegion = new Region(path);
// set { the range for the brightness selector.
this.brightnessMin = this.brightnessRectangle.Top;
this.brightnessMax = this.brightnessRectangle.Bottom;
// Create a region corresponding to the
// brightness rectangle, with a little extra
// "breathing room".
path.AddRectangle(new Rectangle(brightnessRectangle.Left, brightnessRectangle.Top - 10, brightnessRectangle.Width + 10, brightnessRectangle.Height + 20));
// Create region corresponding to brightness
// rectangle. Later code uses this to
// determine if a specified point is within
// the region, using the IsVisible method.
brightnessRegion = new Region(path);
// Set the location for the brightness indicator "marker".
// Also calculate the scaling factor, scaling the height
// to be between 0 and 255.
brightnessX = brightnessRectangle.Left + brightnessRectangle.Width;
brightnessScaling = (double)255 / (brightnessMax - brightnessMin);
// Calculate the location of the brightness
// pointer. Assume it's at the highest position.
brightnessPoint = new Point(brightnessX, brightnessMax);
// Create the bitmap that contains the circular gradient.
CreateGradient();
}
}
示例10: DrawGlow
/// <summary>
/// Draws the glow for the button when the
/// mouse is inside the client area using
/// the GlowColor property.
/// </summary>
/// <param name="g">The graphics object used in the paint event.</param>
private void DrawGlow(Graphics g)
{
if (this.mButtonState == State.Pressed) { return; }
SetClip(g);
using (GraphicsPath glow = new GraphicsPath())
{
glow.AddEllipse(-5, this.Height / 2 - 10, this.Width + 11, this.Height + 11);
using (PathGradientBrush gl = new PathGradientBrush(glow))
{
gl.CenterColor = Color.FromArgb(mGlowAlpha, this.GlowColor);
gl.SurroundColors = new Color[] { Color.FromArgb(0, this.GlowColor) };
g.FillPath(gl, glow);
}
}
g.ResetClip();
}
示例11: Main
public static void Main ()
{
Bitmap bmp = new Bitmap (600, 300);
Graphics dc = Graphics.FromImage (bmp);
Font fnt = new Font ("Arial", 8);
Font fnttitle = new Font ("Arial", 8, FontStyle.Underline);
Matrix matrix = new Matrix ();
GraphicsPath patha = new GraphicsPath ();
GraphicsPath pathb = new GraphicsPath ();
Pen redPen = new Pen (Color.Red, 2);
Region rgn1;
Region rgn2;
int x = 0;
SolidBrush whiteBrush = new SolidBrush (Color.White);
dc.DrawString ("Region samples using GraphicsPath", fnttitle, whiteBrush, 5, 5);
/* First*/
patha.AddLine (60, 40, 90, 90);
patha.AddLine (90, 90, 10, 90);
patha.AddLine (10, 90, 60, 40);
dc.DrawPath (redPen, patha);
pathb.AddEllipse(30, 55, 60, 60);
dc.DrawPath(redPen, pathb);
rgn1 = new Region (patha);
rgn2 = new Region (pathb);
rgn1.Complement (rgn2);
dc.FillRegion (Brushes.Blue, rgn1);
dc.DrawString ("Complement (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 10, 140);
dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
x += 110;
/* Second*/
patha.Reset ();
pathb.Reset ();
patha.AddLine (60+x, 40, 90+x, 90);
patha.AddLine (90+x, 90, 10+x, 90);
patha.AddLine (10+x, 90, 60+x, 40);
dc.DrawPath (redPen, patha);
pathb.AddEllipse (30+x, 55, 60, 60);
dc.DrawPath(redPen, pathb);
rgn1 = new Region (patha);
rgn2 = new Region (pathb);
rgn1.Exclude (rgn2);
dc.FillRegion (Brushes.Blue, rgn1);
dc.DrawString ("Exclude (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 140, 140);
dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
x += 110;
/* Third*/
patha.Reset ();
pathb.Reset ();
patha.AddLine (60+x, 40, 90+x, 90);
patha.AddLine (90+x, 90, 10+x, 90);
patha.AddLine (10+x, 90, 60+x, 40);
dc.DrawPath (redPen, patha);
pathb.AddEllipse (30+x, 55, 60, 60);
dc.DrawPath (redPen, pathb);
rgn1 = new Region (patha);
rgn2 = new Region (pathb);
rgn1.Intersect (rgn2);
dc.FillRegion (Brushes.Blue, rgn1);
dc.DrawString ("Intersect (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 270, 140);
dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
x += 110;
/* Four*/
patha.Reset ();
pathb.Reset ();
patha.AddLine (60+x, 40, 90+x, 90);
patha.AddLine (90+x, 90, 10+x, 90);
patha.AddLine (10+x, 90, 60+x, 40);
dc.DrawPath (redPen, patha);
pathb.AddEllipse (30+x, 55, 60, 60);
dc.DrawPath (redPen, pathb);
rgn1 = new Region (patha);
rgn2 = new Region (pathb);
rgn1.Xor (rgn2);
dc.FillRegion(Brushes.Blue, rgn1);
dc.DrawString ("Xor (" + rgn1.GetRegionScans (matrix).Length +")", fnt, whiteBrush, 380, 140);
dc.DrawRectangles (Pens.Yellow, rgn1.GetRegionScans (matrix));
x += 110;
/* Fifth */
patha.Reset ();
pathb.Reset ();
patha.AddLine (60+x, 40, 90+x, 90);
//.........这里部分代码省略.........
示例12: OnPaint
protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
{
int intRate = 0;
e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Color UseFillColor = new Color();
Color UseBorderColor = new Color();
GraphicsPath ShapePath = new GraphicsPath();
float ptx;
float pty;
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
sf.LineAlignment = StringAlignment.Center;
pty = (this.Height - (RadiusOuter * 2)) / 2;
intRate = 0;
while (!(intRate == MaxRating))
{
ptx = intRate * (RadiusOuter * 2 + ShapeGap) + Padding.Left + (ShapeGap / 2);
if (PaintRating > intRate)
{
if (!IsPainting & HighlightRateFill & (PaintRating != intRate + 1))
{
UseFillColor = ShapeColorHover;
UseBorderColor = ShapeBorderHoverColor;
}
else if (IsPainting & HighlightRateHover & (PaintRating == intRate + 1))
{
UseFillColor = ShapeColorFill;
UseBorderColor = ShapeBorderFilledColor;
}
else
{
UseFillColor = PaintColor;
UseBorderColor = PaintBorderColor;
}
}
else
{
UseFillColor = ShapeColorEmpty;
UseBorderColor = ShapeBorderEmptyColor;
}
ShapePath.Reset();
Point[] pts;
switch (Shape)
{
case eShape.Star:
ShapePath = DrawStar(ptx, pty);
break;
case eShape.Heart:
ShapePath = DrawHeart(ptx, pty);
break;
case eShape.Square:
ShapePath.AddRectangle(new Rectangle((int)ptx, (int)pty, (int)(RadiusOuter * 2), (int)(RadiusOuter * 2)));
break;
case eShape.Circle:
ShapePath.AddEllipse(ptx, pty, RadiusOuter * 2, RadiusOuter * 2);
break;
case eShape.Diamond:
pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter)), new Point((int)(ptx + RadiusOuter), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter)) };
ShapePath.AddPolygon(pts);
break;
case eShape.Triangle:
pts = new Point[] { new Point((int)(ptx + RadiusOuter), (int)pty), new Point((int)(ptx + RadiusOuter * 2), (int)(pty + RadiusOuter * 2)), new Point((int)ptx, (int)(pty + RadiusOuter * 2)) };
ShapePath.AddPolygon(pts);
break;
}
e.Graphics.FillPath(new SolidBrush(UseFillColor), ShapePath);
e.Graphics.DrawPath(new Pen(UseBorderColor, ShapeBorderWidth), ShapePath);
if (ShapeNumberShow != eShapeNumberShow.None)
{
if (ShapeNumberShow == eShapeNumberShow.All | (ShapeNumberShow == eShapeNumberShow.RateOnly & PaintRating == intRate + 1))
{
e.Graphics.DrawString((intRate + 1).ToString(), ShapeNumberFont, new SolidBrush(ShapeNumberColor), new RectangleF(ShapeNumberIndent.X + ptx, ShapeNumberIndent.Y + pty, RadiusOuter * 2, RadiusOuter * 2), sf);
}
}
intRate += 1;
}
if (LabelShow)
{
int R_x = (int)(((RadiusOuter * 2) * (MaxRating)) + LabelIndent + ((ShapeGap) * MaxRating) + Padding.Left);
if (IsPainting)
{
RateLabel.Text = GetLabelText(LabelTypeHover);
}
else
{
RateLabel.Text = GetLabelText(LabelTypeText);
}
RateLabel.Width = (this.Width - R_x);
RateLabel.Height = (this.Height);
RateLabel.Location = new Point(R_x, 0);
}
}
示例13: OnPaint
protected override void OnPaint(PaintEventArgs pe)
{
// Calling the base class OnPaint
base.OnPaint(pe);
//GraphicsState oldState = pe.Graphics.Save();
//pe.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
// this prevents jagged edges along the rubber band
CompassMagnitude();
Graphics g = pe.Graphics;
GraphicsPath serge = new GraphicsPath();
serge.AddEllipse(this.ClientRectangle);
this.Region = new Region(serge);
pe.Graphics.FillEllipse(insideColor,
new Rectangle(0,0,this.Height, this.Width));
pe.Graphics.DrawLine(rubberBand, offset.X, offset.Y,
(float)this.Width/2, (float)this.Width/2);
pe.Graphics.DrawEllipse(Pens.Red,this.Width/3,this.Height/3,this.Width/3,this.Height/3);
pe.Graphics.DrawEllipse(Pens.Red,this.Width/6,this.Height/6,this.Width-this.Width/3,this.Height-this.Height/3);
//pe.Graphics.Restore(oldState);
}
示例14: PaintHook
protected override void PaintHook()
{
G.Clear(BackColor);
G.SmoothingMode = SmoothingMode.HighQuality;
if (_Checked)
{
LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 14)), G1, G2, 90f);
G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
}
else
{
LinearGradientBrush LGB = new LinearGradientBrush(new Rectangle(new Point(0, 0), new Size(14, 16)), G1, G2, 90f);
G.FillEllipse(LGB, new Rectangle(new Point(0, 0), new Size(14, 14)));
}
if (State == MouseState.Over & X < 15)
{
SolidBrush SB = new SolidBrush(Color.FromArgb(10, Color.Black));
G.FillEllipse(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
}
else if (State == MouseState.Down & X < 15)
{
SolidBrush SB = new SolidBrush(Color.FromArgb(20, Color.Black));
G.FillEllipse(SB, new Rectangle(new Point(0, 0), new Size(14, 14)));
}
GraphicsPath P = new GraphicsPath();
P.AddEllipse(new Rectangle(0, 0, 14, 14));
G.SetClip(P);
LinearGradientBrush LLGGBB = new LinearGradientBrush(new Rectangle(0, 0, 14, 5), Color.FromArgb(150, Color.White), Color.Transparent, 90f);
G.FillRectangle(LLGGBB, LLGGBB.Rectangle);
G.ResetClip();
G.DrawEllipse(new Pen(Bo), new Rectangle(new Point(0, 0), new Size(14, 14)));
if (_Checked)
{
SolidBrush LGB = new SolidBrush(Bb);
G.FillEllipse(LGB, new Rectangle(new Point(4, 4), new Size(6, 6)));
}
DrawText(new SolidBrush(TextColor), HorizontalAlignment.Left, 17, -2);
}
示例15: DrawCircleInMemory
private Region DrawCircleInMemory(Point pt1, double radRect)
{
GraphicsPath graphics_rect = new GraphicsPath();
Rectangle ellipse_rect = new Rectangle(pt1.X - (int)radRect, pt1.Y - (int)radRect,
(int)radRect * 2, (int)radRect * 2);
graphics_rect.AddEllipse(ellipse_rect);
return new Region(graphics_rect);
}