Mandelbrot fractal maker

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Mandelbrot fractal maker

Post by GijsB » Thu Jul 21, 2011 1:47 pm

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
(919 Bytes) Downloaded 173 times
Last edited by GijsB on Sat Nov 03, 2012 4:47 pm, edited 4 times in total.

User avatar
kikito
Inner party member
Posts: 3152
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Mandelbrot fractal maker

Post by kikito » Thu Jul 21, 2011 1:52 pm

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

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

Re: Mandelbrot fractal maker

Post by Robin » Thu Jul 21, 2011 1:57 pm

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. :))
Help us help you: attach a .love.

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

Re: Mandelbrot fractal maker

Post by GijsB » Thu Jul 21, 2011 2:28 pm

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
(525 Bytes) Downloaded 144 times

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

Re: Mandelbrot fractal maker

Post by Robin » Thu Jul 21, 2011 4:02 pm

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).
Help us help you: attach a .love.

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

Re: Mandelbrot fractal maker

Post by tentus » Thu Jul 21, 2011 4:18 pm

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

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

Re: Mandelbrot fractal maker

Post by GijsB » Thu Jul 21, 2011 4:34 pm

Robin, yes and there awesome :D

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

Re: Mandelbrot fractal maker

Post by kraftman » Thu Jul 21, 2011 10:26 pm

Very cool (runs much quicker in LoveJIT btw)

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

http://www.youtube.com/watch?v=P3WdnLSI2hs

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

Re: Mandelbrot fractal maker

Post by GijsB » Thu Jul 21, 2011 10:29 pm

But does anybody know how to zoom into it xD?

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

Re: Mandelbrot fractal maker

Post by kraftman » Thu Jul 21, 2011 10:32 pm

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

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests