Esempio n. 1
0
        //获取最终路径
        public bool GetPath(Point start, Point end, Graphics gra, Pen myPen)
        {
            List <PointF> keyPoints = new List <PointF>();
            Point         tmpPnt    = new Point();
            int           count     = 0;

            myPen.Color = Color.Yellow;

            tmpPnt = parents[end.X, end.Y];

            keyPoints.Add(end);

            while (tmpPnt != start)
            {
                count++;
                //gra.DrawEllipse(myPen, tmpPnt.X, tmpPnt.Y, 1, 1);
                tmpPnt = parents[tmpPnt.X, tmpPnt.Y];
                if (count % 10 == 0)
                {
                    keyPoints.Add(tmpPnt);
                }
            }

            keyPoints.Add(start);

            PointF[] pnts = keyPoints.ToArray();

            Bspline.DrawBspline1(pnts.Count(), gra, myPen, pnts);
            return(true);
        }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     PointF[] a = new PointF[3];
     a[0].X = 0;
     a[0].Y = 0;
     a[1].X = 10;
     a[1].Y = 10;
     a[2].X = 20;
     a[2].Y = 50;
     Bspline.DrawBspline1(3, gra, myPen, a);
     //DrawBspline1();
 }