Page 2 of 6

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 10:38 pm
by GijsB
with what 3:?

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 10:54 pm
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.

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 10:56 pm
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..."

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:10 pm
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.

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:14 pm
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

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:21 pm
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!

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:23 pm
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

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:24 pm
by GijsB
kraftman,

ur not making sense right now, explain please -__-

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:26 pm
by kraftman
GijsB wrote:kraftman,

ur not making sense right now, explain please -__-
I said multiply, and you are adding. :)

Re: Mandelbrot fractal maker

Posted: Thu Jul 21, 2011 11:28 pm
by GijsB
whats the diffrence?!
your in both ways making the numbers bigger/smaller
and even when i do that, it WONT work.