I have created a configuration skin that allows you to change the colours of another skin, and I want to add RGB4.exe plus an InputText field where you can input either the RGB or HEX colour. What I would love and appreciate is if it were possible to add a bang that detects the colour model of a variable and converts it to the opposite, and vice versa.
e.g: MainColour=140,160,200 turns into MainColour=#8ca0c8 or the other way round!
Hope this is possible without having to implement a third-party application...
It is currently April 27th, 2024, 10:56 am
[Feature] RGB to HEX and vice versa!
-
- Posts: 26
- Joined: September 17th, 2014, 8:47 pm
-
- Rainmeter Sage
- Posts: 16176
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: [Feature] RGB to HEX and vice versa!
It is. You don't even have to use a lua code, just simple Rainmeter measures.DeathByChocolate wrote:I have created a configuration skin that allows you to change the colours of another skin, and I want to add RGB4.exe plus an InputText field where you can input either the RGB or HEX colour. What I would love and appreciate is if it were possible to add a bang that detects the colour model of a variable and converts it to the opposite, and vice versa.
e.g: MainColour=140,160,200 turns into MainColour=#8ca0c8 or the other way round!
Hope this is possible without having to implement a third-party application...
This first code converts an RGB code to HEX:
Code: Select all
[Rainmeter]
Update=-1
AccurateText=1
DynamicWindowSize=1
[Variables]
ColorCode=140,160,200
[MeasureR]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1"
[MeasureG]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2"
[MeasureB]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3"
[MeasureRemainderR1]
Measure=Calc
Formula=( [MeasureR] % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureQuotientR1]
Measure=Calc
Formula=(( [MeasureR] - MeasureRemainderR1 ) / 16 )
[MeasureRemainderR2]
Measure=Calc
Formula=( MeasureQuotientR1 % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureRemainderG1]
Measure=Calc
Formula=( [MeasureG] % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureQuotientG1]
Measure=Calc
Formula=(( [MeasureG] - MeasureRemainderG1 ) / 16 )
[MeasureRemainderG2]
Measure=Calc
Formula=( MeasureQuotientG1 % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureRemainderB1]
Measure=Calc
Formula=( [MeasureB] % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureQuotientB1]
Measure=Calc
Formula=(( [MeasureB] - MeasureRemainderB1 ) / 16 )
[MeasureRemainderB2]
Measure=Calc
Formula=( MeasureQuotientB1 % 16 )
Substitute="10":"a","11":"b","12":"c","13":"d","14":"e","15":"f"
[MeasureConverted]
Measure=String
String=#[MeasureRemainderR2][MeasureRemainderR1][MeasureRemainderG2][MeasureRemainderG1][MeasureRemainderB2][MeasureRemainderB1]
DynamicVariables=1
[MeterCode]
Meter=STRING
MeasureName=MeasureConverted
X=0
Y=0
FontColor=220,220,220
SolidColor=0,0,0
FontSize=12
Padding=25,5,25,5
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=RGB: #ColorCode##CRLF#HEX: %1
Code: Select all
[Rainmeter]
Update=-1
AccurateText=1
DynamicWindowSize=1
[Variables]
ColorCode=#8ca0c8
[MeasureR1]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\1","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureR2]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\2","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureG1]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\3","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureG2]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\4","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureB1]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\5","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureB2]
Measure=String
String=#ColorCode#
RegExpSubstitute=1
Substitute="^#(.)(.)(.)(.)(.)(.)$":"\6","a":"10","b":"11","c":"12","d":"13","e":"14","f":"15"
[MeasureR]
Measure=Calc
Formula=( 16 * [MeasureR1] + [MeasureR2] )
DynamicVariables=1
[MeasureG]
Measure=Calc
Formula=( 16 * [MeasureG1] + [MeasureG2] )
DynamicVariables=1
[MeasureB]
Measure=Calc
Formula=( 16 * [MeasureB1] + [MeasureB2] )
DynamicVariables=1
[MeasureConverted]
Measure=String
String=[MeasureR],[MeasureG],[MeasureB]
DynamicVariables=1
[MeterCode]
Meter=STRING
MeasureName=MeasureConverted
X=0
Y=0
FontColor=220,220,220
SolidColor=0,0,0
FontSize=12
Padding=25,5,25,5
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=HEX: #ColorCode##CRLF#DEC: %1
http://www.wikihow.com/Convert-Hexadecimal-to-Binary-or-Decimal
http://www.wikihow.com/Convert-from-Decimal-to-Hexadecimal
-
- Posts: 26
- Joined: September 17th, 2014, 8:47 pm
Re: [Feature] RGB to HEX and vice versa!
So much talent in one reply xD
And it works like a charm,thanks Balala, I'll use it from now on until a shorter or simpler version is implemented.
And it works like a charm,thanks Balala, I'll use it from now on until a shorter or simpler version is implemented.
-
- Rainmeter Sage
- Posts: 16176
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania