
Среда программирования:
Lazarus 0.9.30 win32
Статья по теме:
Построение фрактала множества Жулиа
Код программы:
unit Unit1; {$mode objfpc}{$H+} interface uses Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls; type { TForm1 } TForm1 = class(TForm) Button1: TButton; PaintBox1: TPaintBox; procedure Button1Click(Sender: TObject); private { private declarations } public { public declarations } end; var Form1: TForm1; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject); type TComplex = record X : Real; Y : Real; end; const iter = 50; max = 16; var z, t, c : TComplex; x, y, n : Integer; Cancel : Boolean; gd, gm : Smallint; mx, my : Integer; col: TColor; begin Randomize; PaintBox1.Canvas.Clear; Mx := PaintBox1.Canvas.Width div 2; My := PaintBox1.Canvas.Height div 2; for y := -my to my do for x := -mx to mx do begin n := 0; z.x := x * 0.005; z.y := y * 0.005; c.x := 0.11; c.y := -0.66; while (sqr(z.x) + sqr(z.y) < max) and (n < iter) do begin t := z; {z^2 + c} z.x := sqr(t.x) - sqr(t.y) + c.x; z.y := 2*t.x*t.y + c.y; Inc(n); end; if n < iter then begin col := n*6 mod 255; PaintBox1.Canvas.Pixels[mx+x,my+y]:=RGBToColor(col,0,0); end; end; end; end.
Прикрепленный файл | Размер |
---|---|
Исходные коды и исполняемый файл | 763.27 кб |