Color changing depending on its background.

General topics related to Rainmeter.
User avatar

Color changing depending on its background.

July 14th, 2017, 12:17 pm
kyriakos876
   [189 posts]

The title is pretty self explanatory. I would like to know if there is some way to change the color of a skin depending on the background set by the user.

-Thanks in advance.
User avatar

Re: Color changing depending on its background.

July 14th, 2017, 12:41 pm
jsmorley
Developer   [15849 posts]

ChameleonTester_1.0.rmskin
(684.51 KiB) Downloaded 4 times


Code: Select all

[Rainmeter]
Update=100
DynamicWindowSize=1
AccurateText=1

[Metadata]
Name=ChameleonTester
Author=JSMorley
Information=Example of using the Chameleon plugin for Rainmeter
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0
Version=Mar 27, 2016

[Variables]
; Set this to a path with your desktop wallpapers
ImagePath=C:\Users\Jeffrey\Wallpaper

; Set this for the size and position of the wallpaper
; Center, Tile, Stretch, Fit or Fill
Position=Fill

; Chameleon Color Options
; -----------------------
; Background1
; Background2
; Foreground1
; Foreground2
; Light1
; Light2
; Light3
; Light4
; Dark1
; Dark2
; Dark3
; Dark4
; Average

; Chameleon Image Brightness Value
; --------------------------------
; Luminance

[ChameleonDesktop]
Measure=Plugin
Plugin=Chameleon
Type=Desktop

[Background1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Background1

[Background2]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Background2

[Foreground1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Foreground1

[Foreground2]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Foreground2

[Light1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Light1

[Light2]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Light2

[Light3]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Light3

[Light4]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Light4

[Dark1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Dark1

[Dark2]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Dark2

[Dark3]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Dark3

[Dark4]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Dark4

[Average]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Average

[Luminance]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Luminance
IfCondition=Luminance < 0.5
IfTrueAction=[!SetVariable Luminance "Dark"][!SetVariable BorderColor "[*Dark4*]][!SetVariable BackColor "[*Dark3*]"][!SetVariable LabelColor "[*Dark2*]"][!SetVariable ValueColor "[*Dark1*]"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetVariable Luminance "Light"][!SetVariable BorderColor "[*Light4*]][!SetVariable BackColor "[*Light3*]"][!SetVariable LabelColor "[*Light2*]"][!SetVariable ValueColor "[*Light1*]"][!UpdateMeter *][!Redraw]

; Meters

[MeterBackground1]
Meter=Image
W=100
H=50
SolidColor=[Background1]
DynamicVariables=1
ToolTipText=Background1

[MeterBackground2]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Background2]
DynamicVariables=1
ToolTipText=Background2

[MeterForeground1]
Meter=Image
W=100
H=50
Y=20R
SolidColor=[Foreground1]
DynamicVariables=1
ToolTipText=Foreground1

[MeterForeground2]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Foreground2]
DynamicVariables=1
ToolTipText=Foreground2

[MeterLight1]
Meter=Image
W=100
H=50
Y=20R
SolidColor=[Light1]
DynamicVariables=1
ToolTipText=Light1

[MeterLight2]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Light2]
DynamicVariables=1
ToolTipText=Light2

[MeterLight3]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Light3]
DynamicVariables=1
ToolTipText=Light3

[MeterLight4]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Light4]
DynamicVariables=1
ToolTipText=Light4

[MeterDark1]
Meter=Image
W=100
H=50
Y=20R
SolidColor=[Dark1]
DynamicVariables=1
ToolTipText=Dark1

[MeterDark2]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Dark2]
DynamicVariables=1
ToolTipText=Dark2

[MeterDark3]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Dark3]
DynamicVariables=1
ToolTipText=Dark3

[MeterDark4]
Meter=Image
W=100
H=50
Y=2R
SolidColor=[Dark4]
DynamicVariables=1
ToolTipText=Dark4

[MeterAverage]
Meter=Image
W=100
H=50
Y=20R
SolidColor=[Average]
DynamicVariables=1
ToolTipText=Average

; Top Box

[MeterTopBorder]
Meter=Image
X=120
Y=0
W=340
H=240
SolidColor=[BackGround1]
DynamicVariables=1

[MeterTopBack]
Meter=Image
X=130
Y=10
W=320
H=220
SolidColor=[BackGround2]
DynamicVariables=1

[MeterTopLabel]
Meter=String
X=290
Y=37r
StringAlign=Center
StringStyle=Bold
FontColor=[ForeGround1]
FontSize=30
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=Foreground1

[MeterTopValue]
Meter=String
X=290
Y=50r
StringAlign=Center
StringStyle=Bold
FontColor=[ForeGround2]
FontSize=30
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=Foreground2

[MeterTopAverageColor]
Meter=String
X=290
Y=50r
StringAlign=Center
StringStyle=Bold
FontColor=[Average]
FontSize=30
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=Average

; Bottom Box

