Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1407

Help: Rainmeter Skins • Re: Need help with image

$
0
0
Like balala mentioned above, relying on clock time automatically means that you're not necessarily relying on the moment when the skin was loaded - this is precisely why I asked my 2nd question in my 1st reply. That 1 minute must pass in relation to some other moment in time, and if you loaded the skin at 20:00:30 and you're relying on clock time, that means you'll have to wait another 30 seconds from when you loaded the skin in order to change the image at precisely 20:01:00.

So, if you meant "1 minute passed since the skin was loaded", jsmorley's sample would be the base of what you need. On the other hand, if you really meant "1 minute passed since the clock showed a full minute", then balala's alternative would be suited for you.

Assuming the 1st possibility above is the one you want to follow, here's jsmorley's sample adapted to fade / transition between images (I think it can easily be adapted to the other case mentioned by balala, if needed):

Code:

[Rainmeter]Update=1000DynamicWindowSize=1AccurateText=1[Variables]Alpha=0Direction=-1Steps=51[MeasureTransition]Measure=PluginPlugin=ActionTimerActionList1=Start | Repeat Trans,5,#Steps# | CeaseStart=[!SetVariable Alpha (#Direction#=1?0:255)][!UpdateMeasure #CURRENTSECTION#][!UpdateMeter *][!Redraw]Trans=[!SetVariable Alpha (Clamp(#Alpha#+#Direction#*255/#Steps#,0,255))][!UpdateMeasure #CURRENTSECTION#][!UpdateMeter *][!Redraw]Cease=[!SetVariable Alpha (#Direction#=1?255:0)][!UpdateMeasure #CURRENTSECTION#][!UpdateMeter *][!Redraw]UpdateDivider=-1DynamicVariables=1[MeasureMinute]Measure=CalcFormula=(MeasureMinute%60)+1IfCondition=MeasureMinute = 60IfTrueAction=[!SetVariable Direction (-#Direction#)][!UpdateMeasure MeasureTransition][!CommandMeasure MeasureTransition "Stop 1"][!CommandMeasure MeasureTransition "Execute 1"]DynamicVariables=1[MyImageMeter0]Meter=ImageImageName=#@#MyImages\MyImage0.pngImageAlpha=(255-#Alpha#)DynamicVariables=1[MyImageMeter1]Meter=ImageImageName=#@#MyImages\MyImage1.pngImageAlpha=(0+#Alpha#)DynamicVariables=1
Like mentioned earlier, I use opposite ImageAlpha formulas for the two images (one decreasing when Alpha increases, one increasing when Alpha increases), based on a variable I called Alpha. As a result, now the MyNumber variable isn't needed anymore given that I always display both images with opposite transparencies, which will vary / alternate each minute. Therefore, I replaced that variable with one that I called Direction, which alternates between -1 and 1 in order to alternate between increasing and decreasing the value of the Alpha variable in the MeasureTransition measure (setting the variable and triggering the ActionTimer animation in MeasureTransition happens every time 1 minute passed, as per the IfCondition in MeasureMinute).

Then, in the ActionTimer measure, besides its specific syntax described in the link from the manual I mentioned above, I used numeric conditionals (also called ternary operators in other languages) to set the starting and ending Alpha to either 0 or 255 based on the value of Direction (in the Start and Cease "actions"), as well as actually performing the fade / transition by incrementing or decrementing Alpha followed by updating the relevant sections / redrawing the skin. As you probably realized by now, the value of the Direction variable controls whether Alpha is incremented or decremented - it's just a bit of basic math.

P.S. As in jsmorley's sample, this assumes you have MyImage0.png and MyImage1.png in your [SkinFolder]\@Resources\MyImages folder. This is slightly different in balala's version, but, well, they're just paths, they can easily be changed in the ImageName options (#@# means the @Resources folder in your skin).

Statistics: Posted by Yincognito — Yesterday, 9:17 pm



Viewing all articles
Browse latest Browse all 1407

Trending Articles