fractus2_09.cpp
资源名称:fenxin.rar [点击查看]
上传用户:hzcygd
上传日期:2022-04-30
资源大小:109k
文件大小:2k
源码类别:
分形几何
开发平台:
Visual C++
- //---------------------------------------------------------------------------
- #include <vcl.h>
- #pragma hdrstop
- #include "fractus2_09.h"
- //---------------------------------------------------------------------------
- #pragma package(smart_init)
- #pragma resource "*.dfm"
- TForm1 *Form1;
- #include "glib.h"
- int n_br=6;
- int n_st;
- double k,r0=180.0;
- int N;
- double delta=0.0001;TRect rect;
- int select;
- //---------------------------------------------------------------------------
- __fastcall TForm1::TForm1(TComponent* Owner)
- : TForm(Owner)
- {
- }
- //---------------------------------------------------------------------------
- //基本图案的反复映像生成的分形图形(1)
- void __fastcall fractal(double leng,int n)
- {
- int i,j;
- if(n>=N||k<=1.0)
- Form1->Image1->Canvas->Pixels[LPX][LPY]=clWhite;
- else
- {for(i=0;i<n_br;i++)
- {if(!i) fractal(leng/k,n+1);
- for(j=1;j<=n_st;j++)
- {warp(leng*2/k);
- fractal(leng/k,n+1);
- }
- turn(180.0);
- warp(leng*2*n_st/k);
- turn(180.0);
- turn(360.0/n_br);
- }
- }
- }
- void __fastcall TForm1::FormCreate(TObject *Sender)
- {
- Image1->Height=0;Image1->Top=0;
- Image1->Width=Screen->Width;Image1->Height=Screen->Height;
- rect=Rect(0,0,Image1->Width,Image1->Height);//清屏
- Image1->Canvas->CopyMode=cmBlackness;
- Image1->Canvas->CopyRect(rect,Image1->Canvas,rect);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N1Click(TObject *Sender)
- {
- Image1->Canvas->CopyRect(rect,Image1->Canvas,rect);
- k=2*n_st+1;
- setlp(320.0,200.0);
- setangle(90.0);
- fractal(r0,0);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N2Click(TObject *Sender)
- {
- if(SavePictureDialog1->Execute())
- Image1->Picture->SaveToFile(SavePictureDialog1->FileName);
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N3Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N4_1Click(TObject *Sender)
- {
- n_st=1;N=5;
- }
- //---------------------------------------------------------------------------
- void __fastcall TForm1::N4_2Click(TObject *Sender)
- {
- n_st=2;N=4;
- }
- //---------------------------------------------------------------------------