Пример #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;
        }
Пример #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);
        }
Пример #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));
 }
Пример #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);
 }
Пример #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));
 }
Пример #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);
 }
Пример #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));
 }
Пример #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);
 }
Пример #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();
 }
Пример #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);
        }
Пример #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;
        }
Пример #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);
        }
Пример #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);
        }
Пример #14
0
 internal bool IsVisible(RectangleFx bounds)
 {
     throw new NotImplementedException();
 }
Пример #15
0
 public RegionFx(RectangleFx Bounds)
 {
     // TODO: Complete member initialization
     this.Bounds = Bounds;
 }
Пример #16
0
 internal void FillRectangle(Color brush, RectangleFx rectangle)
 {
     DrawingContext.DrawFilledRectangle(rectangle.ToRectangle(), brush);
 }
Пример #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();
 }
Пример #18
0
 public static Point GetSizeAsPoint(this RectangleFx r)
 {
     return(new Point((int)r.Width, (int)r.Height));
 }
Пример #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));
 }
Пример #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);
 }
Пример #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);
 }
Пример #22
0
 public static Vector2 BottomRightAsVector2(this RectangleFx r)
 {
     return(new Vector2(r.Right, r.Bottom));
 }
Пример #23
0
 public static Vector2 GetSizeAsVector2(this RectangleFx r)
 {
     return(new Vector2(r.Width, r.Height));
 }
Пример #24
0
 public bool IntersectsWith(RectangleFx rect)
 {
     return(this.ToRectangleF().IntersectsWith(rect.ToRectangleF()));
 }
Пример #25
0
 static RectangleFx()
 {
     RectangleFx.mEmpty  = new RectangleFx();
     RectangleFx.mMinMax = new RectangleFx(Vector2.One * float.MinValue, Vector2.One * float.MaxValue);
 }
Пример #26
0
 public static Point BottomRightAsPoint(this RectangleFx r)
 {
     return(new Point((int)r.Right, (int)r.Bottom));
 }
Пример #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));
 }