__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
srand(time(NULL));
}
void __fastcall TForm1::Sort(int *tab, int size)
{
int i,j,k;
for(i=1;i<size;i++)
{
j=i;
k=tab[j];
while((j>0) && (tab[j-1]>k))
{
tab[j]=tab[j-1];
j--;
}
tab[j]=k;
}
}
TColor __fastcall TForm1::draw_Color(int value)
{
TColor color;
switch(value)
{
case 0: color=clWhite;break;
case 1: color=clYellow;break;
case 2: color=clBlue;break;
case 3: color=clRed;break;
case 4: color=clSilver;
default: color=clBlack; break;
}
return color;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
TCanvas *tab_Canvas[5];
tab_Canvas[0]=PaintBox1->Canvas;
tab_Canvas[1]=PaintBox2->Canvas;
tab_Canvas[2]=PaintBox3->Canvas;
tab_Canvas[3]=PaintBox4->Canvas;
tab_Canvas[4]=PaintBox5->Canvas;
int i,j,k,l;
int anime=500;
int width=PaintBox1->Width;
int height=PaintBox1->Height;
int r_width=width/2;
int r_height=height/2;
int *r_Eclipse=new int[20];
for(i=0;i<20;i++)
{
r_Eclipse[i]=rand()%(r_height-10)+10;
}
Sort(r_Eclipse,20);
for(i=0;i<anime;i++)
{
j=rand()%5;
tab_Canvas[0]->Brush->Style=bsSolid;
tab_Canvas[0]->Brush->Color=draw_Color(j);
tab_Canvas[0]->Rectangle(0,0,width,height);
tab_Canvas[0]->Brush->Style=bsClear;
for(k=0;k<20;k++)
{
r_Eclipse[k]+=2;
tab_Canvas[0]->Ellipse(r_width-r_Eclipse[k],r_height-r_Eclipse[k],r_width+r_Eclipse[k],r_height+r_Eclipse[k]);
}
for(l=1;l<5;l++)
{
tab_Canvas[l]->CopyRect(Rect(0,0,width,height),tab_Canvas[0],Rect(0,0,width,height));
}
}
delete r_Eclipse;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}