## Mandelbrot fractal maker

GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

### Mandelbrot fractal maker

Edit :

I now know what was wrong with the code and what was wrong with the scaling and moving and zooming etc..

so finnaly :

(move with 'wasd', zoom in and out with mousewheel, increase iterations with and 'u' and 'j' and increase size with 'y' and 'h')
(improvements ideas?)

oh and OpenGL version : http://glsl.heroku.com/e#4645.2
Attachments
Mandelbrot.love
Last edited by GijsB on Sat Nov 03, 2012 4:47 pm, edited 4 times in total.

kikito
Inner party member
Posts: 3151
Joined: Sat Oct 03, 2009 5:22 pm
Contact:

### Re: Mandelbrot fractal maker

Can't MainCalculation be defined once, outside of the loops? Adding parameters, I suppose.
When I write def I mean function.

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Mandelbrot fractal maker

And it may also not be wise to put that code in love.draw. Instead, use Framebuffers. (Just ask if you need help figuring out how they work. )

GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

### Re: Mandelbrot fractal maker

i understand where those framebuffers are for, but i dont know how to use them 3:

anyway, i speeded up the code :
Attachments
Mandelbrot fractal maker.love

Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

### Re: Mandelbrot fractal maker

You are on the right track.

Look at this:

Code: Select all

function MainCalculation(jx, jy, wx, wy, k)
local tx = wx*wx-(wy*wy+jx)
local ty = 2.0*wx*wy+jy
if tx*tx+ty*ty<=m and k<kt then
return MainCalculation(jx, jy, tx, ty, k + 1)
end
return k
end

for x = 0,size,resolution do
local jx = xmin+x*dx
for y = 0,size,resolution do
local jy = ymin+y*dy
table.insert(pixels,{X = x, Y = y, C = MainCalculation(jx, jy, 0, 0, 0)})
end
end
Do you understand what changes I made?

I'll explain Framebuffers if you are ready for it and can't figure it out on your own (but I think you can).

tentus
Inner party member
Posts: 1059
Joined: Sun Oct 31, 2010 7:56 pm
Location: Appalachia
Contact:

### Re: Mandelbrot fractal maker

GijsB wrote:i understand where those framebuffers are for, but i dont know how to use them 3:

anyway, i speeded up the code :
Note that framebuffers are not universally supported (about 81% of us support them, according to this source). I would recommend avoiding them unless you need them, since coding a graceful degradation essentially means twice the work, if not more, for a benefit that about a fifth of the community can never see.
Kurosuke needs beta testers

GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

### Re: Mandelbrot fractal maker

Robin, yes and there awesome

kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

### Re: Mandelbrot fractal maker

Very cool (runs much quicker in LoveJIT btw)

Spent a while reading up on it and playing with the code/colours
test1.png (108.88 KiB) Viewed 3198 times
Also found this which is quite cool:

GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

### Re: Mandelbrot fractal maker

But does anybody know how to zoom into it xD?

kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

### Re: Mandelbrot fractal maker

GijsB wrote:But does anybody know how to zoom into it xD?
change xmin/xmax ymin/ymax

### Who is online

Users browsing this forum: Majestic-12 [Bot] and 3 guests