It is currently September 23rd, 2020, 10:52 am

Invert text colour based on background

General topics related to Rainmeter.
tom0711
Posts: 39
Joined: April 29th, 2020, 5:55 pm

Invert text colour based on background

Post by tom0711 »

I have the" itunes player 2" skin and i wanna make the text (track,album,artist) change automatically based on background, when text is on bright background,make it black,and when text is on dark background,make it white.is it possible?
Image
heres the skin's code:

Code: Select all

[Rainmeter]
Author=siesie.deviantart.com


[Variables]
@Include=#CurrentPath#Variables.inc
Colour=FFFFFF



[mProcessPID]
Measure=Plugin
Plugin=Plugins\Perfmon.dll
PerfMonObject="Process"
PerfMonCounter="ID Process"
PerfMonInstance=itunes
PerfMonDifference=0
UpdateDivider=0,1
	
[mPlaying]
Measure=Calc
Formula=mProcessPID > 0 ? 1 : 0
	IfEqualValue=0
	IfEqualAction=!Execute [!RainmeterShowMeter MeterTitle][!RainmeterHideMeter Track][!RainmeterHideMeter Artist][!RainmeterHideMeter MeterTitle2][!RainmeterHideMeter MeterTitle3][!RainmeterHideMeter MeterTitle4][!RainmeterHideMeter NextTunes][!RainmeterHideMeter PrevTunes][!RainmeterHideMeter PlayTunes][!RainmeterHideMeter PauseTunes][!RainmeterHideMeter Album][!RainmeterHideMeter AlbumBG][!RainmeterHideMeter Black][!RainmeterHideMeter MeterTransparent][!RainmeterHideMeter MeterSoudnVOlume][!RainmeterHideMeter VolumeDown][!RainmeterHideMeter VolumeUp][!RainmeterHideMeter MeterPlayerPosition][!RainmeterHideMeter MeterCurrentTrackTime][!RainmeterHideMeter MeterPositionPercent][!RainmeterHideMeter MeterPosition]
	IfAboveValue=0
	IfAboveAction=!Execute [!RainmeterHideMeter MeterTitle][!RainmeterShowMeter Track][!RainmeterShowMeter Artist][!RainmeterShowMeter MeterTitle2][!RainmeterShowMeter MeterTitle3][!RainmeterShowMeter MeterTitle4] [!RainmeterShowMeter NextTunes][!RainmeterShowMeter PrevTunes][!RainmeterShowMeter PlayTunes][!RainmeterShowMeter PauseTunes][!RainmeterShowMeter Album][!RainmeterShowMeter AlbumBG][!RainmeterShowMeter Black][!RainmeterShowMeter MeterTransparent][!RainmeterShowMeter MeterSoudnVOlume][!RainmeterShowMeter VolumeDown][!RainmeterShowMeter VolumeUp][!RainmeterShowMeter MeterPlayerPosition][!RainmeterShowMeter MeterCurrentTrackTime][!RainmeterShowMeter MeterPositionPercent][!RainmeterShowMeter MeterPosition]
	UpdateDivider=0,0001

[mPositionPercent]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetPlayerPositionPercent
MaxValue=100

[mCurrentTrackTime]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackTime






[mAlbum]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackArtwork



[mTrack]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackName

[mArtist]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackArtist
	

[mAlbum2]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetCurrentTrackAlbum
	
[mPrev]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=PreviousTrack

[mNext]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=NextTrack


[mPlay]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=Play

[mPause]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=Pause

[mSoundVolume]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetSoundVolume
MaxValue=100

[mVolumeDown]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=SoundVolumeDown

[mVolumeUp]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=SoundVolumeUp


[MeterTitle]
Meter=String
####################################
Text=
####################################
FontColor=#Colour#
FontSize=11
FontFace=MV Boli
StringStyle=BOLD
LeftMouseDoubleClickAction=!Execute ["C:\Program Files\Tunes\Tunes.exe"]
AntiAlias=1
x=0

[MeterTitle2]
Meter=String
MeasureName=mTrack
Text=%1
W=#Width#
H=#Height#
FontColor=#Colour#
FontSize=11
FontFace=MV Boli
StringStyle=BOLD
StringAlign=Left
AntiAlias=1
Hidden=0
LeftMouseDoubleClickAction=!Execute ["#AddonsPath#RainRGB\RainRGB.exe" "VarName=Colour" "FileName=#CurrentPath#Spliced_Tunes.ini" "RefreshConfig=Wolfgang\Music"]
x=100
y=10

