Mandelbrot fractal maker
Re: Mandelbrot fractal maker
with what 3:?
Re: Mandelbrot fractal maker
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.
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.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Mandelbrot fractal maker
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..."
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Mandelbrot fractal maker
Or if coroutines aren't your thing. simply use a thread.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..."
Re: Mandelbrot fractal maker
i tried changing the xmin,xmax,etc
but all it does random crap..
help 3:
this is what i have now =
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.
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Mandelbrot fractal maker
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!TechnoCat wrote:Or if coroutines aren't your thing. simply use a thread.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..."
Re: Mandelbrot fractal maker
multiplication ~= additionGijsB 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
Re: Mandelbrot fractal maker
kraftman,
ur not making sense right now, explain please -__-
ur not making sense right now, explain please -__-
Re: Mandelbrot fractal maker
I said multiply, and you are adding.GijsB wrote:kraftman,
ur not making sense right now, explain please -__-
Re: Mandelbrot fractal maker
whats the diffrence?!
your in both ways making the numbers bigger/smaller
and even when i do that, it WONT work.
your in both ways making the numbers bigger/smaller
and even when i do that, it WONT work.
Who is online
Users browsing this forum: No registered users and 1 guest