本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.StartFigure方法的典型用法代码示例。如果您正苦于以下问题:C# GraphicsPath.StartFigure方法的具体用法?C# GraphicsPath.StartFigure怎么用?C# GraphicsPath.StartFigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了GraphicsPath.StartFigure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
using (Graphics g = e.Graphics)
{
GraphicsPath path = new GraphicsPath();
path.AddLine(20, 20, 170, 20);
path.AddLine(20, 20, 20, 100);
// рисуем новую фигуру
path.StartFigure();
path.AddLine(240, 140, 240, 50);
path.AddLine(240, 140, 80, 140);
path.AddRectangle(new Rectangle(30, 30, 200, 100));
// локальное преобразование траектории
//Matrix X = new Matrix();
//X.RotateAt(45, new PointF(60.0f, 100.0f));
//path.Transform(X);
// рисуем path
Pen redPen = new Pen(Color.Red, 2);
g.FillPath(new SolidBrush(Color.Bisque), path);
g.DrawPath(redPen, path);
}
}
示例2: DrawRegionRepresentation
public override void DrawRegionRepresentation(Graphics gc, Render.RenderParameter r, Render.IDrawVisitor drawMethods, PointD mousePosition)
{
if (m_Param.Path.PointCount > 0)
{
GraphicsPath fill = new GraphicsPath();
RectangleF rect = m_Param.Path.GetBounds();
PointD refPt = (PointD)rect.Location + ((PointD)rect.Size.ToPointF()) / 2;
// this will draw beyond the shape's location
for (double i = -rect.Height; i < rect.Height; i++)
{
PointD orth = PointD.Orthogonal(m_Param.V);
PointD pt1 = refPt + orth * i * drawMethods.Spacing(m_Param.C);
PointD pt2 = pt1 + m_Param.V * rect.Width * rect.Height;
PointD pt3 = pt1 - m_Param.V * rect.Width * rect.Height;
PointD pt4 = refPt + m_Param.V * i * drawMethods.Spacing(m_Param.C);
PointD pt5 = pt4 + orth * rect.Width * rect.Height;
PointD pt6 = pt4 - orth * rect.Width * rect.Height;
fill.StartFigure();
fill.AddLine((Point)pt2, (Point)pt3);
fill.StartFigure();
fill.AddLine((Point)pt5, (Point)pt6);
}
GraphicsContainer c = gc.BeginContainer();
gc.SetClip( (Tools.Model.VectorPath) m_Param.Path);
gc.DrawPath(r.RegionGuides, fill);
gc.EndContainer(c);
}
}
示例3: DrawYourSelf
/// <summary>
/// Изчертава елипсите.
/// </summary>
/// <param name="graphics"></param>
public override void DrawYourSelf(Graphics graphics)
{
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddEllipse(Location.X + ModelSize.Width / 3, Location.Y + ModelSize.Height / 3, ModelSize.Width / 3, ModelSize.Height / 3);
path.CloseFigure();
path.StartFigure();
path.AddLine(Location.X + (ModelSize.Width * 2) / 3, Location.Y + ModelSize.Height / 2, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 2);
path.CloseFigure();
path.AddEllipse(new RectangleF(Location, ModelSize));
path.CloseFigure();
path.Transform(this.TMatrix.TransformationMatrix);
/*
* Създава се Pen, който изчертава контура, като използва
* цвят и дебелина (определят се от конструктора)
*/
Pen pen = new Pen(this.BorderColor, this.BorderWidth);
// Правим същото, но за запълването
if (IS_FILLED)
{
SolidBrush brush = new SolidBrush(this.FillColor);
graphics.FillPath(brush, path);
}
graphics.DrawPath(pen, path);
if (this.Selected)
{
this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
this.selectionUnit.DrawYourSelf(graphics);
}
}
示例4: DrawYourSelf
public override void DrawYourSelf(Graphics graphics)
{
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
path.CloseFigure();
path.StartFigure();
path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
path.CloseFigure();
path.AddEllipse(new RectangleF(Location, ModelSize));
path.CloseFigure();
path.Transform(this.TMatrix.TransformationMatrix);
Pen pen = new Pen(this.BorderColor, this.BorderWidth);
if (IS_FILLED)
{
SolidBrush brush = new SolidBrush(this.FillColor);
graphics.FillPath(brush, path);
}
graphics.DrawPath(pen, path);
if (this.Selected)
{
this.selectionUnit = new CoveringRectangle(Rectangle.Round(ReturnBounds()));
this.selectionUnit.DrawYourSelf(graphics);
}
}
示例5: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
Point[] points = {
new Point(5,10) ,
new Point(23 , 130),
new Point(130 , 57)
};
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddEllipse(170 , 170 , 100 , 50);
g.FillPath(Brushes.Black, path);
path.CloseFigure();
path.StartFigure();
path.AddCurve(points , 0.5F);
g.FillPath(Brushes.Blue, path);
//coords
g.TranslateTransform(40, 40);
Point A = new Point(0, 0);
Point B = new Point(150 , 150);
g.DrawLine(new Pen(Brushes.Black, 3), A, B);
g.Dispose();
}
示例6: Form1_Paint
private void Form1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
//Создаем массив точек
Point[] points = {
new Point(5, 10),
new Point(23, 130),
new Point(130, 57)};
GraphicsPath path = new GraphicsPath();
//рисуем первую траекторию
path.StartFigure();
path.AddEllipse(170, 170, 100, 50);
// заливаем траекторию цветом
g.FillPath(Brushes.Aqua, path);
//рисуем вторую траекторию
path.StartFigure();
path.AddCurve(points, 0.5F);
path.AddArc(100, 50, 100, 100, 0, 120);
path.AddLine(50, 150, 50, 220);
// Закрываем траекторию
path.CloseFigure();
//рисуем четвертую траекторию
path.StartFigure();
path.AddArc(180, 30, 60, 60, 0, -170);
g.DrawPath(new Pen(Color.Blue, 3), path);
g.Dispose();
}
示例7: NextSubpath_Int_Int_Bool
public virtual void NextSubpath_Int_Int_Bool()
{
GraphicsPath path = new GraphicsPath ();
path.AddLine (new Point (100, 100), new Point (400, 100));
path.AddLine (new Point (400, 200), new Point (10, 100));
path.StartFigure ();
path.SetMarkers ();
path.AddBezier( 10, 10, 50, 250, 100, 5, 200, 280);
path.CloseFigure ();
path.StartFigure ();
path.SetMarkers ();
path.AddRectangle (new Rectangle (10, 20, 300, 400));
path.StartFigure ();
path.SetMarkers ();
path.AddLine (new Point (400, 400), new Point (400, 10));
GraphicsPathIterator iterator = new GraphicsPathIterator (path);
int start;
int end;
bool isClosed;
int count = iterator.NextSubpath (out start, out end, out isClosed);
Assert.AreEqual (4, count);
Assert.AreEqual (0, start);
Assert.AreEqual (3, end);
Assert.IsFalse (isClosed);
count = iterator.NextSubpath (out start, out end, out isClosed);
Assert.AreEqual (4, count);
Assert.AreEqual (4, start);
Assert.AreEqual (7, end);
Assert.IsTrue (isClosed);
count = iterator.NextSubpath (out start, out end, out isClosed);
Assert.AreEqual (4, count);
Assert.AreEqual (8, start);
Assert.AreEqual (11, end);
Assert.IsTrue (isClosed);
count = iterator.NextSubpath (out start, out end, out isClosed);
Assert.AreEqual (2, count);
Assert.AreEqual (12, start);
Assert.AreEqual (13, end);
Assert.IsFalse (isClosed);
count = iterator.NextSubpath (out start, out end, out isClosed);
Assert.AreEqual (0, count);
Assert.AreEqual (0, start);
Assert.AreEqual (0, end);
Assert.IsTrue (isClosed);
}
示例8: ReturnBounds
public override RectangleF ReturnBounds()
{
GraphicsPath path = new GraphicsPath();
path.StartFigure();
path.AddLine(Location.X, Location.Y + ModelSize.Height / 3, Location.X + ModelSize.Width, Location.Y + ModelSize.Height / 3);
path.CloseFigure();
path.StartFigure();
path.AddLine(Location.X, Location.Y + (ModelSize.Height / 3) * 2, Location.X + ModelSize.Width, Location.Y + (ModelSize.Height * 2) / 3);
path.CloseFigure();
path.AddEllipse(new RectangleF(Location, ModelSize));
path.CloseFigure();
path.Transform(this.TMatrix.TransformationMatrix);
return path.GetBounds();
}
示例9: OnPaint
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
if (BorderRadius == 0)
{
Rectangle rc = ClientRectangle;
rc.Inflate(-(int)Math.Round(BorderWidth / 2.0 + .5), -(int)Math.Round(BorderWidth / 2.0 + .5));
rc.Y = rc.Y - 1;
rc.Height = rc.Height + 1;
e.Graphics.DrawRectangle(new Pen(BorderColor, BorderWidth), rc);
}
else
{
e.Graphics.SmoothingMode = SmoothingMode.AntiAlias;
GraphicsPath gp = Extensions.Create(0, 0, Width - 2, Height - 2, BorderRadius);
Pen p = new Pen(BorderColor, BorderWidth);
e.Graphics.DrawPath(p, gp);
e.Graphics.FillPath(p.Brush, gp);
StringFormat formatting = (StringFormat)StringFormat.GenericTypographic.Clone();
formatting.Alignment = StringAlignment.Center;
formatting.LineAlignment = StringAlignment.Center;
float emsize = e.Graphics.DpiY * Font.Size / 72;
gp = new GraphicsPath();
gp.StartFigure();
gp.AddString(Text, Font.FontFamily, (int)Font.Style, emsize, new Point(Width / 2, Height / 2), formatting);
gp.CloseFigure();
e.Graphics.FillPath(new Pen(ForeColor, 1).Brush, gp);
}
}
示例10: DrawBezierCtrlLines
//------------------------------------------------------------------------------
private static void DrawBezierCtrlLines(Graphics graphics,
MultiPathSegment mps, uint color)
{
int cnt = mps.Count;
if (cnt < 2) return;
Pen pen = new Pen(MakeColor(color));
GraphicsPath gpath = new GraphicsPath();
PointF[] pts = new PointF[2];
pts[0] = PathToPointF(mps[0]);
pts[1] = PathToPointF(mps[1]);
gpath.StartFigure();
gpath.AddLines(pts);
if (mps.IsValid())
if (mps.curvetype == CurveType.CubicBezier)
{
pts[0] = PathToPointF(mps[2]);
pts[1] = PathToPointF(mps[3]);
gpath.StartFigure();
gpath.AddLines(pts);
}
else
{
pts[0] = PathToPointF(mps[2]);
gpath.StartFigure();
gpath.AddLines(pts);
}
graphics.DrawPath(pen, gpath);
pen.Dispose();
gpath.Dispose();
}
示例11: createRoundedRectangles
private GraphicsPath createRoundedRectangles(int x, int y, int width, int height, int radius)
{
int xw = x + width;
int yh = y + height;
int xwr = xw - radius;
int yhr = yh - radius;
int xr = x + radius;
int yr = y + radius;
int r2 = radius * 2;
int xwr2 = xw - r2;
int yhr2 = yh - r2;
GraphicsPath p = new GraphicsPath();
p.StartFigure();
p.AddArc(x, y, r2, r2, 180, 90);
p.AddLine(xr, y, xwr, y);
p.AddArc(xwr2, y, r2, r2, 270, 90);
p.AddLine(xw, yr, xw, yhr);
p.AddArc(xwr2, yhr2, r2, r2, 0, 90);
p.AddLine(xwr, yh, xr, yh);
p.AddArc(x, yhr2, r2, r2, 90, 90);
p.AddLine(x, yhr, x, yr);
p.CloseFigure();
return p;
}
示例12: CreateGrid
/// <summary>
/// creates a grid according to the loaded image
/// </summary>
private void CreateGrid()
{
if (_grid!=null){_grid.Dispose(); _grid=null;}
if (_element==null) return;
//create graphicspath
_grid=new GraphicsPath();
//create columns
for (int x=0; x<=_element.Width; x++)
{
_grid.StartFigure();
_grid.AddLine(x,0,x,_element.Height);
}
//create rows
for (int y=0; y<=_element.Height; y++)
{
_grid.StartFigure();
_grid.AddLine(0,y,_element.Width,y);
}
}
示例13: GetRectangleRegion
public static GraphicsPath GetRectangleRegion(Rectangle rect)
{
GraphicsPath gp = new GraphicsPath();
gp.StartFigure();
gp.AddLine(rect.Left, rect.Top, rect.Right, rect.Top);
gp.AddLine(rect.Right, rect.Top, rect.Right, rect.Bottom);
gp.AddLine(rect.Right, rect.Bottom, rect.Left, rect.Bottom);
gp.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Top);
gp.CloseFigure();
return gp;
}
示例14: ToPath
///<summary>
/// Creates a <see cref="GraphicsPath"/> representing a polygon ring
/// having the given coordinate sequence.
///</summary>
/// <remarks>
/// Uses <see cref="FillMode.Alternate"/> winding rule
/// </remarks>
/// <param name="coordinates">A coordinate sequence</param>
/// <returns>The path for the coordinate sequence</returns>
private static GraphicsPath ToPath(Coordinate[] coordinates)
{
var path = new GraphicsPath(FillMode.Alternate);
path.StartFigure();
if (coordinates.Length > 0)
path.AddLines(ToPointF(coordinates));
path.CloseFigure();
return path;
}
示例15: ContainsPoint
public new bool ContainsPoint(float X, float Y)
{
GraphicsPath Path = new GraphicsPath();
Path.StartFigure();
if (TypeShape == Nows.Ellip)
Path.AddEllipse(Rectan);
else
Path.AddPie(Rectan.X, Rectan.Y, Rectan.Width, Rectan.Height, startAngle, sweepAngle);
Path.CloseFigure();
return Path.IsVisible(X, Y);
}