It is currently March 28th, 2024, 5:00 pm

Changing image using a measure?

Get help with creating, editing & fixing problems with skins
Post Reply
ItalicizedEyes
Posts: 4
Joined: October 1st, 2010, 12:04 am
Contact:

Changing image using a measure?

Post by ItalicizedEyes »

I am trying to make a semi complicated calendar. This is my first time posting and making a skin,so bear with me :)

So anyway,what I am hoping to do is be able to change my calendar image depending on the day. I am using a png image for my calendar, and for instance I want the calendar to use and image that has Monday highlighted, then on Tuesday have an image that tuesday highlighted.

I really want to do this without having do type it in manually, the only things that I think might work is using a time measure or calc. Although Im still not sure. Any help would be greatly appreciated, thank you so much everyone :)
Attachments
TUESDAY.png
and then tuesday, and so one and so forth
Default.png
This is what would be displayed on monday
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

Re: Changing image using a measure?

Post by Aarowaim »

If you use a time measure with a substitution, it will replace %w (the day of the week) with the proper image. So if %w returns
1 (which is usually monday) it will replace that with day1.png. You can also do this with the other time measures. To place the image into your meter, make sure to add DynamicVariables=1 and ImageName=[DayImage] into your meter

Code: Select all

[DayImage]
Measure=Time
Format=%w 
Substitute="0":"Sunday.png","1":"Monday.png","2":"Tuesday.png","3":"Wednesday.png","4":"Thursday.png","5":"Friday.png","6":"Saturday.png"
DynamicVariables=1
 
[MeterDay]
Meter=Image
ImageName=[DayImage]
DynamicVariables=1
NOTE: You can use the substitution on any measure, so you can do this for the month, year and date measures as well.
You can find all the information about the time measure @ http://rainmeter.net/cms/Measures-Time_beta

If you want to display the next few days as images (that aren't highlighted), you'll need some offset measures that will return the next day's value. You can do this by running the time measure through a calc and adding 1 (equal to 1 day). by using this offset version of [CurrentDay], you essentially tell the 2ndDay meter that it is a day later than it really is and it will only display the non-highlighted day images. (day1h.png is the highlighted version of day1.png)

Code: Select all

[DayImage]
Measure=Time
Format=%w 

[2ndDay]
Measure=Calc 
Formula=[DayImage]=6 ? [DayImage]-6 : [DayImage]+1
Substitute="0":"day0.png","1":"day1.png","2":"day2.png","3":"day3.png","4":"day4.png","5":"day5.png","6":"day6.png"
DynamicVariables=1

[3rdDay]
Measure=Calc 
Formula=[DayImage]<4 ? [DayImage]-5 : [DayImage]+2
Substitute="0":"day0.png","1":"day1.png","2":"day2.png","3":"day3.png","4":"day4.png","5":"day5.png","6":"day6.png"
DynamicVariables=1

[CurrentDay]
Measure=Calc 
Formula=[DayImage]
Substitute="0":"day0h.png","1":"day1h.png","2":"day2h.png","3":"day3h.png","4":"day4h.png","5":"day5h.png","6":"day6h.png"

[MeterCurrentDay]
Meter=Image
ImageName=[CurrentDay]
X=0r
Y=0r
DynamicVariables=1

[Meter2ndDay]
Meter=Image
ImageName=[2ndDay]
X=0r
Y=0r
DynamicVariables=1

[Meter3rdDay]
Meter=Image
ImageName=[3rdDay]
X=0r
Y=0r
DynamicVariables=1


Because the day measure only allows 0-6, we add an argument that says if DayImage=6, subtract 6, otherwise, add 1 to DayImage. With the 3rd day measure, because we are adding two, we need to make it so that it says if DayImage is higher than 4,
subtract 5, otherwise, add 2.

You would have to add quite a few of these offset meters and measures in order to populate your whole calendar with images, but it would be very worthwhile. A quick word of advice; re-use a measure as often as you can because it will mean only making the meter to display that image again in a different spot. e.g, all the tuesdays on your calendar would be reading from the same measure.

Remember to use the logical arguments on the cals that offset the time reading and when your making the time measures for the day of the month, make sure to use %#d to drop the zero in front. Also, ensure that all the measures you use for time are the decimal version so that it is much easier than adding extra substitutions.
I hope that this helps. By the way, nice skin.

EDIT: I have edited this post so that it includes more accurate information.
Also, here is a list of the time calcs that you should use.
  • %#d - Day of month as decimal number (01 – 31)
    %#m - Month as decimal number (01 – 12)
    %w - Weekday as decimal number (0 – 6; Sunday is 0) (don't add the # because you don't need to drop zero's)
    %Y - Year with century, as decimal number
EDIT: Fixed the substitution example
Last edited by Aarowaim on October 5th, 2010, 1:31 am, edited 1 time in total.
ItalicizedEyes
Posts: 4
Joined: October 1st, 2010, 12:04 am
Contact:

Re: Changing image using a measure?

Post by ItalicizedEyes »

Thank you so much for liking my skin and replying :)

(I'm still learning the language so sorry for any stupid questions :P )

I tried to use substitute for my highlighted day, and when I saved and refreshed the skin, my image didn't show up.... do you know why?

This is what I have for my code, tell me if I'm doing something wrong

Code: Select all

;----------MEASURES----------

[MeasureTime]
Measure=Time


;----------METERS------------

[DayImage]
Measure=Time
Format=%w
Substitute="1":"Monday01.png","2":"Monday02.png","3":"Monday03.png","4":"Monday04.png","5":"Monday05.png","6":"Tuesday01.png",".7":"Tuesday02.png"
DynamicVariables=1

[MeterDay]
Meter=Image
ImageName=[DayImage]
DynamicVariables=1
ItalicizedEyes
Posts: 4
Joined: October 1st, 2010, 12:04 am
Contact:

Re: Changing image using a measure?

Post by ItalicizedEyes »

Aarowaim wrote:If you use a time measure with a substitution, it will replace %w (the day of the week) with the proper image. So if %w returns
1 (which is usually monday) it will replace that with day1.png. You can also do this with the other time measures. To place the image into your meter, make sure to add DynamicVariables=1 and ImageName=[DayImage] into your meter

Code: Select all

[DayImage]
Measure=Time
Format=%w 
Substitute="1":"day1.png","2":"day2.png","3":"day3.png","4":"day4.png","5":"day5.png","6":"day6.png","7":"day7.png"
DynamicVariables=1
 
[MeterDay]
Meter=Image
ImageName=[DayImage]
DynamicVariables=1
NOTE: You can use the substitution on any measure, so you can do this for the month, year and date measures as well.
You can find all the information about the time measure @ http://rainmeter.net/cms/Measures-Time_beta

If you want to display the next few days as images (that aren't highlighted), you'll need some offset measures that will return the next day's value. You can do this by running the time measure through a calc and adding 1 (equal to 1 day). by using this offset version of [CurrentDay], you essentially tell the 2ndDay meter that it is a day later than it really is and it will only display the non-highlighted day images. (day1h.png is the highlighted version of day1.png)

Code: Select all

[DayImage]
Measure=Time
Format=%w 

[2ndDay]
Measure=Calc 
Formula=[DayImage]=6 ? [DayImage]-6 : [DayImage]+1
Substitute="0":"day0.png","1":"day1.png","2":"day2.png","3":"day3.png","4":"day4.png","5":"day5.png","6":"day6.png"
DynamicVariables=1

[3rdDay]
Measure=Calc 
Formula=[DayImage]<4 ? [DayImage]-5 : [DayImage]+2
Substitute="0":"day0.png","1":"day1.png","2":"day2.png","3":"day3.png","4":"day4.png","5":"day5.png","6":"day6.png"
DynamicVariables=1

[CurrentDay]
Measure=Calc 
Formula=[DayImage]
Substitute="0":"day0h.png","1":"day1h.png","2":"day2h.png","3":"day3h.png","4":"day4h.png","5":"day5h.png","6":"day6h.png"

[MeterCurrentDay]
Meter=Image
ImageName=[CurrentDay]
X=0r
Y=0r
DynamicVariables=1

[Meter2ndDay]
Meter=Image
ImageName=[2ndDay]
X=0r
Y=0r
DynamicVariables=1

[Meter3rdDay]
Meter=Image
ImageName=[3rdDay]
X=0r
Y=0r
DynamicVariables=1


Because the day measure only allows 0-6, we add an argument that says if DayImage=6, subtract 6, otherwise, add 1 to DayImage. With the 3rd day measure, because we are adding two, we need to make it so that it says if DayImage is higher than 4,
subtract 5, otherwise, add 2.

You would have to add quite a few of these offset meters and measures in order to populate your whole calendar with images, but it would be very worthwhile. A quick word of advice; re-use a measure as often as you can because it will mean only making the meter to display that image again in a different spot. e.g, all the tuesdays on your calendar would be reading from the same measure.

Remember to use the logical arguments on the cals that offset the time reading and when your making the time measures for the day of the month, make sure to use %#d to drop the zero in front. Also, ensure that all the measures you use for time are the decimal version so that it is much easier than adding extra substitutions.
I hope that this helps. By the way, nice skin.

EDIT: I have edited this post so that it includes more accurate information.
Also, here is a list of the time calcs that you should use.
  • %#d - Day of month as decimal number (01 – 31)
    %#m - Month as decimal number (01 – 12)
    %w - Weekday as decimal number (0 – 6; Sunday is 0) (don't add the # because you don't need to drop zero's)
    %Y - Year with century, as decimal number

Thank you so much for liking my skin and replying :)

(I'm still learning the language so sorry for any stupid questions :P )

I tried to use substitute for my highlighted day, and when I saved and refreshed the skin, my image didn't show up.... do you know why?

This is what I have for my code, tell me if I'm doing something wrong

Code: Select all

;----------MEASURES----------

[MeasureTime]
Measure=Time


;----------METERS------------

[DayImage]
Measure=Time
Format=%w
Substitute="1":"Monday01.png","2":"Monday02.png","3":"Monday03.png","4":"Monday04.png","5":"Monday05.png","6":"Tuesday01.png",".7":"Tuesday02.png"
DynamicVariables=1

[MeterDay]
Meter=Image
ImageName=[DayImage]
DynamicVariables=1
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

Re: Changing image using a measure?

Post by Aarowaim »

The Format=%w belongs in the time measure (under [MeasureTime] ). It should work. btw, I made a mistake in the substitutions, the %w tells whatever meter you connect it to the day of the week as a number from 0-6 rather than 1-7 like I have in my post. I am editing that post to be correct as soon as I finish this post. Anyway, here is what the code should look like if I fix the mistakes (Including Mine ;) ).

Code: Select all

;----------MEASURES----------

[MeasureTime]
Measure=Time
TimeFormat=%w

;----------METERS------------

[DayImage]
Measure=MeasureTime
Substitute="0":"Monday01.png","1":"Monday02.png","2":"Monday03.png","3":"Monday04.png","4":"Monday05.png","5":"Tuesday01.png","6":"Tuesday02.png"
DynamicVariables=1

[MeterDay]
Meter=Image
ImageName=[DayImage]
X=0
Y=0
DynamicVariables=1
With your meters, I highly recommend that you include the X= and Y= commands. These tell the skin where to position these meters. So for example, under any meter, let's say you want the image to be 100 pixels to the right of where the skin starts, you would put:

Code: Select all

[YourMeter]
X=0
Y=100
If you want a meter to be 10 pixels to the right of [YourMeter], you would put:

Code: Select all

[YourMeter]
X=0
Y=100

[Your2ndMeter]
X=0
Y=10r

The 10r means ten pixels relative to the previous meter listed in the code.

P.S
0 is sunday and 1 is monday, so make sure that you change the images to match.
ItalicizedEyes
Posts: 4
Joined: October 1st, 2010, 12:04 am
Contact:

Re: Changing image using a measure?

Post by ItalicizedEyes »

Aarowaim wrote:The Format=%w belongs in the time measure (under [MeasureTime] ). It should work. btw, I made a mistake in the substitutions, the %w tells whatever meter you connect it to the day of the week as a number from 0-6 rather than 1-7 like I have in my post. I am editing that post to be correct as soon as I finish this post. Anyway, here is what the code should look like if I fix the mistakes (Including Mine ;) ).

Code: Select all

;----------MEASURES----------

[MeasureTime]
Measure=Time
TimeFormat=%w

;----------METERS------------

[DayImage]
Measure=MeasureTime
Substitute="0":"Monday01.png","1":"Monday02.png","2":"Monday03.png","3":"Monday04.png","4":"Monday05.png","5":"Tuesday01.png","6":"Tuesday02.png"
DynamicVariables=1

[MeterDay]
Meter=Image
ImageName=[DayImage]
X=0
Y=0
DynamicVariables=1
With your meters, I highly recommend that you include the X= and Y= commands. These tell the skin where to position these meters. So for example, under any meter, let's say you want the image to be 100 pixels to the right of where the skin starts, you would put:

Code: Select all

[YourMeter]
X=0
Y=100
If you want a meter to be 10 pixels to the right of [YourMeter], you would put:

Code: Select all

[YourMeter]
X=0
Y=100

[Your2ndMeter]
X=0
Y=10r

The 10r means ten pixels relative to the previous meter listed in the code.

P.S
0 is sunday and 1 is monday, so make sure that you change the images to match.

Its still not working.... don't I have to tell it what path the pictures are in? Otherwise, how will it know where to get the pictures?
Aarowaim
Posts: 97
Joined: July 25th, 2010, 7:23 am

Re: Changing image using a measure?

Post by Aarowaim »

ItalicizedEyes wrote:Its still not working.... don't I have to tell it what path the pictures are in? Otherwise, how will it know where to get the pictures?
You do not need to specify a path unless the images are in a different location. Rainmeter automatically assumes that when no path is specified that the images are at the same location as the skin. The problem is that calc measures will not accept strings (text), so instead, I have a different way to achieve this. for this, I'll use my previous example but fixed (and the image names are changed to be easier to understand)
Here it is:

Code: Select all

[Rainmeter]

[2ndDay]
Measure=Time
Format=%w
Substitute="0":"Saturday.png","1":"Sunday.png","2":"Monday.png","3":"Tuesday.png","4":"Wednesday.png","5":"Thursday.png","6":"Friday.png"

[3rdDay]
Measure=Time
Format=%w
Substitute="0":"Friday.png","1":"Saturday.png","2":"Sunday.png","3":"Monday.png","4":"Tuesday.png","5":"Wednesday.png","6":"Thursday.png"

[CurrentDay]
Measure=Time
Format=%w
Substitute="0":"SundayH.png","1":"MondayH.png","2":"TuesdayH.png","3":"WednesdayH.png","4":"ThursdayH.png","5":"FridayH.png","6":"SaturdayH.png"

[MeterCurrentDay]
Meter=Image
MeasureName=CurrentDay
X=10r
Y=0r

[Meter2ndDay]
Meter=Image
MeasureName=2ndDay
X=10r
Y=0r

[Meter3rdDay]
Meter=Image
MeasureName=3rdDay
X=10r
Y=0r
In my above example, I have fixed the problem. Notice that I used MeasureName instead of ImageName? This is because it makes it a lot easier because you don't need to worry about adding DynamicVariables=1 to use the name of a measure outside of MeasureName. You also do not need to add the brackets around the name. To solve the offset problem, rather than offsetting the day that the measure reads, I offset the image and added more time measures rather than calc measures (which only return numbers as the result). The calc measures being unable to return text as a result is the reason that it did not work before.

Now it's your turn to try your hand at fixing your skin. I'm not doing this to be mean, but it will help you to learn and for me to make sure that you understand what I'm teaching. If you still have questions, please ask.
Post Reply