It is currently April 26th, 2024, 11:54 pm

Color Switcher not working

Get help with creating, editing & fixing problems with skins
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Switcher not working

Post by balala »

mak_kawa's code definitely works:

Code: Select all

[Rainmeter]
Update=5000
AccurateText=1
;DynamicWindowSize=1

[Metadata]
Name=
Author=CoffeeJoe
Information=
License=Creative Commons Attribution-NonCommercial-ShareAlike 3.0
Version=

[Variables]
SkinX=300
SkinY=300

[MeasureRandom]
Measure=Calc
Formula=Random
LowBound=1
HighBound=15
UpdateRandom=1
;OnUpdateAction=[!UpdateMeter "MeterString"][!Redraw "MeterString"]

[BackColor]
String=[MeasureRandom]
Measure=String
RegExpSubstitute=1
Substitute="^1$":"101010","^2$":"202020","^3$":"303030","^4$":"404040","^5$":"505050","^6$":"606060","^7":"707070","^8$":"808080","^9$":"909090","^10$":"A0A0A0","^11$":"B0B0B0","^12$":"C0C0C0","^13$":"D0D0D0","14$":"E0E0E0","^15$":"F0F0F0"
DynamicVariables=1

[MeterBack]
;MeasureName=BackColor
Meter=Shape
W=#SkinX#
H=#SkinY#
Shape=Rectangle 0,0,#SkinX#,#SkinY# | Fill Color [BackColor] | StrokeWidth 0
DynamicVariables=1

[MeterString]
MeasureName=BackColor
Meter=String
FontSize=18
SolidColor=606060
Padding=10,10,10,10
FontColor=FFFFFF
Text=%1
;DynamicVariables=1
As mak_kawa said there have been more problems:
  • The MeasureName option doesn't work on String measures. You have to use the String option instead, so the MeasureName=MeasureRandom option of the [BackColor] measure has been replaced with String=[MeasureRandom].
  • In the Substitute option of the same [BackColor] measure the ^ and $ symbols have been added, as described by mak_kawa.
  • The Text=[BackColor] option of the [MeterString] meter has been replaced with:

    Code: Select all

    [MeterString]
    MeasureName=BackColor
    Text=%1
    This allows you to remove the DynamicVariables=1 option, which isn't needed anymore.
And one more: I also commented out the DynamicWindowSize=1 option of the [Rainmeter] section, because at least in case of the posted piece of codse it is not needed, the skin size being static.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Color Switcher not working

Post by mak_kawa »

Hi CoffeeJoe

Necessary modification to work this skin fine is as balala said.

Although not important thing, OnUpdateAction=[!UpdateMeter "MeterBack"][!Redraw MeterBack] in BackColor measure is unnecessary (as balala has commented out), because this measure and [MeterBack] meter are both updated in every update cycle.
Further, !Redraw bang have config name option but not meter name option. So, [!Redraw MeterBack] is invalid.
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Color Switcher not working

Post by CoffeeJoe »

Very nicely done - I will just have to go over my code again, I must have something reversed or spelled wrong. mine which looks very much like this doesn't work yet.
Ill let you know when I figure it out

thanks again
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Color Switcher not working

Post by CoffeeJoe »

Figured it out, it was / is failing on the Substitute String.
When I took the ^ and $ out it started resolving correctly, although the "15" & "5" ... or the "1" & "10" doesn't work no matter what order I put it in.
I'm thinking about it to see if I can imagine / find a better solution.

Thanks guys, I'm unstuck now, and will keep moving
User avatar
CoffeeJoe
Posts: 48
Joined: November 6th, 2019, 4:19 am

Re: Color Switcher not working

Post by CoffeeJoe »

I got it - this seems to work

Code: Select all

"9":"909090","8":"808080","7":"707070","6":"606060","15":"F0F0F0","14":"E0E0E0","13":"D0D0D0","12":"C0C0C0","11":"B0B0B0","10":"A0A0A0","5":"505050","4":"404040","3":"303030","2":"202020","1":"101010"
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Switcher not working

Post by balala »

mak_kawa wrote: December 16th, 2019, 10:19 am Although not important thing, OnUpdateAction=[!UpdateMeter "MeterBack"][!Redraw MeterBack] in BackColor measure is unnecessary (as balala has commented out),
No, not I commented it out, it is commented in the original code as well.
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Switcher not working

Post by balala »

CoffeeJoe wrote: December 16th, 2019, 12:07 pm I got it - this seems to work

Code: Select all

"9":"909090","8":"808080","7":"707070","6":"606060","15":"F0F0F0","14":"E0E0E0","13":"D0D0D0","12":"C0C0C0","11":"B0B0B0","10":"A0A0A0","5":"505050","4":"404040","3":"303030","2":"202020","1":"101010"
No, it's not needed to care too much about the order of the strings. mak_kawa has explained why and I was referencing to his reply. So, you don't have to take care about the order of them, just make a proper regular expression substitution, as posted before and I assure you it will work.
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Color Switcher not working

Post by mak_kawa »

Hi balala

Oops...my misunderstaning, sorry. It was already commented out in OP's first post, and revived in his recent post...
mak_kawa
Posts: 908
Joined: December 30th, 2015, 9:47 am

Re: Color Switcher not working

Post by mak_kawa »

Hi CoffeeJoe

Change of the order of substitution string is not a bad idea. I too sometimes use it. But honestly, this way of substitution includes some sort of ambiguity, so not fully recommended at least for myself.
User avatar
balala
Rainmeter Sage
Posts: 16174
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Color Switcher not working

Post by balala »

mak_kawa wrote: December 16th, 2019, 10:07 pm Oops...my misunderstaning, sorry. It was already commented out in OP's first post, and revived in his recent post...
Doesn't matter too much. Such confusions are happening from time to time...