Ejemplo n.º 1
0
 public bool IntersectsWith(GRect rect)
 {
     return((rect.X < this.X + this.Width) &&
            (this.X < (rect.X + rect.Width)) &&
            (rect.Y < this.Y + this.Height) &&
            (this.Y < rect.Y + rect.Height));
 }
Ejemplo n.º 2
0
        public static GRect Inflate(GRect rect, long x, long y)
        {
            GRect r = rect;

            r.Inflate(x, y);
            return(r);
        }
Ejemplo n.º 3
0
 public bool Contains(GRect rect)
 {
     return((this.X <= rect.X) &&
            ((rect.X + rect.Width) <= (this.X + this.Width)) &&
            (this.Y <= rect.Y) &&
            ((rect.Y + rect.Height) <= (this.Y + this.Height)));
 }
Ejemplo n.º 4
0
        public static GRect Union(GRect a, GRect b)
        {
            long x1 = Math.Min(a.X, b.X);
            long x2 = Math.Max(a.X + a.Width, b.X + b.Width);
            long y1 = Math.Min(a.Y, b.Y);
            long y2 = Math.Max(a.Y + a.Height, b.Y + b.Height);

            return(new GRect(x1, y1, x2 - x1, y2 - y1));
        }
Ejemplo n.º 5
0
        public void Intersect(GRect rect)
        {
            GRect result = GRect.Intersect(rect, this);

            this.X      = result.X;
            this.Y      = result.Y;
            this.Width  = result.Width;
            this.Height = result.Height;
        }
Ejemplo n.º 6
0
        public static GRect Intersect(GRect a, GRect b)
        {
            long x1 = Math.Max(a.X, b.X);
            long x2 = Math.Min(a.X + a.Width, b.X + b.Width);
            long y1 = Math.Max(a.Y, b.Y);
            long y2 = Math.Min(a.Y + a.Height, b.Y + b.Height);

            if (x2 >= x1 &&
                y2 >= y1)
            {
                return(new GRect(x1, y1, x2 - x1, y2 - y1));
            }
            return(GRect.Empty);
        }
Ejemplo n.º 7
0
        public override bool Equals(object obj)
        {
            if (!(obj is GRect))
            {
                return(false);
            }

            GRect comp = (GRect)obj;

            return((comp.X == this.X) &&
                   (comp.Y == this.Y) &&
                   (comp.Width == this.Width) &&
                   (comp.Height == this.Height));
        }