Sorry, you're totally right about the err, if item doesn't have a getBBox function.bartbes wrote: Well that won't work. Let's see, if an item doesn't have a getBBox function, it will error, not just that, if it does, only the first return value will get used, and the rest will be item.t, w and h.
The correct version will be:
Code: Select all
-- (Overridable) Given an item, return its bounding box (l,t,w,h)
function bump.getBBox(item)
return item.getBBox and (item:getBBox()) or item.l, item.t, item.w, item.h
end
Code: Select all
-- if the new bounding box is different from the stored one
local l,t,w,h = bump.getBBox(item)