⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 contor.~pas

📁 简单的分形算法,主要是是演示康托三分集的形成
💻 ~PAS
字号:
unit contor;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
procedure cantor(ax :real;ay : real; bx :real; by :real);
var
  c: Integer; //c 为判断小量,当(bx - ax) < c 时,堆栈释放
  d : Integer; //d为两层线段之间的距离
  cx,cy,dx,dy :real;
  begin
    c := 1;
    d := 20;
    If (bx - ax) < c Then
      begin
        Form1.Canvas.MoveTo(Round(ax),Round(ay));
        Form1.Canvas.LineTo(Round(bx),Round(by));
      end
      Else
      begin
        Form1.Canvas.MoveTo(Round(ax),Round(ay));
        Form1.Canvas.LineTo(Round(bx),Round(by));
        cx := ax + (bx - ax) / 3;
        cy := ay + d;
        dx := bx - (bx - ax) / 3;
        dy := by + d;
        ay := ay + d;
        by := by + d;
        cantor(ax, ay, cx, cy);
        cantor(dx, dy, bx, by);
      end;
    End;

procedure TForm1.Button1Click(Sender: TObject);
begin
  cantor(100, 40, 500, 40);
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -