Add a 'capped' boolean parameter to all drawline/drawLine functions/methods. The idea is that this will produce better joining between lines

This commit is contained in:
Gregory Nutt
2015-04-05 08:50:01 -06:00
parent fca4c51420
commit ae03d56700
10 changed files with 69 additions and 38 deletions
+3 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* libnx/nx/nx_drawcircle.c
*
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -128,7 +128,7 @@ int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
vector.pt1.y = pts[i].y;
vector.pt2.x = pts[i+1].x;
vector.pt2.y = pts[i+1].y;
ret = nx_drawline(hwnd, &vector, width, color);
ret = nx_drawline(hwnd, &vector, width, color, true);
if (ret != OK)
{
return ret;
@@ -141,5 +141,5 @@ int nx_drawcircle(NXWINDOW hwnd, FAR const struct nxgl_point_s *center,
vector.pt1.y = pts[POINT_337p5].y;
vector.pt2.x = pts[POINT_0p0].x;
vector.pt2.y = pts[POINT_0p0].y;
return nx_drawline(hwnd, &vector, width, color);
return nx_drawline(hwnd, &vector, width, color, true);
}
+5 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* libnx/nx/nx_drawline.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -83,6 +83,8 @@
* vector - Describes the line to be drawn
* width - The width of the line
* color - The color to use to fill the line
* capped - Draw a circular cap both ends of the line to support better
* line joins
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
@@ -90,7 +92,8 @@
****************************************************************************/
int nx_drawline(NXWINDOW hwnd, FAR struct nxgl_vector_s *vector,
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES],
bool capped)
{
struct nxgl_trapezoid_s trap[3];
struct nxgl_rect_s rect;
+3 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* libnx/nxtk/nxtk_drawcircletoolbar.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -128,7 +128,7 @@ int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cent
vector.pt1.y = pts[i].y;
vector.pt2.x = pts[i+1].x;
vector.pt2.y = pts[i+1].y;
ret = nxtk_drawlinetoolbar(hfwnd, &vector, width, color);
ret = nxtk_drawlinetoolbar(hfwnd, &vector, width, color, true);
if (ret != OK)
{
return ret;
@@ -141,5 +141,5 @@ int nxtk_drawcircletoolbar(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cent
vector.pt1.y = pts[POINT_337p5].y;
vector.pt2.x = pts[POINT_0p0].x;
vector.pt2.y = pts[POINT_0p0].y;
return nxtk_drawlinetoolbar(hfwnd, &vector, width, color);
return nxtk_drawlinetoolbar(hfwnd, &vector, width, color, true);
}
+3 -3
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* libnx/nxtk/nxtk_drawcirclewindow.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -128,7 +128,7 @@ int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cente
vector.pt1.y = pts[i].y;
vector.pt2.x = pts[i+1].x;
vector.pt2.y = pts[i+1].y;
ret = nxtk_drawlinewindow(hfwnd, &vector, width, color);
ret = nxtk_drawlinewindow(hfwnd, &vector, width, color, true);
if (ret != OK)
{
return ret;
@@ -141,5 +141,5 @@ int nxtk_drawcirclewindow(NXTKWINDOW hfwnd, FAR const struct nxgl_point_s *cente
vector.pt1.y = pts[POINT_337p5].y;
vector.pt2.x = pts[POINT_0p0].x;
vector.pt2.y = pts[POINT_0p0].y;
return nxtk_drawlinewindow(hfwnd, &vector, width, color);
return nxtk_drawlinewindow(hfwnd, &vector, width, color, true);
}
+5 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* libnx/nxtk/nxtk_drawlinetoolbar.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -85,6 +85,8 @@
* vector - Describes the line to be drawn
* width - The width of the line
* color - The color to use to fill the line
* capped - Draw a circular cap both ends of the line to support better
* line joins
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
@@ -92,7 +94,8 @@
****************************************************************************/
int nxtk_drawlinetoolbar(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector,
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES],
bool capped)
{
struct nxgl_trapezoid_s trap[3];
+5 -2
View File
@@ -1,7 +1,7 @@
/****************************************************************************
* libnx/nxtk/nxtk_drawlinewindow.c
*
* Copyright (C) 2011 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -84,6 +84,8 @@
* vector - Describes the line to be drawn
* width - The width of the line
* color - The color to use to fill the line
* capped - Draw a circular cap both ends of the line to support better
* line joins
*
* Return:
* OK on success; ERROR on failure with errno set appropriately
@@ -91,7 +93,8 @@
****************************************************************************/
int nxtk_drawlinewindow(NXTKWINDOW hfwnd, FAR struct nxgl_vector_s *vector,
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES])
nxgl_coord_t width, nxgl_mxpixel_t color[CONFIG_NX_NPLANES],
bool capped)
{
struct nxgl_trapezoid_s trap[3];