用Ellipse函数画圆

DBRBZYY 2007-04-29 05:11:53

而不是用实际的数据来画
例如:
pDC->Ellipse(CRect(0, 20, 100, 120);

我想用一个数组CPoint来解决。
CPoint pt, pt1;
pt.x = RoundPoint[0].x;
pt.y = RoundPoint[0].y;

pt1.x = RoundPoint[1].x;
pt1.y = RoundPoint[1].y;
pDC->Ellipse(CRect(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y));

请那位大哥帮忙一下。
...全文
3517 12 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
dahong12345 2010-11-08
  • 打赏
  • 举报
回复
不懂,请教,请教
husion01 2008-12-20
  • 打赏
  • 举报
回复
看不大懂,请教
_葫芦娃 2008-12-20
  • 打赏
  • 举报
回复
调试一下,我是这么实现的,让举行的长和宽相等就可以了。
UltraBejing 2008-04-30
  • 打赏
  • 举报
回复
关注 接分
techfaith2 2008-04-07
  • 打赏
  • 举报
回复
椭圆可看作圆的特殊情况,仔细检查参数传递的是不是正确.
nnue12 2008-03-22
  • 打赏
  • 举报
回复
把pDC-> Ellipse(CRect(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y));
改为pDC-> Ellipse(CRect(pt.x, pt.y, pt1.x+pt.x, pt1.x+pt.y));
DBRBZYY 2007-04-30
  • 打赏
  • 举报
回复
void CRoundGraph::Draw(CDC *pDC)
{
CPen pen(m_nLineStyle, m_nLineWidth, m_Color);
CPen *pOldPen = pDC->SelectObject(&pen);

int size = m_PositionList.GetSize();

if(size != 2)
return;

POINT RoundPoint[2];
CPoint RoundPoint[2];
for(int i = 0; i< size; i++)
{
RoundPoint[i] = m_PositionList.GetAt(i);

}
if(!m_strName.IsEmpty())//点的名字不为空的时候
{
pDC->TextOut(10, 10, m_strName);//pos.x pos.y
}

CPoint pt, pt1;
pt.x = RoundPoint[0].x;
pt.y = RoundPoint[0].y;

pt1.x = RoundPoint[1].x;
pt1.y = RoundPoint[1].y;

pDC->Ellipse(CRect( RoundPoint[0], RoundPoint[1]));
if ((pt1.x-pt.x)==(pt1.y-pt1.y))
{
pDC->Ellipse(CRect(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y));
}


pDC->SelectObject(pOldPen);
return;


}
以上是我的完整程序啊,我试验了也不行啊。
请那位大哥帮我看看
yoyo_alex_lw 2007-04-29
  • 打赏
  • 举报
回复
Ellipse(x1,y1,x2,y2),你必须确保x2-x1==y2-y1,这样你画出的就是正圆,而不是椭圆了.
像pDC->Ellipse(CRect(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y));这里必须保证pt1.x==pt2.y才会是正圆
livedeal 2007-04-29
  • 打赏
  • 举报
回复
跟踪进去看看,哪个地方不对,可能是pt和pt1的值有问题`~~~~
lastwish 2007-04-29
  • 打赏
  • 举报
回复
Ellipse是用来画椭圆的,pDC->Ellipse(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y)画出来的自然是一个椭圆
DBRBZYY 2007-04-29
  • 打赏
  • 举报
回复
这种方法不行啊,我试验过了,我也知道只要矩形的长等于宽就可以了。
补充一下代码:

CPoint RoundPoint[2];
for(int i = 0; i< size; i++)
{
RoundPoint[i] = m_PositionList.GetAt(i);

}
if(!m_strName.IsEmpty())//点的名字不为空的时候
{
pDC->TextOut(10, 10, m_strName);//pos.x pos.y
}

CPoint pt, pt1;
pt.x = RoundPoint[0].x;
pt.y = RoundPoint[0].y;

pt1.x = RoundPoint[1].x;
pt1.y = RoundPoint[1].y;
pDC->Ellipse(CRect(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y));
livedeal 2007-04-29
  • 打赏
  • 举报
回复
pDC->Ellipse(pt.x, pt.y, pt1.x+pt.x, pt1.y+pt.y);

19,469

社区成员

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

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