Hi Roland, I am using an interactive derivation, JuliaKeyb, which has become a laboratory for testing all sorts of variations.
+/- increase/decrease
arrow keys to pan
z to zoom
f for julia factor
i for iterations
m for color multiplier
j to toggle julia/mandelbrot
r g b for colors
the program is directly altered for all other explorations.
Today's code:
#compact
% Title "Fractal Demo: keyboard: + - r g b f i j m Ctrl P for snapshot"
'% Animated
% ScaleUp
'% PlaceCentral
'% AnchorCentral
'% NoEscape
includepath "$\inc\"
'% filename "t.exe"
'include "RTL64.inc"
include "ConsoleG.inc"
macro limit(v,min,max)
======================
if v>max then
v=max
elseif v<min then
v=min
end if
end macro
indexbase 0
pixel4 juliapix[512*512]
int gc
function JuliaCalc(double x, y, r, s,*oc, int it,jm) as double
==============================================================
double xy,mx=4.0
int k=it
'
if jm then
'SWITCH TO MANDELBROT SET
r=x
s=y
x=0
y=0
end if
'
'for k=0 to it
mov esi,it
(
dec esi
jl exit
'gc+=1
inc dword gc
'xy=x*y
fld qword x
fmul qword y
fstp qword xy
'x=x*x-y*y+r
fld qword x
fmul st0
fld qword y
fmul st0
fsubp st1
fadd qword r
fstp qword x
'y=2*xy+s
fld qword xy
fadd st0
fadd qword s
fstp qword y
'if abs(xy)>mx then exit for
'fld qword mx
'fld qword xy
'fabs
'fcomip
'fstp st0
'ja exit
'if x*x+y*y>mx then exit for
fld qword mx
fld qword x
fmul st0
fld qword y
fmul st0
faddp st1
fcomip
fstp st0
ja exit
'next
repeat
)
oc={x,y}
'return sqr(sqr(abs(y)))
'return sqr(abs(x)+abs(y))
'return sqr(abs(y))
return abs(x)
'return x+y
'return abs(x)+abs(y)
'return abs(xy)
'return hypot(x,y)
'
sub k,esi
'return k*abs(xy)
'fld qword xy
'fabs
'fimul dword k
'return
'return abs(xy)
'fld qword xy
'fabs
'return
'return xy
'fld qword xy
'return
'return xy*xy
'fld qword xy
'fmul st0
'return
'return k
end function
function JuliaRender(double mf,it,jm,mp,sc,xo,yo,rf,gf,bf)
==========================================================
indexbase 0
'mf 2 .. 0 'factor
'rf 0 .. 1 'red
'gf 0 .. 1 'green
'bf 0 .. 1 'blue
sys i , j
double x , y , dz , rc , ic , orb, oc[1]
gc=0
pixel4 jp at @JuliaPix
rc=mf
ic=mf-1.0
dz=sc*3/512
for i=0 to <512
y=yo-1.5*sc+i*dz
for j=0 to <512
x=xo-1.5*sc+j*dz
orb=JuliaCalc(x,y,rc,ic,oc,it,jm)*mp
'
'RECIPROCALS
if oc[0] then oc[0]=1/abs(oc[0])
if oc[1] then oc[1]=1/abs(oc[1])
jp.r=abs(oc[0])*mp*rf
jp.g=abs(oc[0])*abs(oc[1])*mp*gf
jp.b=abs(oc[1])*mp*bf
'jp.r=orb*rf 'red
'jp.g=orb*gf 'green
'jp.b=orb*bf 'blue
jp.a=255 'alpha
@jp+=4 'next pixel
next j
next i
end function
function main()
===============
'
indexbase 1
static int init,it,jm,mp
static double rf,gf,bf,jf,jfi,sc,xo,yo
if not init then
sc=1
xo=0
yo=0
rf=1.0
gf=.5
bf=.2
jf=0
jfi=0.002
it=10
mp=5
init=1
NewTexture JuliaTex
end if
if lastkey or lastchar then
static float kvi=.01, kva=0.05
static int kii=1
int cey=lastchar
kva=.05*sc
if cey>0x60 and cey<0x7b then cey-=32 'to uppercase
'
if key[189] then kvi=-.01 : kii=-1 '-'
if key[187] then kvi= .01 : kii= 1 '+'
if key[VK_RIGHT] then xo+=kva 'ARROW RIGHT'
if key[VK_LEFT] then xo-=kva 'ARROW LEFT'
if key[VK_UP] then yo+=kva 'ARROW UP'
if key[VK_DOWN] then yo-=kva 'ARROW DOWN'
if key[0x5A] then sc*=(1-kvi*5) 'Z' ZOOM
if key[0x46] then jf+=kvi 'F' FACTOR
if cey=0x49 then it+=kii 'I' ITERATIONS
if cey=0x4a then jm=1-jm 'J' JULIA/MANDELBROT MODE
if cey=0x4d then mp+=kii 'M' OUTPUT MULTIPLIER
if key[0x52] then rf+=kvi 'R' RED
if key[0x47] then gf+=kvi 'G' GREEN
if key[0x42] then bf+=kvi 'B' BLUE
'
'limit sc, .01,100 'Julia Zoom
'limit jf, 0,2 'Julia factor
limit it, 1,1000 'JuliaCalc iterations
limit mp, 1,1000 'Julia output multiplier
limit rf, 0,1 'red
limit gf, 0,1 'green
limit bf, 0,1 'blue
'
'
lastkey=0
lastchar=0
end if
'
'DISPLAY FACTORS
def fi " %1:" str(%1,0)
def ff " %1:" str(%1,2)
def ff3 " %1:" str(%1,3)
printl ff jf fi it fi mp ff3 sc ff3 xo ff3 yo ff rf ff gf ff bf
'
JuliaRender jf,it,jm,mp,sc,xo,yo,rf,gf,bf
'jf+=jfi
'if jf<0.0 then
' jf=0.0 : jfi=-jfi
'elseif jf>2.0 then
' jf=2.0 : jfi=-jfi
'end if
pushstate
move 15,-15.0
'UserMovement m2,200
flat : color 1,1,1,1
texture JuliaTex
DynSynthTexture JuliaTex,JuliaPix,512*512*4
quadnorm 15.0,15.0 'apply image texture to quad
texture 0
popstate
'
end function
EndScript