Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include <math.h>
- #include "Unit1.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- void Serp(double x0, double y0,double x1, double y1,double n)
- {
- if(n>0)
- {
- Form1->Image1->Canvas->Brush->Color = clPurple;
- Form1->Image1->Canvas->FillRect(Rect(x0 + (x1-x0)/3, y0 + (y1-y0)/3, x0 + 2*(x1-x0)/3, y0+2*(y1-y0)/3 ));
- Form1->Image1->Canvas->Brush->Color = clWhite;
- Serp(x0 , y0 , x0 + (x1-x0)/3, y0+ (y1-y0)/3, n-1 );
- Serp(x0 + (x1-x0)/3, y0 , x0 + 2*(x1-x0)/3, y0+ (y1-y0)/3, n-1 );
- Serp(x0 + 2*(x1-x0)/3, y0 , x0 + 3*(x1-x0)/3, y0+ (y1-y0)/3, n-1 );
- Serp(x0 , y0 + (y1-y0)/3 , x0 + (x1-x0)/3 , y0+2*(y1-y0)/3, n-1 );
- Serp(x0 +2*(x1-x0)/3 , y0 + (y1-y0)/3 , x0 + 3*(x1-x0)/3, y0+2*(y1-y0)/3, n-1 );
- Serp(x0 , y0+2*(y1-y0)/3 , x0 + (x1-x0)/3, y0+ 3*(y1-y0)/3, n-1 );
- Serp(x0 + (x1-x0)/3, y0+2*(y1-y0)/3 , x0 + 2*(x1-x0)/3, y0+ 3*(y1-y0)/3, n-1 );
- Serp(x0 + 2*(x1-x0)/3, y0+2*(y1-y0)/3 , x0 + 3*(x1-x0)/3, y0+ 3*(y1-y0)/3, n-1 );
- }
- }
- void __fastcall TForm1::Button1Click(TObject *Sender)
- {
- double n=0;
- n=StrToFloat(Edit1->Text);
- double x0=0,y0=0,
- x1=550,y1=550;
- Form1->Image1->Canvas->Rectangle(x0,y0,x1,y1);
- Serp(x0,y0,x1,y1,n);
- }
- //---------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement