chrisjn52 Posted May 23, 2016 Report Share Posted May 23, 2016 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 More sharing options...
inmarket Posted May 23, 2016 Report Share Posted May 23, 2016 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 More sharing options...
chrisjn52 Posted May 23, 2016 Author Report Share Posted May 23, 2016 (edited) 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 May 23, 2016 by chrisjn52 Incomplete description Link to comment Share on other sites More sharing options...
chrisjn52 Posted May 23, 2016 Author Report Share Posted May 23, 2016 Since a picture is worth a thousand words............... Link to comment Share on other sites More sharing options...
inmarket Posted May 24, 2016 Report Share Posted May 24, 2016 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 More sharing options...
chrisjn52 Posted May 25, 2016 Author Report Share Posted May 25, 2016 You are correct, adding 1 to the x axis for the two right hand side coordinates of the up arrow improves the uniformity and the aesthetics when viewed in close proximity to a down arrow that serves as a visual reference. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now