各位大神好,帮忙看看如下问题,先谢谢了!
如题,画圆角矩形时采用cos和sin函数和半径r来计算出圆角坐标,然后画点,画其它直线,组成圆角矩形,并没有问题。
填充圆角矩形时采用:外层朝里层先画r个圆角矩形,然后矩形填充起来,但画r个圆角矩形的过程有点问题,有漏点,如下图:
代码如下:
int draw_roundrect(int x1,int y1,int x2,int y2,int r,unsigned int color)
{
draw_line_(x1+r,y1,x2-x1-r*2,color);
draw_line_(x1+r,y2,x2-x1-r*2,color);
draw_linel(x1,y1+r,y2-y1-r*2,color);
draw_linel(x2,y1+r,y2-y1-r*2,color);
draw_arc(x1+r,y1+r,r,90,180,color);
draw_arc(x2-r,y1+r,r,0,90,color);
draw_arc(x1+r,y2-r,r,180,270,color);
draw_arc(x2-r,y2-r,r,270,360,color);
return 0;
}
int fill_roundrect(int x1,int y1,int x2,int y2,int r,unsigned int color)
{
int i;
for(i=1;i<=r;i++){
draw_roundrect(x1+i,y1+i,x2-i,y2-i,r,color);
}
fill_rect(x1+r,y1+r,x2-r,y2-r,color);
return 0;
}
