It is currently August 5th, 2020, 2:01 pm

Creating Independent Counters

Tips and Tricks from the Rainmeter Community
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Creating Independent Counters

Post by KreAch3R »

smurfier wrote:To be honest I covered it as well as I felt was necessary. Also, you should be able to cut back on the parenthesis by following the order of operations.

Code: Select all

[ScrollCounter]
Measure=Calc
Formula=(ScrollCounter+1)%61*#restart1#
DynamicVariables=1
IfEqualValue=60
IfEqualAction=!Execute !bangs
IfBelowValue=1
IfBelowAction=!SetVariable restart1 1
I'm sorry, but I couldn't find it in the first post. I am talking about the combination of the two of course, because both of them are indeed in the first post. I learned them from there. :)

As far as the order of operations, I hadn't thought that the % was actually a division. I had in mind that it's the counter's special parameter. Thanks :)
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
Kaelri
Developer
Posts: 1739
Joined: July 25th, 2009, 4:47 am

Re: Creating Independent Counters

Post by Kaelri »

KreAch3R wrote:As far as the order of operations, I hadn't thought that the % was actually a division. I had in mind that it's the counter's special parameter. Thanks :)
The % operator is your friend. I waited way too long to learn it, and once I did, it solved a lot of problems for me. What it does (in this context) is divide two numbers and return the remainder. For example:

1%4 = 1
2%4 = 2
3%4 = 3
4%4 = 0
5%4 = 1
6%4 = 2

That's why it's enormously useful for detecting the end of a "counter," looping a series, etc.
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Creating Independent Counters

Post by KreAch3R »

Wow. This just opens a whole new way of doing or understanding things (except for the skins I have already used it but I didn't know what it was doing). Thanks for sharing that Kaelri. It should be added to the manual, too.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
pankit_1990
Posts: 1
Joined: October 15th, 2011, 12:49 pm

Re: Creating Independent Counters

Post by pankit_1990 »

Code: Select all

[Rainmeter]
Author=Kenz0 (mail2kenz0@gmail.com)
BackgroundMode=0
Update=12

;Metadata added by RainBrowser
;http://rainmeter.net/RainWiki/index.php?title=Rainmeter_101#.5BMetadata.5D

[Metadata]
Name=
Config=
Description=
Instructions=
Version=
Tags=
License=
Variant=
Preview=

;End of added Metadata

[MeasureMove]
Measure=Calc
Formula=Counter % #SCREENAREAHEIGHT#

[MeasurePositionX]
Measure=Calc
Formula=(#SCREENAREAWIDTH# / 2) - 50

[MeasureTrigger]
Measure=Calc
Formula=Counter % 2
IfEqualValue=1
IfEqualAction=!RainmeterMove [MeasurePositionX] [MeasureMove]

[MeterBackground]
Meter=IMAGE
X=0
Y=1
W=1024
H=1
SolidColor=0, 0, 0,1
SolidColor2=255, 255, 255,200
GradientAngle=45.0
i am having this code. and it moves the horizontal bar up to down.
but i want that bar to be vertical and wants to move it from left to right or right to left. It is having counter code. that is why i am asking over here.
Can anyone help me please? thanks in advance. :) :???: ;)
User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Creating Independent Counters

Post by smurfier »

I believe this should do the trick. You'll have to tweak the H=1024 on [MeterBackground].

Code: Select all

[Rainmeter]
Author=Kenz0 (mail2kenz0@gmail.com)
BackgroundMode=0
Update=12

;Metadata added by RainBrowser
;http://rainmeter.net/RainWiki/index.php?title=Rainmeter_101#.5BMetadata.5D

[Metadata]
Name=
Config=
Description=
Instructions=
Version=
Tags=
License=
Variant=
Preview=

;End of added Metadata

[MeasureMove]
Measure=Calc
Formula=Counter % #SCREENAREAWIDTH#

[MeasurePositionY]
Measure=Calc
Formula=(#SCREENAREAHEIGHT# / 2) - 50

[MeasureTrigger]
Measure=Calc
Formula=Counter % 2
IfEqualValue=1
IfEqualAction=!RainmeterMove [MeasureMove] [MeasurePositionY]
DynamicVariables=1

[MeterBackground]
Meter=IMAGE
X=0
Y=1
W=1
H=1024
SolidColor=0, 0, 0,1
SolidColor2=255, 255, 255,200
GradientAngle=45.0
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 . . .
User avatar
TweaknFreak
Posts: 220
Joined: July 14th, 2012, 7:26 am

Re: Creating Independent Counters

Post by TweaknFreak »

Is it possible to do a fade out effect with this counter and linking it to any image meter's Alpha value??
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
User avatar
smurfier
Moderator
Posts: 1937
Joined: January 29th, 2010, 1:43 am
Location: Willmar, MN

Re: Creating Independent Counters

Post by smurfier »

TweaknFreak wrote:Is it possible to do a fade out effect with this counter and linking it to any image meter's Alpha value??
I suppose it is.

Code: Select all

[Rainmeter]
Update=50

[cAlpha]
Measure=Calc
Formula=cAlpha+5
IfAboveValue=255
IfAboveAction=[!HideMeter mImage][!DisableMeasure #CURRENTSECTION#]
Disabled=1

[mImage]
Meter=Image
ImageName=Something.png
ImageAlpha=(255-[cAlpha])
DynamicVariables=1
LeftMouseUpAction=!EnableMeasure cAlpha
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 . . .
User avatar
TweaknFreak
Posts: 220
Joined: July 14th, 2012, 7:26 am

Re: Creating Independent Counters

Post by TweaknFreak »

Thanx very much ! :)
Be one of the iNEViTABLES - Storm, Earthquake, Lightning, Flood - and the world will bow down to you.

My current desktop
[hsimg]http://i1313.photobucket.com/albums/t559/TweaknFreak/6-22-20149-46-40PM_zps7bcbc1f6.png[/hsimg]
User avatar
eclectic-tech
Rainmeter Sage
Posts: 4063
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Creating Independent Counters

Post by eclectic-tech »

First, thanks Smurfier for this excellent thread on counters!!! :thumbup:

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!
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Creating Independent Counters

Post by KreAch3R »

smurfier wrote: Bonus Lesson: Making a counter that counts down, not up

Code: Select all

[cCounter]
Measure=Calc
Formula=(cCounter-1+(#MaxNumber#+1))%(#MaxNumber#+1)
This one is a bit harder to explain. What we are doing is taking the value of the counter and subtracting 1. Then we have to add the value of our MaxNumber else we'll just end up with a negative value. Now we have to take the remainder of that value using Modulo to get our final value.
Because I'm having a hard time understanding how this works, and my hopeless efforts did nothing, is there a way to have a bang add "2" to the current measure value, and then the measure continues it's countdown? Something like !SetVariable "Add" "2" that would make the measure go from, let's say, "14" to "16", and then continue declining again, "15", "14", etc.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image