Ejemplo n.º 1
0
        private void DrawPolygon(Pen p)
        {
            SutherHodgmanAlgo LeftClip  = new SutherHodgmanAlgo(Points);
            SutherHodgmanAlgo RightClip = new SutherHodgmanAlgo(TransformedPoints);
            DDA DDAAlgo = new DDA(g);

            for (int i = 0; i < Points.Count; i++)
            {
                int k = (i + Points.Count - 1) % Points.Count;
                DDAAlgo.Draw(p, Points[i].X, Points[i].Y, Points[k].X, Points[k].Y);
                DDAAlgo.Draw(p, TransformedPoints[i].X, TransformedPoints[i].Y, TransformedPoints[k].X, TransformedPoints[k].Y);
                if (Points.Count > 1)
                {
                    LeftClip.SutherHodgman(g, InPolygonPen, LeftEdges.ToArray());
                }
                if (Points.Count > 1)
                {
                    RightClip.SutherHodgman(g, InPolygonPen, RightEdges.ToArray());
                }
            }
        }
Ejemplo n.º 2
0
        public void SutherHodgman(Graphics g, Pen p, Point[] Edges)
        {
            for (int i = 0; i < Edges.Length - 1; i++)
            {
                Clip(new Point[2] {
                    Edges[i], Edges[i + 1]
                });
            }
            Clip(new Point[2] {
                Edges[Edges.Length - 1], Edges[0]
            });
            DDA DDAAlgo = new DDA(g);

            for (int j = 0; j < PoligonPoints.Count - 1; j++)
            {
                DDAAlgo.Draw(p, PoligonPoints[j].X, PoligonPoints[j].Y, PoligonPoints[j + 1].X, PoligonPoints[j + 1].Y);
            }

            if (PoligonPoints.Count > 1)
            {
                DDAAlgo.Draw(p, PoligonPoints[PoligonPoints.Count - 1].X, PoligonPoints[PoligonPoints.Count - 1].Y, PoligonPoints[0].X, PoligonPoints[0].Y);
            }
        }