MFC画任意多边形?

blbluesky 2010-04-02 07:09:51
从一个对话框得到边数
...全文
599 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
GKatHere 2010-04-03
  • 打赏
  • 举报
回复
呀呀呀(一声)!!
360度平分边数,得夹角
根据夹角,多边形边长得多边形圆的半径
根据夹角,半径得各个点,
连接各个点
balancenada 2010-04-03
  • 打赏
  • 举报
回复
学习一下
Tchely.Pan 2010-04-03
  • 打赏
  • 举报
回复
直接用直线画就好了
zxdyu2009 2010-04-02
  • 打赏
  • 举报
回复
void CMyView::OnDraw(CDC* pDC)
{
// find the client area
CRect rect;
GetClientRect(rect);

// draw with a thick blue pen
CPen penBlue(PS_SOLID, 5, RGB(0, 0, 255));
CPen* pOldPen = pDC->SelectObject(&penBlue);

// and a solid red brush
CBrush brushRed(RGB(255, 0, 0));
CBrush* pOldBrush = pDC->SelectObject(&brushRed);

// Find the midpoints of the top, right, left, and bottom
// of the client area. They will be the vertices of our polygon.
CPoint pts[4];
pts[0].x = rect.left + rect.Width()/2;
pts[0].y = rect.top;

pts[1].x = rect.right;
pts[1].y = rect.top + rect.Height()/2;

pts[2].x = pts[0].x;
pts[2].y = rect.bottom;

pts[3].x = rect.left;
pts[3].y = pts[1].y;

// Calling Polygon() on that array will draw three lines
// between the points, as well as an additional line to
// close the shape--from the last point to the first point
// we specified.
pDC->Polygon(pts, 4);

// Put back the old objects.
pDC->SelectObject(pOldPen);
pDC->SelectObject(pOldBrush);
}
cdsnpeter 2010-04-02
  • 打赏
  • 举报
回复
输入边个数。然后计算顶点坐标。
使用Polygon画多边形。

19,468

社区成员

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

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