cached library functions in local vars

This commit is contained in:
Ulrich Schmidt 2016-11-06 09:10:10 +01:00
parent 6286203075
commit aad95de809
5 changed files with 26 additions and 21 deletions

View file

@ -1,4 +1,5 @@
-- This file is part of SUIT, copyright (c) 2016 Matthias Richter
local floor = math.floor;
local BASE = (...):match('(.-)[^%.]+$')
@ -13,7 +14,7 @@ return function(core, normal, ...)
opt.state = core:registerMouseHit(opt.id, x,y, function(u,v)
local id = opt.normal:getData()
assert(id:typeOf("ImageData"), "Can only use uncompressed images")
u, v = math.floor(u+.5), math.floor(v+.5)
u, v = floor(u+.5), floor(v+.5)
if u < 0 or u >= opt.normal:getWidth() or v < 0 or v >= opt.normal:getHeight() then
return false
end