tangxu
2024-12-29 72e75456f8b30ec5b6f355539d9c883b0f810d21
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// THIS FILE IS PART OF SVG PROJECT
// THE SVG PROJECT IS AN OPENSOURCE LIBRARY LICENSED UNDER THE MS-PL License.
// COPYRIGHT (C) svg-net. ALL RIGHTS RESERVED.
// GITHUB: https://github.com/svg-net/SVG
 
namespace AntdUI.Svg.Pathing
{
    public sealed class SvgClosePathSegment : SvgPathSegment
    {
        public override void AddToPath(System.Drawing.Drawing2D.GraphicsPath graphicsPath)
        {
            var pathData = graphicsPath.PathData;
 
            if (pathData.Points.Length > 0)
            {
                // Important for custom line caps.  Force the path the close with an explicit line, not just an implicit close of the figure.
 
                if (!pathData.Points[0].Equals(pathData.Points[pathData.Points.Length - 1]))
                {
                    int i = pathData.Points.Length - 1;
                    while (i >= 0 && pathData.Types[i] > 0) i--;
                    if (i < 0) i = 0;
                    graphicsPath.AddLine(pathData.Points[pathData.Points.Length - 1], pathData.Points[i]);
                }
 
                graphicsPath.CloseFigure();
            }
        }
 
        public override string ToString()
        {
            return "z";
        }
    }
}