在路径上添加一个圆角矩形

王朝other·作者佚名  2006-01-10
窄屏简体版  字體: |||超大  

//BOOL pathAddRoundRecangle( GraphicsPath *path , RectF rect , float roundSize )

//功能:在路径上添加一个圆角矩形

//程序员:黄江斌

//时间:8:40 2005-10-1

//最后修改时间:8:41 2005-10-1

BOOL yourClass::pathAddRoundRecangle(

GraphicsPath *path ,

RectF rect ,

float roundSize )

{

float left = rect.X;

float top = rect.Y;

float right = rect.Width + rect.X;

float bottom = rect.Height + rect.Y;

//如果取值不合法,指定roundSize为10或较短边的1/4

if( roundSize <= 0 )

roundSize = 10;

float shortOne = rect.Width < rect.Height ? rect.Width : rect.Height;

if( roundSize > shortOne / 4 )

roundSize = shortOne / 4;

//左上角

path->AddArc( left , top , 2 * roundSize , 2 * roundSize , 180 , 90 );

//上横线

path->AddLine( left + roundSize , top , right - roundSize , top );

//右上角

path->AddArc( right - 2 * roundSize , top , 2 * roundSize , 2 * roundSize , 270 , 90 );

//右竖线

path->AddLine( right , top + roundSize , right , bottom - roundSize );

//右下角

path->AddArc( right - 2 * roundSize , bottom - 2 * roundSize , 2 * roundSize , 2 * roundSize , 0 , 90 );

//下横线

path->AddLine( left + roundSize , bottom , right - roundSize , bottom );

//左下角

path->AddArc( left , bottom - 2 * roundSize , 2 * roundSize , 2 * roundSize , 90 , 90 );

//左竖线

path->AddLine( left , top + roundSize , left , bottom - roundSize );

return TRUE;

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航