Exemplo n.º 1
0
        public Rect(Point <T> pt1, Point <T> pt2)
        {
            bool xCondition = GenericArithmetic <T> .gt(pt1.x, pt2.x);

            bool yCondition = GenericArithmetic <T> .gt(pt1.x, pt2.x);

            if (xCondition)             // pt1.x > pt2.x
            {
                x     = pt2.x;
                width = GenericArithmetic <T> .substract(pt1.x, pt2.x);
            }
            else
            {
                x     = pt1.x;
                width = GenericArithmetic <T> .substract(pt2.x, pt1.x);
            }

            if (yCondition)             // pt1.y > pt2.y
            {
                y      = pt2.y;
                height = GenericArithmetic <T> .substract(pt1.y, pt2.y);
            }
            else
            {
                y      = pt1.y;
                height = GenericArithmetic <T> .substract(pt2.y, pt1.y);
            }
        }
Exemplo n.º 2
0
        public bool contains(Point <T> pt)
        {
            var br = bottomRight;

            return(!GenericArithmetic <T> .lt(pt.x, x) &&
                   !GenericArithmetic <T> .lt(pt.y, y) &&
                   !GenericArithmetic <T> .gt(pt.x, br.x) &&
                   !GenericArithmetic <T> .gt(pt.y, br.y));
        }
Exemplo n.º 3
0
        public static Rect <T> operator |(Rect <T> a, Rect <T> b)
        {
            var abr = a.bottomRight;
            var bbr = b.bottomRight;
            T   x   = GenericArithmetic <T> .lt(a.x, b.x) ? a.x : b.x;

            T y = GenericArithmetic <T> .lt(a.y, b.y) ? a.y : b.y;

            T w = GenericArithmetic <T> .substract(
                GenericArithmetic <T> .gt(abr.x, bbr.x)?abr.x : bbr.x,
                x);

            T h = GenericArithmetic <T> .substract(
                GenericArithmetic <T> .gt(abr.y, bbr.y)?abr.y : bbr.y,
                y);

            return(new Rect <T>(x, y, w, h));
        }