private void SetPath(Point [] pts, byte [] types)
        {
            NativeObject.Clear();
            if (((PathPointType)types [0] & PathPointType.PathTypeMask) != PathPointType.Start)
            {
                NativeObject.moveTo(pts [0].X, pts [0].Y);
            }

            for (int i = 0; i < pts.Length; i++)
            {
                switch (((PathPointType)types [i] & PathPointType.PathTypeMask))
                {
                case PathPointType.Start:
                    NativeObject.moveTo(pts [i].X, pts [i].Y);
                    break;

                case PathPointType.Line:
                    NativeObject.lineTo(pts [i].X, pts [i].Y);
                    break;

                case PathPointType.Bezier3:
                    float x1 = pts [i].X;
                    float y1 = pts [i].Y;
                    i++;
                    float x2 = pts [i].X;
                    float y2 = pts [i].Y;
                    i++;
                    float x3 = pts [i].X;
                    float y3 = pts [i].Y;
                    NativeObject.curveTo(x1, y1, x2, y2, x3, y3);
                    break;
                }
                if (((PathPointType)types [i] & PathPointType.CloseSubpath) != 0)
                {
                    NativeObject.closePath();
                }

                if (((PathPointType)types [i] & PathPointType.PathMarker) != 0)
                {
                    NativeObject.SetMarkers();
                }
            }
        }
        public void AddBeziers(PointF [] pts)
        {
            if (pts == null)
            {
                throw new ArgumentNullException("points");
            }

            AddBezier(pts [0].X, pts [0].Y,
                      pts [1].X, pts [1].Y,
                      pts [2].X, pts [2].Y,
                      pts [3].X, pts [3].Y);

            for (int i = 4; i < pts.Length; i += 3)
            {
                NativeObject.curveTo(
                    pts [i].X, pts [i].Y,
                    pts [i + 1].X, pts [i + 1].Y,
                    pts [i + 2].X, pts [i + 2].Y);
            }
        }
        /// <summary>
        /// Based on http://pubpages.unh.edu/~cs770/a5/cardinal.html
        /// </summary>
        /// <param name="pts">point array (x1,y1,x2,y2 ...).
        /// The first and last points considered only for calculations, but are not added.</param>
        void AddCurve(float[] pts, bool connect, float tension)
        {
            tension /= 3f; //looks like a good pick

            if (connect)
            {
                NativeObject.lineTo(pts[2], pts[3]);
            }
            else
            {
                NativeObject.moveTo(pts[2], pts[3]);
            }

            float dx = pts[4] - pts[0];
            float dy = pts[5] - pts[1];

            float sx = pts[2] + tension * dx;
            float sy = pts[3] + tension * dy;

            for (int offset = 2, total = pts.Length - 4; offset < total; offset += 2)
            {
                int cur_offset = offset;
                int pX         = cur_offset++;
                int pY         = cur_offset++;
                int X          = cur_offset++;
                int Y          = cur_offset++;
                int nX         = cur_offset++;
                int nY         = cur_offset++;

                dx = pts[nX] - pts[pX];
                dy = pts[nY] - pts[pY];

                float rx = pts[X] - tension * dx;
                float ry = pts[Y] - tension * dy;

                NativeObject.curveTo(sx, sy, rx, ry, pts[X], pts[Y]);

                sx = pts[X] + tension * dx;
                sy = pts[Y] + tension * dy;
            }
        }