mattitta wrote: ↑January 26th, 2019, 3:46 am
I've started by making a color selector using rainRGB for font colors and image colors.
What I would like to do is that when I pick a font color is to have a complementary color for the image, right now I would have to go online to find that color. Is this even possible or not any help would be appreciated.
You can find a good description of complementary colors here:
https://forum.rainmeter.net/viewtopic.php?f=119&t=26837&p=140161&hilit=complementary+colors#p140153
and here:
https://forum.rainmeter.net/viewtopic.php?f=119&t=26837&p=140161&hilit=complementary+colors#p140161
Based on the above descriptions, I added a few measures to your code, to make the needed calculations. Here they are: add the following measures to your code:
Code: Select all
[MeasureRed]
Measure=String
String=#ImageTint#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\1"
DynamicVariables=1
[MeasureGreen]
Measure=String
String=#ImageTint#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\2"
DynamicVariables=1
[MeasureBlue]
Measure=String
String=#ImageTint#
RegExpSubstitute=1
Substitute="^(\d{1,3}),(\d{1,3}),(\d{1,3})$":"\3"
DynamicVariables=1
[MeasureComplementaryRed]
Measure=Calc
Formula=(( Max ( [MeasureRed], Max ( [MeasureGreen], [MeasureBlue] ))) + ( Min ( [MeasureRed], Min ( [MeasureGreen], [MeasureBlue] ))) - [MeasureRed] )
DynamicVariables=1
[MeasureComplementaryGreen]
Measure=Calc
Formula=(( Max ( [MeasureRed], Max ( [MeasureGreen], [MeasureBlue] ))) + ( Min ( [MeasureRed], Min ( [MeasureGreen], [MeasureBlue] ))) - [MeasureGreen] )
DynamicVariables=1
[MeasureComplementaryBlue]
Measure=Calc
Formula=(( Max ( [MeasureRed], Max ( [MeasureGreen], [MeasureBlue] ))) + ( Min ( [MeasureRed], Min ( [MeasureGreen], [MeasureBlue] ))) - [MeasureBlue] )
DynamicVariables=1
[MeasureComplementaryColor]
Measure=String
String=[MeasureComplementaryRed],[MeasureComplementaryGreen],[MeasureComplementaryBlue]
DynamicVariables=1
The
DynamicVariables=1 option isn't absolutely needed, but I added it to each measure (see below why).
[MeasureRed], [MeasureGreen] and [MeasureBlue] are returning the color components of the original color, [MeasureComplementaryRed], [MeasureComplementaryGreen] and [MeasureComplementaryBlue] are calculating the components of the complementary color and finally, as probably you figured it out, [MeasureComplementaryColor] is returning the complementary color of the original #ImageTint#.
If you need, a set of similar measures has to be added, to get the complementary color of #FontColor#.
Now a few words about why have I added the
DynamicVariables=1 option to all above measures. Usually refreshing the skin is an operation which should have to be avoided:
https://forum.rainmeter.net/viewtopic.php?f=5&t=22739&p=120238&hilit=refresh+balala#p120238
So, instead of just writing the variables with !WriteKeyValue bangs, I'd add some !SetVariable bangs to the LeftMouseUpAction options of [MeterColor1] - [MeterColor20], respectively [MeterColor1a] - [MeterColor20a] meters and would remove the !Refresh bangs. For example the updated [MeterColor1] meter would be:
Code: Select all
[MeterColor1]
Meter=IMAGE
ImageName=#@#ColorSet.png
X=30
Y=80
W=20
LeftMouseUpAction=[!WriteKeyValue Variables FontColor "255,255,255" "#@#Variables.inc"][!SetVariable FontColor "255,255,255"][!UpdateMeter "MeterShape"][!UpdateMeter "MeterLine2"][!UpdateMeter "MeterSettingsText"][!UpdateMeter "MeterFontColor"][!UpdateMeter "MeterChangeImageColor"][!Redraw]
ImageTint=255,255,255
ToolTipText="White"
Along with this, you also have to add a
DynamicVariables=1 option to all meters and measures which are using this variable ([MeterShape], [MeterLine2], [MeterSettingsText], [MeterFontColor] and [MeterChangeImageColor] and the above measures, where I already added it).
And one more: !Execute is a
deprecated bang. Don't use it.
Please let me know if you succeeded implementing all this.