示例#1
0
        public XNAPolygon ToPolygon()
        {
            XNAPolygon polygon = new XNAPolygon(pdevice)
            {
                StrokeWidth = StrokeWidth,
                Stroke      = Stroke
            };

            foreach (var line in lines)
            {
                foreach (var point in line.Points)
                {
                    polygon.AddPoint(point);
                }
            }
            return(polygon);
        }
示例#2
0
 public XNAPolygon ToPolygon()
 {
     XNAPolygon polygon = new XNAPolygon(pdevice)
     {
         StrokeWidth = StrokeWidth,
         Stroke = Stroke
     };
     foreach (var line in lines)
     {
         foreach (var point in line.Points)
         {
             polygon.AddPoint(point);
         }
     }
     return polygon;
 }
示例#3
0
        public void Draw(Shape shape)
        {
            if (isClose)
            {
                return;
            }
            if (lineWidth <= 1)
            {
                float[] points = shape.GetPoints();
                if (points.Length == 0)
                {
                    return;
                }
                GLBegin(GL.GL_LINE_STRIP);
                for (int i = 0; i < points.Length; i += 2)
                {
                    GLVertex2f(points[i], points[i + 1]);
                }
                if (shape.Closed())
                {
                    GLVertex2f(points[0], points[1]);
                }
                GLEnd();
            }
            else
            {
                float[] points = shape.GetPoints();
                if (points == null)
                {
                    return;
                }
                if (points.Length == 0)
                {
                    return;
                }
                if (shape is Path)
                {
                    float x = points[0];
                    float y = points[1];

                    for (int i = 0; i < points.Length; i += 2)
                    {
                        DrawLine(x, y, points[i], points[i + 1]);
                        x = points[i];
                        y = points[i + 1];
                    }
                }
                else
                {
                    int hashCode = 1;
                    for (int i = 0; i < points.Length; i++)
                    {
                        hashCode = LSystem.Unite(hashCode, points[i]);
                    }
                    XNAPolygon xnaPolygon = (XNAPolygon)CollectionUtils.Get(lazyXnaPolygon, hashCode);
                    if (xnaPolygon == null)
                    {
                        xnaPolygon = new XNAPolygon(GL.device);
                        xnaPolygon.StrokeWidth = lineWidth;
                        for (int i = 0; i < points.Length; i += 2)
                        {
                            xnaPolygon.AddPoint(new Vector2(points[i], points[i + 1]));
                        }
                        if (shape.Closed())
                        {
                            xnaPolygon.AddPoint(new Vector2(points[0], points[1]));
                        }
                        CollectionUtils.Put(lazyXnaPolygon, hashCode, xnaPolygon);
                    }
                    xnaPolygon.Stroke = color;
                    XnaBatchBegin(color);
                    xnaPolygon.Draw(xnaBatch);
                    XnaBatchEnd();
                }
            }
        }