示例#1
0
        static public void SplitByX(this RectF2 item, float x, out RectF2 left, out RectF2 right)
        {
            float split = x.Min(item.GetRight());

            left  = RectF2Extensions.CreateStrictMinMaxRectF2(item.min, item.max.GetWithX(split));
            right = RectF2Extensions.CreateStrictMinMaxRectF2(item.min.GetWithX(split), item.max);
        }
示例#2
0
 static public RectF2 GetRectF2(this RectI2 item)
 {
     return(RectF2Extensions.CreateLowerLeftRectF2(
                item.GetLowerLeftPoint().GetVectorF2(),
                item.GetSize().GetVectorF2()
                ));
 }
示例#3
0
        static public void SplitByY(this RectF2 item, float y, out RectF2 bottom, out RectF2 top)
        {
            float split = y.Min(item.GetTop());

            bottom = RectF2Extensions.CreateStrictMinMaxRectF2(item.min, item.max.GetWithY(split));
            top    = RectF2Extensions.CreateStrictMinMaxRectF2(item.min.GetWithY(split), item.max);
        }
示例#4
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())
                       ));
        }
示例#5
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
                       ));
        }
示例#6
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);
                }
            }
        }
示例#7
0
 static public RectF2 GetRect(this VectorF2 item)
 {
     return(RectF2Extensions.CreateCenterRectF2(item, VectorF2.ZERO));
 }