feat(cbs/utils): add a way to automatically get a map from a mask
This commit is contained in:
parent
24b26cc9fc
commit
a1d0cd0225
1 changed files with 17 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue