VC++ 箭头的画法

来源:互联网 发布:印第安纳伯明顿 知乎 编辑:程序博客网 时间:2024/03/28 22:49

void CAsDlg::DrawArrowhead(CDC *pDC, int x0, int y0, int x, int y, int archor_width)
{
/*****************************************/
// 
//     参数:pDC 设备DC
// 
//     x0,y0,x,y  箭头的起点和终点
//    
//     archor_width = 箭頭寬度
//
/******************************************/
 int x2,y2,x3,y3;
 double a=atan((double)(x0-x)/(double)(y-y0));
 x2=30*sin(a+PI/6+2*PI)+x;
 y2=y-30*cos(a+PI/6+2*PI);
 x3=30*sin(a-PI/6+2*PI)+x;
 y3=y-30*cos(a-PI/6+2*PI);
 pDC->MoveTo(y0,x0);
 pDC->LineTo(y,x);
 pDC->MoveTo(y2,x2);
 pDC->LineTo(y,x);
 pDC->MoveTo(y3,x3);
 pDC->LineTo(y,x);
}

原创粉丝点击