In an effort to make the background of my application more engaging and dynamic, yet subtle, I was playing around with tinting to great a fading effect. The idea is to have the subtle changes in color of the background texture i’m using, to give the user a more dynamic impression. Apps that come to mind are Nodebeat, bloom, and such. Below is, albeit sloppy, my execution thus far. Any ideas regarding how to accomplish this “dynamic” user experience?
The function is called on an enterframe listener.
[lua]function bkgTinting()
local normFactor = (enso.context.frameCount)/(enso.context.frameCountConstant)
local totalCount = (enso.context.totalFrameCount)/(enso.context.frameCountConstant)
–if normFactor >= 1 then
– normFactor = .99
– enso.context.frameCount = 1
–end
–if normFactor <= .08 then
– normFactor = .1
–end
if totalCount < 1 then
local diff = {r = enso.context.fillOne[‘r’]-enso.context.fillInitial[‘r’],
g = enso.context.fillOne[‘g’]-enso.context.fillInitial[‘g’],
b = enso.context.fillOne[‘b’]-enso.context.fillInitial[‘b’]}
enso.bkg:setFillColor(enso.context.fillInitial[‘r’] + normFactor * diff[‘r’], enso.context.fillInitial[‘g’] + normFactor * diff[‘g’], enso.context.fillInitial[‘b’] + normFactor * diff[‘b’])
enso.bkg:toBack()
elseif totalCount > 1 and totalCount <2 then
local diff = {r = enso.context.fillTwo[‘r’]-enso.context.fillOne[‘r’],
g = enso.context.fillTwo[‘g’]-enso.context.fillOne[‘g’],
b = enso.context.fillTwo[‘b’]-enso.context.fillOne[‘b’]}
enso.bkg:setFillColor(enso.context.fillOne[‘r’] + normFactor * diff[‘r’], enso.context.fillOne[‘g’] + normFactor * diff[‘g’], enso.context.fillOne[‘b’] + normFactor * diff[‘b’])
enso.bkg:toBack()
elseif totalCount > 2 and totalCount <3 then
local diff = {r = enso.context.fillThree[‘r’]-enso.context.fillTwo[‘r’],
g = enso.context.fillThree[‘g’]-enso.context.fillTwo[‘g’],
b = enso.context.fillThree[‘b’]-enso.context.fillTwo[‘b’]}
enso.bkg:setFillColor(enso.context.fillTwo[‘r’] + normFactor * diff[‘r’], enso.context.fillTwo[‘g’] + normFactor * diff[‘g’], enso.context.fillTwo[‘b’] + normFactor * diff[‘b’])
enso.bkg:toBack()
elseif totalCount > 3 and totalCount <4 then
local diff = {r = enso.context.fillFour[‘r’]-enso.context.fillThree[‘r’],
g = enso.context.fillFour[‘g’]-enso.context.fillThree[‘g’],
b = enso.context.fillFour[‘b’]-enso.context.fillThree[‘b’]}
enso.bkg:setFillColor(enso.context.fillThree[‘r’] + normFactor * diff[‘r’], enso.context.fillThree[‘g’] + normFactor * diff[‘g’], enso.context.fillThree[‘b’] + normFactor * diff[‘b’])
enso.bkg:toBack()
elseif totalCount > 4 and totalCount <5 then
local diff = {r = enso.context.fillFive[‘r’]-enso.context.fillFour[‘r’],
g = enso.context.fillFive[‘g’]-enso.context.fillFour[‘g’],
b = enso.context.fillFive[‘b’]-enso.context.fillFour[‘b’]}
enso.bkg:setFillColor(enso.context.fillFour[‘r’] + normFactor * diff[‘r’], enso.context.fillFour[‘g’] + normFactor * diff[‘g’], enso.context.fillFour[‘b’] + normFactor * diff[‘b’])
enso.bkg:toBack()
end
print(normFactor)
enso.bkg:toBack()
enso.context.frameCount = enso.context.frameCount + 1
enso.context.totalFrameCount = enso.context.totalFrameCount +1
end [import]uid: 13050 topic_id: 17749 reply_id: 317749[/import]