This repository has been archived on 2024-12-25. You can view files and clone it, but cannot push or open issues or pull requests.
OldPascalProjects/Graphics/GraphWPF/MandelbrotWPF.pas
2024-03-10 20:32:51 +03:00

45 lines
1.4 KiB
ObjectPascal
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// Демонстрация фрактальной графики. Множество Мандельброта
// Для каждой точки комплексной плоскости z=(x,y) выполняем итерационный процесс z=z*2+c, c=(cx,cy)
// Считаем количество итераций i до тех пор пока не выполнится условие |z|>max
// После этого рисуем точку z=(x,y) с насыщенностью красного цвета, пропорциональной i
uses GraphWPF;
const
max = 10;
coef1 = 0.5;
coef2 = 0.88;
scalex = 0.0035;
scaley = 0.0035;
dx = 430;
dy = 300;
begin
Window.Title := 'Фракталы: множество Мандельброта';
Window.SetSize(600,600);
Window.CenterOnScreen;
var m := Window.Width.Round;
var n := Window.Height.Round;
var a := new Color[m,n];
for var ix:=0 to m-1 do
for var iy:=0 to n-1 do
begin
var cx := scalex * (ix - dx);
var cy := scaley * (iy - dy);
var c := Cplx(cx,cy);
var z := Cplx(0,0);
var i := 1;
while i<255 do
begin
z := z*z+c;
if z.Magnitude>max then break;
i += 1;
end;
if i>=255 then a[ix,iy] := Colors.Red
else a[ix,iy] := RGB(255,255-i,255-i);
end;
DrawPixels(0,0,a);
Writeln('Время расчета = ',Milliseconds/1000,' с');
end.