It is currently March 29th, 2024, 6:40 am

How do I make an image go up and down smoothly?

Get help with creating, editing & fixing problems with skins
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5384
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: How do I make an image go up and down smoothly?

Post by eclectic-tech »

balala wrote: July 5th, 2019, 6:29 pm I doubt a code with such a low Update (Update=25 in this case) is using less resources then the code with default update, working with the ActionTimer plugin. I simply doubt this. From my experience, I can say the codes working with ActionTimer measures are most efficient ones.
In this case, if you run these 2 skins alone, the Loop method version uses 0~1% (always less than 1% CPU) while the ActionTimer method skin, set to run continuously, uses 0.5~1.5%. :???:

I will leave it up to the OP to decide what method works best for him based on what else is happening in the skin. The Loop measure skin has a default update of 1000 ms (25X40) and only the 2 measures and image meter are running at the faster update rate.

It's good to have options. :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How do I make an image go up and down smoothly?

Post by balala »

eclectic-tech wrote: July 5th, 2019, 8:34 pm The Loop measure skin has a default update of 1000 ms (25X40) and only the 2 measures and image meter are running at the faster update rate.
Theoretically yes, but practically, this is not always true. Yes, I know this was the intention when the DefaultUpdateDivider was introduced, but on a much more complex skin there are a lot of details to be taken into account.
eclectic-tech wrote: July 5th, 2019, 8:34 pm It's good to have options. :thumbup:
Right.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: How do I make an image go up and down smoothly?

Post by jsmorley »

While in general we don't recommend using ActionTimer for never-ending animations, it can be done with something like this:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
OnRefreshAction=[!CommandMeasure MeasureSlider "Execute 1"]

[Variables]
U=[!UpdateMeasure MeasureSlider][!UpdateMeter MeterBox][!Redraw]
YPos=25

[MeterBox]
Meter=Image
W=70
H=70
Y=#YPos#
SolidColor=255,0,0,255
DynamicVariables=1

[MeasureSlider]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat MoveUp, 50, 26 | Wait 1 | Repeat MoveDown, 50, 26 | Wait 1 | Restart
MoveUp=[!SetVariable YPos "(Clamp(#YPos#-1,0,25))"]#U#
MoveDown=[!SetVariable YPos "(Clamp(#YPos#+1,0,25))"]#U#
Restart=[!SetVariable YPos "25"]#U#[!CommandMeasure MeasureSlider "Execute 1"]
DynamicVariables=1
As you extend this into a more realistic use, do be very careful to design it thoughtfully. Ensure things have a chance to "finish" before you restart the actions, and remember that ActionTimer is not "free", abusing it can lead to laggy mouse actions and other unpleasant stuff, even crashing Rainmeter.