Ejemplo n.º 1
0
        public void DrawSolidRectangle(FloatRectangle rect, Color color, FloatRectangle?clip = null)
        {
            var temp = rect.Clamp(clip);
            //temp = rect;
            Vector3 topLeft     = new Vector3(temp.X, temp.Y, 0);
            Vector3 bottomLeft  = new Vector3(temp.X, temp.Y + temp.Height, 0);
            Vector3 bottomRight = new Vector3(temp.X + temp.Width, temp.Y + temp.Height, 0);
            Vector3 topRight    = new Vector3(temp.X + temp.Width, temp.Y, 0);

            VertexPositionColor[] vertices = new VertexPositionColor[6];
            vertices[0] = new VertexPositionColor(topLeft, color);
            vertices[1] = new VertexPositionColor(topRight, color);
            vertices[2] = new VertexPositionColor(bottomRight, color);
            vertices[3] = new VertexPositionColor(bottomRight, color);
            vertices[4] = new VertexPositionColor(bottomLeft, color);
            vertices[5] = new VertexPositionColor(topLeft, color);

            this.DrawUserPrimitives(PrimitiveType.TriangleList, vertices, 0, 2);
        }
Ejemplo n.º 2
0
        public void DrawRectangle(FloatRectangle rectangle, Color color, Color?bgColor = null, FloatRectangle?clip = null)
        {
            if (bgColor != null)
            {
                DrawSolidRectangle(rectangle, bgColor.Value);
            }

            var rect = rectangle.Clamp(clip);
            // rect = rectangle;
            List <Line> lines = new List <Line>
            {
                BuildLine(new Vector2(rect.X, rect.Y), new Vector2(rect.Right, rect.Y), color, clip),
                BuildLine(new Vector2(rect.Right, rect.Y), new Vector2(rect.Right, rect.Bottom), color, clip),
                BuildLine(new Vector2(rect.Right, rect.Bottom), new Vector2(rect.X, rect.Bottom), color, clip),
                BuildLine(new Vector2(rect.X, rect.Bottom), new Vector2(rect.X, rect.Y), color, clip)
            };

            DrawLines(lines, null);
        }