Exemplo n.º 1
0
        static public RectF2 GetConstrainedAboveY(this RectF2 item, float y)
        {
            if (item.GetBottom() < y)
            {
                return(item.GetVerticallyShifted(y - item.GetBottom()));
            }

            return(item);
        }
Exemplo n.º 2
0
        static public IEnumerable <RectF2> GetSubtraction(this RectF2 item, RectF2 to_subtract)
        {
            if (item.TryGetIntersection(to_subtract, out to_subtract) == false)
            {
                yield return(item);
            }
            else
            {
                RectF2 left;
                if (RectF2Extensions.TryCreateStrictMinMaxRectF2(
                        item.GetLeft(), to_subtract.GetBottom(),
                        to_subtract.GetLeft(), to_subtract.GetTop(),
                        out left
                        ))
                {
                    yield return(left);
                }

                RectF2 right;
                if (RectF2Extensions.TryCreateStrictMinMaxRectF2(
                        to_subtract.GetRight(), to_subtract.GetBottom(),
                        item.GetRight(), to_subtract.GetTop(),
                        out right
                        ))
                {
                    yield return(right);
                }

                RectF2 bottom;
                if (RectF2Extensions.TryCreateStrictMinMaxRectF2(
                        item.GetLeft(), item.GetBottom(),
                        item.GetRight(), to_subtract.GetBottom(),
                        out bottom
                        ))
                {
                    yield return(bottom);
                }

                RectF2 top;
                if (RectF2Extensions.TryCreateStrictMinMaxRectF2(
                        item.GetLeft(), to_subtract.GetTop(),
                        item.GetRight(), item.GetTop(),
                        out top
                        ))
                {
                    yield return(top);
                }
            }
        }
Exemplo n.º 3
0
        static public RectF2 GetEncompassing(this RectF2 item, RectF2 rect)
        {
            return(RectF2Extensions.CreateStrictMinMaxRectF2(
                       item.GetLeft().Min(rect.GetLeft()),
                       item.GetBottom().Min(rect.GetBottom()),

                       item.GetRight().Max(rect.GetRight()),
                       item.GetTop().Max(rect.GetTop())
                       ));
        }
Exemplo n.º 4
0
        static public bool TryGetIntersection(this RectF2 item, RectF2 rect, out RectF2 intersection)
        {
            return(RectF2Extensions.TryCreateStrictMinMaxRectF2(
                       item.GetLeft().Max(rect.GetLeft()),
                       item.GetBottom().Max(rect.GetBottom()),

                       item.GetRight().Min(rect.GetRight()),
                       item.GetTop().Min(rect.GetTop()),
                       out intersection
                       ));
        }
Exemplo n.º 5
0
        static public bool FullyContains(this RectF2 item, RectF2 target)
        {
            if (item.GetLeft() <= target.GetLeft() && item.GetRight() >= target.GetRight())
            {
                if (item.GetBottom() <= target.GetBottom() && item.GetTop() >= target.GetTop())
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 6
0
        static public bool TryGetConstrainedBy(this RectF2 item, RectF2 bounds, out RectF2 output)
        {
            output = item.GetConstrainedAboveX(bounds.GetLeft())
                     .GetConstrainedBelowX(bounds.GetRight())
                     .GetConstrainedAboveY(bounds.GetBottom())
                     .GetConstrainedBelowY(bounds.GetTop());

            if (bounds.FullyContains(output))
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        static public float GetSide(this RectF2 item, RectSide side)
        {
            switch (side)
            {
            case RectSide.Left: return(item.GetLeft());

            case RectSide.Right: return(item.GetRight());

            case RectSide.Bottom: return(item.GetBottom());

            case RectSide.Top: return(item.GetTop());
            }

            throw new UnaccountedBranchException("side", side);
        }
Exemplo n.º 8
0
 static public VectorF2 GetLowerRightPoint(this RectF2 item)
 {
     return(new VectorF2(item.GetRight(), item.GetBottom()));
 }
Exemplo n.º 9
0
 static public void SplitByYBottomOffset(this RectF2 item, float y_offset, out RectF2 bottom, out RectF2 top)
 {
     item.SplitByY(item.GetBottom() + y_offset, out bottom, out top);
 }