It is currently April 26th, 2024, 1:08 am

Changing the color of text dynamically for clock

General topics related to Rainmeter.
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Changing the color of text dynamically for clock

Post by LeftSide »

So basically if I wanted the text displaying the time change it's color every second, how should I go about it?
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing the color of text dynamically for clock

Post by jsmorley »

There are tons of ways, here is one:

Code: Select all

[Rainmeter]
Update=1000

[MeasureRed]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=0
HighBound=255

[MeasureGreen]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=0
HighBound=255

[MeasureBlue]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=0
HighBound=255

[MeasureHourMinute]
Measure=Time
Format=%#I:%M

[MeasureSecond]
Measure=Time
Format=%S

[MeterHourMinute]
Meter=String
MeasureName=MeasureHourMinute
FontFace=Arial
FontSize=70
FontColor=255,255,255,255
StringStyle=Bold
Antialias=1
Text=%1:

[MeterSecond]
Meter=String
MeasureName=MeasureSecond
X=-27R
FontFace=Arial
FontSize=70
FontColor=[MeasureRed],[MeasureGreen],[MeasureBlue],255
StringStyle=Bold
Antialias=1
DynamicVariables=1
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Re: Changing the color of text dynamically for clock

Post by LeftSide »

This works perfectly. Thanks!
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Re: Changing the color of text dynamically for clock

Post by LeftSide »

Follow-up ..

Does `UpdateRandom` take variables/meters? I tried but it doesn't work.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing the color of text dynamically for clock

Post by jsmorley »

LeftSide wrote:Follow-up ..

Does `UpdateRandom` take variables/meters? I tried but it doesn't work.
UpdateRandom is just a true (1) or false (0) option for a Calc measure using the Random function. It simply tells the measure to get a "new" random number on each update of the skin.
Otherwise the default behavior is to get a single random number that would not change unless the skin is refreshed.
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Re: Changing the color of text dynamically for clock

Post by LeftSide »

Oh jeez damnit I meant `LowBound` and `HighBound`. Excuse my brain fart.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing the color of text dynamically for clock

Post by jsmorley »

LeftSide wrote:Oh jeez damnit I meant `LowBound` and `HighBound`. Excuse my brain fart.
You can use a variable defined in the [Variables] section as #VarName#. You can also use the number value of a measure with [MeasureName:], as long as you also put DynamicVariables=1 on the measure where you are setting LowBound / HighBound.

Note, I used [MeasureName:] since you want the number value of the measure and not a string value. If the measure you are using only returns a number (or the number and string values are the same numerical value) then you can just use [MeasureName].
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Re: Changing the color of text dynamically for clock

Post by LeftSide »

Then I must be doing it wrong...

Here I have put `LowBound=[Color_Time_mS]` but as you see `[MeasureGreen]` is disobeying (its value `114` is less than lowerbound 128.77725). I think it's taking any value from 0-255 regardless of what I put in LowerBound except for a number.

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

Re: Changing the color of text dynamically for clock

Post by jsmorley »

Without DynamicVariables=1 on [MeasureGreen] (for instance), it will only use the very first value that the calc measure returns, and is never updated.
LeftSide
Posts: 35
Joined: July 3rd, 2012, 6:16 pm

Re: Changing the color of text dynamically for clock

Post by LeftSide »

Thanks so much! I did read the part about setting DynamicVariables but kept on thinking it's only required in [Meter]s. Another brain fart x_x. Thanks again :)