[MeterBottomBorder]
Meter=Image
X=120
Y=([MeterTopBorder:Y]+[MeterTopBorder:H] + 70)
W=340
H=240
SolidColor=#BorderColor#
DynamicVariables=1

[MeterBottomBack]
Meter=Image
X=130
Y=([MeterBottomBorder:Y] + 10)
W=320
H=220
SolidColor=#BackColor#
DynamicVariables=1

[MeterBottomLabel]
Meter=String
X=290
Y=37r
StringAlign=Center
StringStyle=Bold
FontColor=#ValueColor#
FontSize=30
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=#Luminance#1

[MeterBottomValue]
Meter=String
X=290
Y=50r
StringAlign=Center
StringStyle=Bold
FontColor=#LabelColor#
FontSize=30
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=#Luminance#2

[MeterBottomAverageColor]
Meter=String
X=290
Y=50r
StringAlign=Center
StringStyle=Bold
FontColor=[Average]
FontSize=30
SolidColor=0,0,0,1
AntiAlias=1
DynamicVariables=1
Text=Average

[MeterLuminanceBack]
Meter=Image
X=130
Y=560
W=320
H=50
SolidColor=#BackColor#
DynamicVariables=1

[MeterLuminanceText]
Meter=String
MeasureName=Luminance
X=290
Y=10r
StringAlign=Center
StringStyle=Bold
FontColor=#ValueColor#
FontSize=20
SolidColor=0,0,0,1
AntiAlias=1
NumOfDecimals=3
DynamicVariables=1
Text=Luminance is %1

; Wallpaper Changer

[MeasureFolder]
Measure=Plugin
Plugin=FileView
Recursive=0
Path=#ImagePath#\
Extensions=jpg;png

[MeasureCount]
Measure=Plugin
Plugin=FileView
Path=[MeasureFolder]
Type=FileCount
OnChangeAction=[!SetOption MeasureRandom HighBound [MeasureCount]]
DynamicVariables=1

[MeasureRandom]
Measure=Script
Group=ImageMeasures
ScriptFile=RandomImage.lua
UpdateDivider=-1
Disabled=1
OnUpdateAction=[!UpdateMeasure MeasureImagePath]

[MeasureImagePath]
Measure=Plugin
Group=ImageMeasures
Plugin=FileView
Path=[MeasureFolder]
Type=FilePath
IgnoreCount=1
Index=[MeasureRandom]
UpdateDivider=-1
Disabled=1
DynamicVariables=1

[MeterIconBack]
Meter=Image
X=130
Y=250
W=320
H=50
SolidColor=[Average]
DynamicVariables=1
LeftMouseUpAction=[!EnableMeasureGroup ImageMeasures][!UpdateMeasure MeasureRandom][!SetWallpaper "[MeasureImagePath]" #Position#]

[MeterSetIcon]
Meter=Image
X=270
Y=260
W=32
H=32
AntiAlias=1
ImageName=#@#Images\SetIcon.png
SolidColor=0,0,0,1
DynamicVariables=1

[MeterD2L1]
Meter=Image
X=130
Y=630
W=320
H=50
SolidColor=[Dark1]
SolidColor2=[Light1]
ToolTipText=Dark1 to Light1
DynamicVariables=1

[MeterD2L2]
Meter=Image
X=130
Y=5R
W=320
H=50
SolidColor=[Dark2]
SolidColor2=[Light2]
ToolTipText=Dark2 to Light2
DynamicVariables=1

[MeterD2L3]
Meter=Image
X=130
Y=5R
W=320
H=50
SolidColor=[Dark1]
SolidColor2=[Dark2]
ToolTipText=Dark1 to Dark2
DynamicVariables=1

[MeterD2L4]
Meter=Image
X=130
Y=5R
W=320
H=50
SolidColor=[Light1]
SolidColor2=[Light2]
ToolTipText=Light1 to Light2
DynamicVariables=1




User avatar

Re: Color changing depending on its background.

July 14th, 2017, 12:46 pm
kyriakos876
   [189 posts]

Straight up perfect! Thanks for the example as well. Appreciate it.
User avatar

Re: Color changing depending on its background.

July 14th, 2017, 12:58 pm
jsmorley
Developer   [15849 posts]

It's a marvelous plugin. Really. For shear cleverness, it's one of the best I have ever seen.

The only caution I would give about setting skin colors automatically based on the desktop wallpaper, is that it can be tricky depending on where they position the skin. The plugin figures out the predominant colors in the dark to light ranges in the background image, and can even tell you the overall luminescence of the image. However, if you then set a meter to use one of the "light" or "dark" colors, that may be more satisfying (or even visible) when on top of some part of the wallpaper, and less on some other.

I'd be tempted to use Chameleon to gather a "pallet" of colors based on the wallpaper, and offer the user a way to select from this pallet for different elements of the skin. That way the plugin does 90% of the work of selecting colors, but allows the user to tweak and fine tune things for where they really want the skin to live on the screen.

Return to “General Discussion”



Who is online

Users browsing this forum: Google [Bot] and 1 guest