Example #1
0
 public bool IsRectCompletelyInside(RectF rect)
 {
     return(IsPointInside(rect.TopLeft) && IsPointInside(rect.TopRight) &&
            IsPointInside(rect.BottomLeft) && IsPointInside(rect.BottomRight));
 }
Example #2
0
 public bool Equals(RectF value)
 {
     return(RectF.Equals(this, value));
 }
Example #3
0
 public bool IsCompletelyInside(RectF rect)
 {
     return(rect.Contains(P1) && rect.Contains(P2) && rect.Contains(P3));
 }
Example #4
0
 public static RectF Inflate(RectF rect, Float width, Float height)
 {
     rect.Inflate(width, height);
     return(rect);
 }
Example #5
0
 public static RectF Transform(RectF rect, MatrixF matrix)
 {
     MathUtil.TransformRect(ref rect, ref matrix);
     return(rect);
 }
Example #6
0
 public static RectF Offset(RectF rect, Float offsetX, Float offsetY)
 {
     rect.Offset(offsetX, offsetY);
     return(rect);
 }
Example #7
0
 public static RectF Inflate(RectF rect, SizeF size)
 {
     rect.Inflate(size._width, size._height);
     return(rect);
 }
Example #8
0
 public static RectF Offset(RectF rect, VectorF offsetVector)
 {
     rect.Offset(offsetVector.X, offsetVector.Y);
     return(rect);
 }
Example #9
0
 public static RectF Union(RectF rect, PointF point)
 {
     rect.Union(new RectF(point, point));
     return(rect);
 }
Example #10
0
 public static RectF Union(RectF rect1, RectF rect2)
 {
     rect1.Union(rect2);
     return(rect1);
 }
Example #11
0
 public static RectF Intersect(RectF rect1, RectF rect2)
 {
     rect1.Intersect(rect2);
     return(rect1);
 }
Example #12
0
        internal static void TransformRect(ref RectF rect, ref MatrixF matrix)
        {
            if (rect.IsEmpty)
            {
                return;
            }

            MatrixTypes matrixType = matrix._type;

            // If the matrix is identity, don't worry.
            if (matrixType == MatrixTypes.TRANSFORM_IS_IDENTITY)
            {
                return;
            }

            // Scaling
            if (0 != (matrixType & MatrixTypes.TRANSFORM_IS_SCALING))
            {
                rect._x      *= matrix._m11;
                rect._y      *= matrix._m22;
                rect._width  *= matrix._m11;
                rect._height *= matrix._m22;

                // Ensure the width is always positive.  For example, if there was a reflection about the
                // y axis followed by a translation into the visual area, the width could be negative.
                if (rect._width < 0.0)
                {
                    rect._x    += rect._width;
                    rect._width = -rect._width;
                }

                // Ensure the height is always positive.  For example, if there was a reflection about the
                // x axis followed by a translation into the visual area, the height could be negative.
                if (rect._height < 0.0F)
                {
                    rect._y     += rect._height;
                    rect._height = -rect._height;
                }
            }

            // Translation
            if (0 != (matrixType & MatrixTypes.TRANSFORM_IS_TRANSLATION))
            {
                // X
                rect._x += matrix._offsetX;

                // Y
                rect._y += matrix._offsetY;
            }

            if (matrixType == MatrixTypes.TRANSFORM_IS_UNKNOWN)
            {
                // Al Bunny implementation.
                PointF point0 = matrix.Transform(rect.TopLeft);
                PointF point1 = matrix.Transform(rect.TopRight);
                PointF point2 = matrix.Transform(rect.BottomRight);
                PointF point3 = matrix.Transform(rect.BottomLeft);

                // Width and height is always positive here.
                rect._x = Math.Min(Math.Min(point0.X, point1.X), Math.Min(point2.X, point3.X));
                rect._y = Math.Min(Math.Min(point0.Y, point1.Y), Math.Min(point2.Y, point3.Y));

                rect._width  = Math.Max(Math.Max(point0.X, point1.X), Math.Max(point2.X, point3.X)) - rect._x;
                rect._height = Math.Max(Math.Max(point0.Y, point1.Y), Math.Max(point2.Y, point3.Y)) - rect._y;
            }
        }