如何画一个圆形的分割线啊,就像时钟一样,再圆周围有刻度的。

jenes 2006-05-19 11:00:46
画圆盘和1-12刻度的函数如下所示,谢谢各位了啊
// Create a yellow pen with which we'll
// draw the ellipse.
CPen Pen( PS_SOLID, 5, RGB( 255, 255, 0 ) );

// Select the new pen into the DC and
// remember the pen that was selected out.
CPen *pOldPen = pDC->SelectObject( &Pen );

// Draw the clock face border with
// the Ellipse function.
pDC->Ellipse( 5, 5, Rect.right - 5,
Rect.bottom - 5 );

double Radians;

// Out text color will be red.
pDC->SetTextColor( RGB( 255, 0, 0 ) );

for( i=1; i<=12; i++ ){

// Format the digit CString object
// for the current clock number.
strDigits.Format( "%d", i );

// Get the text extent of the
// text so that we can center
// it about a point.
size =
pDC->GetTextExtent( strDigits,
strDigits.GetLength() );

// Calculate the number of radians
// for the current clock number.
Radians = (double) i * 6.28 / 12.0;

// Calculate the x coordinate. We
// use the text extent to center
// the text about a point.
x = nCenterX -
( size.cx / 2 ) +
(int) ( (double) ( nCenterX - 20 ) *
sin( Radians ) );

// Calculate the y coordinate. We
// use the text extent to center
// the text about a point.
y = nCenterY -
( size.cy / 2 ) -
(int) ( (double) ( nCenterY - 20 ) *
cos( Radians ) );

// Draw the text.
pDC->TextOut( x, y, strDigits );

}
...全文
444 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
jenes 2006-05-19
  • 打赏
  • 举报
回复
我就是想把每分钟的刻度在圆盘面上画出来,谢谢了

15,975

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