• Welcome to Dark Bit Factory & Gravity.
 

Mandelbrot source code..

Started by Shockwave, July 26, 2006

Previous topic - Next topic

0 Members and 0 Guests are viewing this topic.

Shockwave

Here's another quick code on a fractal tip!



' Little Mandlebrot using tinyptc by Shockwave ^ DBF
' Fuck I must be bored tonight....
'
' For those learning fractals, the colour of the point is determined by how many
' iterations of z=z^2 +c it takes to determine if a point is a part of the set or
' if it bails out before it can be determined (try playing with the iterations variable).
' Meh! Last time I coded one of these it was in Pascal in college a long time ago.
'
'-------------------------------------------------------------------------------

#DEFINE PTC_WIN
#Include Once "tinyptc.bi"
If( ptc_open( "LITTLE MANDELBROT BY SHOCKWAVE^DBF", 640, 480 ) = 0 ) Then End
dim shared buffer(640*480) as integer
dim shared as double XADD,XPX,YADD,YPY,AAAA,BBBB,FLOOP,AAA,BBB
option explicit
dim shared MINIMUM_X,MAXIMUM_X,TWAT,BOLLOCKS,PASS,ITERATIONS,y,x as integer
dim shared COLOUR_MULT as double

        MINIMUM_X = 0
        MAXIMUM_X = 640
        TWAT = 0
        BOLLOCKS = 479
PASS=6
ITERATIONS=50
COLOUR_MULT = (500/ITERATIONS)
do     
XADD= (4/(MAXIMUM_X - MINIMUM_X))
XPX=-2.5
YADD= (4/(BOLLOCKS - TWAT))
YPY=-2
        for y = TWAT to BOLLOCKS
XPX=-2.5
for x = MINIMUM_X to MAXIMUM_X
                AAA=XPX
                BBB=YPY
                FLOOP=0
do
        FLOOP=FLOOP+1
        AAAA=AAA*AAA-BBB*BBB+XPX
        BBBB=2*AAA*BBB+YPY
        AAA=AAAA
        BBB=BBBB         
loop until ((FLOOP>ITERATIONS) or ((AAA*AAA)+(BBB*BBB)>PASS))
                if FLOOP>=ITERATIONS then                 
                FLOOP=0                 
                else               
                FLOOP=FLOOP*COLOUR_MULT               
                end if
                buffer((y*640)+x)=rgb(0,FLOOP,FLOOP)         
                XPX = XPX + XADD
        next x
        YPY = YPY + YADD
        next y
ptc_update@buffer(0)
loop until inkey$<>""

Shockwave ^ Codigos
Challenge Trophies Won:

Clyde

Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.


Challenge Trophies Won:

Shockwave

Shockwave ^ Codigos
Challenge Trophies Won:

psygate

Nice Work! I especially love the colors around the mandelbrot!
Book! O0




PS: Why I write book instead of cool? If you type cool into your Mobile phone with the t9 on, you get at first book instead of cool! *lol*
He who controlles the minds commands the many.
He who commands the many, conqueres the minds.

Shockwave

Glad you folks like it. Sorry for the variable names, I was drunk when I made it :)

Book.
Shockwave ^ Codigos
Challenge Trophies Won: