I'd be tempted
not to have to create three string measures, and have to do that for every color I might want to split that way. I'd lean toward a simple Lua function, that would only be one extra measure, and would be usable in any number of places.
Skin:
Code: Select all
[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1
[Variables]
BGColor1=255,100,155
[Lua]
Measure=Script
ScriptFile=SplitColor.lua
Disabled=1
[MeterRed]
Meter=String
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=#BGColor1#
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=Red is: [Lua:SplitColor('#BGColor1#', 'Red')]
[MeterGreen]
Meter=String
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=#BGColor1#
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=Green is: [Lua:SplitColor('#BGColor1#', 'Green')]
[MeterBlue]
Meter=String
Y=5R
FontSize=11
FontWeight=400
FontColor=255,255,255,255
SolidColor=#BGColor1#
Padding=5,5,5,5
AntiAlias=1
DynamicVariables=1
Text=Blue is: [Lua:SplitColor('#BGColor1#', 'Blue')]
SplitColor.lua:
Code: Select all
function SplitColor(colorArg, componentArg)
if string.upper(componentArg) == 'RED' then
return string.match(colorArg, '^([%d]+)')
elseif string.upper(componentArg) == 'GREEN' then
return string.match(colorArg, '^[%d]+,([%d]+)')
elseif string.upper(componentArg) == 'BLUE' then
return string.match(colorArg, '^[%d]+,[%d]+,([%d]+)')
end
end
1.jpg
This is by its nature dynamic if the desired color code variable changes, and is only updated when the meter(s) is updated, not requiring separate updates of any other measure(s). In fact, as you might note, the [Lau] measure is disabled, as there is no need to ever update it. It is simply a static "host" for the SplitColor() function, which is called on demand.
I would note that while pattern matching in Lua is very similar to PCRE in regular expression, it is not identical, and there are some differences in syntax that need to be considered.
Glad to explain the string.match function or Inline Lua if you need help.
You do not have the required permissions to view the files attached to this post.