コード例 #1
0
        public void AddLines(PointF [] points)
        {
            if (points == null)
            {
                throw new ArgumentNullException("points");
            }

            if (points.Length == 0)
            {
                return;
            }

            if (NativeObject.LastFigureClosed)
            {
                NativeObject.moveTo(points[0].X, points[0].Y);
            }
            else
            {
                NativeObject.lineTo(points[0].X, points[0].Y);
            }

            for (int i = 1; i < points.Length; i++)
            {
                NativeObject.lineTo(points[i].X, points[i].Y);
            }
        }
コード例 #2
0
 internal void AddRectangle(float x, float y, float w, float h)
 {
     NativeObject.moveTo(x, y);
     NativeObject.lineTo(x + w, y);
     NativeObject.lineTo(x + w, y + h);
     NativeObject.lineTo(x, y + h);
     NativeObject.closePath();
 }
コード例 #3
0
        public void AddPolygon(PointF [] points)
        {
            if (points == null)
            {
                throw new ArgumentNullException("points");
            }

            if (points.Length < 3)
            {
                throw new ArgumentException("Invalid parameter used.");
            }

            NativeObject.moveTo(points[0].X, points[0].Y);
            for (int i = 1; i < points.Length; i++)
            {
                NativeObject.lineTo(points[i].X, points[i].Y);
            }
            NativeObject.closePath();
        }
コード例 #4
0
        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();
                }
            }
        }
コード例 #5
0
        /// <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;
            }
        }