v = 1/log(2) (2 is the degree of the rational function)
ax = -0.7028233689263 (x-coordinate of lower left corner)
ay = 0.1142331238418 (y-coordinate of lower left corner)
h = 0.0092906805859 (width of the section)
g = h/800
m = 850 (maximum iteration number)
thick = h * 0.0005 (thickness of the boundary)
dens = 24.9 (density of the colours)
disp = 432.0 (displacement of the colour scale)
for i = 0 to 799 do
begin
cx = ax + i * g (x-coordinate of pixel (i, j))
for j = 0 to 599 do
begin
cy = ay + j * g (y-coordinate of pixel (i, j))
x = cri
y = 0
xd = 0
yd = 0
f = 0
n = 0
while (n < m) and (f < r) do
begin
n = n + 1
x1 = x * x - y * y
y1 = 2 * x * y
f = x * x + y * y
x2 = 2 * x - p * x1 / (f * f)
y2 = 2 * y + p * y1 / (f * f)
temp = xd
xd = x2 * xd - y2 * yd + 1
yd = x2 * yd + y2 * temp
fd = xd * xd + yd * yd
x = x1 + p * x / f + cx
y = y1 - p * y / f + cy
f = x * x + y * y
end
if (n = m) or (log(f) * sqrt(f) < thick * sqrt(fd)) then
setpixel(i, 599 - j, 0)
else
begin
s = n - v * (log(log(f)) - u)
n = round(dens * s + disp) mod 720
col = paletteRGB(col1[n], col2[n], col3[n])
setpixel(i, 599 - j, col)
end
end
end作者: xuefeiyang 时间: 2011-10-6 13:53
说明:
We have set c = cx + icy, z = x + iy, z' = xd + iyd and x1 + iy1 = (x + iy)2, and we have used that 1/z = z-/|z|2.
The successive calculation of the derivative z' is xd + iyd = (x2 + iy2)*(xd + iyd) + 1, where x2 + iy2 = 2*(x + iy) - p*(x1 - iy1)/(f*f) and f = x2 + y2. The next point in the iteration is x + iy = (x1 + iy1) + p*(x - iy)/f + (cx + icy). The distance function is
log(√f)*√f/√fd (= log(f)*√f/(2*√fd))
for the last z-value, here f = x2 + y2 and fd = xd2 + yd2. The number in the interval [0, 1] to be subtracted from the iteration number (in order to get the real iteration number), is log(log(|z|)/log(r))/log(2) = v*(log(log(f)) - u), for the last z, here v = 1/log(2) and u = log(log(r)).
paletteRGB(r, g, b) is the integer indexing the colour with RGB-values (r, g, b), 0 gives black. col, col2 and col3 are the arrays from 0 to 719 of integers from 0 to 255 constructed in the next section.