标签:
构造一个函数,是在startPoint,endPoint间画一条带箭头的线段: void CTry1View::DrawLine(POINT startPoint, POINT endPoint) { CClientDC dc(this); dc.MoveTo(startPoint); dc.LineTo(endPoint); double PI = 3.1415926; double t=PI/4; //箭头与直线夹角 double l=0.2; //箭头边长度占直线长度的百分比 POINT arrowPoint; arrowPoint.x = (int)(l*((startPoint.x-endPoint.x)*cos(t)-(startPoint.y-endPoint.y)*sin(t))+endPoint.x); arrowPoint.y = (int)(l*((startPoint.x-endPoint.x)*sin(t)+(startPoint.y-endPoint.y)*cos(t))+endPoint.y); dc.MoveTo(endPoint); dc.LineTo(arrowPoint); arrowPoint.x = (int)(l*((startPoint.x-endPoint.x)*cos(-t)-(startPoint.y-endPoint.y)*sin(-t))+endPoint.x); arrowPoint.y = (int)(l*((startPoint.x-endPoint.x)*sin(-t)+(startPoint.y-endPoint.y)*cos(-t))+endPoint.y); dc.MoveTo(endPoint); dc.LineTo(arrowPoint); }
标签:
原文地址:http://www.cnblogs.com/Decmber/p/4951871.html