刚开始学习windows编程,弄了个画图的程序,艰难的入门中 ……欢迎提点
界面
点击菜单选择不同的画笔 ,鼠标按下拉动到松开的距离为半径画出图形。
五边形的坐标赋值
case myPentagon:
r=(int)sqrt(pow((double)(PointEnd.x-m_PointBegin.x),2)+pow((double)(PointEnd.y-m_PointBegin.y),2));
apt[0].x=m_PointBegin.x;
apt[0].y=m_PointBegin.y-r;
apt[1].x=(LONG)(m_PointBegin.x-r*sin(72*PI/180));
apt[1].y=(LONG)(m_PointBegin.y-r*cos(72*PI/180));
apt[2].x=(LONG)(m_PointBegin.x-r*sin(36*PI/180));
apt[2].y=(LONG)(m_PointBegin.y+r*cos(36*PI/180));
apt[3].x=(LONG)(m_PointBegin.x+r*sin(36*PI/180));
apt[3].y=(LONG)(m_PointBegin.y+r*cos(36*PI/180));
apt[4].x=(LONG)(m_PointBegin.x+r*sin(72*PI/180));
apt[4].y=(LONG)(m_PointBegin.y-r*cos(72*PI/180));
dc.Polygon(apt,5);
break;
windows窗口下五边形坐标公式
0(x,y-r) 1(x-rsin72°, y-rcos72° ) 2 (x-rsin36°,y+rcos36°)
3(x+rsin36°,y+rcos36°) 4(x+rsin72°,y-rcos72°)
case myStar:
r=(int)sqrt(pow((double)(PointEnd.x-m_PointBegin.x),2)+pow((double)(PointEnd.y-m_PointBegin.y),2));
apt[0].x=m_PointBegin.x;
apt[0].y=m_PointBegin.y-r;
apt[3].x=(LONG)(m_PointBegin.x-r*sin(72*PI/180));
apt[3].y=(LONG)(m_PointBegin.y-r*cos(72*PI/180));
apt[1].x=(LONG)(m_PointBegin.x-r*sin(36*PI/180));
apt[1].y=(LONG)(m_PointBegin.y+r*cos(36*PI/180));
apt[4].x=(LONG)(m_PointBegin.x+r*sin(36*PI/180));
apt[4].y=(LONG)(m_PointBegin.y+r*cos(36*PI/180));
apt[2].x=(LONG)(m_PointBegin.x+r*sin(72*PI/180));
apt[2].y=(LONG)(m_PointBegin.y-r*cos(72*PI/180));
dc.SetPolyFillMode(WINDING);
dc.Polygon(apt,5);
break;
其他简单的直接调用函数就可以画出来 。