feat(cbs/utils): add a way to automatically get a map from a mask

This commit is contained in:
Kazhnuz 2019-08-22 22:04:38 +02:00
parent 24b26cc9fc
commit a1d0cd0225

View file

@ -67,6 +67,23 @@ function maputils.isInMask(x, y, ox, oy, shape, size, direction)
end
end
function maputils.maskToMap(ox, oy, shape, size, direction)
local map = maputils.newEmptyMap()
for i, line in ipairs(map) do
for j, case in ipairs(line) do
local isInMask = maputils.isInMask(j, i, ox, oy, shape, size, direction)
if (isInMask) then
map[i][j] = 1
else
map[i][j] = 0
end
end
end
return map
end
function maputils.gridToPixel(x, y, center)
local pixelx, pixely
local center = center or false