Ah, now I get it. Yes, you're absolutely right.
It is currently March 28th, 2024, 9:23 am
fading trough 3 colors... how to do it?
- Yincognito
- Rainmeter Sage
- Posts: 7017
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
- balala
- Rainmeter Sage
- Posts: 16109
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: fading trough 3 colors... how to do it?
Here is the promissed code. This time zou don!t have to use -1 for the components of the not used colors, all those components can be left empty (in the posted code the components of colors from 6 to 10 are left so).
Unfortunately I added even more measures (replaced the [MeasureColorX] measures with [MeasureColorXRed], [MeasureColorXGreen] and [MeasureColorXBlue]).
Please let me know your opinion.
Code: Select all
[Rainmeter]
Update=1000
[Variables]
R1=198
G1=251
B1=200
R2=196
G2=92
B2=38
R3=14
G3=175
B3=67
R4=19
G4=196
B4=118
R5=58
G5=95
B5=5
R6=
G6=
B6=
R7=
G7=
B7=
R8=
G8=
B8=
R9=
G9=
B9=
R10=
G10=
B10=
Range=0
[MeasureColor3Red]
Measure=String
String=#R3#
IfMatch=^$|^-1$|#*R3*#
IfMatchAction=[!SetVariable Color3R "0"][!SetVariable R3 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color3R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor3Green]
Measure=String
String=#G3#
IfMatch=^$|^-1$|#*G3*#
IfMatchAction=[!SetVariable Color3G "0"][!SetVariable G3 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color3G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor3Blue]
Measure=String
String=#B3#
IfMatch=^$|^-1$|#*B3*#
IfMatchAction=[!SetVariable Color3B "0"][!SetVariable B3 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color3B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor4Red]
Measure=String
String=#R4#
IfMatch=^$|^-1$|#*R4*#
IfMatchAction=[!SetVariable Color4R "0"][!SetVariable R4 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color4R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor4Green]
Measure=String
String=#G4#
IfMatch=^$|^-1$|#*G4*#
IfMatchAction=[!SetVariable Color4G "0"][!SetVariable G4 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color4G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor4Blue]
Measure=String
String=#B4#
IfMatch=^$|^-1$|#*B4*#
IfMatchAction=[!SetVariable Color4B "0"][!SetVariable B4 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color4B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor5Red]
Measure=String
String=#R5#
IfMatch=^$|^-1$|#*R5*#
IfMatchAction=[!SetVariable Color5R "0"][!SetVariable R5 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color5R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor5Green]
Measure=String
String=#G5#
IfMatch=^$|^-1$|#*G5*#
IfMatchAction=[!SetVariable Color5G "0"][!SetVariable G5 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color5G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor5Blue]
Measure=String
String=#B5#
IfMatch=^$|^-1$|#*B5*#
IfMatchAction=[!SetVariable Color5B "0"][!SetVariable B5 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color5B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor6Red]
Measure=String
String=#R6#
IfMatch=^$|^-1$|#*R6*#
IfMatchAction=[!SetVariable Color6R "0"][!SetVariable R6 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color6R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor6Green]
Measure=String
String=#G6#
IfMatch=^$|^-1$|#*G6*#
IfMatchAction=[!SetVariable Color6G "0"][!SetVariable G6 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color6G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor6Blue]
Measure=String
String=#B6#
IfMatch=^$|^-1$|#*B6*#
IfMatchAction=[!SetVariable Color6B "0"][!SetVariable B6 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color6B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor7Red]
Measure=String
String=#R7#
IfMatch=^$|^-1$|#*R7*#
IfMatchAction=[!SetVariable Color7R "0"][!SetVariable R7 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color7R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor7Green]
Measure=String
String=#G7#
IfMatch=^$|^-1$|#*G7*#
IfMatchAction=[!SetVariable Color7G "0"][!SetVariable G7 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color7G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor7Blue]
Measure=String
String=#B7#
IfMatch=^$|^-1$|#*B7*#
IfMatchAction=[!SetVariable Color7B "0"][!SetVariable B7 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color7B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor8Red]
Measure=String
String=#R8#
IfMatch=^$|^-1$|#*R8*#
IfMatchAction=[!SetVariable Color8R "0"][!SetVariable R8 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color8R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor8Green]
Measure=String
String=#G8#
IfMatch=^$|^-1$|#*G8*#
IfMatchAction=[!SetVariable Color8G "0"][!SetVariable G8 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color8G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor8Blue]
Measure=String
String=#B8#
IfMatch=^$|^-1$|#*B8*#
IfMatchAction=[!SetVariable Color8B "0"][!SetVariable B8 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color8B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor9Red]
Measure=String
String=#R9#
IfMatch=^$|^-1$|#*R9*#
IfMatchAction=[!SetVariable Color9R "0"][!SetVariable R9 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color9R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor9Green]
Measure=String
String=#G9#
IfMatch=^$|^-1$|#*G9*#
IfMatchAction=[!SetVariable Color9G "0"][!SetVariable G9 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color9G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor9Blue]
Measure=String
String=#B9#
IfMatch=^$|^-1$|#*B9*#
IfMatchAction=[!SetVariable Color9B "0"][!SetVariable B9 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color9B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor10Red]
Measure=String
String=#R10#
IfMatch=^$|^-1$|#*R10*#
IfMatchAction=[!SetVariable Color10R "0"][!SetVariable R10 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color10R "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor10Green]
Measure=String
String=#G10#
IfMatch=^$|^-1$|#*G10*#
IfMatchAction=[!SetVariable Color10G "0"][!SetVariable G10 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color10G "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureColor10Blue]
Measure=String
String=#B10#
IfMatch=^$|^-1$|#*B10*#
IfMatchAction=[!SetVariable Color10B "0"][!SetVariable B10 "-1"][!UpdateMeasure "MeasureNumOfColors"]
IfNotMatchAction=[!SetVariable Color10B "1"][!UpdateMeasure "MeasureNumOfColors"]
UpdateDivider=-1
[MeasureNumOfColors]
Measure=Calc
Formula=( Floor (( 6 + #Color3R# + #Color3G# + #Color3B# + #Color4R# + #Color4G# + #Color4B# + #Color5R# + #Color5G# + #Color5B# + #Color6R# + #Color6G# + #Color6B# + #Color7R# + #Color7G# + #Color7B# + #Color8R# + #Color8G# + #Color8B# + #Color9R# + #Color9G# + #Color9B# + #Color10R# + #Color10G# + #Color10B# ) / 3 ))
DynamicVariables=1
UpdateDivider=-1
[MeterColor]
Meter=Image
SolidColor=(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#R1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#R2#-#R1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#R2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R3#-#R2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#R3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R4#-#R3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#R4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R5#-#R4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#R5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R6#-#R5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#R6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R7#-#R6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#R7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R8#-#R7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#R8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R9#-#R8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#R9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R10#-#R9#)))),(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#G1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#G2#-#G1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#G2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G3#-#G2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#G3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G4#-#G3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#G4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G5#-#G4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#G5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G6#-#G5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#G6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G7#-#G6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#G7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G8#-#G7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#G8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G9#-#G8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#G9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G10#-#G9#)))),(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#B1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#B2#-#B1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#B2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B3#-#B2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#B3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B4#-#B3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#B4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B5#-#B4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#B5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B6#-#B5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#B6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B7#-#B6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#B7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B8#-#B7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#B8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B9#-#B8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#B9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B10#-#B9#))))
X=0
Y=0
W=100
H=50
DynamicVariables=1
MouseScrollDownAction=[!SetVariable Range "(Clamp((#Range#-1),0,100))"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
MouseScrollUpAction=[!SetVariable Range "(Clamp((#Range#+1),0,100))"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
- eclectic-tech
- Rainmeter Sage
- Posts: 5380
- Joined: April 12th, 2012, 9:40 pm
- Location: Cedar Point, Ohio, USA
- Contact:
Re: fading trough 3 colors... how to do it?
It's great to code as much as possible in native Rainmeter when it is practical.
But I think the Blend Color script is the easiest way to control blending colors, and controlling transparency, using a single measure. Lua and Rainmeter work very well together and this script provides maximum flexibility in controlling RGB color blending, and transparencies as a bonus.
But I think the Blend Color script is the easiest way to control blending colors, and controlling transparency, using a single measure. Lua and Rainmeter work very well together and this script provides maximum flexibility in controlling RGB color blending, and transparencies as a bonus.
- jsmorley
- Developer
- Posts: 22628
- Joined: April 19th, 2009, 11:02 pm
- Location: Fort Hunt, Virginia, USA
Re: fading trough 3 colors... how to do it?
Aside from the color, or "hue", the HSLib.lua library can also mess with "saturation" and "brightness" in some useful ways.
- Yincognito
- Rainmeter Sage
- Posts: 7017
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: fading trough 3 colors... how to do it?
Mine is just 1 measure more... Not my fault though: Rainmeter doesn't update variables in the same option (or measure, for that matter) they were changed, so...eclectic-tech wrote: ↑August 8th, 2020, 7:48 pm It's great to code as much as possible in native Rainmeter when it is practical.
But I think the Blend Color script is the easiest way to control blending colors, and controlling transparency, using a single measure.
blendcolor.gif
Lua and Rainmeter work very well together and this script provides maximum flexibility in controlling RGB color blending, and transparencies as a bonus.
Other than that, the Lua variant may be a single measure ... in Rainmeter, but an equal or greater amount of code is written in the Lua script, something that is easily forgotten. The benefits are of course, that the script is already written, other handy functions are already there, you don't have to reinvent the wheel and all that, but assuming one starts at 0 it's more or less the same amount of work (and I'm being nice on this assessment, considering that Lua presents its own challenges for someone who knows only native Rainmeter).
Bottom line, in my view the complexity (even the practicality, in some cases) is similar, the only thing that tips the balance in favor of one variant or another is whether the script or native code is already written by someone else...
That being said, I wonder why didn't Rainmeter use Lua (or Javascript, or Python, etc.) written code from the start? It's a bit problematic to have these folks all write in native Rainmeter, then tell them "you know, a Lua variant is easier and it works very well with Rainmeter, try that". I mean, they already had to learn native code and all, in most cases even that code still presents challenges for them, throwing Lua at them is going to work fine if it's just a simple script doing X and Y that doesn't need adjustments, but what if that script needs such adjustments, what then? I'm not contesting the easiness of an already made script in Lua, I'm just try to put myself in the shoes of someone who needs to do something in Rainmeter and doesn't have either the native code nor the Lua equivalent yet - which variant is easier and more practical then?
Re: fading trough 3 colors... how to do it?
Hi eclectic-techeclectic-tech wrote: ↑August 8th, 2020, 7:48 pm It's great to code as much as possible in native Rainmeter when it is practical.
But I think the Blend Color script is the easiest way to control blending colors, and controlling transparency, using a single measure.
blendcolor.gif
Lua and Rainmeter work very well together and this script provides maximum flexibility in controlling RGB color blending, and transparencies as a bonus.
I'm trying to use the BlendColor script here:
Code: Select all
[Volume]
Measure=Plugin
Plugin=Win7AudioPlugin
[VolumeCalc]
Measure=Calc
Formula=Volume
MinValue=0
MaxValue=100
IfCondition=VolumeCalc <= 0
IfTrueAction=[#SO# VolIcon Text #T7#][#SO# VolIcon Padding 0,0,0,0]#U5#
IfCondition2=(VolumeCalc > 0) && (VolumeCalc <= 50)
IfTrueAction2=[#SO# VolIcon Text #T8#][#SO# VolIcon Padding -2,0,0,0]#U5#
IfCondition3=(VolumeCalc > 50)
IfTrueAction3=[#SO# VolIcon Text #T9#][#SO# VolIcon Padding 0,0,0,0]#U5#
[ExampleColorMeasure]
Measure=Script
ScriptFile=#@#BlendColor.lua
MeasureToBlend=VolumeCalc
RedScale=0,50,255,46|50,100,46,255
GreenScale=0,50,198,233|50,100,233,62
BlueScale=0,50,33,164|50,100,164,154
AlphaScale=0,100,220,220
[VolumeText]
Meter=String
MeterStyle=TextStyle
Text=VOL
[VolIcon]
Meter=String
MeterStyle=Lock
FontColor=[&ExampleColorMeasure]
DynamicVariables=1
I'm getting the following errors:
Script: BlendColor.lua:124: 'end' expected (to close 'function' at line 1) near '<eof>' and
Script: File not valid (Gruvy\KBD\KBD.ini - [ExampleColorMeasure])
Any suggestion?
Thanks in advance!
Re: fading trough 3 colors... how to do it?
Analized my copy of BlendColor.lua and discover at the very beginning of the file (line 1) a function Initialize() that was not commented; so i did change it in --function Initialize() (I guess I may just erase the line...) and the first error is fixed.
Now though I'm getting this:
Script: BlendColor.lua:47: attempt to index local 'inputMeter' (a nil value)
Please bear in mind this LuaKnowledge=0 on my side...
- Yincognito
- Rainmeter Sage
- Posts: 7017
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: fading trough 3 colors... how to do it?
Until eclectic-tech or jsmorley help you with the Lua variant, I know you try all the options and all, but just wanted to make sure: you did manage to integrate my variant into your volume code when you tried it, didn't you? Cause I never asked...
I think you should let that line there, as it belongs to a function. You should double check if you copied the script accordingly from eclectic-tech's post (don't mess with the encoding of the file, by the way, just paste in bare Notepad), because I tried his code again, this time in my @Resources folder and it works without issues.brax64 wrote: ↑August 9th, 2020, 12:04 am
Analized my copy of BlendColor.lua and discover at the very beginning of the file (line 1) a function Initialize() that was not commented; so i did change it in --function Initialize() (I guess I may just erase the line...) and the first error is fixed.
Now though I'm getting this:
Script: BlendColor.lua:47: attempt to index local 'inputMeter' (a nil value)
Apart from the fact that I'm not sure this is a problem with the code posted by eclectic-tech, this only confirms what I talked about earlier: when the Lua code needs to be adjusted (not sure it's the case here, but for the sake of the argument), the "practical" and "easy" Lua solution suddenly becomes a bit different for the regular user, unlike a native code one, where it is assumed the user knows more or less how to deal with it.
Re: fading trough 3 colors... how to do it?
My Apologies,
fixed the whole thing; made a mistake changing MeasureToBlend=VolumeCalc to MeasureToBlend=[VolumeCalc]
while trying to debug, set back again MeasureToBlend=VolumeCalc now everything's working fine.
Please disregards my last 2 post...
fixed the whole thing; made a mistake changing MeasureToBlend=VolumeCalc to MeasureToBlend=[VolumeCalc]
while trying to debug, set back again MeasureToBlend=VolumeCalc now everything's working fine.
Please disregards my last 2 post...
- Yincognito
- Rainmeter Sage
- Posts: 7017
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: fading trough 3 colors... how to do it?
Why not trying to add colors into a string, like "255,0,0;0,255,0;0,0,255;..." and validate the colors or find their number based on that? I mean, I know it involves a bit of regex (or a bit more, LOL), but it would help avoid creating so many measures and allow you to do this in one or two measures instead...balala wrote: ↑August 8th, 2020, 6:48 pm Here is the promissed code. This time zou don!t have to use -1 for the components of the not used colors, all those components can be left empty (in the posted code the components of colors from 6 to 10 are left so).
Unfortunately I added even more measures (replaced the [MeasureColorX] measures with [MeasureColorXRed], [MeasureColorXGreen] and [MeasureColorXBlue]).
Please let me know your opinion.Code: Select all
[Rainmeter] Update=1000 [Variables] R1=198 G1=251 B1=200 R2=196 G2=92 B2=38 R3=14 G3=175 B3=67 R4=19 G4=196 B4=118 R5=58 G5=95 B5=5 R6= G6= B6= R7= G7= B7= R8= G8= B8= R9= G9= B9= R10= G10= B10= Range=0 [MeasureColor3Red] Measure=String String=#R3# IfMatch=^$|^-1$|#*R3*# IfMatchAction=[!SetVariable Color3R "0"][!SetVariable R3 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color3R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor3Green] Measure=String String=#G3# IfMatch=^$|^-1$|#*G3*# IfMatchAction=[!SetVariable Color3G "0"][!SetVariable G3 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color3G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor3Blue] Measure=String String=#B3# IfMatch=^$|^-1$|#*B3*# IfMatchAction=[!SetVariable Color3B "0"][!SetVariable B3 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color3B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor4Red] Measure=String String=#R4# IfMatch=^$|^-1$|#*R4*# IfMatchAction=[!SetVariable Color4R "0"][!SetVariable R4 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color4R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor4Green] Measure=String String=#G4# IfMatch=^$|^-1$|#*G4*# IfMatchAction=[!SetVariable Color4G "0"][!SetVariable G4 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color4G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor4Blue] Measure=String String=#B4# IfMatch=^$|^-1$|#*B4*# IfMatchAction=[!SetVariable Color4B "0"][!SetVariable B4 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color4B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor5Red] Measure=String String=#R5# IfMatch=^$|^-1$|#*R5*# IfMatchAction=[!SetVariable Color5R "0"][!SetVariable R5 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color5R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor5Green] Measure=String String=#G5# IfMatch=^$|^-1$|#*G5*# IfMatchAction=[!SetVariable Color5G "0"][!SetVariable G5 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color5G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor5Blue] Measure=String String=#B5# IfMatch=^$|^-1$|#*B5*# IfMatchAction=[!SetVariable Color5B "0"][!SetVariable B5 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color5B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor6Red] Measure=String String=#R6# IfMatch=^$|^-1$|#*R6*# IfMatchAction=[!SetVariable Color6R "0"][!SetVariable R6 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color6R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor6Green] Measure=String String=#G6# IfMatch=^$|^-1$|#*G6*# IfMatchAction=[!SetVariable Color6G "0"][!SetVariable G6 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color6G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor6Blue] Measure=String String=#B6# IfMatch=^$|^-1$|#*B6*# IfMatchAction=[!SetVariable Color6B "0"][!SetVariable B6 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color6B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor7Red] Measure=String String=#R7# IfMatch=^$|^-1$|#*R7*# IfMatchAction=[!SetVariable Color7R "0"][!SetVariable R7 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color7R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor7Green] Measure=String String=#G7# IfMatch=^$|^-1$|#*G7*# IfMatchAction=[!SetVariable Color7G "0"][!SetVariable G7 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color7G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor7Blue] Measure=String String=#B7# IfMatch=^$|^-1$|#*B7*# IfMatchAction=[!SetVariable Color7B "0"][!SetVariable B7 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color7B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor8Red] Measure=String String=#R8# IfMatch=^$|^-1$|#*R8*# IfMatchAction=[!SetVariable Color8R "0"][!SetVariable R8 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color8R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor8Green] Measure=String String=#G8# IfMatch=^$|^-1$|#*G8*# IfMatchAction=[!SetVariable Color8G "0"][!SetVariable G8 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color8G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor8Blue] Measure=String String=#B8# IfMatch=^$|^-1$|#*B8*# IfMatchAction=[!SetVariable Color8B "0"][!SetVariable B8 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color8B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor9Red] Measure=String String=#R9# IfMatch=^$|^-1$|#*R9*# IfMatchAction=[!SetVariable Color9R "0"][!SetVariable R9 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color9R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor9Green] Measure=String String=#G9# IfMatch=^$|^-1$|#*G9*# IfMatchAction=[!SetVariable Color9G "0"][!SetVariable G9 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color9G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor9Blue] Measure=String String=#B9# IfMatch=^$|^-1$|#*B9*# IfMatchAction=[!SetVariable Color9B "0"][!SetVariable B9 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color9B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor10Red] Measure=String String=#R10# IfMatch=^$|^-1$|#*R10*# IfMatchAction=[!SetVariable Color10R "0"][!SetVariable R10 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color10R "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor10Green] Measure=String String=#G10# IfMatch=^$|^-1$|#*G10*# IfMatchAction=[!SetVariable Color10G "0"][!SetVariable G10 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color10G "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureColor10Blue] Measure=String String=#B10# IfMatch=^$|^-1$|#*B10*# IfMatchAction=[!SetVariable Color10B "0"][!SetVariable B10 "-1"][!UpdateMeasure "MeasureNumOfColors"] IfNotMatchAction=[!SetVariable Color10B "1"][!UpdateMeasure "MeasureNumOfColors"] UpdateDivider=-1 [MeasureNumOfColors] Measure=Calc Formula=( Floor (( 6 + #Color3R# + #Color3G# + #Color3B# + #Color4R# + #Color4G# + #Color4B# + #Color5R# + #Color5G# + #Color5B# + #Color6R# + #Color6G# + #Color6B# + #Color7R# + #Color7G# + #Color7B# + #Color8R# + #Color8G# + #Color8B# + #Color9R# + #Color9G# + #Color9B# + #Color10R# + #Color10G# + #Color10B# ) / 3 )) DynamicVariables=1 UpdateDivider=-1 [MeterColor] Meter=Image SolidColor=(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#R1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#R2#-#R1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#R2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R3#-#R2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#R3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R4#-#R3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#R4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R5#-#R4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#R5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R6#-#R5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#R6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R7#-#R6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#R7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R8#-#R7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#R8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R9#-#R8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#R9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#R10#-#R9#)))),(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#G1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#G2#-#G1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#G2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G3#-#G2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#G3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G4#-#G3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#G4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G5#-#G4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#G5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G6#-#G5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#G6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G7#-#G6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#G7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G8#-#G7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#G8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G9#-#G8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#G9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#G10#-#G9#)))),(((#Range#<=(100/([MeasureNumOfColors]-1)))*(#B1#+(#Range#/(100/([MeasureNumOfColors]-1)))*(#B2#-#B1#)))+(((#Range#>(100/([MeasureNumOfColors]-1)))&&(#Range#<=(200/([MeasureNumOfColors]-1))))*(#B2#+((#Range#-(100/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B3#-#B2#)))+(((#Range#>(200/([MeasureNumOfColors]-1)))&&(#Range#<=(300/([MeasureNumOfColors]-1))))*(#B3#+((#Range#-(200/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B4#-#B3#)))+(((#Range#>(300/([MeasureNumOfColors]-1)))&&(#Range#<=(400/([MeasureNumOfColors]-1))))*(#B4#+((#Range#-(300/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B5#-#B4#)))+(((#Range#>(400/([MeasureNumOfColors]-1)))&&(#Range#<=(500/([MeasureNumOfColors]-1))))*(#B5#+((#Range#-(400/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B6#-#B5#)))+(((#Range#>(500/([MeasureNumOfColors]-1)))&&(#Range#<=(600/([MeasureNumOfColors]-1))))*(#B6#+((#Range#-(500/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B7#-#B6#)))+(((#Range#>(600/([MeasureNumOfColors]-1)))&&(#Range#<=(700/([MeasureNumOfColors]-1))))*(#B7#+((#Range#-(600/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B8#-#B7#)))+(((#Range#>(700/([MeasureNumOfColors]-1)))&&(#Range#<=(800/([MeasureNumOfColors]-1))))*(#B8#+((#Range#-(700/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B9#-#B8#)))+(((#Range#>(800/([MeasureNumOfColors]-1)))&&(#Range#<=(900/([MeasureNumOfColors]-1))))*(#B9#+((#Range#-(800/([MeasureNumOfColors]-1)))/(100/([MeasureNumOfColors]-1)))*(#B10#-#B9#)))) X=0 Y=0 W=100 H=50 DynamicVariables=1 MouseScrollDownAction=[!SetVariable Range "(Clamp((#Range#-1),0,100))"][!UpdateMeter "#CURRENTSECTION#"][!Redraw] MouseScrollUpAction=[!SetVariable Range "(Clamp((#Range#+1),0,100))"][!UpdateMeter "#CURRENTSECTION#"][!Redraw]
By the way, such an approach is probably doable in my variant as well - I'll have to think whether to add it or not, since although it would turn the lines where I set the RGBA components in the [Variables] section into a single line, it would still need an additional measure (I care very much to have as few as possible).