It is currently April 27th, 2024, 4:41 pm

OnChangeAction with ColorExtract Plugin.

Get help with creating, editing & fixing problems with skins
Aryx
Posts: 34
Joined: December 20th, 2023, 9:18 am

OnChangeAction with ColorExtract Plugin.

Post by Aryx »

Hello! :welcome: This is my first post, so, I don't know if I have made some errors or not.

I have used the following measure, but when the cover changes, the colors of the previous (edit:colors) cover are retained. I thought I could use something that would refresh automatically, so, I tried OnChangeAction and it most certainly did not work. I can't get the reason, so can anyone help me in this regard?

Code: Select all

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
RegExpSubstitute=1
Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1
Do I have to attach the refernces to the code too? Because the problem persists here, so, I thought - keep it short and simple.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: OnChangeAction with ColorExtract Plugin.

Post by eclectic-tech »

Your code works to remove the alpha value from the color.
It does not set it to red (255,0,0) because the value is never empty.

Did you add DynamicVariables=1 to your cover meter?

Edit: If you are still having issues, please post the entire code.
Aryx
Posts: 34
Joined: December 20th, 2023, 9:18 am

Re: OnChangeAction with ColorExtract Plugin.

Post by Aryx »

I know my code works. Since it gives the value as rrr,ggg,bbb,aaa , so, I removed the alpha part using regex. Also, if there is no cover color present, I defaulted (?) the value to 255,0,0.

To answer your question, yes, I have set DynamicVariables=1 in my cover. It is known as the cover automatically changes.

Code: Select all

[MeasureCover]
Measure=PLUGIN
Plugin=NOWPLAYING
PlayerName=AIMP
PlayerType=COVER
;OnChangeAction=[!UpdateMeter MeterCover]
Group=Info

[MeterBackground]
Meter=Shape
Shape=Rectangle 2,2,110,110,4
Group=Cover
DynamicVariables=1

[MeterCover]
Meter=IMAGE
MeasureName=MeasureCover
X=[MeterBackground:X]
Y=[MeterBackground:Y]
W=[MeterBackground:W]
H=[MeterBackground:H]
Container=MeterBackground
DynamicVariables=1
Group=Cover

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
RegExpSubstitute=1
Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1

[MeterTest]
Meter=String
X=([MeterCover:X]+[MeterCover:W])
FontSize=15
FontColor=[CoverColor]
Text=Test
DynamicVariables=1
The above only utilises one type of color from the said plugin. And is only for test purposes. It shows only the cover and text saying test - with font color same as the cover - as provided by the plugin.

Also, do I have to add DynamicVariables=1 everywhere? What does it do?
I looked at a topic here: https://forum.rainmeter.net/viewtopic.php?t=43343 - can I use Song's title changes to execute a refresh on the skin?
Thank you @Eclectic-Tech! Nice Holiday-DP you got there! :rosegift: (FInally: How does your name stand out and how can I do that to mine? Edit: The Purple-Color text/username. I looked at the preferences and found nothing related to this.)

Another Edit: You can specify any image here ImagePath= ; also, I think an invalid path might give out no value at all, so, you can test 255,0,0. Finally, is there any limit to edits one can perform?
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: OnChangeAction with ColorExtract Plugin.

Post by Yincognito »

