TForm1 *Form1;
int A[2];
int B[2];
int C[2];
TColor color = clBtnFace;
TStringList *liste;
TOpenDialog *OpenDialog1;
int dreieck;
int zaehler = 0;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::PaintBox1Paint(TObject *Sender)
{
liste = new TStringList();
liste->LoadFromFile("dreieck.txt");
A[0]= StrToInt(liste->Strings[0]);
A[1]= StrToInt(liste->Strings[1]);
B[0]= StrToInt(liste->Strings[2]);
B[1]= StrToInt(liste->Strings[3]);
C[0]= StrToInt(liste->Strings[4]);
C[1]= StrToInt(liste->Strings[5]);
PaintBox1->Canvas->Brush->Color = clGreen;
PaintBox1->Canvas->MoveTo(A[0],A[1]);
PaintBox1->Canvas->LineTo(B[0],B[1]);
PaintBox1->Canvas->LineTo(C[0],C[1]);
PaintBox1->Canvas->LineTo(A[0],A[1]);
int Center[2];
Center[0] = (A[0]+B[0]+C[0])/3;
Center[1] = (A[1]+B[1]+C[1])/3;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
Label1->Caption="";
int Center[2];
Center[0] = (A[0]+B[0]+C[0])/3;
Center[1] = (A[1]+B[1]+C[1])/3;
if((zaehler % 3) == 0)
{
PaintBox1->Canvas->Pen->Width = 1;
PaintBox1->Canvas->Pen->Color = clBlack;
PaintBox1->Canvas->Brush->Color = clGreen;
PaintBox1->Canvas->FloodFill(Center[0], Center[1], clBlack, fsBorder);
Label1->Font->Color = clGreen;
Label1->Caption = "Grün";
}
else if((zaehler % 3) == 1)
{
PaintBox1->Canvas->Pen->Width = 1;
PaintBox1->Canvas->Pen->Color = clBlack;
PaintBox1->Canvas->Brush->Color = clBlue;
PaintBox1->Canvas->FloodFill(Center[0], Center[1], clBlack, fsBorder);
Label1->Font->Color = clBlue;
Label1->Caption = "Blau";
}
else //zahler % 3 == 2
{
PaintBox1->Canvas->Pen->Width = 1;
PaintBox1->Canvas->Pen->Color = clBlack;
PaintBox1->Canvas->Brush->Color = clRed;
PaintBox1->Canvas->FloodFill(Center[0], Center[1], clBlack, fsBorder);
Label1->Font->Color = clRed;
Label1->Caption = "Rot";
}
zaehler++;
}