Фрактал клен
С++ Builder 6
Компиляция и сборка под Windows 10
=
=
=
=
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
b = 0.5; r = 2; n = 8;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Matr ( double x0, double y0, double a,
double L, int n)
{
int k=350,// размер
x=325,// смещение по Х
y=190,// смещение по Y
s=500;// отоброзить зеркально поворот на 180
for (int i = 0; i <= 2*r; i += r)
{
xB = x0 + cos(a + i*b)*L;
yB = y0 + sin(a + i*b)*L;
Image1->Canvas->MoveTo( x0*k+x, s-(y0*k+y) ) ;
Image1->Canvas->LineTo( xB*k+x, s-(yB*k+y) );
if (n > 0) Matr (xB, yB, a+(i-1)*b, L/2, n-1);
}
}
//------------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
b = (double)UpDown2->Position/10;
Label3->Caption=FloatToStr( b);
r = UpDown3->Position;
Label4->Caption=r;
n = UpDown1->Position;
Label2->Caption=n;
Image1->Canvas->FillRect(Rect (0,0,Image1->Width, Image1->Height));
Image1->Canvas->Pen->Width = 1;
Image1->Canvas->Pen->Color = clGreen; //clBlack;
Image1->Canvas->MoveTo( 325 , 347 ) ;
Image1->Canvas->LineTo( 325 , 547 );
Matr(0.0, -0.1, 0.60, 0.5, n);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
Button1Click(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::UpDown2Click(TObject *Sender, TUDBtnType Button)
{
Button1Click(Sender);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::UpDown3Click(TObject *Sender, TUDBtnType Button)
{
Button1Click(Sender);
}
//---------------------------------------------------------------------------
=
//---------------------------------------------------------------------------
#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <math.h>
#include <Math.hpp>
#include <ComCtrls.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
TImage *Image1;
TButton *Button1;
TBevel *Bevel1;
TLabel *Label1;
TUpDown *UpDown1;
TLabel *Label2;
TUpDown *UpDown2;
TUpDown *UpDown3;
TLabel *Label3;
TLabel *Label4;
void __fastcall Button1Click(TObject *Sender);
void __fastcall UpDown1Click(TObject *Sender, TUDBtnType Button);
void __fastcall UpDown2Click(TObject *Sender, TUDBtnType Button);
void __fastcall UpDown3Click(TObject *Sender, TUDBtnType Button);
private: // User declarations
public: // User declarations
double xB, yB, b ; int r , n ;
void __fastcall Matr ( double x0, double y0, double a,double L, int n);
__fastcall TForm1(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif
=
=
=
|