-- ColorChanger v1.3 by Smurfier (smurfier20@gmail.com)
-- This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License.
PROPERTIES={Colors='';MeasureName='';MinimumValue=0;MaximumValue=1;}
function Initialize()
MinValue,Colors,Measure=tonumber(PROPERTIES.MinimumValue),{},SKIN:GetMeasure(PROPERTIES.MeasureName)
for a=1,4 do Colors[a]={} end
if string.len(PROPERTIES.Colors)==0 or not string.match(PROPERTIES.Colors,'%d+%s-,%s-%d+%s-,%s-%d+') then
print('ColorChanger: Invalid color string')
elseif not Measure then
print('ColorChanger: Cannot retrieve Measure '..PROPERTIES.MeasureName)
else
for a in string.gmatch(PROPERTIES.Colors,'[^%|]+') do
local b={}
for c in string.gmatch(a,'[^,]+') do table.insert(b,tonumber(c)) end
for d=1,4 do table.insert(Colors[d],b[d] and b[d] or 255) end
end
Divider=math.ceil((tonumber(PROPERTIES.MaximumValue)-MinValue)/(#Colors[1]-1))
end
end
function Update()
if #Colors[1]<2 or not Measure then
return #Colors[1]==1 and string.gsub(PROPERTIES.Colors,'|','') or '255,255,255,255'
else
local rValue,uColor=Measure:GetValue()-MinValue,{}
Num=math.floor(rValue/Divider)
for i=1,4 do table.insert(uColor,Average(Colors[i][Num+1],Colors[i][Num+2],rValue%Divider,Divider)) end
return table.concat(uColor,',')
end
end
function Average(a,b,c,d) return (a*(d-c)+(b and b or 0)*c)/d end
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .
Hello! I found this today and want to use it for my desktop. There are 2 issues one of which i have fixed but the other is the speed in which the color change happens. Is there a way to speed up the change of colors? right now it changes colors once per second. but i would like it to change 10 colors per sec.
BTW the issue I fixed was the color would stop at bright blue and switch to red without the purple.
I would caution that setting a skin to Update=16 (which is the lowest effective value) will cause it to use a lot of CPU depending on what you are doing in the skin.
I would be very hesitant to have a skin that has more than a meter or two and uses a Calc measure in a counter-loop and runs a Lua script every 16 milliseconds that changes a color. Just a word to the wise... At a minimum, if you have other measures in the skin, be sure to put an UpdateDivider on them so they are not all hammering the system every 16 milliseconds.
I wanted it around 200-300 so 16 isnt going to be an issue but now I have to figure out how to incorporate it in my current setup. I'm attempting to setup a color changing audio visualizer. I'm using Lano visualizer currently and just playing around with it.