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

Re: Mandelbrot fractal maker

Post by GijsB »

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

Re: Mandelbrot fractal maker

Post by kraftman »

lol, you wrote it!

to zoom in, decrease their values, to zoom out, increase them. E.g. multiply all of their values by 0.9 to zoom in, 1.1 to zoom out.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Mandelbrot fractal maker

Post by Jasoco »

And if creating the Fractal takes too long, with some work you could also make it so it will update and draw a progress bar while it is calculating by taking advantage of calling stuff like love.timer.step(), love.graphics.clear(), drawing your progress stuff to the screen and then love.graphics.present(). That might be more advanced, but when used properly it can be useful. It can be called inside any process that takes a while. You just don't want to call it every loop since it slows the thing down, instead you call that stuff every certain loops. Like every 10 or every 100. Since the loop works much faster than a normal frame does, you could go through a thousand loops in a few frames time. So you could even call it every 1000 iterations and still have a pretty good progress indication. And it doesn't have to be a bar, it can be a spinner or a simple message that says "Calculating! Please wait..."
User avatar
TechnoCat
Inner party member
Posts: 1611
Joined: Thu Jul 30, 2009 12:31 am
Location: Milwaukee, WI
Contact:

Re: Mandelbrot fractal maker

Post by TechnoCat »

Jasoco wrote:And if creating the Fractal takes too long, with some work you could also make it so it will update and draw a progress bar while it is calculating by taking advantage of calling stuff like love.timer.step(), love.graphics.clear(), drawing your progress stuff to the screen and then love.graphics.present(). That might be more advanced, but when used properly it can be useful. It can be called inside any process that takes a while. You just don't want to call it every loop since it slows the thing down, instead you call that stuff every certain loops. Like every 10 or every 100. Since the loop works much faster than a normal frame does, you could go through a thousand loops in a few frames time. So you could even call it every 1000 iterations and still have a pretty good progress indication. And it doesn't have to be a bar, it can be a spinner or a simple message that says "Calculating! Please wait..."
Or if coroutines aren't your thing. simply use a thread.
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Mandelbrot fractal maker

Post by GijsB »

i tried changing the xmin,xmax,etc
but all it does random crap..
help 3:

this is what i have now =

Code: Select all


resolution =2

size = 100
kt = 50
m = 4.0
xmin = 2.1
xmax = -0.6
ymin = -1.5
ymax = 1.5
dx = (xmax-xmin)/size
dy = (ymax-ymin)/size
pixels = {}
function run()
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
end
run()
function love.draw()
	for i,v in pairs(pixels) do
		love.graphics.setColor( -v.C, -v.C, -v.C, 255 )
		love.graphics.rectangle("fill",v.X,v.Y,resolution,resolution)
	end
end
function love.keypressed(k)
	if k == "right" then
		xmin = xmin+0.9
		xmax = xmax-0.9
		ymin = ymin+0.9
		ymax = ymax-0.9	
	elseif k == "left" then
		xmin = xmin+0.9
		xmax = xmax-0.9
		ymin = ymin+0.9
		ymax = ymax-0.9	
	end
	run()
end
Last edited by GijsB on Thu Jul 21, 2011 11:21 pm, edited 1 time in total.
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Mandelbrot fractal maker

Post by Jasoco »

TechnoCat wrote:
Jasoco wrote:And if creating the Fractal takes too long, with some work you could also make it so it will update and draw a progress bar while it is calculating by taking advantage of calling stuff like love.timer.step(), love.graphics.clear(), drawing your progress stuff to the screen and then love.graphics.present(). That might be more advanced, but when used properly it can be useful. It can be called inside any process that takes a while. You just don't want to call it every loop since it slows the thing down, instead you call that stuff every certain loops. Like every 10 or every 100. Since the loop works much faster than a normal frame does, you could go through a thousand loops in a few frames time. So you could even call it every 1000 iterations and still have a pretty good progress indication. And it doesn't have to be a bar, it can be a spinner or a simple message that says "Calculating! Please wait..."
Or if coroutines aren't your thing. simply use a thread.
Simply? Aren't threads a lot harder to figure out how to code? I know I've never known how to use them. Tell me how!
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Mandelbrot fractal maker

Post by kraftman »

GijsB wrote:i tried changing the xmin,xmax,etc
but all it does random crap..
help 3:

this is what i have now =

Code: Select all


resolution =2

size = 100
kt = 50
m = 4.0
xmin = 2.1
xmax = -0.6
ymin = -1.5
ymax = 1.5
dx = (xmax-xmin)/size
dy = (ymax-ymin)/size
pixels = {}
function run()
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
end
run()
function love.draw()
	for i,v in pairs(pixels) do
		love.graphics.setColor( -v.C, -v.C, -v.C, 255 )
		love.graphics.rectangle("fill",v.X,v.Y,resolution,resolution)
	end
end
function love.keypressed(k)
	if k == "right" then
		xmin = xmin+0.9
		xmax = xmax-0.9
		ymin = ymin+0.9
		ymax = ymax-0.9	
	elseif k == "left" then
		xmin = xmin+0.9
		xmax = xmax-0.9
		ymin = ymin+0.9
		ymax = ymax-0.9	
	end
	run()
end
multiplication ~= addition
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Mandelbrot fractal maker

Post by GijsB »

kraftman,

ur not making sense right now, explain please -__-
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: Mandelbrot fractal maker

Post by kraftman »

GijsB wrote:kraftman,

ur not making sense right now, explain please -__-
I said multiply, and you are adding. :)
User avatar
GijsB
Party member
Posts: 380
Joined: Wed Jul 20, 2011 10:19 pm
Location: Netherlands

Re: Mandelbrot fractal maker

Post by GijsB »

whats the diffrence?!
your in both ways making the numbers bigger/smaller
and even when i do that, it WONT work.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests