pDC->Polygon绘制箭头
时间: 2023-07-21 08:58:55 浏览: 138
JSAPI Dojo -> Arcgis Server(SDE) -> InsertPolygon
以下是绘制箭头的示例代码:
```c++
// 绘制箭头
void DrawArrow(CDC* pDC, CPoint fromPt, CPoint toPt, int size)
{
// 计算箭头末端点坐标
double angle = atan2(fromPt.y - toPt.y, fromPt.x - toPt.x);
CPoint arrow1, arrow2;
arrow1.x = toPt.x + size * cos(angle + M_PI / 6);
arrow1.y = toPt.y + size * sin(angle + M_PI / 6);
arrow2.x = toPt.x + size * cos(angle - M_PI / 6);
arrow2.y = toPt.y + size * sin(angle - M_PI / 6);
// 绘制线段和箭头
pDC->MoveTo(fromPt);
pDC->LineTo(toPt);
pDC->MoveTo(arrow1);
pDC->LineTo(toPt);
pDC->LineTo(arrow2);
}
```
其中,参数`fromPt`和`toPt`分别表示箭头的起点和终点,`size`表示箭头的大小。箭头是由一条直线和两条斜线组成的,通过计算箭头末端点的坐标,然后绘制线段和箭头即可。
阅读全文