wmii

git clone git://oldgit.suckless.org/wmii/
Log | Files | Refs | README | LICENSE

rect_intersection.c (442B)


      1 /* Copyright ©2006-2010 Kris Maglione <maglione.k at Gmail>
      2  * See LICENSE file for license details.
      3  */
      4 #include <stuff/geom.h>
      5 #include <stuff/util.h>
      6 
      7 Rectangle
      8 rect_intersection(Rectangle r, Rectangle r2) {
      9 	Rectangle ret;
     10 
     11 	/* ret != canonrect(ret) ≡ no intersection. */
     12 	ret.min.x = max(r.min.x, r2.min.x);
     13 	ret.max.x = min(r.max.x, r2.max.x);
     14 	ret.min.y = max(r.min.y, r2.min.y);
     15 	ret.max.y = min(r.max.y, r2.max.y);
     16 	return ret;
     17 }