I have problems using the smoot coloring algorithm. I just don’t get them implemented in my Code.
This is the main code which causes an error after some calculated pixel rows:
g:=StrToInt(Edit3.Text); //maximum iteration count
for x:=0 to Width do
begin
for y:=0 to Height do
begin
zr:=x*(br-ar)/Width+ar;
zi:=y*(bi-ai)/Height+ai;
n:=1;
zr0:=zr;
zi0:=zi;
while (n<g) and (zr*zr+zi*zi<4) do
begin
zrh:=zr;
zr:=zr*zr-zi*zi+zr0;
zi:=zrh*zi+zi*zrh+zi0;
Inc(n) //iterations
end;
n:=Round(n+1-(log2(log2(sqrt(zr*zr+zi*zi))/log2(4)))); //<-- this should smoothen the iterations
Draw_Pixels(n,g,x,y,Image1.Canvas)
end
end;
end;
Henry
If you ever end up with
zr == zi == 0, you’ll be trying to takelog2(0), which is not defined (-infas a limit).If
zr*zr+zi*ziis ever equal to or less than one, the innerlog2will return 0 or a negative value, which will break the outerlog2(can’t take the log of a negative number as long as you’re dealing with reals).(And I don’t think that will scale smoothly for values of
zr*zr+zi*zislightly over 1.)