public bool IntersectsWith(MapRect 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)); }
public static MapRect Inflate(MapRect rect, int x, int y) { MapRect r = rect; r.Inflate(x, y); return(r); }
public bool Contains(MapRect 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))); }
public static MapRect Union(MapRect a, MapRect b) { int x1 = Math.Min(a.X, b.X); int x2 = Math.Max(a.X + a.Width, b.X + b.Width); int y1 = Math.Min(a.Y, b.Y); int y2 = Math.Max(a.Y + a.Height, b.Y + b.Height); return(new MapRect(x1, y1, x2 - x1, y2 - y1)); }
public void Intersect(MapRect rect) { MapRect result = MapRect.Intersect(rect, this); this.X = result.X; this.Y = result.Y; this.Width = result.Width; this.Height = result.Height; }
public static MapRect Intersect(MapRect a, MapRect b) { int x1 = Math.Max(a.X, b.X); int x2 = Math.Min(a.X + a.Width, b.X + b.Width); int y1 = Math.Max(a.Y, b.Y); int y2 = Math.Min(a.Y + a.Height, b.Y + b.Height); if (x2 >= x1 && y2 >= y1) { return(new MapRect(x1, y1, x2 - x1, y2 - y1)); } return(MapRect.Empty); }
public override bool Equals(object obj) { if (!(obj is MapRect)) { return(false); } MapRect comp = (MapRect)obj; return((comp.X == this.X) && (comp.Y == this.Y) && (comp.Width == this.Width) && (comp.Height == this.Height)); }