本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.StartFigure方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.GraphicsPath.StartFigure方法的具体用法?C# System.Drawing.Drawing2D.GraphicsPath.StartFigure怎么用?C# System.Drawing.Drawing2D.GraphicsPath.StartFigure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath.StartFigure方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawFilledPath
private void DrawFilledPath(SeriesBase series, System.Drawing.Pen pen,System.Drawing.Brush brush)
{
var path = new System.Drawing.Drawing2D.GraphicsPath();
if (series is AreaSeries)
{
path.StartFigure();
AreaSeries areaSeries = series as AreaSeries;
var points = areaSeries.AreaPoints;
var pointCount = areaSeries.AreaPoints.Count;
for (int i = 0; i < pointCount - 1; i++)
{
System.Drawing.PointF startPoint = points[i].AsDrawingPointF();
System.Drawing.PointF endPoint = points[i + 1].AsDrawingPointF();
path.AddLine(startPoint, endPoint);
}
path.CloseAllFigures();
switch (RenderingMode)
{
case RenderingMode.GDIRendering:
GDIGraphics.FillPath(brush, path);
break;
case RenderingMode.Default:
break;
case RenderingMode.WritableBitmap:
WritableBitmapGraphics.FillPath(brush, path);
break;
default:
break;
}
}
}
示例2: getDrawingPoints
/// <summary>
/// takes in a parsed path and returns a list of points that can be used to draw the path
/// </summary>
/// <returns>The drawing points.</returns>
/// <param name="segments">Segments.</param>
public Vector2[] getDrawingPoints( List<SvgPathSegment> segments, float flatness = 3 )
{
var path = new System.Drawing.Drawing2D.GraphicsPath();
for( var j = 0; j < segments.Count; j++ )
{
var segment = segments[j];
if( segment is SvgMoveToSegment )
{
path.StartFigure();
}
else if( segment is SvgCubicCurveSegment )
{
var cubicSegment = segment as SvgCubicCurveSegment;
path.AddBezier( toDrawPoint( segment.start ), toDrawPoint( cubicSegment.firstCtrlPoint ), toDrawPoint( cubicSegment.secondCtrlPoint ), toDrawPoint( segment.end ) );
}
else if( segment is SvgClosePathSegment )
{
// important for custom line caps. Force the path the close with an explicit line, not just an implicit close of the figure.
if( path.PointCount > 0 && !path.PathPoints[0].Equals( path.PathPoints[path.PathPoints.Length - 1] ) )
{
var i = path.PathTypes.Length - 1;
while( i >= 0 && path.PathTypes[i] > 0 )
i--;
if( i < 0 )
i = 0;
path.AddLine( path.PathPoints[path.PathPoints.Length - 1], path.PathPoints[i] );
}
path.CloseFigure();
}
else if( segment is SvgLineSegment )
{
path.AddLine( toDrawPoint( segment.start ), toDrawPoint( segment.end ) );
}
else if( segment is SvgQuadraticCurveSegment )
{
var quadSegment = segment as SvgQuadraticCurveSegment;
path.AddBezier( toDrawPoint( segment.start ), toDrawPoint( quadSegment.firstCtrlPoint ), toDrawPoint( quadSegment.secondCtrlPoint ), toDrawPoint( segment.end ) );
}
else
{
Debug.warn( "unknown type in getDrawingPoints" );
}
}
path.Flatten( new System.Drawing.Drawing2D.Matrix(), flatness );
return System.Array.ConvertAll( path.PathPoints, i => new Vector2( i.X, i.Y ) );
}
示例3: UpdateGrid
public void UpdateGrid()
{
myGridPen = new Pen( Image.GridColour )
{
DashStyle = System.Drawing.Drawing2D.DashStyle.Dash
};
myGrid = new System.Drawing.Drawing2D.GraphicsPath();
int xDiff = (int) ( Image.GridWidth * Image.ZoomScale );
int yDiff = (int) ( Image.GridHeight * Image.ZoomScale );
if ( xDiff > 1 )
{
for ( int x = Image.GridHorizontalOffset; x <= Image.Width; x += Image.GridWidth )
{
myGrid.StartFigure();
myGrid.AddLine( x * Image.ZoomScale, 0,
x * Image.ZoomScale, myDisplaySize.Height );
}
}
if ( yDiff > 1 )
{
for ( int y = Image.GridVerticalOffset; y <= Image.Height; y += Image.GridHeight )
{
myGrid.StartFigure();
myGrid.AddLine( 0, y * Image.ZoomScale,
myDisplaySize.Width, y * Image.ZoomScale );
}
}
Invalidate();
}
示例4: CreateRoundedGraphicsPath
/// <summary>角の丸い矩形のGraphicsPathを生成する</summary>
public static System.Drawing.Drawing2D.GraphicsPath CreateRoundedGraphicsPath(RectangleF bounds, float xRadius, float yRadius) {
float left = bounds.X;
float top = bounds.Y;
float right = bounds.Right;
float bottom = bounds.Bottom;
var path = new System.Drawing.Drawing2D.GraphicsPath();
path.StartFigure();
path.AddArc(left, top, xRadius * 2, yRadius * 2, 180, 90);
path.AddArc(right - xRadius * 2, top, xRadius * 2, yRadius * 2, 270, 90);
path.AddArc(right - xRadius * 2, bottom - yRadius * 2, xRadius * 2, yRadius * 2, 0, 90);
path.AddArc(left, bottom - yRadius * 2, xRadius * 2, xRadius * 2, 90, 90);
path.CloseFigure();
return path;
}
示例5: Carte_Paint
private void Carte_Paint(object sender, PaintEventArgs e)
{
int i;
double w, h;
//projet = ((Musliw.MusliW)(this.MdiParent)).projet;
Graphics page = e.Graphics;
//page.Clear(this.BackColor);
w = this.Width;
h = this.Height;
Pen stylo = new Pen(fen.stylo_couleur, (int)fen.epaisseur);
Font fonte = new Font(FontFamily.GenericSansSerif, 7,FontStyle.Bold);
this.ForeColor = Color.Black;
Brush brosse =new SolidBrush(fen.brosse_couleur);
Brush brosse_texte = new SolidBrush(fen.couleur_texte);
double dx = w / (projet.reseaux[nproj].xu - projet.reseaux[nproj].xl);
double dy = h / (projet.reseaux[nproj].yu - projet.reseaux[nproj].yl);
double deltax,deltay,voldeltax,voldeltay;
double cx = 0.5f * (projet.reseaux[nproj].xu + projet.reseaux[nproj].xl);
double cy = 0.5f * (projet.reseaux[nproj].yu + projet.reseaux[nproj].yl);
//MessageBox.Show(xl.ToString() + " " + yu.ToString());
PointF p1=new PointF();
PointF p2 = new PointF();
PointF p3 = new PointF();
PointF p4 = new PointF();
PointF p5 = new PointF();
PointF[] points = new PointF[4] ;
double angle=0,norme=0;
double sinx = 0, cosx = 1;
if (fen.volume_echelle < 1e-6f)
{
fen.volume_echelle = 1e-6f;
}
for (i = 0; i < projet.reseaux[nproj].links.Count; i++)
{
norme = fen.norme(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur);
if ((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_visible == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_visible == true && norme > 0) && (projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].is_valid == true && projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].is_valid == true))
{
//page.DrawRectangle(stylo, 0f, 0f, 200, 200);
//MessageBox.Show(((res.nodes[i].x - res.xl) * delta).ToString() + " " + ((res.yu - res.nodes[i].y) * delta).ToString()+" "+w.ToString()+" "+h.ToString());
deltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
deltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart+0.5f*fen.epaisseur);
cosx = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
sinx = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, 1);
voldeltax = fen.deltax(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
voldeltay = fen.deltay(projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y, projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y, fen.ecart + 0.5f * fen.epaisseur + projet.reseaux[projet.reseau_actif].links[i].volau / fen.volume_echelle);
page.DrawLine(stylo, (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay), (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax),(float) (((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay),(float) (((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax));
p1.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + deltay);
p1.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + deltax);
p2.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].x - fen.xl) / fen.echelle) + voldeltay);
p2.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].no].y) / fen.echelle) + voldeltax);
p3.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + voldeltay);
p3.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + voldeltax);
p4.X = (float)(((projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].x - fen.xl) / fen.echelle) + deltay);
p4.Y = (float)(((fen.yu - projet.reseaux[nproj].nodes[projet.reseaux[nproj].links[i].nd].y) / fen.echelle) + deltax);
System.Drawing.Drawing2D.GraphicsPath epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
System.Drawing.Drawing2D.GraphicsPath texte_epaisseur = new System.Drawing.Drawing2D.GraphicsPath();
epaisseur.StartFigure();
points[0] = p1;
points[1] = p2;
points[2] = p3;
points[3] = p4;
epaisseur.AddPolygon(points);
epaisseur.CloseFigure();
//page.FillPath(brosse, epaisseur);
//page.FillPolygon(brosse, points);
//page.DrawPolygon(stylo,points);
epaisseur.Reset();
texte_epaisseur.StartFigure();
p5.X = 0.5f * (p3.X + p2.X);
p5.Y = 0.5f * (p3.Y + p2.Y);
texte_epaisseur.AddString(projet.reseaux[projet.reseau_actif].links[i].volau.ToString("0"), FontFamily.GenericSansSerif, 0, (float)fen.taille_texte, new PointF(p5.X, p5.Y), StringFormat.GenericDefault);
RectangleF encombrement = texte_epaisseur.GetBounds();
// texte_epaisseur.AddRectangle(encombrement);
//texte_epaisseur.AddPie(p5.X,p5.Y,2,2,0,360);
page.FillPolygon(brosse, points);
page.DrawPolygon(stylo, points);
if (encombrement.Width < fen.norme(p1.X, p4.X, p1.Y, p4.Y, 1) && projet.reseaux[projet.reseau_actif].links[i].volau > 0)
{
System.Drawing.Drawing2D.Matrix rotation = new System.Drawing.Drawing2D.Matrix();
if (cosx >= 0 && sinx <= 0)
{
angle = 180f * ((float)Math.Acos(cosx) / (float)Math.PI);
rotation.RotateAt((float)angle, p5);
rotation.Translate(p5.X - encombrement.X, p5.Y - encombrement.Y);
System.Drawing.Drawing2D.Matrix trans = new System.Drawing.Drawing2D.Matrix();
texte_epaisseur.Transform(rotation);
trans.Translate((float)(-0.5f * encombrement.Width * cosx),(float)( 0.5f * encombrement.Width * sinx));
//.........这里部分代码省略.........