[MeterTitle3]
Meter=String
MeasureName=mArtist
Text=%1
w=#Width#
H=#Height#
FontColor=#Colour#
FontSize=10
FontFace=MV Boli
StringStyle=Bold
StringAlign=Left
AntiAlias=1
Hiden=0
y=40
x=100


[MeterTitle4]
Meter=String
MeasureName=mAlbum2
Text=%1
w=#Width#
H=#Height#
FontColor=FFFFFF
FontSize=10
FontFace=MV Boli
StringStyle=BOLD
//StringCase=Upper
StringAlign=Left
AntiAlias=1
Hiden=0
y=25
x=100







[PrevTunes]
Meter=Image
ImageName=Prev.png
x=100
Y=60
FontColor=255,255,255,255
FontFace=MV Boli
FontSize=20
AntiAlias=1
LeftMouseUpAction=!RainmeterPluginBang "mPrev"




[NextTunes]
Meter=Image
ImageName=Next.png
x=190
Y=60
AntiAlias=1
LeftMouseUpAction=!RainmeterPluginBang "mNext"

[PauseTunes]
Meter=Image
ImageName=Pause.png
X=130
Y=60
AntiAlias=1
LeftMouseUpAction=!RainmeterPluginBang "mPause"

[PlayTunes]
Meter=Image
ImageName=Play.png
X=160
Y=60
AntiAlias=1
LeftMouseUpAction=!RainmeterPluginBang "mPlay"

[AlbumBG]
Meter=IMAGE
imageName=bg.png
w=94
h=94
x=3
y=1


[Album]
Meter=IMAGE
MeasureName=mAlbum
X=10
Y=8
W=80
H=80



[MeterPosition]
Meter=Image
ImageName=black.png
x=10
y=70
w=80
h=18
hidden=1



[MeterPositionPercent]
Meter=Bar
MeasureName=mPositionPercent
X=13
Y=84
W=80
H=2
BarColor=FFFFFF
BarOrientation=HORIZONTAL
Hidden=1

[MeterCurrentTrackTime]
Meter=STRING
MeasureName=mCurrentTrackTime
X=62
Y=70
FontColor=FFFFFF
FontFace=MV Boli
FontSize=7
StringStyle=Bold
StringEffect=Shadow
StringAlign=left
FontEffectColor=000000
AntiAlias=1
Hidden=1

[mPlayerPosition]
Measure=Plugin
Plugin=Plugins\iTunesPlugin.dll
Command=GetPlayerPosition
MaxValue=100

[mMin]
Measure=Calc
Formula=(mPlayerPosition - (mPlayerPosition % 60)) /60

[mSec1]
Measure=Calc
Formula=(mPlayerPosition % 60) < 10 ? 0 : 1
Substitute="1":""

[mSec2]
Measure=Calc
Formula=mPlayerPosition % 60

[MeterPlayerPosition]
Meter=STRING
MeasureName=mMin
MeasureName2=mSec1
MeasureName3=mSec2
X=11
Y=70
FontColor=FFFFFF
FontFace=MV Boli
FontSize=7
FontEffectColor=000000
StringStyle=Bold
StringEffect=shadow
StringAlign=LEFT
Text="%1:%2%3"
AntiAlias=1
Hidden=1

[Black]
Meter=Image
ImageName=black.png
x=10
y=8
w=80
h=18
hidden=1

[MeterSoundVolume]
Meter=Bar
MeasureName=mSoundVolume
X=29
Y=16
W=40
H=2
BarColor=FFFFFF
BarOrientation=HORIZONTAL
Hidden=1

[MeterVolumeDown]
Meter=Image
X=11
Y=11
ImageName=VolumeDown.png
LeftMouseDownAction=!execute [!RainmeterPluginBang "mVolumeDown"]
Hidden=1


[MeterVolumeUp]
Meter=Image
X=74
Y=11
ImageName=VolumeUp.png
LeftMouseDownAction=!execute [!RainmeterPluginBang "mVolumeUp"]
Hidden=1

