Change GDISP poly fns to support translation

Change GDISP poly fns to support translation - required for adding poly
functions to GWIN
ugfx_release_2.6
Andrew Hannam 2013-03-18 18:27:52 +10:00
parent e7b54696f6
commit cc5729dedd
3 changed files with 52 additions and 47 deletions

View File

@ -658,30 +658,35 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color);
/**
* @brief Draw an enclosed polygon (convex, non-convex or complex).
*
* @param[in] tx, ty Transform all points in pntarray by tx, ty
* @param[in] pntarray An array of points
* @param[in] cnt The number of points in the array
* @param[in] color The color to use
*
* @api
*/
void gdispDrawPoly(const point *pntarray, unsigned cnt, color_t color);
void gdispDrawPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color);
/**
* @brief Fill a convex polygon
* @details Doesn't handle non-convex or complex polygons.
*
* @param[in] tx, ty Transform all points in pntarray by tx, ty
* @param[in] pntarray An array of points
* @param[in] cnt The number of points in the array
* @param[in] color The color to use
*
* @note Convex polygons are those that have no internal angles. That is;
* you can draw a line from any point on the polygon to any other point
* on the polygon without it going outside the polygon.
* on the polygon without it going outside the polygon. In our case we generalise
* this a little by saying that an infinite horizontal line (at any y value) will cross
* no more than two edges on the polygon. Some non-convex polygons do fit this criteria
* and can therefore be drawn.
* @note This routine is designed to be very efficient with even simple display hardware.
*
* @api
*/
void gdispFillConvexPoly(const point *pntarray, unsigned cnt, color_t color);
void gdispFillConvexPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color);
#endif
/* Extra Text Functions */

View File

@ -566,16 +566,16 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
}
#if GDISP_NEED_CONVEX_POLYGON
void gdispDrawPoly(const point *pntarray, unsigned cnt, color_t color) {
void gdispDrawPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) {
const point *epnt, *p;
epnt = &pntarray[cnt-1];
for(p = pntarray; p < epnt; p++)
gdispDrawLine(p->x, p->y, p[1].x, p[1].y, color);
gdispDrawLine(p->x, p->y, pntarray->x, pntarray->y, color);
gdispDrawLine(tx+p->x, ty+p->y, tx+p[1].x, ty+p[1].y, color);
gdispDrawLine(tx+p->x, ty+p->y, tx+pntarray->x, ty+pntarray->y, color);
}
void gdispFillConvexPoly(const point *pntarray, unsigned cnt, color_t color) {
void gdispFillConvexPoly(coord_t tx, coord_t ty, const point *pntarray, unsigned cnt, color_t color) {
const point *lpnt, *rpnt, *epnts;
fpcoord_t lx, rx, lk, rk;
coord_t y, ymax, lxc, rxc;
@ -622,14 +622,14 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
*/
if (lxc < rxc) {
if (rxc - lxc == 1)
gdispDrawPixel(lxc, y, color);
gdispDrawPixel(tx+lxc, ty+y, color);
else
gdispDrawLine(lxc, y, rxc-1, y, color);
gdispDrawLine(tx+lxc, ty+y, tx+rxc-1, ty+y, color);
} else if (lxc > rxc) {
if (lxc - rxc == 1)
gdispDrawPixel(rxc, y, color);
gdispDrawPixel(tx+rxc, ty+y, color);
else
gdispDrawLine(rxc, y, lxc-1, y, color);
gdispDrawLine(tx+rxc, ty+y, tx+lxc-1, ty+y, color);
}
lx += lk;

View File

@ -306,16 +306,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x+gh->width/2; arw[0].y = gh->y;
arw[1].x = gh->x+gh->width-1; arw[1].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[2].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[3].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = gh->y+gh->height-1;
arw[4].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = gh->y+gh->height-1;
arw[5].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[6].x = gh->x; arw[6].y = gh->y+gh->height/ARROWHEAD_DIVIDER;
arw[0].x = gh->width/2; arw[0].y = 0;
arw[1].x = gh->width-1; arw[1].y = gh->height/ARROWHEAD_DIVIDER;
arw[2].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->height/ARROWHEAD_DIVIDER;
arw[3].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = gh->height-1;
arw[4].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = gh->height-1;
arw[5].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->height/ARROWHEAD_DIVIDER;
arw[6].x = 0; arw[6].y = gh->height/ARROWHEAD_DIVIDER;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
@ -324,16 +324,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x+gh->width/2; arw[0].y = gh->y+gh->height-1;
arw[1].x = gh->x+gh->width-1; arw[1].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[2].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[3].x = gh->x+(gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = gh->y;
arw[4].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = gh->y;
arw[5].x = gh->x+(gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[6].x = gh->x; arw[6].y = gh->y+gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[0].x = gh->width/2; arw[0].y = gh->height-1;
arw[1].x = gh->width-1; arw[1].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[2].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[2].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[3].x = (gh->width + gh->width/ARROWBODY_DIVIDER)/2; arw[3].y = 0;
arw[4].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[4].y = 0;
arw[5].x = (gh->width - gh->width/ARROWBODY_DIVIDER)/2; arw[5].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
arw[6].x = 0; arw[6].y = gh->height-1-gh->height/ARROWHEAD_DIVIDER;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
@ -342,16 +342,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x; arw[0].y = gh->y+gh->height/2;
arw[1].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[1].y = gh->y;
arw[2].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[2].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = gh->x+gh->width-1; arw[3].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = gh->x+gh->width-1; arw[4].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[5].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->x+gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->y+gh->height-1;
arw[0].x = 0; arw[0].y = gh->height/2;
arw[1].x = gh->width/ARROWHEAD_DIVIDER; arw[1].y = 0;
arw[2].x = gh->width/ARROWHEAD_DIVIDER; arw[2].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = gh->width-1; arw[3].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = gh->width-1; arw[4].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->width/ARROWHEAD_DIVIDER; arw[5].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->height-1;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
@ -360,16 +360,16 @@ void gwinButtonDraw_Square(GHandle gh, bool_t isdown, const char *txt, const GBu
(void) param;
point arw[7];
arw[0].x = gh->x+gh->width-1; arw[0].y = gh->y+gh->height/2;
arw[1].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[1].y = gh->y;
arw[2].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[2].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = gh->x; arw[3].y = gh->y+(gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = gh->x; arw[4].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[5].y = gh->y+(gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->x+gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->y+gh->height-1;
arw[0].x = gh->width-1; arw[0].y = gh->height/2;
arw[1].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[1].y = 0;
arw[2].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[2].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[3].x = 0; arw[3].y = (gh->height - gh->height/ARROWBODY_DIVIDER)/2;
arw[4].x = 0; arw[4].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[5].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[5].y = (gh->height + gh->height/ARROWBODY_DIVIDER)/2;
arw[6].x = gh->width-1-gh->width/ARROWHEAD_DIVIDER; arw[6].y = gh->height-1;
gdispFillConvexPoly(arw, 7, pstyle->color_fill);
gdispDrawPoly(arw, 7, pstyle->color_edge);
gdispFillConvexPoly(gh->x, gh->y, arw, 7, pstyle->color_fill);
gdispDrawPoly(gh->x, gh->y, arw, 7, pstyle->color_edge);
gdispDrawStringBox(gh->x+1, gh->y+1, gh->width-2, gh->height-2, txt, gh->font, pstyle->color_txt, justifyCenter);
}
#endif