本文整理汇总了C#中System.Drawing.Drawing2D.GraphicsPath.Flatten方法的典型用法代码示例。如果您正苦于以下问题:C# System.Drawing.Drawing2D.GraphicsPath.Flatten方法的具体用法?C# System.Drawing.Drawing2D.GraphicsPath.Flatten怎么用?C# System.Drawing.Drawing2D.GraphicsPath.Flatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Drawing.Drawing2D.GraphicsPath
的用法示例。
在下文中一共展示了System.Drawing.Drawing2D.GraphicsPath.Flatten方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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 ) );
}
示例2: Paint
/// <summary>
/// Repaints the form with cool background and stuff
/// </summary>
/// <param name="graph">The graphics object to paint to, the element will be drawn to 0,0</param>
override public void Paint(Graphics graph)
{
//Draws Rectangular Shapes
if (Shape == ModelShapes.Arrow)
{
_arrowPath = new System.Drawing.Drawing2D.GraphicsPath();
//Draws the basic shape
Pen arrowPen;
if (Highlight < 1)
arrowPen = new Pen(Color.Cyan, 3F);
else
arrowPen = new Pen(Color.Black, 3F);
//Draws the curved arrow
Point[] lineArray = new Point[4];
lineArray[0] = new Point(_startPoint.X, _startPoint.Y);
lineArray[1] = new Point(_startPoint.X - ((_startPoint.X - _stopPoint.X) / 3), _startPoint.Y);
lineArray[2] = new Point(_stopPoint.X - ((_stopPoint.X - _startPoint.X) / 3), _stopPoint.Y);
lineArray[3] = new Point(_stopPoint.X, _stopPoint.Y);
graph.DrawBeziers(arrowPen, lineArray);
_arrowPath.AddBeziers(lineArray);
_arrowPath.Flatten();
//Draws the arrow head
Point[] arrowArray = new Point[3];
arrowArray[0] = _stopPoint;
arrowArray[1] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)),_stopPoint.Y - 2);
arrowArray[2] = new Point(_stopPoint.X - (5 * Math.Sign(_stopPoint.X - _startPoint.X)), _stopPoint.Y + 2);
graph.DrawPolygon(arrowPen,arrowArray);
//Garbage collection
arrowPen.Dispose();
}
}
示例3: PaintOneRange
//.........这里部分代码省略.........
logicalPosValid = !logicalPos.IsNaN && vPosLogical != vMeanLogical;
}
if (negErrCol != null)
{
var vNegLogical = layer.Scales[axisNumber].PhysicalVariantToNormal(negErrCol[originalRowIndex]);
vNegLogical = Calc.RMath.ClampToInterval(vNegLogical, logicalClampMinimum, logicalClampMaximum);
logicalNeg.SetR(axisNumber, vNegLogical);
logicalNegValid = !logicalNeg.IsNaN && vNegLogical != vMeanLogical;
}
if (object.ReferenceEquals(negErrCol, posErrCol))
{
logicalNegValid = false; // then we need only to plot the positive column, since both colums are identical
}
}
break;
} // end switch
if (!(logicalPosValid || logicalNegValid))
continue; // nothing to do for this point if both pos and neg logical point are invalid.
if (logicalNegValid)
{
errorBarPath.Reset();
layer.CoordinateSystem.GetIsoline(errorBarPath, logicalMean, logicalNeg);
PointF[] shortenedPathPoints = null;
bool shortenedPathPointsCalculated = false;
if (_useSymbolGap)
{
double gap = _symbolGapOffset + _symbolGapFactor * symbolSize;
if (gap > 0)
{
errorBarPath.Flatten();
var pathPoints = errorBarPath.PathPoints;
shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(gap / 2), RADouble.NewAbs(0));
shortenedPathPointsCalculated = true;
if (null == shortenedPathPoints && _forceVisibilityOfEndCap && !(strokePen.EndCap is Altaxo.Graph.Gdi.LineCaps.FlatCap))
{
var totalLineLength = GdiExtensionMethods.TotalLineLength(pathPoints);
var shortTheLineBy = Math.Max(0, totalLineLength - 0.125 * strokePen.Width);
shortenedPathPoints = GdiExtensionMethods.ShortenedBy(pathPoints, RADouble.NewAbs(shortTheLineBy), RADouble.NewAbs(0));
}
}
}
if (shortenedPathPointsCalculated)
{
if (null != shortenedPathPoints)
{
g.DrawLines(strokePen, shortenedPathPoints);
}
}
else
{
g.DrawPath(strokePen, errorBarPath);
}
}
if (logicalPosValid)
{
errorBarPath.Reset();
layer.CoordinateSystem.GetIsoline(errorBarPath, logicalMean, logicalPos);
PointF[] shortenedPathPoints = null;
bool shortenedPathPointsCalculated = false;