resolution = 4
size = 600
kt = 100
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()
pixels = {}
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/2
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 == "d" then
xmin = xmin+dx*10
xmax = xmax+dx*10
dx = (xmax-xmin)/size
run()
elseif k == "a" then
xmin = xmin-dx*10
xmax = xmax-dx*10
dx = (xmax-xmin)/size
run()
elseif k == "s" then
ymin = ymin+dy*10
ymax = ymax+dy*10
dy = (ymax-ymin)/size
run()
elseif k == "w" then
ymin = ymin-dy*10
ymax = ymax-dy*10
dy = (ymax-ymin)/size
run()
elseif k == "q" then
xmin = xmin*0.9
xmax = xmax*0.9
ymin = ymin*0.9
ymax = ymax*0.9
dx = (xmax-xmin)/size
dy = (ymax-ymin)/size
run()
elseif k == "e" then
xmin = xmin/0.9
xmax = xmax/0.9
ymin = ymin/0.9
ymax = ymax/0.9
dx = (xmax-xmin)/size
dy = (ymax-ymin)/size
run()
end
end
resolution = 4
size = 600
kt = 100
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()
pixels = {}
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/2
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 == "d" then
xmin = xmin+dx*10
xmax = xmax+dx*10
dx = (xmax-xmin)/size
run()
elseif k == "a" then
xmin = xmin-dx*10
xmax = xmax-dx*10
dx = (xmax-xmin)/size
run()
elseif k == "s" then
ymin = ymin+dy*10
ymax = ymax+dy*10
dy = (ymax-ymin)/size
run()
elseif k == "w" then
ymin = ymin-dy*10
ymax = ymax-dy*10
dy = (ymax-ymin)/size
run()
elseif k == "q" then
xmin = xmin*0.9
xmax = xmax*0.9
ymin = ymin*0.9
ymax = ymax*0.9
dx = (xmax-xmin)/size
dy = (ymax-ymin)/size
run()
elseif k == "e" then
xmin = xmin/0.9
xmax = xmax/0.9
ymin = ymin/0.9
ymax = ymax/0.9
dx = (xmax-xmin)/size
dy = (ymax-ymin)/size
run()
end
end
when changing your look = you can change the x and the y, but the diffrence between max-min must keep the same.
when zooming in = you must smaller the x and y
when changing your look = you can change the x and the y, but the diffrence between max-min must keep the same.
when zooming in = you must smaller the x and y
so when you mutliply, or divide, you get the same numbers as when dividing and mulitplying with y(because that was the problem; you got diffrent numbers)