Ejemplo n.º 1
0
        public static void Intersect(ref RectangleFx rect1, ref RectangleFx rect2, out RectangleFx result)
        {
            result = new RectangleFx();
            float num8 = rect1.Max.X;
            float num7 = rect2.Max.X;
            float num6 = rect1.Max.Y;
            float num5 = rect2.Max.Y;
            float num2 = (rect1.Min.X > rect2.Min.X) ? rect1.Min.X : rect2.Min.X;
            float num  = (rect1.Min.Y > rect2.Min.Y) ? rect1.Min.Y : rect2.Min.Y;
            float num4 = (num8 < num7) ? num8 : num7;
            float num3 = (num6 < num5) ? num6 : num5;

            if ((num4 > num2) && (num3 > num))
            {
                result.Min.X = num2;
                result.Min.Y = num;
                result.Max.X = num4;
                result.Max.Y = num3;
            }

            result.Min.X = 0;
            result.Min.Y = 0;
            result.Max.X = 0;
            result.Max.Y = 0;
        }
Ejemplo n.º 2
0
        public static RectangleFx Intersect(RectangleFx rect1, RectangleFx rect2)
        {
            RectangleFx result;

            float num8 = rect1.Max.X;
            float num7 = rect2.Max.X;
            float num6 = rect1.Max.Y;
            float num5 = rect2.Max.Y;
            float num2 = (rect1.Min.X > rect2.Min.X) ? rect1.Min.X : rect2.Min.X;
            float num  = (rect1.Min.Y > rect2.Min.Y) ? rect1.Min.Y : rect2.Min.Y;
            float num4 = (num8 < num7) ? num8 : num7;
            float num3 = (num6 < num5) ? num6 : num5;

            if ((num4 > num2) && (num3 > num))
            {
                result.Min.X = num2;
                result.Min.Y = num;
                result.Max.X = num4;
                result.Max.Y = num3;

                return(result);
            }

            result.Min.X = 0;
            result.Min.Y = 0;
            result.Max.X = 0;
            result.Max.Y = 0;

            return(result);
        }
Ejemplo n.º 3
0
 public bool Equals(RectangleFx other)
 {
     return
         ((this.Min.X == other.Min.X) &&
          (this.Min.Y == other.Min.Y) &&
          (this.Max.X == other.Max.X) &&
          (this.Max.Y == other.Max.Y));
 }
Ejemplo n.º 4
0
 public void Intersects(ref RectangleFx rect, out bool result)
 {
     result =
         (this.Min.X < rect.Max.X) &&
         (this.Min.Y < rect.Max.Y) &&
         (this.Max.X > rect.Min.X) &&
         (this.Max.Y > rect.Min.Y);
 }
Ejemplo n.º 5
0
 public bool Intersects(RectangleFx rect)
 {
     return
         ((this.Min.X < rect.Max.X) &&
          (this.Min.Y < rect.Max.Y) &&
          (this.Max.X > rect.Min.X) &&
          (this.Max.Y > rect.Min.Y));
 }
Ejemplo n.º 6
0
 public void Contains(ref RectangleFx rect, out bool result)
 {
     result =
         (this.Min.X <= rect.Min.X) &&
         (this.Min.Y <= rect.Min.Y) &&
         (this.Max.X >= rect.Max.X) &&
         (this.Max.Y >= rect.Max.Y);
 }
Ejemplo n.º 7
0
 public bool Contains(RectangleFx rect)
 {
     return
         ((this.Min.X <= rect.Min.X) &&
          (this.Min.Y <= rect.Min.Y) &&
          (this.Max.X >= rect.Max.X) &&
          (this.Max.Y >= rect.Max.Y));
 }
