public FloatRectangle(FloatRectangle rectangle, bool boundless = false)
        {
            this.X      = rectangle.X;
            this.Y      = rectangle.Y;
            this.Width  = rectangle.Width;
            this.Height = rectangle.Height;

            this.Boundless = boundless;
        }
Exemple #2
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);
        }
Exemple #3
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);
        }
        public FloatRectangle?Translate(FloatRectangle?input)
        {
            if (!input.HasValue)
            {
                return(null);
            }

            var b = bounds;

            if (input.Value.Boundless)
            {
                b = new FloatRectangle(Solids.Instance.Bounds);
            }

            return(new FloatRectangle(
                       b.X + (b.Width * input.Value.X),
                       b.Y + (b.Height * input.Value.Y),
                       b.Width * input.Value.Width,
                       b.Height * input.Value.Height
                       ));
        }
 public bool IsWithinBounds(FloatRectangle fr)
 {
     return((fr.BottomRight.X > bounds.X || fr.TopLeft.X < bounds.BottomRight.X) &&
            (fr.BottomRight.Y > bounds.Y || fr.TopLeft.Y < bounds.BottomRight.Y));
 }
 public void SetBounds(FloatRectangle bounds)
 {
     this.bounds = bounds;
 }
 public void SetBounds(Rectangle bounds)
 {
     this.bounds = new FloatRectangle(bounds);
 }