I know the Convert Colors section of the Rainmeter Snippets gives a way to do this conversion, but that is done with a small lua script. My solution avoids this, the conversion being done with Rainmeter code, without using a lua script.
If you want to try the code, you have to enter the color code which will be converted, as the DecColor variable. You can use either a code with, or one without Alpha component (so with three or with four components). The result will be accordingly, containing six or eight digits.
Is this code useful for you? Does it works well? Any comment would be welcomed.
Thanks.
The code:
Code: Select all
[Rainmeter]
Update=-1
BackgroundMode=2
SolidColor=0,0,0,1
[Variables]
DecColor=244,5,136,152
[MeasureComponents]
Measure=String
String=#DecColor#
RegExpSubstitute=1
Substitute="^(.*),(.*),(.*),(.*)$":"1","^(.*),(.*),(.*)$":"0"
IfCondition=([#CURRENTSECTION#]=0)
IfTrueAction=[!SetOption MeasureDigits String "[*MeasureDigitRed1*][*MeasureDigitRed2*][*MeasureDigitGreen1*][*MeasureDigitGreen2*][*MeasureDigitBlue1*][*MeasureDigitBlue2*]"][!UpdateMeasure "MeasureDigits"][!UpdateMeter "MeterColor"][!Redraw]
IfFalseAction=[!SetOption MeasureDigits String "[*MeasureDigitRed1*][*MeasureDigitRed2*][*MeasureDigitGreen1*][*MeasureDigitGreen2*][*MeasureDigitBlue1*][*MeasureDigitBlue2*][*MeasureDigitAlpha1*][*MeasureDigitAlpha2*]"][!UpdateMeasure "MeasureDigits"][!UpdateMeter "MeterColor"][!Redraw]
DynamicVariables=1
[MeasureRed]
Measure=String
String=#DecColor#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1","^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1"
Group=ColorComponents
[MeasureGreen]
Measure=String
String=#DecColor#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2","^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2"
Group=ColorComponents
[MeasureBlue]
Measure=String
String=#DecColor#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3","^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3"
Group=ColorComponents
[MeasureAlpha]
Measure=String
String=#DecColor#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"0","^(\d{1,3}),(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\4"
Group=ColorComponents
[MeasureDigitRed2]
Measure=Calc
Formula=( [MeasureRed] % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Digits
[MeasureDigitRed1]
Measure=Calc
Formula=(( Floor ( [MeasureRed] / 16 )) % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Digits
[MeasureDigitGreen2]
Measure=Calc
Formula=( [MeasureGreen] % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Digits
[MeasureDigitGreen1]
Measure=Calc
Formula=(( Floor ( [MeasureGreen] / 16 )) % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Digits
[MeasureDigitBlue2]
Measure=Calc
Formula=( [MeasureBlue] % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Digits
[MeasureDigitBlue1]
Measure=Calc
Formula=(( Floor ( [MeasureBlue] / 16 )) % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Digits
[MeasureDigitAlpha2]
Measure=Calc
Formula=( [MeasureAlpha] % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Alpha
[MeasureDigitAlpha1]
Measure=Calc
Formula=(( Floor ( [MeasureAlpha] / 16 )) % 16 )
RegExpSubstitute=1
Substitute="^10$":"A","^11$":"B","^12$":"C","^13$":"D","^14$":"E","^15$":"F"
DynamicVariables=1
Group=Alpha
[MeasureDigits]
Measure=String
DynamicVariables=1
Group=Digits
[MeterColor]
Meter=STRING
MeasureName=MeasureDigits
X=0
Y=0
Padding=15,5,15,5
FontColor=#DecColor#
SolidColor=0,0,0,120
FontSize=18
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=RGB: #DecColor##CRLF#Hexa: %1
DynamicVariables=1