It is currently May 7th, 2024, 10:03 am

Changing Font Colour Daily

Get help with creating, editing & fixing problems with skins
BenG
Posts: 39
Joined: March 15th, 2012, 4:32 pm

Changing Font Colour Daily

Post by BenG »

Anyone got any idea how I could do this?
I want the day to change colour every day the code I have is from a skin I picked up

Code: Select all

[MeterDay]
MeasureName=MeasureDay
Meter=STRING
X=100
Y=20
FontColor=87F717
FontSize=20
FontFace=Tw Cen MT
StringAlign=LEFT
StringStyle=Normal
AntiAlias=1
Does anyone have any ideas where I could start as I'm a bit lost? Cheers,

Ben

EDIT: I am aware I can use Substitute such as

Code: Select all

Substitute="Monday":"255,255,255,255","Tuesday":"102,204,255,255"
But I want it to be random =/
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing Font Colour Daily

Post by jsmorley »

Something like this would work:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureDay]
Measure=Time
Format=%A

[MeasureNewDay]
Measure=Time
Format=%#H
IfEqualValue=1
IfEqualAction=[!UpdateMeasure MeasureRed][!UpdateMeasure MeasureGreen][!UpdateMeasure MeasureBlue]

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

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

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

[MeterDay]
MeasureName=MeasureDay
Meter=STRING
X=0
Y=0
FontColor=[MeasureRed],[MeasureGreen],[MeasureBlue],255
FontSize=20
FontFace=Arial
StringAlign=LEFT
StringStyle=Normal
AntiAlias=1
DynamicVariables=1
This will change the color to a random one every day at 1am. If you change IfEqualValue=1 to IfEqualValue=0, then it will change every day at midnight, and will also change when you refresh the skin.
BenG
Posts: 39
Joined: March 15th, 2012, 4:32 pm

Re: Changing Font Colour Daily

Post by BenG »

I'll give it a go. Where did you put the colour codes? or doesn't it need them?
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing Font Colour Daily

Post by jsmorley »

BenG wrote:I'll give it a go. Where did you put the colour codes? or doesn't it need them?
IfEqualAction=[!UpdateMeasure MeasureRed][!UpdateMeasure MeasureGreen][!UpdateMeasure MeasureBlue]

This creates the color code by updating those three measures. They will each return a random number from 0 to 255, and then you use those numbers in the FontColor= setting in the meter.

You might end up with [MeasureRed] being 42, [MeasureGreen] being 133 and [MeasureBlue] being 210. So the FontColor will end up as FontColor=42,133,210,255, a darkish blue. Purely random settings like this will result in some really ugly colors sometimes of course, but that is the price you are going to pay for having it be random.
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing Font Colour Daily

Post by jsmorley »

Ah sorry, I made one mistake in my post to you

IfEqualAction=[!UpdateMeasure MeasureRed][!UpdateMeasure MeasureGreen][!UpdateMeasure MeasureBlue]

Should be IfEqualAction=!Execute [!UpdateMeasure MeasureRed][!UpdateMeasure MeasureGreen][!UpdateMeasure MeasureBlue]
BenG
Posts: 39
Joined: March 15th, 2012, 4:32 pm

Re: Changing Font Colour Daily

Post by BenG »

Ah I understand nice work. Starting to understand the coding too which is nice, I'm going to try and develop it so It'll be random but only for the brightest colours. I keep getting nasty browns and stuff which is understandable. Cheers though dude should help me with my project :)
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing Font Colour Daily

Post by jsmorley »

Yeah, I would probably not use this approach myself, as there is no easy way to avoid some really fugly colors when you randomize the red,green,blue like this. I would be more tempted to use a Lua script, creating a table of a dozen or so colors I liked, then have the skin fire the Lua script once a day and pick a random color out of that table. Then I could have it still be somewhat random, but only using colors that make sense.

I can post a quick example of how I would approach that if you are interested.
BenG
Posts: 39
Joined: March 15th, 2012, 4:32 pm

Re: Changing Font Colour Daily

Post by BenG »

Yeah that sounds good. I can try and adapt it to be random everyday, this seems more like what I was after
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Changing Font Colour Daily

Post by jsmorley »

I would do something like:

Skin:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1

[MeasureDay]
Measure=Time
Format=%A

[MeasureNewDay]
Measure=Time
Format=%#H
IfEqualValue=0
IfEqualAction=!Execute [!UpdateMeasure MeasureRandom][!CommandMeasure MeasureScript "SelectColor([MeasureRandom]);"]
DynamicVariables=1

[MeasureRandom]
Measure=Calc
Formula=Random
UpdateRandom=1
LowBound=1
HighBound=10
UpdateDivider=-1

[MeasureScript]
Measure=Script
ScriptFile=#CURRENTPATH#Test.lua
UpdateDivider=-1

[MeterDay]
MeasureName=MeasureDay
Meter=STRING
X=0
Y=0
FontColor=255,255,255,255
FontSize=20
FontFace=Arial
StringAlign=LEFT
StringStyle=Normal
AntiAlias=1
DynamicVariables=1
Test.lua:

Code: Select all

function Initialize()

	tColors =
	{
		'250,117,120';
		'250,117,188';
		'219,117,250';
		'117,120,250';
		'117,181,250';
		'117,250,250';
		'117,250,170';
		'155,250,117';
		'248,250,117';
		'250,210,117';
	}
		

end -->Initialize

function SelectColor(parm)
	
	SKIN:Bang('!SetOption MeterDay FontColor '..tColors[parm])

end -->SelectColor
What this does once a day (and on refresh) is get a random number in the skin from 1 to 10 (it could be from 1 to any number of colors you want). Then it fires that random number to the Lua script as a parameter to a function called SelectColor(). In the Lua, we have set up a table when the skin is first loaded that contains 10 color codes. (again you could have as many as you want, just need to change the skin to match) The SelectColor() function uses the parameter passed by the skin, which is that number from 1 to 10, and selects the matching color code out of the tColors table. Then it simply sets the FontColor of the meter to that color using a bang.

Let me know if there is anything here you don't understand, I'll try to further explain if needed.
User avatar
smurfier
Moderator
Posts: 1931
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Changing Font Colour Daily

Post by smurfier »

With a little tweaking, the lua script can test if the day changed for you, as well as do the whole random color bit.

Code: Select all

function Initialize()
	Today=0
	tColors = {
		'250,117,120';
		'250,117,188';
		'219,117,250';
		'117,120,250';
		'117,181,250';
		'117,250,250';
		'117,250,170';
		'155,250,117';
		'248,250,117';
		'250,210,117';
	}
      

end -->Initialize

function Update()
	
	local Time=os.date('*t')
	if Time.day~=Today then
		ColorChange()
		Today=Time.day
	end
	
end -->Update

function ColorChange()
	SKIN:Bang('!SetOption MeterDay FontColor '..tColors[math.random(#tColors)])
end -->ColorChange
GitHub | DeviantArt | Tumblr
This is the song that never ends. It just goes on and on my friends. Some people started singing it not knowing what it was, and they'll continue singing it forever just because . . .