System.Drawing.Drawing2D.GraphicsPath.ConvertBezierToLines C# (CSharp) Method

ConvertBezierToLines() static private method

static private ConvertBezierToLines ( GraphicsPath path, int index, float flatness, List flat_points, List flat_types ) : bool
path GraphicsPath
index int
flatness float
flat_points List
flat_types List
return bool
        static bool ConvertBezierToLines(GraphicsPath path, int index, float flatness, List<PointF> flat_points, List<byte> flat_types)
        {
            PointF pt;

            // always PathPointTypeLine
            byte type = (byte)PathPointType.Line;;

            if ((index <= 0) || (index + 2 >= path.points.Count))
                return false; // bad path data

            var start = path.points [index - 1];
            var first = path.points [index];
            var second = path.points [index + 1];
            var end = path.points [index + 2];

            // we can't add points directly to the original list as we could end up with too much recursion
            var points = new List<PointF> ();
            if (!nr_curve_flatten (start.X, start.Y, first.X, first.Y, second.X, second.Y, end.X, end.Y, flatness, 0, points))
            {
                // curved path is too complex (i.e. would result in too many points) to render as a polygon
                return false;
            }

            // recursion was within limits, append the result to the original supplied list
            if (points.Count > 0)
            {
                flat_points.Add (points [0]);
                flat_types.Add (type);
            }

            // always PathPointTypeLine
            for (int i = 1; i < points.Count; i++)
            {

                pt = points [i];
                flat_points.Add (pt);
                flat_types.Add (type);
            }

            return true;
        }