Brahmabrot { ; This is different from standart Buddhabrot in that ; colours are calculated from progressive curves ; using Wave Trichrome method, who are inspired by RGB Buddhabrots but needs fewer iterations. ; As it don't tests for insdes or outsides of fractal, but mixes buddhabrot and antibuddhabrot. ; Alsou it used both mandelbrot and newton bailout. ; source code for this mostly is taken from Susan D. Chambless buddhabrot. ; and one more loop. ; Some formulas like Swirl transform, Royal, SummonerEye, Gavarun are by Kram1032. ;By Edgar Malinovsky 02.12.2012. ;http://www.fractalforums.com/fractal-programs/problems-with-implementing-budhabrot-in-uf/ ;08.12.2012 ; Added newton bailout revealing more features. ; Tweeking of parameters, so that there are less dots. ; Changed some formulas for another. ; You may redistribute this algorithm, modify, derivate or use comercialy as you wish as long as you give proper credits. $DEFINE DIRECT global: float increaser=0 float antilightR=1/@lightR float antilightG=1/@lightG float antilightB=1/@lightB int seed = @seedinput float dataR=1 float dataG=1 float dataB=1 int pwid = trunc(#width) int phgt = trunc(#height) ;3 arrays for RGB float pixR[trunc(#width),trunc(#height)] ; offscreen image float pixG[trunc(#width),trunc(#height)] ; offscreen image float pixB[trunc(#width),trunc(#height)] ; offscreen image ;calculate buddha loop many times int superloop=1 int slcounter =0 complex locations[@maxiter] ; collect locations int cnt = 0 ; Loop counters float colourcnt = 0 ;colourcounter int x = 0, int y = 0 ; Loop counters & integer coords float xc = real(#center) ; Scaling constants float yc = -imag(#center) float srcMinX = - (@srcWidth * 0.5) float srcMinY = - (@srcHeight * 0.5) float scale = (#height * #magn) / 3*(@sizescaling) float nsamples =0 int irandX1 =0 int irandY1 =0 float srcX1 =0 float srcY1 =0 complex z =0 complex c =0 complex zold=1 int iter =0 int locindex =0 float dx =0 float dy =0 ; Initialize arrays of RGB pixels with neutral colour. while x < #width y = 0 while y < #height pixR[x, y] = @ambient pixG[x, y] = @ambient pixB[x, y] = @ambient y = y + 1 endwhile x = x + 1 endwhile ; Main buddha iteration loop nsamples = round(#width * #height* #magn) cnt = 0 ;if sample number is too large, divide single ;loop in many small. 12 divides better than 10, so multiples of 12 is used. IF @sampleDensity > 497664 nsamples = trunc(nsamples/3456) superloop=3456 ELSEIF @sampleDensity > 41472 nsamples = trunc(nsamples/288) superloop=288 ELSEIF @sampleDensity > 3456 nsamples = trunc(nsamples/24) superloop=24 ELSE nsamples = trunc(nsamples/4) superloop=4 ENDIF nsamples = nsamples * @sampleDensity while slcounter < superloop ; superloop while cnt < nsamples ;main buddha loop ; generate random integers (-#randomrange to #randomrange) irandX1 = seed = random(seed) irandY1 = seed = random(seed) ; convert to random float numbers srcX1 = (abs(irandX1) / #randomrange)*@srcWidth + srcMinX srcY1 = (abs(irandY1) / #randomrange)*@srcHeight + srcMinY ; Mbrot set with random c value z = 0 c = srcX1 + flip(srcY1) zold=1 ; iteration count and modulus, this don't need large bailout iter = 0 while ( (cabs(z) < 4) && (cabs(zold-z) >0.001 ) && (iter < @maxIter) ) ;fractal formula loop zold=z IF (@formula ==0) ;Mandelbrot z= z^@power +c ELSEIF (@formula ==1) ;Talis z= z^@power/(z^(@power-1) + @talisadd) +c ELSEIF (@formula ==2) ;Starbrot z= z*0.5 - z^@starpower + c ELSEIF (@formula ==3) ;Tricorn z= conj(z^@power)+c ELSEIF (@formula ==4) ;BurningSihp z=abs(z^@power)+c ELSEIF (@formula ==5) ;8th modulus Mbrot z=sqr(z) z=(z^8+z^8)^0.125+c ELSEIF (@formula ==6) ;Unit Vector - Mbrot z=z^@power+c z= z/cabs(z)*@unitvector +z ELSEIF (@formula ==7) ;Quadratic General z= sqr(real(z)) + sqr(imag(z))+ flip(real(z)*imag(z)*@quadfactor) + c ELSEIF (@formula ==8) ;Celtic Mandelbrot z = z^@power z = z - real(z) + abs(real(z)) - c ELSEIF (@formula ==9) ;Rotated Mandelbrot z=z^@power+c z=sqr(z)/cabs(z) ELSEIF (@formula ==10) ;Chebyshev4Axolotl z = (sqr(z)*(35 * sqr(z) - 30) + 3) / 8 + c ELSEIF (@formula ==11) ;Mbrot*iters z=z^@power*iter*0.05 +c ELSEIF (@formula ==12) ;Talis*iters z=z^@power*(z^(@power-1)+iter*0.05)+c ELSEIF (@formula ==13) ;Tricorn*iters z= conj(z^@power*iter*0.05)+c ELSEIF (@formula ==14) ;BurningShip*iters z= abs(z^@power*iter*0.05)+c ELSEIF (@formula ==15) ;QuadGen*iters z= (sqr(real(z)) + sqr(imag(z))+ flip(real(z)*imag(z)*@quadfactor) )*iter*0.05 + c ELSEIF (@formula ==16) ;Manowar z = z^2 + zold + c ELSEIF (@formula ==17) ;Multipowerbrot Odd z= ((((z^3*c+1i)^3)+1i)^3)+1i ELSEIF (@formula ==18) ;MagnetII z=sqr((z*z*z+3*z*(c-1)+(c-1)*(c-2))/(sqr(z)*3+3*(c-2)*z+(c-1)*(c-2)+1)) ELSEIF (@formula ==19) ;ChebyshevT4 z = c*(sqr(z)*(sqr(z)*8+8)+1) ELSEIF (@formula ==20) ;PerpendicularMbrot z=sqr(real(z)) - sqr(imag(z)) -flip(2*imag(z)*abs(real(z))) + c ELSEIF (@formula==21) ;Royal Imagination z=sqr(real(z))- sqr(sqr(imag(z))) + flip( 2*real(z)*imag(z) ) +c ELSEIF (@formula ==22) ;Swirl Mbrot z=(exp(flip(cabs(z)+atan2(z)) ) *z )^@power +c ELSEIF (@formula ==23) ;ConjugateBeholder z=(z + c) / ( conj(z)- c+ @talisadd ) ELSEIF (@formula ==24) ;Gavarun z=(cabs(z))^(@talisadd + flip(atan2(z) ) ) +c ELSEIF (@formula ==25) ;MalinovskyDeco z=sinh(z)*z^(@power-1) - c^@power ELSEIF (@formula ==26) ;Multipowerbrot Even z= sqr( ( sqr( z*z*c +1 )) -1 ) -1 ENDIF locations[iter] = z iter = iter + 1 endwhile ;end fractal formula loop locindex = 1 ;for background contrast starts with 1. while( locIndex < iter ) ;colour loop cnt = cnt+1 dx = real( locations[locIndex] ) - xc dy = imag( locations[locIndex] ) - yc ; Scale to image x = round(dx*scale + pwid*0.5) y = round(dy*scale + phgt*0.5) ; Plot the point only if inside image if x >= 0 && x < pwid && y >= 0 && y < phgt ;colours calculated as RGB curves colourcnt=colourcnt+1 increaser=recip(sqrt(colourcnt)) dataR = (dataR + increaser )/( @scalarR + abs(pixR[x, y])*antilightR) dataG = (dataG + increaser )/( @scalarG + abs(pixG[x, y])*antilightG) dataB = (dataB + increaser )/( @scalarB + abs(pixB[x, y])*antilightB) pixR[x, y] = pixR[x, y] + dataR pixG[x, y] = pixG[x, y] + dataG pixB[x, y] = pixB[x, y] + dataB endif locIndex = locIndex + 1 endwhile ;end colour loop endwhile ;end main buddha loop ;change random seed, increase superloop counter, ;set main loop to 0 and go throught next cycle. cnt=0 slcounter = slcounter+1 seed = @seedinput + slcounter endwhile ;end superloop ;now formula will go throught pixels by fractal generator. init: int xcrd = 0 int ycrd = 0 float resultR = 0 float resultG = 0 float resultB = 0 float resultAlpha=0 final: xcrd = #x ycrd = #y resultR = abs(pixR[xcrd, ycrd]) resultG = abs(pixG[xcrd, ycrd]) resultB = abs(pixB[xcrd, ycrd]) IF (@postfn==0) ;nothing ELSEIF (@postfn==1) resultR=sin(resultR) resultG=sin(resultG) resultB=sin(resultB) ELSEIF (@postfn==2) resultR=1- resultR resultG=1- resultG resultB=1- resultB ELSEIF (@postfn==3) resultR=sqr(resultR) resultG=sqr(resultG) resultB=sqr(resultB) ELSEIF (@postfn==4) resultR=1-sin(resultR) resultG=1-sin(resultG) resultB=1-sin(resultB) ELSEIF (@postfn==5) float sumR = resultR float sumG = resultG float sumB = resultB resultR=abs(resultR -sqrt(sumG*sumB)*0.5) resultG=abs(resultG -sqrt(sumR*sumB)*0.5) resultB=abs(resultB -sqrt(sumR*sumG)*0.5) ELSEIF (@postfn==6) resultR= abs( resultR -round(resultR) ) resultG= abs( resultG -round(resultG) ) resultB= abs( resultB -round(resultB) ) ELSEIF (@postfn==7) resultR=tanh(resultR) resultG=tanh(resultG) resultB=tanh(resultB) ELSEIF (@postfn==8) resultR=sin((resultR) )*cos((resultG)) resultG=sin((resultG) )*cos((resultR)) resultB=sin((resultB) )*cos((resultR)) ELSEIF (@postfn==9) resultR=sqr(sin(#pi*resultR)) resultG=sqr(sin(#pi*resultG)) resultB=sqr(sin(#pi*resultB)) ENDIF ; switching colour channels. IF (@switchRGB==0) ;nothing ELSEIF (@switchRGB==1) resultAlpha=resultG resultG=resultR resultR=resultAlpha ELSEIF (@switchRGB==2) resultAlpha=resultB resultB=resultR resultR=resultAlpha ELSEIF (@switchRGB==3) resultAlpha=resultB resultB=resultG resultG=resultAlpha ENDIF ;colour mode: direct, using palette, or mixed. IF (@palette==0) #color = rgb(resultR, resultG, resultB) ELSEIF (@palette==1) #color = gradient(resultG) ELSEIF (@palette==2) ;gradient is by arithmetic mean of RGB color gradcolor=gradient( (resultR+resultG+resultB)*0.333333333333333 ) ;harmonic of gradient and RGB resultR=2/( recip (red(gradcolor))+ recip(resultR) ) resultG=2/( recip (green(gradcolor))+ recip(resultG) ) resultB=2/( recip (blue(gradcolor))+ recip(resultB) ) resultAlpha=alpha(gradcolor) #color = rgba(resultR, resultG, resultB,resultAlpha) ELSEIF (@palette==3) ; colour mode like of Fractal Explorer. ; uses pallete, but each chanell is calculated seperately. resultR=red(gradient(resultR)) resultG=green(gradient(resultG)) resultB=blue(gradient(resultB)) resultAlpha=alpha(gradient( resultG)) #color = rgba(resultR, resultG, resultB, resultAlpha) ELSEIF (@palette==4) ;all waves included. #color=gradient(3/(recip(resultR) + recip(resultG) + recip(resultB) ) ) ENDIF default: title = "Brahmabrot" render = false heading caption = "Use with Pixel aka No Formula." endheading heading caption = "Buddha Block" endheading int param sampleDensity caption = "Sample density/incrse" default = 100 hint="Main variable. The larger value, the more points hits image, the more detailed will be image. Put relatively small value for fast first calculation, then increase for smooth pic." endparam int param maxiter caption = "Max Iterations" default = 200 hint = "Maxiter for fractal. Long orbits will stay in certain alredy dense region, but small maxiter will make this too blury." endparam int param seedinput caption = "Lucky Number" default = -8 hint="Random seed used to calculate random numbers who realy aren't that random. Different seeds marks different firstfound orbits." endparam heading caption = "Formula Block" endheading param formula caption="Fractal Formula" default=0 enum= "Mandelbrot" "Talis" "Starbrot" "Tricorn" "BurningSihp" "8th modulus Mbrot" "Unit Vector - Mbrot" "Quadratic General" "Celtic Mandelbrot" "Rotated Mandelbrot" "ChebyshevAxolotl" "Mbrot*iters" "Talis+iters" "Tricorn*iters" "BurningShip*iters" "QuadGen*iters" "Manowar" "Multipowerbrot Odd" "MagnetII" "ChebyshevT4" "PerpendicularMbrot" "Royal Mbrot" "Swirl Mbrot" "SummonerEye" "Gavarun" "MalinovskyDeco" "Multipowerbrot Even" hint= "Fractal formula used for calculation. Mbrot here stands fro Mandelbrot." endparam float param power caption="Power" default=2 visible = (@formula == 0||@formula == 1||@formula == 3||@formula == 4||@formula == 6||@formula == 8||@formula == 9||@formula == 11||@formula == 12||@formula == 13||@formula == 14||@formula == 22||@formula == 25) hint="Degree of formula." endparam int param starpower caption="Star Power" default=7 hint="Star sides = power-1" visible = (@formula == 2) endparam float param unitvector caption="Unit vector amount" default=-0.5 hint="Coefficient N for z=z+N*z/|z|" visible = (@formula == 6) endparam float param talisadd caption="Talis addition" default=1 hint="In Talis adds value to z z=z^2/(z+add). In another fomulas adds value in respective places. In Gavarun it is real part of complex power." visible = (@formula == 1||@formula ==23||@formula ==24) endparam float param quadfactor caption="Factor of x*y" default=2.5 hint="2 is very celtic and 2 is very cosmic." visible = (@formula == 7||@formula ==15) endparam heading caption = "Pixel input Block" endheading float param sizescaling caption = "Size Scale" default = 1 hint="Scaling here works as zooming in or out." endparam float param srcWidth caption = "Pixel source Width" default = 5.0 hint="Input pixel area depends on width and height. Too much is waste of PC resources, not enough will mean that some fractal parts will dissapear. " endparam float param srcHeight caption = "Pixel source Height" default = 4.0 endparam heading caption = "Colour Block" endheading param palette caption = "Colour Mode" enum= "Direct Colouring" "Gradient Based" "Mixed Harmonic" "Fractal Explorer like" "Gradient by Harmonic" default=0 hint= "Gradient Based is gradient calculated from green channel, gradient harmonic is gradient calc from mean of all channels. Mixed is harmonic mean between gradient colour (by mean of RGB) and RGB channels. Fractal Explorer like is RGB values calculated seperately from gradient. All exept direct colouring uses gradient and alpha channel." endparam param switchRGB caption = "Switch Colours" enum ="None" "Switch Red and Green" "Switch Red and Blue" "Switch Green and Blue" default=0 hint= "Switch colour channels to change image tones in direct mode, so that don't need to change light and scalar of RGB." endparam float param ambient caption = "Ambient Light" default = 0.12 hint="Greyscale colour value of uniterated pixel. Result then is added / substracted from this." endparam param postfn caption = "Transfer Function" enum = "0- None" "1- Sin (periodic)" "2- Inverted" "3- Square Power (sharper)" "4- SinInverted (periodic)" "5- Accentuate RGB" "6- Solarisation (periodic)" "7- Hyperbolic Tangent" "8- SineCosineMix (periodic)" "9- Haversine (periodic)" default = 0 hint="The same as UF, but applied before colour mode, and works with direct colour. Periodic will colour white regions." endparam heading caption = "Info" text = "Version of Buddhabrot. Use with pixel aka no formula and wait. To increase render quality increase sample density. Difference from standart Buddhabrot is that this version don't test for escaping or non escaping orbits so it is mix of Buddhabrot and Antibuddhabrot, it have mixed mandelbrot and newton bailout and that RGB colours are calculated by Wave Trichrome method. It is alsou faster than most Buddhabrots. It is s suposed to work with plain direct colouring. If with large sample density it becomes too white try periodic transfer funtions. If with very large sample density and resolution it ceases to render, it's becouse fractal exceeded upper limit of integer numbers. http://www.fractalforums.com/fractal-programs/problems-with-implementing-budhabrot-in-uf/" endheading heading caption = "RGB block" endheading float param lightR caption = "Red light" default = 0.38 endparam float param scalarR caption = "Red scalar" default = 0.7 endparam float param lightG caption = "Green light" default = 0.98 endparam float param scalarG caption = "Green scalar" default = 1.6 endparam float param lightB caption = "Blue light" default = 0.14 endparam float param scalarB caption = "Blue scalar" default = 0.3 endparam }