Home > Programming > Fractals > Bifur |
const
escape=4.0;
{ escape value }
attract=0.0001;
{
attractor sensitivity }
const
Black = 0;
Blue = 1;
Green = 2;
Cyan = 3;
Red = 4;
Magenta = 5;
Brown = 6;
LightGray = 7;
DarkGray = 8;
LightBlue = 9;
LightGreen =10;
LightCyan =11;
LightRed =12;
LightMagenta =13;
Yellow =14;
White =15;
function GetRGBColor(color:byte):longint;
begin
case Color of
black : GetRGBColor := RGB(0,0,0);
blue : GetRGBColor := RGB(0,0,128);
green : GetRGBColor := RGB(0,128,0);
cyan : GetRGBColor := RGB(0,255,255);
red : GetRGBColor := RGB(128,0,0);
magenta : GetRGBColor := RGB(128,0,128);
brown : GetRGBColor := RGB(128,128,0);
lightgray : GetRGBColor := RGB(192,192,192);
darkgray : GetRGBColor := RGB(128,128,128);
lightBlue : GetRGBColor := RGB(0,0,255);
lightGreen : GetRGBColor := RGB(0,255,0);
lightcyan : GetRGBColor := RGB(0,255,255);
lightRed : GetRGBColor := RGB(255,0,0);
lightmagenta : GetRGBColor := RGB(255,0,255);
yellow: GetRGBColor := RGB(255,255,0);
white : GetRGBColor := RGB(255,255,255);
else
GetRGBColor := RGB(0,0,255);
end;
end;
////////////////////////////////////////////////////////////////////////////////
procedure Bifur(ABitmap: TBitmap);
var
i, j : integer;
{ loop variables}
MaxX : integer;
{ Maximum X screen coordinate}
MaxY : integer;
{ Maximum Y screen coordinate}
x : double;
{ iterated value }
c : double;
{ constant of iteration
}
MaxColor : byte;
{ maximum number
of colors on graphics card }
scale : double;
{ plotting scale factor }
sf : integer;
{ user input scale factor }
curColor : byte;
MaxY2 : integer;
Iterate : double;
Rect : TRect;
jTop : integer;
begin
SetRect(Rect, 0, 0,
ABitmap.Width, ABitmap.Height);
with Rect do
begin
MaxX := right - left;
MaxY := bottom - top; {
find maximum Y coordinate }
if (MaxX = 0) or (MaxY = 0) then exit;
MaxY2 := MaxY div 2;
jTop := MaxY2 + top;
Iterate := 2.25 / MaxX;
sf := 5;
MaxColor := 15; { Maximum number of colors }
scale := sf * MaxX / 8;
{ calculate overall scale factor }
c := -2.0;
{ set starting point }
for i := 1 to MaxX do
begin
x := 0.0;
{ calculate orbit about x=0 }
c := c + iterate;
{ iterate c }
for j := 1 to 50 do { skip
first 50 iterations }
x := x * x + c;
for j := 51 to 200
do {
calculate orbit after 200 iterations}
begin
x := x * x + c;
CurColor := GetRGBColor(j div
MaxColor);
ABitmap.Canvas.Pixels[i + Left,round(x *
scale)+jTop] := curColor;
end;
end
end;
end;
////////////////////////////////////////////////////////////////////////////////
� 2004 Jim Valavanis