public GraphicsPath GetGraphicsPath() { if (gp == null) { gp = new GraphicsPath(); PointF initPoint = new PointF(0, 0); PointF lastPoint = new PointF(0, 0); SvgPathSegList segments = (SvgPathSegList)PathSegList; SvgPathSeg segment; int nElems = segments.NumberOfItems; for (int i = 0; i < nElems; i++) { segment = (SvgPathSeg)segments.GetItem(i); if (segment is SvgPathSegMoveto) { SvgPathSegMoveto seg = (SvgPathSegMoveto)segment; gp.StartFigure(); lastPoint = initPoint = seg.AbsXY; } else if (segment is SvgPathSegLineto) { SvgPathSegLineto seg = (SvgPathSegLineto)segment; PointF p = seg.AbsXY; gp.AddLine(lastPoint.X, lastPoint.Y, p.X, p.Y); lastPoint = p; } else if (segment is SvgPathSegCurveto) { SvgPathSegCurveto seg = (SvgPathSegCurveto)segment; PointF xy = seg.AbsXY; PointF x1y1 = seg.CubicX1Y1; PointF x2y2 = seg.CubicX2Y2; gp.AddBezier(lastPoint.X, lastPoint.Y, x1y1.X, x1y1.Y, x2y2.X, x2y2.Y, xy.X, xy.Y); lastPoint = xy; } else if (segment is SvgPathSegArc) { SvgPathSegArc seg = (SvgPathSegArc)segment; PointF p = seg.AbsXY; if (lastPoint.Equals(p)) { // If the endpoints (x, y) and (x0, y0) are identical, then this // is equivalent to omitting the elliptical arc segment entirely. } else if (seg.R1 == 0 || seg.R2 == 0) { // Ensure radii are valid gp.AddLine(lastPoint, p); } else { CalculatedArcValues calcValues = seg.GetCalculatedArcValues(); GraphicsPath gp2 = new GraphicsPath(); gp2.StartFigure(); gp2.AddArc( calcValues.Cx - calcValues.CorrRx, calcValues.Cy - calcValues.CorrRy, calcValues.CorrRx * 2, calcValues.CorrRy * 2, calcValues.AngleStart, calcValues.AngleExtent ); Matrix matrix = new Matrix(); matrix.Translate( -calcValues.Cx, -calcValues.Cy ); gp2.Transform(matrix); matrix = new Matrix(); matrix.Rotate(seg.Angle); gp2.Transform(matrix); matrix = new Matrix(); matrix.Translate(calcValues.Cx, calcValues.Cy); gp2.Transform(matrix); gp.AddPath(gp2, true); } lastPoint = p; } else if (segment is SvgPathSegClosePath) { gp.CloseFigure(); lastPoint = initPoint; } } string fillRule = GetPropertyValue("fill-rule"); if (fillRule == "evenodd") { gp.FillMode = FillMode.Alternate; } else { gp.FillMode = FillMode.Winding; } } return(gp); }