First, thanks Smurfier for this excellent thread on counters!!!
I searched through the forum for information on making a looping or cycling counter with "no joy"
It can be done in Lua and maybe that is the best way, but I need to get better at that!
So in the meantime, I thought someone may find a looping counter useful...
(My apology if I missed this somewhere on the forums!)
Description: A counter that would "loop"; start at a number, count down to zero, then count back to the starting number, and do it all over again.
The
objective is to generate a "seamless" cycle of numbers.
Not counting from zero to XXX, then jumping back to zero.
It is actually not done in the counter measure, but in a formula that uses a standard counter measure and ABS(); the formula is placed in either a variable, a meter, or another measure.
It continuously cycles through a range, with the ability to define step rate and pause it.
Here is a sample to generate a looping range of numbers from 200 to zero and back to 200 in steps of 2.
The variables:
Code: Select all
[Rainmeter]
Update=1000
[Variables]
Pause=1
Multiplier1=2
Range1=200
MyRange1=(ABS(#Range1#/2-[CycleCounter1])*#Multiplier1#)
The counter code would be:
Code: Select all
[CycleCounter1]
Measure=Calc
Formula=(CycleCounter1%#Range1#)+#Pause#
DynamicVariables=1
The #MyRange1# variable will be a range of numbers starting at 200, counting to zero, and then back to 200 in steps of 2, then start over again. The #MyRange1# formula controls the actual range {100 to -100} and stepping rate {multiplied by 2}... then generates an ALWAYS positive number because of the ABS() action.
Be Aware: the "MyRange1# generated number starts at 1/2 of the variable value of #Range1# (NOT at zero), and count from 1/2 of the #Range1# variable, through zero, then down to the negative value of 1/2 of the #Range1# variable It does this at the #Multiplier1# step rate, and generates a seamless looping range of numbers because the
ABS() always returns a positive number.
Example: Range of 510 would generate 255 to -255 if the multiplier is 1. The generated values would be 255 to zero, then back up to 255 because of the ABS() action.
You can then use the #MyRange1# variable in meters to control, let's say "Text alpha":
Code: Select all
[TextLabel]
Meter=String
X=(#ScreenAreaWidth#/2)
Y=(#ScreenAreaHeight#/2)
H=14
W=200
FontSize=8
FontColor=255,255,255,(25+#MyRange1#)
StringEffect=BORDER
ClipString=1
Text="Text is slowly changing alpha..."
DynamicVariables=1
The result is an string meter that will change alpha over a time frame of several minutes (with rainmeter update set at 1000), then repeat.
There are many uses for a looping or cycling counter. I use them to provide seamless thansitions, and YES, it does LOAD the system but gives some nice effects without needing scripts.
Welcome any thoughts about this... I thought someone may find this useful.
Be aware that rainmeter is not designed for animations and over use of this will make rainmeter use more of your system resources.
Thanks again Smurfier!