Aryx wrote: December 20th, 2023, 1:03 pm I know my code works. Since it gives the value as rrr,ggg,bbb,aaa , so, I removed the alpha part using regex.
I don't think that's enough. I can't test your exact code as I removed all but the artist and track tags from my audio files, but from what I could test, it seems that plugin doesn't work with, say, PNG files (it has some logic since a transparent color has no visual representation regardless of whether you remove the aaa alpha value or not, though this doesn't seem to be documented anywhere on the plugin page). It will work, however, with JPG ones:

Code: Select all

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

---Measures---

[MeasureCover]
Measure=String
String=D:\Images\Wallpapers\- Single -\Water.jpg
;String=#@#4.png

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
RegExpSubstitute=1
Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1

---Meters---

[MeterBackground]
Meter=Shape
Shape=Rectangle 2,2,110,110,4
DynamicVariables=1

[MeterCover]
Meter=Image
MeasureName=MeasureCover
X=[MeterBackground:X]
Y=[MeterBackground:Y]
W=[MeterBackground:W]
H=[MeterBackground:H]
DynamicVariables=1

[MeterTest]
Meter=String
X=([MeterCover:X]+[MeterCover:W])
FontSize=15
FontColor=[CoverColor]
Text=Test
DynamicVariables=1
Assuming you set proper image paths for your system on line 10 and 11 (the String options in MeasureCover), if you comment the former and uncomment the latter, you'll see what I mean. Now, I'm not sure what kind of image does AIMP / NowPlaying return in your case, but if it's a PNG, it could explain the issue you're having...
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
Aryx
Posts: 34
Joined: December 20th, 2023, 9:18 am

Re: OnChangeAction with ColorExtract Plugin.

Post by Aryx »

I don't think @Incognito that you got my point :uhuh: . Let me break that up a bit for clarity:
1. The Album Cover is dynamic and changes as per the track and player. It has nothing to do with the static paths/filenames.
2. The Plugin can 'extract' the color accurately. It is not affected by png or jpg in my scenario atleast.
3. The Skin needs a 'Refresh' after a cover is changed to change the stored colors.
4. The Alpha values have been removed as I change the opacity - for the font's color it is normal, but, for the border-effect it is lower than full. However, if it is affecting the outcomes, then I'll happily remove that part or use different measures for the same.

Now, since I aptly discussed the problem, and proposed a solution that I thought could work, I don't see any other way to explain this any further than it already has been.

I did set the static paths for images (not covers*) - both jpg and png, but, it was working like it should. Can you explain what do you mean by "...if you comment the former and uncomment the latter, you'll see what I mean."?

*Not covers - Rainmeter leads the path to a .tmp file (seen in the About Skin Interface). AIMP leads to a file that is created only when it is clicked (unsure where it is stored earlier) as Title_of_the_Song.jpg/png.

Edit: A better test skin - Loads cover - retrieves all colors on test-texts, if not available, red, green, blue and grey are shown. This test will use only the cover from the song playing and not some static file. This is to show that if none of the colors match the cover, refreshing will change them to the way they should have been extracted.:

Code: Select all

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

---Measures---

[MeasureCover]
Measure=PLUGIN
Plugin=NOWPLAYING
PlayerName=AIMP
PlayerType=COVER

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
RegExpSubstitute=1
Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1

[CoverColor1]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Accent1
RegExpSubstitute=1
Substitute=",(255)$":"","":"0,255,0"
DynamicVariables=1

[CoverColor2]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Accent2
RegExpSubstitute=1
Substitute=",(255)$":"","":"0,0,255"
DynamicVariables=1

[CoverColorBG]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Background
RegExpSubstitute=1
Substitute=",(255)$":"","":"125,125,125"
DynamicVariables=1


---Meters---

[MeterBackground]
Meter=Shape
Shape=Rectangle 2,2,110,110,4 | Fill Color 0,0,0,200
DynamicVariables=1

[MeterCover]
Meter=Image
MeasureName=MeasureCover
X=[MeterBackground:X]
Y=[MeterBackground:Y]
W=[MeterBackground:W]
H=[MeterBackground:H]
DynamicVariables=1

[MeterTest]
Meter=String
X=([MeterCover:X]+[MeterCover:W])
FontSize=15
FontColor=[CoverColor]
Text=Test0
DynamicVariables=1
AntiAlias=1

[MeterTest1]
Meter=String
X=([MeterTest:X])
Y=([MeterTest:Y]+30)
FontSize=15
FontColor=[CoverColor1]
Text=Test1
DynamicVariables=1
AntiAlias=1

[MeterTest2]
Meter=String
X=([MeterTest:X])
Y=([MeterTest1:Y]+30)
FontSize=15
FontColor=[CoverColor2]
Text=Test2
DynamicVariables=1
AntiAlias=1

[MeterTest3]
Meter=String
X=([MeterTest:X])
Y=([MeterTest2:Y]+30)
FontSize=15
FontColor=[CoverColorBG]
Text=Test3
DynamicVariables=1
AntiAlias=1
User avatar
balala
Rainmeter Sage
Posts: 16177
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OnChangeAction with ColorExtract Plugin.

Post by balala »

Aryx wrote: December 20th, 2023, 6:12 pm 3. The Skin needs a 'Refresh' after a cover is changed to change the stored colors.
Not sure what you mean by "stored color", but the [CoverColor] measure is following the actual cover. When the cover changes, the value returned by this measure is changing as well. No refresh needed for this.
Aryx
Posts: 34
Joined: December 20th, 2023, 9:18 am

Re: OnChangeAction with ColorExtract Plugin.

Post by Aryx »

That's not true for me. Can you share your code?

Stored Color:
Say: Cover1 has some color as 243,255,215 and changes to Cover2, the plugin/measure retains the color 243,255,215 and any new value, say, 125,15,255 is presented only after refresh.
User avatar
balala
Rainmeter Sage
Posts: 16177
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: OnChangeAction with ColorExtract Plugin.

Post by balala »

Aryx wrote: December 20th, 2023, 6:55 pm That's not true for me. Can you share your code?
I'm using your code: this one. See the just recorded screenshot. When the cover changes, the color returned by the [CoverColor] measure changes as well on next update cycle. You can see the color returned by the measure on hte upper left corner of the skin. I added this only String meter, to can precisely follow the value of the measure.
Just to be extremely precise, here is the full code of my skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicwindowSize=1

[MeasureCover]
Measure=PLUGIN
Plugin=NOWPLAYING
PlayerName=WMP
PlayerType=COVER
;OnChangeAction=[!UpdateMeter MeterCover]
Group=Info

[MeterBackground]
Meter=Shape
Shape=Rectangle 2,2,110,110,4
Group=Cover
DynamicVariables=1

[MeterCover]
Meter=IMAGE
MeasureName=MeasureCover
X=[MeterBackground:X]
Y=[MeterBackground:Y]
W=[MeterBackground:W]
H=[MeterBackground:H]
Container=MeterBackground
DynamicVariables=1
Group=Cover

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
;RegExpSubstitute=1
;Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1

[MeterTest]
Meter=String
X=([MeterCover:X]+[MeterCover:W])
FontSize=15
FontColor=[CoverColor]
Text=Test
DynamicVariables=1

[MyMeter]
Meter=STRING
MeasureName=CoverColor
X=10
Y=10
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=10
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1
DynamicVariables=1
The newly added meter is the last one, called [MyMeter]. What is the Update value of your code (since you didn't add the [Rainmeter] section)?
You do not have the required permissions to view the files attached to this post.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5407
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: OnChangeAction with ColorExtract Plugin.

Post by eclectic-tech »

In my tests, the temp filename of the cover image DOES NOT CHANGE when using AIMP or Winamp as the player, so the skin never sees a "changing" value for the cover measure.

One way to correct this for those players is to monitor the track title in a separate NowPlaying measure and refresh the skin when it changes.

Code: Select all

[MeasureTitle]
Measure=Plugin
Plugin=NowPlaying
PlayerName=AIMP
PlayerType=TITLE
OnChangeAction=[!Log "Updating Colors"][!Refresh]

[MeasureCover]
Measure=Plugin
Plugin=NowPlaying
PlayerName=[MeasureTitle]
PlayerType=COVER

I haven't used this plugin very often but, in my tests, the plugin only updated colors on a "!Refresh" bang; using bangs to update the measures and meters did not work. :uhuh:
User avatar
Yincognito
Rainmeter Sage
Posts: 7177
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: OnChangeAction with ColorExtract Plugin.

Post by Yincognito »

Aryx wrote: December 20th, 2023, 6:12 pm I don't think @Incognito that you got my point :uhuh: . Let me break that up a bit for clarity:
1. The Album Cover is dynamic and changes as per the track and player. It has nothing to do with the static paths/filenames.
2. The Plugin can 'extract' the color accurately. It is not affected by png or jpg in my scenario atleast.
3. The Skin needs a 'Refresh' after a cover is changed to change the stored colors.
4. The Alpha values have been removed as I change the opacity - for the font's color it is normal, but, for the border-effect it is lower than full. However, if it is affecting the outcomes, then I'll happily remove that part or use different measures for the same.

Now, since I aptly discussed the problem, and proposed a solution that I thought could work, I don't see any other way to explain this any further than it already has been.

I did set the static paths for images (not covers*) - both jpg and png, but, it was working like it should. Can you explain what do you mean by "...if you comment the former and uncomment the latter, you'll see what I mean."?

*Not covers - Rainmeter leads the path to a .tmp file (seen in the About Skin Interface). AIMP leads to a file that is created only when it is clicked (unsure where it is stored earlier) as Title_of_the_Song.jpg/png.

Edit: A better test skin - Loads cover - retrieves all colors on test-texts, if not available, red, green, blue and grey are shown. This test will use only the cover from the song playing and not some static file. This is to show that if none of the colors match the cover, refreshing will change them to the way they should have been extracted.:

Code: Select all

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

---Measures---

[MeasureCover]
Measure=PLUGIN
Plugin=NOWPLAYING
PlayerName=AIMP
PlayerType=COVER

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
RegExpSubstitute=1
Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1

[CoverColor1]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Accent1
RegExpSubstitute=1
Substitute=",(255)$":"","":"0,255,0"
DynamicVariables=1

[CoverColor2]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Accent2
RegExpSubstitute=1
Substitute=",(255)$":"","":"0,0,255"
DynamicVariables=1

[CoverColorBG]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Background
RegExpSubstitute=1
Substitute=",(255)$":"","":"125,125,125"
DynamicVariables=1


---Meters---

[MeterBackground]
Meter=Shape
Shape=Rectangle 2,2,110,110,4 | Fill Color 0,0,0,200
DynamicVariables=1

[MeterCover]
Meter=Image
MeasureName=MeasureCover
X=[MeterBackground:X]
Y=[MeterBackground:Y]
W=[MeterBackground:W]
H=[MeterBackground:H]
DynamicVariables=1

[MeterTest]
Meter=String
X=([MeterCover:X]+[MeterCover:W])
FontSize=15
FontColor=[CoverColor]
Text=Test0
DynamicVariables=1
AntiAlias=1

[MeterTest1]
Meter=String
X=([MeterTest:X])
Y=([MeterTest:Y]+30)
FontSize=15
FontColor=[CoverColor1]
Text=Test1
DynamicVariables=1
AntiAlias=1

[MeterTest2]
Meter=String
X=([MeterTest:X])
Y=([MeterTest1:Y]+30)
FontSize=15
FontColor=[CoverColor2]
Text=Test2
DynamicVariables=1
AntiAlias=1

[MeterTest3]
Meter=String
X=([MeterTest:X])
Y=([MeterTest2:Y]+30)
FontSize=15
FontColor=[CoverColorBG]
Text=Test3
DynamicVariables=1
AntiAlias=1
My bad, I misunderstood, I thought the problem was with retrieving the data itself (and yes, PNGs do work, after all - got that wrong too). The problem is when changing tracks, and I can confirm it happens in my Winamp as well. I used your code, to which I added the last meter by balala above. Result - both the measures and the meters (and in the Log too) don't react when changing / jumping between tracks:

Code: Select all

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

---Measures---

[MeasureCover]
Measure=PLUGIN
Plugin=NOWPLAYING
PlayerName=Winamp
PlayerType=COVER

[CoverColor]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
RegExpSubstitute=1
Substitute=",(255)$":"","":"255,0,0"
DynamicVariables=1

[CoverColor1]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Accent1
RegExpSubstitute=1
Substitute=",(255)$":"","":"0,255,0"
DynamicVariables=1

[CoverColor2]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Accent2
RegExpSubstitute=1
Substitute=",(255)$":"","":"0,0,255"
DynamicVariables=1

[CoverColorBG]
Measure=Plugin
Plugin=ColorExtract
ImagePath=[MeasureCover]
ColorType=Background
RegExpSubstitute=1
Substitute=",(255)$":"","":"125,125,125"
DynamicVariables=1


---Meters---

[MeterBackground]
Meter=Shape
Shape=Rectangle 2,2,110,110,4 | Fill Color 0,0,0,200
DynamicVariables=1

[MeterCover]
Meter=Image
MeasureName=MeasureCover
X=[MeterBackground:X]
Y=[MeterBackground:Y]
W=[MeterBackground:W]
H=[MeterBackground:H]
DynamicVariables=1

[MeterTest]
Meter=String
X=([MeterCover:X]+[MeterCover:W])
FontSize=15
FontColor=[CoverColor]
Text=Test0
DynamicVariables=1
AntiAlias=1

[MeterTest1]
Meter=String
X=([MeterTest:X])
Y=([MeterTest:Y]+30)
FontSize=15
FontColor=[CoverColor1]
Text=Test1
DynamicVariables=1
AntiAlias=1

[MeterTest2]
Meter=String
X=([MeterTest:X])
Y=([MeterTest1:Y]+30)
FontSize=15
FontColor=[CoverColor2]
Text=Test2
DynamicVariables=1
AntiAlias=1

[MeterTest3]
Meter=String
X=([MeterTest:X])
Y=([MeterTest2:Y]+30)
FontSize=15
FontColor=[CoverColorBG]
Text=Test3
DynamicVariables=1
AntiAlias=1

[MyMeter]
Meter=STRING
MeasureName=CoverColor
X=10
Y=10
Padding=15,5,15,5
FontColor=220,220,220
FontEffectColor=0,0,0
StringEffect=Shadow
SolidColor=0,0,0,150
FontSize=10
FontFace=Segoe UI
StringStyle=BOLD
StringAlign=LEFT
AntiAlias=1
Text=%1
DynamicVariables=1
For some reason, WMP works for balala in that regard (or, he just tried with the first played track and did not change between tracks). Oh, and by the way, getting the right color works not only by refreshing, but also by stopping playing before changing tracks, at least for Winamp (don't know for AIMP or WMP).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth