diff --git a/libnx/nx/nx_drawline.c b/libnx/nx/nx_drawline.c index f29c3b60976..162dd153889 100644 --- a/libnx/nx/nx_drawline.c +++ b/libnx/nx/nx_drawline.c @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -107,9 +107,15 @@ int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, } #endif + /* Split the line into trapezoids */ + ret = nxgl_splitline(vector, trap, &rect, width); switch (ret) { + /* 0: Line successfully broken up into three trapezoids. Values in + * traps[0], traps[1], and traps[2] are valid. + */ + case 0: ret = nx_filltrapezoid(hwnd, NULL, &trap[0], color); if (ret == OK) @@ -122,18 +128,45 @@ int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector, } break; + /* 1: Line successfully represented by one trapezoid. Value in traps[1] + * is valid. + */ + case 1: ret = nx_filltrapezoid(hwnd, NULL, &trap[1], color); break; + /* 2: Line successfully represented by one rectangle. Value in rect is + * valid + */ + case 2: ret = nx_fill(hwnd, &rect, color); break; + /* <0: On errors, a negated errno value is returned. */ + default: set_errno(-ret); return ERROR; } + /* Draw circular caps at each end of the line to support better line joins */ + + if (capped && width >= 3) + { + nxgl_coord_t radius = width >> 1; + + /* Draw a circle at pt1 */ + + ret = nx_fillcircle(hwnd, &vector->pt1, radius, color); + if (ret == OK) + { + /* Draw a circle at pt2 */ + + ret = nx_fillcircle(hwnd, &vector->pt2, radius, color); + } + } + return ret; } diff --git a/libnx/nx/nx_fillcircle.c b/libnx/nx/nx_fillcircle.c index aba0fd649a2..7bfa1551f52 100644 --- a/libnx/nx/nx_fillcircle.c +++ b/libnx/nx/nx_fillcircle.c @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ #define NCIRCLE_TRAPS 8 @@ -110,5 +110,6 @@ int nx_fillcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center, return ret; } } + return OK; } diff --git a/libnx/nxtk/nxtk_drawlinetoolbar.c b/libnx/nxtk/nxtk_drawlinetoolbar.c index 8c2810ce38f..61cef31d3b3 100644 --- a/libnx/nxtk/nxtk_drawlinetoolbar.c +++ b/libnx/nxtk/nxtk_drawlinetoolbar.c @@ -48,7 +48,7 @@ #include /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -110,9 +110,15 @@ int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, } #endif + /* Split the line into trapezoids */ + ret = nxgl_splitline(vector, trap, &rect, width); switch (ret) { + /* 0: Line successfully broken up into three trapezoids. Values in + * traps[0], traps[1], and traps[2] are valid. + */ + case 0: ret = nxtk_filltraptoolbar(hfwnd, &trap[0], color); if (ret == OK) @@ -125,18 +131,45 @@ int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, } break; + /* 1: Line successfully represented by one trapezoid. Value in traps[1] + * is valid. + */ + case 1: ret = nxtk_filltraptoolbar(hfwnd, &trap[1], color); break; + /* 2: Line successfully represented by one rectangle. Value in rect is + * valid + */ + case 2: ret = nxtk_filltoolbar(hfwnd, &rect, color); break; + /* <0: On errors, a negated errno value is returned. */ + default: set_errno(EINVAL); return ERROR; } + /* Draw circular caps at each end of the line to support better line joins */ + + if (capped && width >= 3) + { + nxgl_coord_t radius = width >> 1; + + /* Draw a circle at pt1 */ + + ret = nxtk_fillcircletoolbar(hfwnd, &vector->pt1, radius, color); + if (ret == OK) + { + /* Draw a circle at pt2 */ + + ret = nxtk_fillcircletoolbar(hfwnd, &vector->pt2, radius, color); + } + } + return ret; } diff --git a/libnx/nxtk/nxtk_drawlinewindow.c b/libnx/nxtk/nxtk_drawlinewindow.c index 8183bf79dec..584ff457cb5 100644 --- a/libnx/nxtk/nxtk_drawlinewindow.c +++ b/libnx/nxtk/nxtk_drawlinewindow.c @@ -48,7 +48,7 @@ #include /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -109,9 +109,15 @@ int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, } #endif + /* Split the line into trapezoids */ + ret = nxgl_splitline(vector, trap, &rect, width); switch (ret) { + /* 0: Line successfully broken up into three trapezoids. Values in + * traps[0], traps[1], and traps[2] are valid. + */ + case 0: ret = nxtk_filltrapwindow(hfwnd, &trap[0], color); if (ret == OK) @@ -124,18 +130,45 @@ int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector, } break; + /* 1: Line successfully represented by one trapezoid. Value in traps[1] + * is valid. + */ + case 1: ret = nxtk_filltrapwindow(hfwnd, &trap[1], color); break; - case 2: + /* 2: Line successfully represented by one rectangle. Value in rect is + * valid + */ + + case 2: ret = nxtk_fillwindow(hfwnd, &rect, color); break; + /* <0: On errors, a negated errno value is returned. */ + default: set_errno(EINVAL); return ERROR; } + /* Draw circular caps at each end of the line to support better line joins */ + + if (capped && width >= 3) + { + nxgl_coord_t radius = width >> 1; + + /* Draw a circle at pt1 */ + + ret = nxtk_fillcirclewindow(hfwnd, &vector->pt1, radius, color); + if (ret == OK) + { + /* Draw a circle at pt2 */ + + ret = nxtk_fillcirclewindow(hfwnd, &vector->pt2, radius, color); + } + } + return ret; } diff --git a/libnx/nxtk/nxtk_fillcircletoolbar.c b/libnx/nxtk/nxtk_fillcircletoolbar.c index b4ec94edd86..af502c76607 100644 --- a/libnx/nxtk/nxtk_fillcircletoolbar.c +++ b/libnx/nxtk/nxtk_fillcircletoolbar.c @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ #define NCIRCLE_TRAPS 8 @@ -111,5 +111,6 @@ int nxtk_fillcircletoolbar(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center return ret; } } + return OK; } diff --git a/libnx/nxtk/nxtk_fillcirclewindow.c b/libnx/nxtk/nxtk_fillcirclewindow.c index ee59ace1e00..b155e85ff92 100644 --- a/libnx/nxtk/nxtk_fillcirclewindow.c +++ b/libnx/nxtk/nxtk_fillcirclewindow.c @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Pre-Processor Definitions + * Pre-processor Definitions ****************************************************************************/ #define NCIRCLE_TRAPS 8 @@ -111,5 +111,6 @@ int nxtk_fillcirclewindow(NXWINDOW hfwnd, FAR const struct nxgl_point_s *center, return ret; } } + return OK; }