Monday 12 May 2014

FontManager, small API change

Well, I don't like changing the API of something that's been released, but in this case it's necessary.  It  only affects the call to the modifiers and I suspect no-one other than me has written one yet.

It was a bad call in the first place anyway - in the modifier calls, the parameters are normal parameters, but in the extensions I have in my head it would end up with ten of them :(

What I have changed is the signature of the modifier, rather than providing the information as a parameter e.g.

function pulser(modifier, cPos, elapsed, index, length)

it passes everything except the first two as a table

function pulser(modifier, cPos, info)

the names are the same, so to use it in modifiers all you need to do is add "info." before elapsed, index and length so this:

function pulser(modifier, cPos, elapsed, index, length)
local w = math.floor(elapsed/250) % length + 1
if info.index == w then  
local newScale = 1 + (elapsed % 250) / 250
modifier.xScale,modifier.yScale = newScale,newScale
end
end

becomes this:

function pulser(modifier, cPos, info)
local w = math.floor(info.elapsed/250) % info.length + 1
if info.index == w then  
local newScale = 1 + (info.elapsed % 250) / 250
modifier.xScale,modifier.yScale = newScale,newScale
end
end

internally there is a bit of reengineering to support some new features, but externally this is the only change.

Sorry ! It shouldn't happen again.

No comments:

Post a Comment