diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-20 01:55:05 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-04-20 01:55:05 +0000 |
commit | 60af61e86dfef73118ca1b21052085819df772a8 (patch) | |
tree | f2b4ec25a9371b71f253d018d7ac34e932a5c95f /nuttx/graphics/nxglib | |
parent | 0a237f936cc0145ea529c8ecca596061a044450d (diff) | |
download | nuttx-60af61e86dfef73118ca1b21052085819df772a8.tar.gz nuttx-60af61e86dfef73118ca1b21052085819df772a8.tar.bz2 nuttx-60af61e86dfef73118ca1b21052085819df772a8.zip |
Correct 1-bit errors in intersection calculations
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3526 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxglib')
-rw-r--r-- | nuttx/graphics/nxglib/nxglib_nonintersecting.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/nuttx/graphics/nxglib/nxglib_nonintersecting.c b/nuttx/graphics/nxglib/nxglib_nonintersecting.c index dcfc2590f..0a77059a0 100644 --- a/nuttx/graphics/nxglib/nxglib_nonintersecting.c +++ b/nuttx/graphics/nxglib/nxglib_nonintersecting.c @@ -88,6 +88,43 @@ void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4], /* Then return the four rectangles representing the regions NON included * in the intersection. Some of these rectangles may be invalid (zero * area), but those can be picked off using nxgl_nullrect() + * + * rect1.pt1 + * +-------------------------+ + * | rect2.pt1 | + * | int.pt1 | + * | +-------------------------+ + * | | | | + * | | | | + * +-------------------------+ | + * | rect1.pt2 | + * | int.pt2 | + * +-------------------------+ + * rect2.pt2 + * rect1.pt1 + * +-------------------------+ + * rect2.pt1 |int.pt1 | + * +---------+---------------+ | + * | | | | + * | | | | + * | | |int.pt2 | + * | +---------------+---------+ + * | | rect1.pt2 + * +-------------------------+ + * rect2.pt2 + * rect2.pt1 + * +-------------------------+ + * | rect1.pt1 | + * | int.pt1 | + * | +-------------------------+ + * | | | | + * | | | | + * | | | | + * +---------+---------------+ | + * | rect2.pt2 | + * | int.pt2 | + * +-------------------------+ + * rect1.pt2 */ result[NX_TOP_NDX].pt1.x = rect1->pt1.x; @@ -100,14 +137,14 @@ void nxgl_nonintersecting(FAR struct nxgl_rect_s result[4], result[NX_BOTTOM_NDX].pt2.x = rect1->pt2.x; result[NX_BOTTOM_NDX].pt2.y = rect1->pt2.y; - result[NX_LEFT_NDX].pt1.x = rect1->pt1.x + 1; + result[NX_LEFT_NDX].pt1.x = rect1->pt1.x; result[NX_LEFT_NDX].pt1.y = intersection.pt1.y; - result[NX_LEFT_NDX].pt2.x = intersection.pt1.x; + result[NX_LEFT_NDX].pt2.x = intersection.pt1.x - 1; result[NX_LEFT_NDX].pt2.y = intersection.pt2.y; - result[NX_RIGHT_NDX].pt1.x = intersection.pt2.x; + result[NX_RIGHT_NDX].pt1.x = intersection.pt2.x + 1; result[NX_RIGHT_NDX].pt1.y = intersection.pt1.y; - result[NX_RIGHT_NDX].pt2.x = rect1->pt2.x - 1; + result[NX_RIGHT_NDX].pt2.x = rect1->pt2.x; result[NX_RIGHT_NDX].pt2.y = intersection.pt2.y; } |