箭头张角60度,臂宽为12
void lineArrow(int x1, int y1, int x2, int y2)
{
line(x1, y1, x2, y2);
double distance = sqrt((y1 - y2) * (y1 - y2) + (x1 - x2) * (x1 - x2));
double tmpx = double(x1 + (x2 - x1) * (1 - (12 * sqrt(3) / 2) / distance));
double tmpy = double(y1 + (y2 - y1) * (1 - (12 * sqrt(3) / 2) / distance));
if (y1 == y2)
{
line(x2, y2, int(tmpx), int(tmpy + 6));
line(x2, y2, int(tmpx), int(tmpy - 6));
}
else
{
double k = (double(x2) - double(x1)) / (double(y1) - double(y2));
double increX = 6 / sqrt(k * k + 1);
double increY = 6 * k / sqrt(k * k + 1);
line(x2, y2, int(tmpx + increX), int(tmpy + increY));
line(x2, y2, int(tmpx - increX), int(tmpy - increY));
}
}