Jump to content

gdispGFillConvexPoly Behaviour


chrisjn52

Recommended Posts

Whilst developing a Spinbox widget I discovered that the arrow triangle polygons drawn when using gdispGFillConvexPoly were not the same for the following code snippet. 

static const point upArrow[] = { {0, SPIN_ARROW_SZ}, {SPIN_ARROW_SZ, SPIN_ARROW_SZ}, {SPIN_ARROW_SZ/2, 0} };
static const point downArrow[] = { {0, -SPIN_ARROW_SZ}, {SPIN_ARROW_SZ, -SPIN_ARROW_SZ}, {SPIN_ARROW_SZ/2, 0} };

gdispGFillConvexPoly(gw->g.display, gw->g.x+iwidth+((SPIN_SCROLLWIDTH-SPIN_ARROW_SZ)/2+2), gw->g.y+2, upArrow, 3, ps->edge);

The upArrow has the last row of pixels missing and is due to lxc being equal to rxc in gdisp.c which results in one less iteration of the loop in gdisp.c in the following section of code at line 2844.

		/* Scan down the line segments until we hit a boundary */
			for(; y < ymax; y++) {
				lxc = NONFIXED(lx);
				rxc = NONFIXED(rx);
				/*
				 * Doesn't print the right hand point in order to allow polygon joining.
				 * Also ensures that we draw from left to right with the minimum number
				 * of pixels.
				 */
				if (lxc < rxc) {
					g->p.x=tx+lxc; g->p.y=ty+y; g->p.x1=tx+rxc-1; hline_clip(g);
				} else if (lxc > rxc) {
					g->p.x=tx+rxc; g->p.y=ty+y; g->p.x1=tx+lxc-1; hline_clip(g);
				}

This behaviour can be fixed by increasing ymax by one if lxc == rxc but I am not sure if there are other ramifications.

 

Link to comment
Share on other sites

Yes it is true that the polygon fill is asymmetric by 1 pixel on the right and it is intentional behaviour. It is mentioned in the polygon filling code in the comment about polygon joining.

I guess however that we should adjust the arrow definitions to compensate.

Can you please test the numbers for the right arrow edges to correct the problem and we will add it to the repository. 

Link to comment
Share on other sites

I'm sorry but I am not sure what you are asking for in your last sentence? Are you asking me to test a left and right arrow?

The Uparrow triangle polygon is missing the bottom complete row of pixels rather than just one pixel to the right?

Edited by chrisjn52
Incomplete description
Link to comment
Share on other sites

Adjust the pixel values passed in the polygon points array to fix the appearance. If you can then post the changes we will make equivalent changes in the other standard controls.

I suspect adding 1 to each x value on the right hand side of the polygon will fix the appearance problem. I asked if you could please do it and let us know as currently i am working on uGFX V3 api and dont have time to test it.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...