It is currently March 29th, 2024, 12:51 am

Can anyone teach me how to use the chameleon plugin?

Get help with creating, editing & fixing problems with skins
adnansamihr
Posts: 2
Joined: September 7th, 2021, 2:54 pm

Can anyone teach me how to use the chameleon plugin?

Post by adnansamihr »

So I use windynamic wallpaper which changes based on day and night and I wanted this skin (https://www.deviantart.com/apexxx-sensei/art/Lumiero-828277050) to change automatically based on the background. I found this plugin (https://forum.rainmeter.net/viewtopic.php?t=21655) on the forums but I cant figure out how to use it with my skin. I did download an example skin and it works fine. So if anyone can actually teach me how to use this step by step it would be amazing or you can just modify it urself if you have time but I really want to learn how to do this myself.
User avatar
death.crafter
Rainmeter Sage
Posts: 1399
Joined: April 24th, 2021, 8:13 pm

Re: Can anyone teach me how to use the chameleon plugin?

Post by death.crafter »

adnansamihr wrote: September 7th, 2021, 3:03 pm So I use windynamic wallpaper which changes based on day and night and I wanted this skin (https://www.deviantart.com/apexxx-sensei/art/Lumiero-828277050) to change automatically based on the background. I found this plugin (https://forum.rainmeter.net/viewtopic.php?t=21655) on the forums but I cant figure out how to use it with my skin. I did download an example skin and it works fine. So if anyone can actually teach me how to use this step by step it would be amazing or you can just modify it urself if you have time but I really want to learn how to do this myself.
It's really the update rate that matters. The plugin's manual page lays out everything it can do. See if the Chameleon section of Lumiero has a very high update divider or UpdateDivider=-1.

If so make it either 1 or remove the option. For instantaneous change detection, add an on change action to the Chameleon section. Example:

Code: Select all

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

[DesktopForegeound1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Color=Foreground1
OnChangeAction=[!UpdateMeter MeterTime][!Redraw]

[MeasureTime]
Measure=Time
Format=%H:%M

[MeterTime]
Meter=String
FontSize=16
FontColor=[DesktopForeground1]
AntiAlias=1
DynamicVariables=1
MeasureName=MeasureTime
Also the DynamicVariables=1 in the Meter Time section matters. So that it can get the new value when the Chameleon child measure changes.
from the Realm of Death
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can anyone teach me how to use the chameleon plugin?

Post by jsmorley »

It is important and useful that you check out the documentation for Chameleon at:
https://github.com/socks-the-fox/Chameleon

The long and the short of it is:

1) Create a Chameleon "parent" measure. That will sample your desktop wallpaper
2) Create one or more Chameleon "child" measure(s) that will select one of the supported values that Chameleon will return.

These are:
Background1
Foreground1
Background2
Foreground2
Light1
Light2
Light3
Light4
Dark1
Dark2
Dark3
Dark4
Average
Luminance
3) Use the values returned by those "child" measures as a [SectionVariable] anywhere you want a color. That might be in FontColor or SolidColor, or anywhere else you are using a color value.
4) Be sure to set DynamicVariables=1 on the meters that contain those color values.

Code: Select all

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

[Variables]

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

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

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

[MeterOutput]
Meter=String
FontSize=40
FontWeight=400
FontColor=[Light1]
SolidColor=[Dark1]
DynamicVariables=1
Padding=5,5,5,5
AntiAlias=1
Text=Hello World
That's the most basic and simple example. In order to be a bit more "dynamic" based on how dark or light the overall wallpaper is, you might use the Luminance value like this:

Code: Select all

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

[Variables]

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

