aUCBLogo Demos and Tests / mandel_mjs6
be mandel_mjs6
(ss 0.4)
ct
store=[] store_num = int 0
;t=timefine
col_range=5
ht pu
sx=600 ;800
sy=400;600
s_ratio=sx/sy
sxmin=0-sx/2
symin=0-sy/2
setscreenrange sxmin symin -1*sxmin -1*symin
maxiter=200
col=[]
dx=0
dy=0
set_col_array maxiter
cmin=-2-1.2i cmax=0.7+1.2i
m_plot cmin cmax
be iterate_sine z c maxiter
repeat maxiter ; compute orbit
[ z=(sine z) + z*z
z+=c
if or (abs real z) > 10
(abs imag z) > 10[output repcount]
]
output maxiter
end
be set_col_array maxiter
col=array maxiter
repeat maxiter
[ n=repcount
col.n=HSB
n*col_range*0.001*360 1 1
]
col.maxiter=0
end
be col_val k col_range col_list
local [p q] p=0.6 q=1-p
if empty? bf col_range [setpc (first col_list)*(p+q*k) op pc]
if not k > first col_range
[ setpc (first col_list)*(p+q*k) op pc]
op col_val k bf col_range bf col_list
end
be c_choice
pr [use mouse to determine c]
op mouseSelect cmin
end
be j_plot zmin1 zmax1 c
store=fput (list "j maxiter zmin1 zmax1 c col_range) store
store_num+=1
(show store store_num)
cs
zmin=zmin1 zmax=zmax1 ;makes values global
zrange=zmax-zmin
dx= (real zrange)/(sx-1)
dy= (imag zrange)/(sy-1)
repeat sy
[ry=repcount-1
y=zmin+ry*dy*1i
repeat sx
[rx=repcount-1
z=rx*dx+y
;n=mandelIterateLogo z c maxiter
;n=mandeliterate z c maxiter
n=iterate_sine z c maxiter
setpixel list rx+sxmin ry+symin col.n
] if (Int mod ry 8)==0 [updateGraph]
if key?
[j_pr j_case stop]
]
j_pr
j_case
end
be j_pr
ct
pr [Enter letter]
pr [s - stop]
pr [c - colour range]
pr [r - choose new area with mouse]
pr [m - return to mandel]
pr [l iteration limit]
pr [b previous plot]
consolesetfocus
end
be j_case
cj=rc
case cj
[["s pr "stop stop]
["c pr list "colour range col_range
pr[Enter new colour range]
pr[value from 1.0 to 20.0]
col_range=first rl
set_col_array maxiter
j_plot zmin zmax c]
["m mandel_mjs6 ];stop
["r ct
pr [Use the mouse for selection of a coordinate!]
pr[1st left-click: centre of new region]
pr[2nd left-click: boundary radius of new region]
rectZ ];stop
["l pr list "maxiter value maxiter
pr[Enter new maxiter value]
maxiter=first rl
set_col_array maxiter
j_plot zmin zmax c]
["b previous ] ;stop
[else j_case]
]consolesetfocus
end
be m_plot cmin cmax
store=fput (list "m maxiter cmin cmax col_range) store
store_num +=1 (show store store_num)
cs
crange=cmax-cmin
dx=(real crange)/(sx-1)
dy=(imag crange)/(sy-1)
;t=timefine
for [ry 1 sy]
[ y=cmin+1i*(ry-1)*dy
;z0=0i+0
repeat sx
[
rx=repcount
c = (rx-1) * dx + y
;z=z0
;;n=mandelIterateLogo 0+0i c maxiter
;n=mandelIterate 0i+0 c maxiter
;n=iterate_sine 0i+0 c maxiter
n=mandelIterateSine 0i+0 c maxiter
;n = iterate z c maxiter
setpixel list rx+sxmin ry+symin col.n
]
if (Int mod ry 16)==0 [updateGraph]
if key?
[m_pr m_case stop]
;updategraph
]updategraph
;(pr timefine-t "seconds) wait 100
m_pr
m_case
end
be m_pr
ct
pr [Enter letter]
pr [s - stop]
pr [c - colour range]
pr [r - choose new area with mouse]
pr [j julia plot]
pr [i initial mandel]
pr [l iteration limit]
pr [b previous plot]
;pr [p - previous plot]
consolesetfocus
end
be m_case
cj= rc
case cj
[["r ct
pr [Use the mouse for selection of a coordinate!]
pr[1st left-click: centre of new region]
pr[2nd left-click: boundary radius of new region]
rectC
]
["c pr list "colour range col_range
pr[Enter new colour range]
pr[value from 1.0 to 20.0]
col_range=first rl
set_col_array maxiter
m_plot cmin cmax]
["s pr "stop stop]
["j j_plot -2-2i 2+2i c_choice ];stop
["i mandel_mjs6 ];stop
["l pr list "maxiter value maxiter
pr[Enter new maxiter value]
maxiter=first rl
set_col_array maxiter
m_plot cmin cmax]
["b previous ];stop
[else m_case]
]consolesetfocus
end
be previous
if store_num==1[store_num= int 0 store=[] m_plot cmin cmax stop]
local [temp]
temp=first bf store
store= bf bf store store_num -= 2
if(item 1 temp) == "m
[maxiter=(item 2 temp) col_range=last temp
set_col_array maxiter
m_plot (item 3 temp) (item 4 temp)
stop]
maxiter=(item 2 temp) col_range=last temp
set_col_array maxiter
j_plot (item 3 temp) (item 4 temp) (item 5 temp)
end
be rectC
local[c1 c2]
c1=mouseSelect cmin
c2=mouseSelect cmin
radius=norm (c2-c1) off_x= radius/sqrt (1+s_ratio*s_ratio)
;off_y=s_ratio*off_x
off_z=off_x+1i*s_ratio*off_x
;plot_store = lput list c1-off_z c1+off_z plot_store
cs
cmin=c1-off_z cmax=c1+off_z
m_plot cmin cmax
end
be rectZ
local[z1 z2]
z1=mouseSelect zmin
z2=mouseSelect zmin
radius=norm (z2-z1) off_x= radius/sqrt (1+s_ratio*s_ratio)
;off_y=s_ratio*off_x
off_z=off_x+1i*s_ratio*off_x
cs
zmin=z1-off_z zmax=z1+off_z
j_plot zmin zmax c
end
be mouseSelect pmin ;cmin or zmin
local "c
;updateGraph
while [mousebuttons==0]
[xc=(mousex-1-sxmin)*dx
yc=(mousey-1-symin)*dy
c=pmin+xc+1i*yc
;dispatchMessages
]
;wait 2
; (pr)
until [MouseButtons==0][]
output c
end
be mandelIteratelogo z c maxiter
repeat maxiter ; compute orbit
[ z*=z z*=z z*=z
z+=c
;(show "real real z)
;z = z*z + c
if or (abs real z) > 2
(abs imag z) > 2[output repcount]
]
output maxiter
end
be sinh x
op ((exp x)-exp 0-x)/2
end
be cosh x
op ((exp x)+exp 0-x)/2
end
be sine z
local[x y ]
x=(real z)*180/3.1415926535897 y=imag z
op (sin x)*(cosh y)+1i*(cos x)*sinh y
end
end