1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
| struct etat1 { TPoint p;
int numero; }; //structure d'un sommet
void DrawArrow(TPoint A, TPoint B,TImage *Image)
{
int a = B.x - A.x;
int b = B.y - A.y;
int D = sqrt(a*a+b*b);
int c = a*A.y - b*A.x;
int c1 = -(a*A.x+b*A.y);
etat1 P, P2, Q, Q2, E, F;
if (a==0) // DX
{
P.p.x = P2.p.x = A.x;
P.p.y = A.y + 0.5*D; P2.p.y = A.y - 0.5*D;
if(b<0){P=P2;};
Q.p.x = Q2.p.x = A.x;
Q.p.y = A.y + (0.5*D + 10); Q2.p.y = A.y - (0.5*D + 10);
if(b<0){Q=Q2;};
E.p.x = P.p.x -5; F.p.x = P.p.x+5;
E.p.y = F.p.y = P.p.y;
}
else
{
if (b==0)
{
P.p.y = P2.p.y = A.y;
P.p.x = A.x + 0.5*D; P2.p.x = A.x - 0.5*D;
if(a<0){P=P2;};
Q.p.y = Q2.p.y = A.y;
Q.p.x = A.x + (0.5*D + 10); Q2.p.x = A.x - (0.5*D + 10);
if(a<0){Q=Q2;};
E.p.y = P.p.y -5; F.p.y = P.p.y+5;
E.p.x = F.p.x = P.p.x;
}
else
{
Get_Two_Points(b, -a, c, c1, 0.5*D*D, &P, &P2);
Get_Two_Points(b, -a, c, c1, D*(0.5*D + 10), &Q, &Q2);
if(!((a>0)^(P2.p.x>A.x))){P=P2;};
if(!((a>0)^(Q2.p.x>A.x))){Q=Q2;};
int c2 = -(a*P.p.x+b*P.p.y);
Get_Two_Points(a, b, c2, -c,5*D, &E, &F);
}
}
TPoint *MyArrow = new TPoint[3];
MyArrow[0] = E.p;
MyArrow[1] = F.p;
MyArrow[2] = Q.p;
**** TColor MyCol = Image->Canvas->Brush->Color;
//ca beug a ce niveau
int MyWidth = Image->Canvas->Pen->Width;
Image->Canvas->Pen->Width = 1;
Image->Canvas->Brush->Color = Image->Canvas->Pen->Color;
Image->Canvas->Polygon(MyArrow, 2);
Image->Canvas->Brush->Color = MyCol;
Image->Canvas->Pen->Width = MyWidth;
delete[] MyArrow;
} |
Partager