绘制带刻度的直线【MFC】
目前只是个功能雏形,而且数据测试也不到位。
发现任何问题欢迎评论区说明或指正(▽)。
void drawScale(CDC* pDC, CPoint start, CPoint end) {
double PI = acos(-1);
pDC->SelectObject(new CPen(PS_SOLID, 1, RGB(0, 0, 0)));
pDC->MoveTo(start);
pDC->LineTo(end);
int x = start.x, y = start.y;
double angle;
if (start.x == end.x)angle = PI / 2;
else angle = atan(1.0*(end.y - start.y) / (end.x - start.x));
while (x <= end.x&&y<=end.y) {
pDC->MoveTo(*(new CPoint(x - 5 * cos(PI / 2 - angle), y + 5 * sin(PI / 2 - angle))));
pDC->LineTo(*(new CPoint(x, y)));
x = x + 10 * cos(angle);
y = y + 10 * sin(angle);
}
}