[Light1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Light1
OnChangeAction=[!UpdateMeasureGroup Luminance]

[Dark1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Dark1
OnChangeAction=[!UpdateMeasureGroup Luminance]

[ChameleonLuminance]
Measure=Plugin
Group=Luminance
Plugin=Chameleon
Type=Desktop
UpdateDivider=-1
CropX=#CURRENTCONFIGX#
CropY=#CURRENTCONFIGY#
CropW=#CURRENTCONFIGWIDTH#
CropH=#CURRENTCONFIGHEIGHT#
DynamicVariables=1

[Luminance]
Measure=Plugin
Group=Luminance
Plugin=Chameleon
Parent=ChameleonLuminance
Format=Dec
Color=Luminance
UpdateDivider=-1
IfCondition=Luminance <= 0.5
IfTrueAction=[!SetVariable Color1 "[Dark1]"][!SetVariable Color2 "[Light1]"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetVariable Color1 "[Light1]"][!SetVariable Color2 "[Dark1]"][!UpdateMeter *][!Redraw]
IfConditionMode=1

[MeterOutput]
Meter=String
FontSize=40
FontWeight=400
FontColor=#Color1#
SolidColor=#Color2#
DynamicVariables=1
Padding=5,5,5,5
AntiAlias=1
Text=Hello World
So the point of that is that if the Luminance of the wallpaper is overall "dark", you might want to switch to a "light" background and a "dark" foreground. If the Luminance of the wallpaper is overall "light", you might want to switch to a "dark" background and a "light" foreground.

Note that I am using the "crop" options on the Luminance parent measure to constrain the area it samples to just what is under the actual skin. I do that since any given wallpaper might have areas of "dark" and "light", and you want the luminance to just consider what is under the skin itself.

Note that I am using UpdateDivider=-1 on the Luminance measure(s) so it's not doing a lot of extra work on every skin update. You only want to test for the Luminance and take action when the wallpaper actually changes.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can anyone teach me how to use the chameleon plugin?

Post by jsmorley »

So if we take that Date.ini from the suite you linked to, you can add the ability to react to the color/brightness of the wallpaper like this:

Code: Select all

[Rainmeter]
Update=1000
Author=Connect-R
BackgroundMode=2
SolidColor=0,0,0,1
DynamicWindowSize=1
AccurateText=1
MouseScrollUpAction=[!SetVariable Scale "(#Scale#+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#+#ScrollMouseIncrement#)"][!Refresh] 
MouseScrollDownAction=[!SetVariable Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#-#ScrollMouseIncrement# < 0.2 ? 0.2 : #Scale#-#ScrollMouseIncrement#)"][!Refresh]

[Variables]
@include=#@#Variables.inc
@include2=#@#Language\Language.inc
Scale=1.1

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

[Light1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Light1
OnChangeAction=[!UpdateMeasureGroup Luminance]

[Dark1]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonDesktop
Format=Dec
Color=Dark1
OnChangeAction=[!UpdateMeasureGroup Luminance]

[ChameleonLuminance]
Measure=Plugin
Group=Luminance
Plugin=Chameleon
Type=Desktop
UpdateDivider=-1
CropX=#CURRENTCONFIGX#
CropY=#CURRENTCONFIGY#
CropW=#CURRENTCONFIGWIDTH#
CropH=#CURRENTCONFIGHEIGHT#
DynamicVariables=1

[Luminance]
Measure=Plugin
Group=Luminance
Plugin=Chameleon
Parent=ChameleonLuminance
Format=Dec
Color=Luminance
UpdateDivider=-1
IfCondition=Luminance <= 0.5
IfTrueAction=[!SetVariable Color1 "[Light1]"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetVariable Color1 "[Dark1]"][!UpdateMeter *][!Redraw]
IfConditionMode=1

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeasureDate]
Measure=Time
Format=%d

[MeasureDay]
Measure=Time
Format="%A"
Substitute=#Date#

[MeasureMonth]
Measure=Time
Format="%B"
Substitute=#Date#

;-------------------------------------------------------------
;-------------------------------------------------------------

[MeterDate]
Meter=String
MeasureName=MeasureDate
StringAlign=Left
FontFace=Comfortaa
FontColor=#Color1#
FontSize=(80*#Scale#)
X=(5*#Scale#)
Y=(0*#Scale#)
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterMonth]
Meter=String
MeasureName=MeasureMonth
StringAlign=Left
FontFace=Comfortaa
FontColor=#Color1#
FontSize=(16*#Scale#)
X=(5*#Scale#)
Y=(10*#Scale#)R
Text=%1
AntiAlias=1
DynamicVariables=1

[MeterDay]
Meter=String
MeasureName=MeasureDay
StringAlign=Left
FontFace=Comfortaa
FontColor=#Color1#,100
FontSize=(10*#Scale#)
X=(5*#Scale#)
Y=(5*#Scale#)R
Text=#Today's# %1
AntiAlias=1
DynamicVariables=1


1.png

2.png


Note that the original author was using "static" color values set as #Variables# in that .inc @Include file. Since we are going to be "overriding" those values and dynamically changing the #Variables# for the color(s), we need to add DynamicVariables=1 to each and every meter using them.

Note that all the examples I gave will only react to the Luminance when the wallpaper actually changes. In order to have it react to you dragging the skin to another position on the screen, you might add a measure like:

Code: Select all

[MeasureChangePosition]
Measure=Calc
Formula=#CURRENTCONFIGX#
DynamicVariables=1
OnChangeAction=[!UpdateMeasureGroup Luminance]
You do not have the required permissions to view the files attached to this post.
adnansamihr
Posts: 2
Joined: September 7th, 2021, 2:54 pm

Re: Can anyone teach me how to use the chameleon plugin?

Post by adnansamihr »

Great, thanks a lot its working really well. I was just curious, can you change different parts of the skin to light or dark. For example, in the time skin from the same pack I want to make the last line a dark shade cause its hard to read. So can I make that part only to be dark while others are light?
Screenshot 2021-09-08 030333.png
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Can anyone teach me how to use the chameleon plugin?

Post by jsmorley »

adnansamihr wrote: September 7th, 2021, 9:40 pm Great, thanks a lot its working really well. I was just curious, can you change different parts of the skin to light or dark. For example, in the time skin from the same pack I want to make the last line a dark shade cause its hard to read. So can I make that part only to be dark while others are light?Screenshot 2021-09-08 030333.png
I think on that one you might want to remove the ,100 from this line in [MeterDay]:

FontColor=#Color1#,100

It's hard to read because it has a lot of transparency. Since the color itself is based on the colors in the wallpaper, having significant transparency can make the meter kinda blend in with the wallpaper more than you might like. That transparency is better suited to the original approach he had of just manually choosing a really dark version if you have a light wallpaper, and a really light version if you have a dark wallpaper. It's not going to work as well with the dynamic colors.

I will point out that as clever as Chameleon is, and it is just insanely clever, there are limitations. For instance, if you have an area of the wallpaper that your skin is on that is exactly 0.5 (50%) Luminance, then both dark and light on top of it will work equally well, and equally poorly. There is no way to really be certain that with any given wallpaper, the skin is going to look great on it. This is probably particularly true if the skin doesn't have any "background" of its own, where you can at least force some "contrast" between the background and the foreground.