I wrote the last days a little Lua script for me and maybe someone will find it useful.
INI
Code: Select all
[mColorSpectrum]
Measure=Script
ScriptFile=#@#Lua\ColorSpectrum.lua
Red=0
Green=255
Blue=0
Range=10
Direction=1
Code: Select all
function Initialize()
-- ColorSpectrum v1.1
Rorg = SELF:GetNumberOption('Red')
Gorg = SELF:GetNumberOption('Green')
Borg = SELF:GetNumberOption('Blue')
R = SELF:GetNumberOption('Red')
G = SELF:GetNumberOption('Green')
B = SELF:GetNumberOption('Blue')
Range = SELF:GetNumberOption('Range', 1)
Direction = SELF:GetNumberOption('Direction', 1)
c = 0
if R<=G and R<=B then Low=R -- set Low
elseif G<=R and G<=B then Low=G
elseif B<=R and B<=G then Low=B
end
if R>=G and R>=B then High=R -- set High
elseif G>=R and G>=B then High=G
elseif B>=R and B>=G then High=B
end
end
function Update()
c = c+Range
if Direction == 0 then -- 360 -> 0
if R==High and G==Low and B<High then B=Borg+c Rorg=High
elseif R>Low and G==Low and B==High then R=Rorg-c Gorg=Low
elseif R==Low and G<High and B==High then G=Gorg+c Borg=High
elseif R==Low and G==High and B>Low then B=Borg-c Rorg=Low
elseif R<High and G==High and B==Low then R=Rorg+c Gorg=High
elseif R==High and G>Low and B==Low then G=Gorg-c Borg=Low
else print('ColorSpectrum: StartColor is white/grey/black.')
end
elseif Direction == 1 then -- 0 -> 360
if R==High and G<High and B==Low then G=Gorg+c Rorg=High
elseif R>Low and G==High and B==Low then R=Rorg-c Borg=Low
elseif R==Low and G==High and B<High then B=Borg+c Gorg=High
elseif R==Low and G>Low and B==High then G=Gorg-c Rorg=Low
elseif R<High and G==Low and B==High then R=Rorg+c Borg=High
elseif R==High and G==Low and B>Low then B=Borg-c Gorg=Low
else print('ColorSpectrum: StartColor is white/grey/black.')
end
end
if R>High then R=High -- prevent the value to become lower/higher than Low/High
elseif G>High then G=High
elseif B>High then B=High
elseif R<Low then R=Low
elseif G<Low then G=Low
elseif B<Low then B=Low
end
if R==High and G==Low and B==Low then c=0 -- reset Counter
elseif R==High and G==Low and B==High then c=0
elseif R==Low and G==Low and B==High then c=0
elseif R==Low and G==High and B==High then c=0
elseif R==Low and G==High and B==Low then c=0
elseif R==High and G==High and B==Low then c=0
end
SKIN:Bang('!SetVariable', 'Red', R)
SKIN:Bang('!SetVariable', 'Green', G)
SKIN:Bang('!SetVariable', 'Blue', B)
SKIN:Bang('!SetVariable', 'RGB', R..','..G..','..B)
end
And with "Range" you can set the change per script update (If no Range is set, then Range is 1)
The script creates the following Variables:
- Red (The red value of the color)
- Green (The green value of the color)
- Blue (The blue value of the color)
- RGB (The complete color)
Example: