Author Topic: Mandelbrot source code..  (Read 3572 times)

0 Members and 1 Guest are viewing this topic.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Mandelbrot source code..
« on: July 26, 2006 »
Here's another quick code on a fractal tip!

Code: [Select]

' 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:

Offline Clyde

  • A Little Fuzzy Wuzzy
  • DBF Aficionado
  • ******
  • Posts: 7271
  • Karma: 71
    • View Profile
Re: Mandelbrot source code..
« Reply #1 on: July 26, 2006 »
Cool mate.
Still Putting The IT Into Gravy
If Only I Knew Then What I Know Now.

Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Mandelbrot source code..
« Reply #2 on: July 26, 2006 »
Cheers clydester :)
Shockwave ^ Codigos
Challenge Trophies Won:

Offline psygate

  • Completly Insane.
  • Atari ST
  • ***
  • Posts: 173
  • Karma: 7
  • That boy needs therapy.
    • View Profile
Re: Mandelbrot source code..
« Reply #3 on: July 31, 2006 »
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.

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17414
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Mandelbrot source code..
« Reply #4 on: August 01, 2006 »
Glad you folks like it. Sorry for the variable names, I was drunk when I made it :)

Book.
Shockwave ^ Codigos
Challenge Trophies Won: