|
|
Rounded rectangles have become a critical part of modern GUI design. However, FLTK provides minimal support for drawing rounded rectangles. The current Box api provides no means of setting a custom radius for RoundedFrames, which leaves it up to the programmer to design a custom solution. So, I think we could save people time by providing a method for drawing rounded rectangles.
Such a method already exists in fl_rounded_box:
static void rbox(int fill, int x, int y, int w, int h) {
int i;
int rs, rsy;
rs = w*2/5; rsy = h*2/5;
if (rs > rsy) rs = rsy; // use smaller radius
if (rs > RS) rs = RS;
if (rs == 5) rs = 4; // use only even sizes for small corners (STR #2943)
if (rs == 7) rs = 8; // note: 8 is better than 6 (really)
if (fill) fl_begin_polygon(); else fl_begin_loop();
for (i=0; i<RN; i++)
fl_vertex_r(x + offset[RN-i-1]*rs, y + offset[i] * rs);
for (i=0; i<RN; i++)
fl_vertex_r(x + offset[i]*rs, y + h-1 - offset[RN-i-1] * rs);
for (i=0; i<RN; i++)
fl_vertex_r(x + w-1 - offset[RN-i-1]*rs, y + h-1 - offset[i] * rs);
for (i=0; i<RN; i++)
fl_vertex_r(x + w-1 - offset[i]*rs, y + offset[RN-i-1] * rs);
if (fill) fl_end_polygon(); else fl_end_loop();
}
While it's nice to be able to set the global radius size, we might also want to have rounded frames with different radiuses.
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
[ Direct Link to Message ] | |
|
| |