46 lines
885 B
Text
46 lines
885 B
Text
link graphics
|
|
|
|
procedure main()
|
|
width := 750
|
|
height := 600
|
|
limit := 100
|
|
WOpen("size="||width||","||height)
|
|
every x:=1 to width & y:=1 to height do
|
|
{
|
|
z:=complex(0,0)
|
|
c:=complex(2.5*x/width-2.0,(2.0*y/height-1.0))
|
|
j:=0
|
|
while j<limit & cAbs(z)<2.0 do
|
|
{
|
|
z := cAdd(cMul(z,z),c)
|
|
j+:= 1
|
|
}
|
|
Fg(mColor(j,limit))
|
|
DrawPoint(x,y)
|
|
}
|
|
WriteImage("./mandelbrot.gif")
|
|
WDone()
|
|
end
|
|
|
|
procedure mColor(x,limit)
|
|
max_color := 2^16-1
|
|
color := integer(max_color*(real(x)/limit))
|
|
|
|
return(if x=limit
|
|
then "black"
|
|
else color||","||color||",0")
|
|
end
|
|
|
|
record complex(r,i)
|
|
|
|
procedure cAdd(x,y)
|
|
return complex(x.r+y.r,x.i+y.i)
|
|
end
|
|
|
|
procedure cMul(x,y)
|
|
return complex(x.r*y.r-x.i*y.i,x.r*y.i+x.i*y.r)
|
|
end
|
|
|
|
procedure cAbs(x)
|
|
return sqrt(x.r*x.r+x.i*x.i)
|
|
end
|