private: // User declarations
int centr_x,centr_y,width,height;
void __fastcall line_C(TImage *t);
void __fastcall ellipse_C(TImage *t);
void __fastcall rectangle_C(TImage *t,int x,int y, int width, int height);
void __fastcall using_R(TImage *t);
void __fastcall line_D(TImage *t);
TColor __fastcall draw_Color(int value);
void __fastcall chaos_R();
void __fastcall chaos_E();
void __fastcall left_R();
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
width=Image1->Width;
height=width;
centr_x=width/2;
centr_y=centr_x;
srand(time(NULL));
}
//---------------------------------------------------------------------------
void __fastcall TForm1::line_C(TImage *t)
{
t->Canvas->MoveTo(0,0);
t->Canvas->LineTo(width,height);
t->Canvas->MoveTo(0,height);
t->Canvas->LineTo(width,0);
}
void __fastcall TForm1::ellipse_C(TImage *t)
{
int r=10;
int i;
for(i=r;i<width;i+=r)
{
t->Canvas->Ellipse(centr_x,centr_y,i,i);
}
}
void __fastcall TForm1::rectangle_C(TImage *t,int x,int y, int width, int height)
{
t->Canvas->MoveTo(x,y);
t->Canvas->LineTo(x+width,y);
t->Canvas->LineTo(x+width,y+height);
t->Canvas->LineTo(x,y+height);
t->Canvas->LineTo(x,y);
}
void __fastcall TForm1::using_R(TImage *t)
{
int i;
int r=10;
int x,y;
x=width-200;
y=200;
for(i=0;i<width;i+=r)
rectangle_C(t,i,height-i,r*3,r*3);
}
void __fastcall TForm1::line_D(TImage *t)
{
int i,j;
int r=5;
t->Canvas->Pen->Color=clGreen;
for(i=centr_x;i<width;i+=r)
{
t->Canvas->MoveTo(centr_x,centr_y);
t->Canvas->LineTo(i,height);
}
t->Canvas->Pen->Color=clRed;
for(j=centr_y;j<height;j+=r)
{
t->Canvas->MoveTo(centr_x,centr_y);
t->Canvas->LineTo(width,j);
}
}
TColor __fastcall TForm1::draw_Color(int value)
{
TColor color;
switch(value)
{
case 0: color=clBlack;break;
case 1: color=clRed; break;
case 2: color=clBlue;break;
case 4: color=clGreen;break;
case 5: color=clYellow;break;
case 6: color=clFuchsia;break;
case 7: color=clLime;break;
case 8: color=clPurple;break;
case 9: color=clGray;break;
default: color=clWhite;
}
return color;
}
void __fastcall TForm1::chaos_R()
{
int min,max,i,value,random;
int left,top;
min=3,max=25;
TColor temp_Color;
for(i=0;i<30;i++)
{
random=rand()%10;
value=min+rand()%(max-min);
temp_Color=draw_Color(random);
Image1->Canvas->Pen->Color=temp_Color;
Image2->Canvas->Pen->Color=temp_Color;
Image3->Canvas->Pen->Color=temp_Color;
Image4->Canvas->Pen->Color=temp_Color;
left=rand()%centr_x;
top=centr_y+rand()%centr_y;
rectangle_C(Image1,left,top,value,value);
rectangle_C(Image2,left,top,value,value);
rectangle_C(Image3,left,top,value,value);
rectangle_C(Image4,left,top,value,value);
}
}
void __fastcall TForm1::chaos_E()
{
int min,max,i,value_x,value_y,random;
int left,top;
min=3,max=25;
TColor temp_Color;
for(i=0;i<15;i++)
{
random=rand()%10;
value_x=min+rand()%(max-min);
value_y=min+rand()%(max-min);
temp_Color=draw_Color(random);
Image1->Canvas->Pen->Color=temp_Color;
Image2->Canvas->Pen->Color=temp_Color;
Image3->Canvas->Pen->Color=temp_Color;
Image4->Canvas->Pen->Color=temp_Color;
left=centr_x+rand()%centr_x;
top=rand()%centr_y;
Image1->Canvas->Ellipse(left,top,left-value_x,top-value_y);
Image2->Canvas->Ellipse(left,top,left-value_x,top-value_y);
Image3->Canvas->Ellipse(left,top,left-value_x,top-value_y);
Image4->Canvas->Ellipse(left,top,left-value_x,top-value_y);
}
}
void __fastcall TForm1::left_R()
{
int width=35;
TColor temp_Color;
int random;
random=rand()%10;
temp_Color=draw_Color(random);
Image1->Canvas->Pen->Color=temp_Color;
Image2->Canvas->Pen->Color=temp_Color;
Image3->Canvas->Pen->Color=temp_Color;
Image4->Canvas->Pen->Color=temp_Color;
rectangle_C(Image1,5,5,width,width);
rectangle_C(Image2,5,5,width,width);
rectangle_C(Image3,5,5,width,width);
rectangle_C(Image4,5,5,width,width);
random=rand()%10;
temp_Color=draw_Color(random);
Image1->Canvas->Pen->Color=temp_Color;
Image2->Canvas->Pen->Color=temp_Color;
Image3->Canvas->Pen->Color=temp_Color;
Image4->Canvas->Pen->Color=temp_Color;
Image1->Canvas->MoveTo(5,5);
Image1->Canvas->LineTo(width,width);
Image1->Canvas->MoveTo(5,width);
Image1->Canvas->LineTo(width,5);
Image2->Canvas->MoveTo(5,5);
Image2->Canvas->LineTo(width,width);
Image2->Canvas->MoveTo(5,width);
Image2->Canvas->LineTo(width,5);
Image3->Canvas->MoveTo(5,5);
Image3->Canvas->LineTo(width,width);
Image3->Canvas->MoveTo(5,width);
Image3->Canvas->LineTo(width,5);
Image4->Canvas->MoveTo(5,5);
Image4->Canvas->LineTo(width,width);
Image4->Canvas->MoveTo(5,width);
Image4->Canvas->LineTo(width,5);
}
void __fastcall TForm1::Button1Click(TObject *Sender)
{
line_C(Image1);
line_C(Image2);
line_C(Image3);
line_C(Image4);
ellipse_C(Image1);
ellipse_C(Image2);
ellipse_C(Image3);
ellipse_C(Image4);
using_R(Image1);
using_R(Image2);
using_R(Image3);
using_R(Image4);
line_D(Image1);
line_D(Image2);
line_D(Image3);
line_D(Image4);
chaos_R();
chaos_E();
left_R();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
Close();
}