local p={}function p.Apply(p,d)local L=#p local J=p[1]and#p[1]or 0 for L=1,d,1 do local W=(L-1)/d for d=1,J,1 do p[L][d]=p[L][d]*W end end for W=L-d,L,1 do local F=(d-(W-(L-d)))/d for d=1,J,1 do p[W][d]=p[W][d]*F end end for J=1,d,1 do local W=(J-1)/d for d=1,L,1 do p[d][J]=p[d][J]*W end end for W=J-d,J,1 do local F=(d-(W-(J-d)))/d for d=1,L,1 do p[d][W]=p[d][W]*F end end end return p
local module = {}

function module.Apply(Heightmap,Distance)
	local width = #Heightmap
	local height = Heightmap[1] and #Heightmap[1] or 0

	for x=1,Distance do
		local fade = (x-1)/Distance
		for y = 1,height do
			Heightmap[x][y] = Heightmap[x][y] * fade
		end
	end

	for x=width-Distance,width do
		local fade = (Distance - (x - (width-Distance))) / Distance
		for y = 1,height do
			Heightmap[x][y] = Heightmap[x][y] * fade
		end
	end

	for y=1,Distance do
		local fade = (y-1)/Distance
		for x = 1,width do
			Heightmap[x][y] = Heightmap[x][y] * fade
		end
	end

	for y=height-Distance,height do
		local fade = (Distance - (y - (height-Distance))) / Distance
		for x = 1,width do
			Heightmap[x][y] = Heightmap[x][y] * fade
		end
	end
end

return module
