示例#1
0
        public void FillPath(Point[] points, Color c)
        {
            var polly = new TpplPoly(points.Length);

            for (int i = 0; i < points.Length; i++)
            {
                polly[i].X = points[i].X;
                polly[i].Y = points[i].Y;
            }

            var outlist = new List <TpplPoly>();

            var p = new TpplPartition();

            p.Triangulate_EC(polly, outlist);

            foreach (var tpplPoly in outlist)
            {
                var a = tpplPoly.Points[0];
                var b = tpplPoly.Points[1];
                var v = tpplPoly.Points[2];

                FillTriangle(0, 0, new Point((int)a.X, (int)a.Y), new Point((int)b.X, (int)b.Y),
                             new Point((int)v.X, (int)v.Y), c);
            }
        }
示例#2
0
        public void FillPolygon(Point[] points, Color c)
        {
            var polly = new TpplPoly(points.Length + 1);

            for (int i = 0; i < points.Length; i++)
            {
                polly[i].X = points[i].X;
                polly[i].Y = points[i].Y;
            }

            polly[polly.Count - 1].X = points[0].X;
            polly[polly.Count - 1].Y = points[0].Y;

            var outlist = new List <TpplPoly>();

            var p = new TpplPartition();

            p.Triangulate_EC(polly, outlist);


            //for debugging
            var colors = new Color[]
            {
                Colors.Red,
                Colors.Blue
            };


            for (var index = 0; index < outlist.Count; index++)
            {
                var tpplPoly = outlist[index];
                var a        = tpplPoly.Points[0];
                var b        = tpplPoly.Points[1];
                var v        = tpplPoly.Points[2];

                FillTriangle(0, 0, new Point((int)a.X, (int)a.Y), new Point((int)b.X, (int)b.Y),
                             new Point((int)v.X, (int)v.Y),
                             c);
            }
        }