[MeterTransparent]
Meter=Image
Imagename=Transp.png
w=100
h=100
x=0
y=0
MouseOverAction=!execute [!RainmeterShowMeter MeterPosition][!RainmeterShowMeter MeterPlayerPosition][!RainmeterShowMeter MeterCurrentTrackTime][!RainmeterShowMeter MeterPositionPercent][!RainmeterShowMeter MeterSoundVolume][!RainmeterShowMeter MeterVolumeUp][!RainmeterShowMeter MeterVolumeDown][!RainmeterShowMeter Black]
MouseLeaveAction=!execute [!RainmeterHideMeter MeterPosition][!RainmeterHideMeter MeterPlayerPosition][!RainmeterHideMeter MeterCurrentTrackTime][!RainmeterHideMeter MeterPositionPercent][!RainmeterHideMeter MeterSoundVolume][!RainmeterHideMeter MeterVolumeUp][!RainmeterHideMeter MeterVolumeDown][!RainmeterHideMeter Black]






User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Invert text colour based on background

Post by jsmorley »

You are going to need something like this:

Code: Select all

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

[Variables]
Light=255,255,255,255
Dark=0,0,0,255

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

[Luminance]
Measure=Plugin
Plugin=Chameleon
Parent=ChameleonLuminance
Format=Dec
Color=Luminance
IfCondition=Luminance <= 0.5
IfTrueAction=[!SetOption MeterString FontColor "#Light#"][!UpdateMeter *][!Redraw]
IfFalseAction=[!SetOption MeterString FontColor "#Dark#"][!UpdateMeter *][!Redraw]

[MeterString]
Meter=String
FontSize=30
FontWeight=400
AntiAlias=1
SolidColor=0,0,0,1
Text=Hello World

https://forum.rainmeter.net/viewtopic.php?f=127&t=21655#p114867

That will sample the desktop wallpaper under the skin, and depending on the relative brightness (luminance) of the area, will set the FontColor of the String meter accordingly.

Be sure you install the Chameleon plugin before you start.

https://software.socksthefox.net/chameleon/
tom0711
Posts: 39
Joined: April 29th, 2020, 5:55 pm

Re: Invert text colour based on background

Post by tom0711 »

thanks! so how do i combine this code with my skin code? just add it to my skin code, or do i need to replace something in one of the codes?
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Invert text colour based on background

Post by jsmorley »

tom0711 wrote: May 1st, 2020, 12:39 pm thanks! so how do i combine this code with my skin code? just add it to my skin code, or do i need to replace something in one of the codes?
That is some really old skin code you have there, and I'd have to have the entire thing, all zipped up, so I have all the images you are currently using as well as the .ini code.

Zip up the entire skin and attach it here and I can take a look.
tom0711
Posts: 39
Joined: April 29th, 2020, 5:55 pm

Re: Invert text colour based on background

Post by tom0711 »

this is the skin
You do not have the required permissions to view the files attached to this post.
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Invert text colour based on background

Post by jsmorley »

Which one of those .ini files do you use? I'm not really interested in doing a lot of work on all of them.
tom0711
Posts: 39
Joined: April 29th, 2020, 5:55 pm

Re: Invert text colour based on background

Post by tom0711 »

iTunesPlayer_Album_Style_2
jsmorley wrote: May 1st, 2020, 1:41 pm Which one of those .ini files do you use? I'm not really interested in doing a lot of work on all of them.
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Invert text colour based on background

Post by jsmorley »

tom0711 wrote: May 1st, 2020, 3:10 pm iTunesPlayer_Album_Style_2
Ok, I'll take a look at it. Do you really still use iTunes for Windows?
tom0711
Posts: 39
Joined: April 29th, 2020, 5:55 pm

Re: Invert text colour based on background

Post by tom0711 »

Yes
User avatar
jsmorley
Developer
Posts: 21386
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Invert text colour based on background

Post by jsmorley »

Sorry, I have gotten a bit delayed in looking at this. I'm still planning to try and help you out.

The problems with working on this are:

1) I don't use, and would never in a million years install, iTunes on my PC.
2) Absolutely everything about this skin uses old, deprecated syntax and approaches. Not fatal, but I can't in good conscience leave them as they are.
3) The skin uses "images" for the player controls, and those are hard to effectively change colors dynamically. I want to replace them with symbol "fonts" instead.

So give me some time to chew on this.