LCD LIB

Dependents:   HagridOS5

Fork of RA8875 by David Smart

Files at this revision

API Documentation at this revision

Comitter:
WiredHome
Date:
Tue Jun 13 23:12:26 2017 +0000
Parent:
147:3494792458d9
Child:
149:c62c4b2d6a15
Commit message:
Final fix on the computation of the Intersection of two rectangles, when you want to access to the resulting intersection. Prior versions worked if only if point1 was the top-left and point2 the bottom-right. This version works for any corner pair.

Changed in this revision

RA8875.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/RA8875.cpp	Mon Jun 12 22:15:08 2017 +0000
+++ b/RA8875.cpp	Tue Jun 13 23:12:26 2017 +0000
@@ -555,10 +555,10 @@
     if (Intersect(*pRect1, *pRect2)) {
         rect_t iSect;
         
-        iSect.p1.x = max(pRect1->p1.x, pRect2->p1.x);
-        iSect.p1.y = max(pRect1->p1.y, pRect2->p1.y);
-        iSect.p2.x = min(pRect1->p2.x, pRect2->p2.x);
-        iSect.p2.y = min(pRect1->p2.y, pRect2->p2.y);
+        iSect.p1.x = max(min(pRect1->p1.x,pRect1->p2.x),min(pRect2->p1.x,pRect2->p2.x));
+        iSect.p1.y = max(min(pRect1->p1.y,pRect1->p2.y),min(pRect2->p1.y,pRect2->p2.y));
+        iSect.p2.x = min(max(pRect1->p1.x,pRect1->p2.x),max(pRect2->p1.x,pRect2->p2.x));
+        iSect.p2.y = min(max(pRect1->p1.y,pRect1->p2.y),max(pRect2->p1.y,pRect2->p2.y));
         *pRect1 = iSect;
         return true;
     } else {