44 lines
932 B
Lua
44 lines
932 B
Lua
-- Global config table
|
|
Config = {
|
|
-- Radius of each grid point
|
|
pointRadius = 7,
|
|
-- Radius of line start/end point
|
|
linePointRadius = 10,
|
|
-- Size of each grid cell
|
|
cellSize = 30,
|
|
|
|
-- love2d line drawing settings
|
|
lineStyle = "smooth",
|
|
lineWidth = 5,
|
|
|
|
-- drag sensivity, px
|
|
dragSensivity = 5
|
|
}
|
|
|
|
-- Colors table
|
|
Color = {
|
|
white = { 1, 1, 1 },
|
|
red = { 1, 0, 0 },
|
|
green = { 0, 1, 0 },
|
|
blue = { 0, 0, 1 }
|
|
}
|
|
|
|
-- Find key by value in table by predicate
|
|
function tableFind( table, value, pred )
|
|
for key, innervalue in pairs( table ) do
|
|
if pred( value, innervalue ) then
|
|
return key
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
|
|
-- Find if value exists in table by predicate
|
|
function tableHas( table, value, pred )
|
|
for key, innervalue in pairs( table ) do
|
|
if pred( value, innervalue ) then
|
|
return true
|
|
end
|
|
end
|
|
return false
|
|
end
|