Ejemplo n.º 8
0
 public static RectangleFx InverseTransform(Matrix matrix, RectangleFx rect)
 {
     if (matrix.Determinant() != 0.0f)
     {
         Matrix tempMatrix = Matrix.Identity;
         tempMatrix = Matrix.Multiply(tempMatrix, matrix);
         tempMatrix = Matrix.Invert(tempMatrix);
         rect       = MatrixExtensions.Transform(tempMatrix, rect);
     }
     return(rect);
 }
Ejemplo n.º 9
0
 internal void DrawRectangle(Color brush, RectangleFx rectangle)
 {
     DrawingContext.Begin(
         SpriteSortMode.Deferred,
         BlendState.AlphaBlend,
         SamplerState.LinearClamp, DepthStencilState.None,
         RasterizerState.CullNone,
         null,
         Transform);
     //DrawingContext.Begin();
     DrawingContext.DrawRectangle(rectangle.ToRectangle(), brush);
     DrawingContext.End();
 }
Ejemplo n.º 10
0
        internal static RectangleFx Transform(Matrix matrix, RectangleFx rect)
        {
            float x      = rect.X;
            float y      = rect.Y;
            float width  = rect.Width;
            float height = rect.Height;

            PTS4[0].X = x;
            PTS4[0].Y = y;
            PTS4[1].X = x + width;
            PTS4[1].Y = y;
            PTS4[2].X = x + width;
            PTS4[2].Y = y + height;
            PTS4[3].X = x;
            PTS4[3].Y = y + height;

            PTS4 = MatrixExtensions.TransformPoints(matrix, PTS4);

            float minX = PTS4[0].X;
            float minY = PTS4[0].Y;
            float maxX = PTS4[0].X;
            float maxY = PTS4[0].Y;

            for (int i = 1; i < 4; i++)
            {
                x = PTS4[i].X;
                y = PTS4[i].Y;

                if (x < minX)
                {
                    minX = x;
                }
                if (y < minY)
                {
                    minY = y;
                }
                if (x > maxX)
                {
                    maxX = x;
                }
                if (y > maxY)
                {
                    maxY = y;
                }
            }

            RectangleFx ret = new RectangleFx(minX, minY, maxX - minX, maxY - minY);

            return(rect);
        }
Ejemplo n.º 11
0
        public static void Union(ref RectangleFx rect1, ref RectangleFx rect2, out RectangleFx result)
        {
            result = new RectangleFx();

            float num6 = rect1.Max.X;
            float num5 = rect2.Max.X;
            float num4 = rect1.Max.Y;
            float num3 = rect2.Max.Y;
            float num2 = (rect1.Min.X < rect2.Min.X) ? rect1.Min.X : rect2.Min.X;
            float num  = (rect1.Min.Y < rect2.Min.Y) ? rect1.Min.Y : rect2.Min.Y;
            float num8 = (num6 > num5) ? num6 : num5;
            float num7 = (num4 > num3) ? num4 : num3;

            result.Min.X = num2;
            result.Min.Y = num;
            result.Max.X = num8;
            result.Max.Y = num7;
        }
Ejemplo n.º 12
0
        internal void AddRectangle(RectangleFx rect)
        {
            float x = rect.X;
            float y = rect.Y;
            float w = rect.Width;
            float h = rect.Height;


            AddPoint(new PointFx(x, y), PathPointType.Start);
            AddPoint(new PointFx(x + w, y), PathPointType.Line);
            AddPoint(new PointFx(x + w, y + h), PathPointType.Line);
            AddPoint(new PointFx(x, y + h), PathPointType.Line);
            AddPoint(new PointFx(x, y), PathPointType.CloseSubpath);
            //AddLine(x, y, x + w, y);
            //AddLine(x + w, y, x + w, y + h);
            //AddLine(x + w, y + h, x, y + h);
            //AddLine(x, y + h, x, y);
        }
