Skip to content

Instantly share code, notes, and snippets.

@nefftd
Created March 23, 2015 19:35
Show Gist options
  • Save nefftd/9214509cf3d9a1a9b2a6 to your computer and use it in GitHub Desktop.
Save nefftd/9214509cf3d9a1a9b2a6 to your computer and use it in GitHub Desktop.
-- General helpers
function mod.guard(val) -- Bounds val [0,1] and NaN->0
mod:argcheck(val,1,'number')
if val < 0 or val ~= val then val = 0
elseif val > 1 then val = 1 end
return val
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment