Пример #1
0
        /// <summary>
        /// Draws the given polygon
        /// </summary>
        /// <param name="polygon">Polygon to render</param>
        /// <param name="color">Color to use when drawing</param>
        /// <param name="dashed">If true, polygon will be dashed</param>
        public void DrawPolygon(VectorPolygon polygon, Color color, bool dashed)
        {
            int step = (dashed == true) ? 2 : 1; ;

            if (polygon == null)
            {
                throw new ArgumentNullException("polygon");
            }
            for (int i = 0; i < polygon.TransformedPoints.Length; i += step)
            {
                if (currentIndex >= vertices.Length - 2)
                {
                    End();
                    Begin();
                }
                vertices[currentIndex].Position.X =
                    polygon.TransformedPoints[i % polygon.TransformedPoints.Length].X;
                vertices[currentIndex].Position.Y =
                    polygon.TransformedPoints[i % polygon.TransformedPoints.Length].Y;
                vertices[currentIndex++].Color = color;
                vertices[currentIndex].Position.X =
                    polygon.TransformedPoints[(i + 1) %
                    polygon.TransformedPoints.Length].X;
                vertices[currentIndex].Position.Y =
                    polygon.TransformedPoints[(i + 1) %
                    polygon.TransformedPoints.Length].Y;
                vertices[currentIndex++].Color = color;
                lineCount++;
            }
        }
Пример #2
0
 /// <summary>
 /// Draws the given polygon
 /// </summary>
 /// <param name="polygon">Polygon to render</param>
 /// <param name="color">Color to use when drawing</param>
 public void DrawPolygon(VectorPolygon polygon, Color color)
 {
     DrawPolygon(polygon, color, false);
 }