Ejemplo n.º 13
0
        public static RectangleFx Union(RectangleFx rect1, RectangleFx rect2)
        {
            RectangleFx result = new RectangleFx();

            float num6 = rect1.Max.X;
            float num5 = rect2.Max.X;
            float num4 = rect1.Max.Y;
            float num3 = rect2.Max.Y;
            float num2 = (rect1.Min.X < rect2.Min.X) ? rect1.Min.X : rect2.Min.X;
            float num  = (rect1.Min.Y < rect2.Min.Y) ? rect1.Min.Y : rect2.Min.Y;
            float num8 = (num6 > num5) ? num6 : num5;
            float num7 = (num4 > num3) ? num4 : num3;

            result.Min.X = num2;
            result.Min.Y = num;
            result.Max.X = num8;
            result.Max.Y = num7;

            return(result);
        }
Ejemplo n.º 14
0
 internal bool IsVisible(RectangleFx bounds)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 15
0
 public RegionFx(RectangleFx Bounds)
 {
     // TODO: Complete member initialization
     this.Bounds = Bounds;
 }
Ejemplo n.º 16
0
 internal void FillRectangle(Color brush, RectangleFx rectangle)
 {
     DrawingContext.DrawFilledRectangle(rectangle.ToRectangle(), brush);
 }
Ejemplo n.º 17
0
 internal void DrawString(string text, SpriteFont renderFont, Color textBrush, RectangleFx rectangleF, System.Drawing.StringFormat stringFormat)
 {
     DrawingContext.Begin(
         SpriteSortMode.Deferred,
         BlendState.AlphaBlend,
         SamplerState.LinearClamp, DepthStencilState.None,
         RasterizerState.CullCounterClockwise,
         null,
         Transform);
     //DrawingContext.Begin();
     DrawingContext.DrawText(renderFont, text, new Vector2(rectangleF.X, rectangleF.Y), textBrush);
     DrawingContext.End();
 }
Ejemplo n.º 18
0
 public static Point GetSizeAsPoint(this RectangleFx r)
 {
     return(new Point((int)r.Width, (int)r.Height));
 }
Ejemplo n.º 19
0
 public static RectangleFx FromLTRB(this RectangleFx src, float left, float top, float right, float bottom)
 {
     return(new RectangleFx(src.Left, src.Top, src.Right - src.Left, src.Bottom - src.Top));
 }
Ejemplo n.º 20
0
 public static bool Contains(this RectangleFx r, Vector2 pos)
 {
     return(pos.X >= r.Left && pos.X <= r.Left + r.Width && pos.Y >= r.Top && pos.Y <= r.Top + r.Height);
 }
Ejemplo n.º 21
0
 public static bool Contains(this RectangleFx r, float x, float y)
 {
     return(x >= r.Left && x <= r.Left + r.Width && y >= r.Top && y <= r.Top + r.Height);
 }
Ejemplo n.º 22
0
 public static Vector2 BottomRightAsVector2(this RectangleFx r)
 {
     return(new Vector2(r.Right, r.Bottom));
 }
Ejemplo n.º 23
0
 public static Vector2 GetSizeAsVector2(this RectangleFx r)
 {
     return(new Vector2(r.Width, r.Height));
 }
Ejemplo n.º 24
0
 public bool IntersectsWith(RectangleFx rect)
 {
     return(this.ToRectangleF().IntersectsWith(rect.ToRectangleF()));
 }
Ejemplo n.º 25
0
 static RectangleFx()
 {
     RectangleFx.mEmpty  = new RectangleFx();
     RectangleFx.mMinMax = new RectangleFx(Vector2.One * float.MinValue, Vector2.One * float.MaxValue);
 }
Ejemplo n.º 26
0
 public static Point BottomRightAsPoint(this RectangleFx r)
 {
     return(new Point((int)r.Right, (int)r.Bottom));
 }
Ejemplo n.º 27
0
 public static RectangleFx CenterRectangle(this RectangleFx r, int x, int y)
 {
     return(new RectangleFx(x - r.Center.X, y - r.Center.Y, r.Width, r.Height));
 }