It is currently October 19th, 2020, 9:01 pm

Growing and shrinking bar based on time

Help with creating, editing & fixing problems with skins
rainmad
Posts: 4
Joined: October 15th, 2020, 5:18 pm

Growing and shrinking bar based on time

Post by rainmad »

Hi,

I would like to create a simple animation,

1. a bar grows from nothing till full in 6 seconds
2. pauses for 2 seconds
3. then shrinks til nothing for 4 seconds
4. Repeat 1 to 3

Is it difficult? and possible? Thank you.
User avatar
Yincognito
Posts: 2759
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Growing and shrinking bar based on time

Post by Yincognito »

rainmad wrote: October 15th, 2020, 5:35 pm Hi,

I would like to create a simple animation,

1. a bar grows from nothing till full in 6 seconds
2. pauses for 2 seconds
3. then shrinks til nothing for 4 seconds
4. Repeat 1 to 3

Is it difficult? and possible? Thank you.
Possible, yes. Difficult, probably not. By the way, what orientation would you like the bar to have?
User avatar
balala
Rainmeter Sage
Posts: 11575
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Growing and shrinking bar based on time

Post by balala »

rainmad wrote: October 15th, 2020, 5:35 pm Hi,

I would like to create a simple animation,

1. a bar grows from nothing till full in 6 seconds
2. pauses for 2 seconds
3. then shrinks til nothing for 4 seconds
4. Repeat 1 to 3

Is it difficult? and possible? Thank you.
Yincognito for sure will come out with his own solution, but here is my simplest solution I was able to come out with:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Step=1
Wait=2

[MeasureGrow]
Measure=Calc
Formula=( MeasureGrow  + #Step# )
IfCondition=(#CURRENTSECTION#=0)
IfTrueAction=[!PauseMeasure "#CURRENTSECTION#"][!SetVariable Step "1"][!Delay "(1000*#Wait#)"][!UnpauseMeasure "#CURRENTSECTION#"]
IfCondition2=(#CURRENTSECTION#=6)
IfTrueAction2=[!PauseMeasure "#CURRENTSECTION#"][!SetVariable Step "-1.5"][!Delay "(1000*#Wait#)"][!UnpauseMeasure "#CURRENTSECTION#"]
MinValue=0
MaxValue=6
DynamicVariables=1

[MeterBar]
MeasureName=MeasureGrow
Meter=BAR
X=0
Y=0
W=200
H=20
BarColor=185,250,160,255
SolidColor=150,150,150,255
BarOrientation=Horizontal
If you want a vertical bar, just replace the BarOrientation option of the [MeterBar] meter with BarOrientation=Vertical and interchange the W and H values of the same meter between them (using W=20 and H=200).
rainmad
Posts: 4
Joined: October 15th, 2020, 5:18 pm

Re: Growing and shrinking bar based on time

Post by rainmad »

Wow... thanks!
I noticed the 4 seconds is actually derived from 6/4 = 1.5..
I guess it's ok, I just wanted it configurable, did not expect it to divide so nicely :)

I still can't figure out the syntax to save my life. But thanks once again!
User avatar
Yincognito
Posts: 2759
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Growing and shrinking bar based on time

Post by Yincognito »

balala wrote: October 15th, 2020, 6:52 pmYincognito for sure will come out with his own solution, but here is my simplest solution I was able to come out with [...]
You were right, I did:

Code: Select all

[Variables]
Update=1000
PxNone=0
PxFull=240
Height=30
Padding=5
UpdateCount=0
Increment=0
Multiplier=(1000/#Update#)

[Rainmeter]
Update=#Update#
DynamicWindowSize=1
AccurateText=1

---Measures---

[PxValue]
Measure=Calc
Formula=(PxValue+#Increment#)
MinValue=#PxNone#
MaxValue=#PxFull#
IfCondition=(#UpdateCount#>=0) && (#UpdateCount#<6)
IfTrueAction=[!SetVariable Increment (#PxFull#/(6*#Multiplier#))]
IfCondition2=(#UpdateCount#>=6) && (#UpdateCount#<8)
IfTrueAction2=[!SetVariable Increment 0]
IfCondition3=(#UpdateCount#>=8) && (#UpdateCount#<12)
IfTrueAction3=[!SetVariable Increment (-#PxFull#/(4*#Multiplier#))]
OnUpdateAction=[!SetVariable UpdateCount ((#UpdateCount#+1/#Multiplier#)%12)]
DynamicVariables=1

---Meters---

[Background]
Meter=Image
W=(#PxFull#+#Padding#*2)
H=(#Height#+#Padding#*2)
SolidColor=0,0,0,64

[Bar]
Meter=Bar
X=#Padding#r
Y=#Padding#r
W=#PxFull#
H=#Height#
BarColor=185,250,160,255
SolidColor=150,150,150,255
BarOrientation=Horizontal
MeasureName=PxValue
It's not the simplest, but it's flexible (one can adjust any parameter, from the width of the bar to the update rate of the skin, and things will adapt accordingly) and precise.

By the way, if you pay attention, your implementation doesn't stay 2 updates (i.e. seconds) at full, just one second. Also, the first empty to full lasts 5 updates (counting from refresh time), while subsequent ones last 6 updates. Probably due to the needed tricks in Rainmeter to have a counter start at 0...

P.S. Isn't it funny how we both shamelessly copy paste the bar example in the manual? :lol:

EDIT: The UpdateCount, Increment and Multiplier values in the [Variables] section should not be modified. The rest of the variables there are open to change.
Last edited by Yincognito on October 15th, 2020, 8:01 pm, edited 2 times in total.
User avatar
balala
Rainmeter Sage
Posts: 11575
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Growing and shrinking bar based on time

Post by balala »

Yincognito wrote: October 15th, 2020, 7:44 pm P.S. Isn't it funny how we both shamelessly copy paste the bar example in the manual? :lol:
It's not shamelessly at all. The manual is the easiest and much quick way to get simple codes, which can be used in our examples, so why not?
rainmad
Posts: 4
Joined: October 15th, 2020, 5:18 pm

Re: Growing and shrinking bar based on time

Post by rainmad »

Gosh thanks to both! I'm glad I reached out for help. It would have taken me forever to do this myself.
No possibility of it moving smoothly up and down I guess? ;-)
User avatar
Yincognito
Posts: 2759
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Growing and shrinking bar based on time

Post by Yincognito »

rainmad wrote: October 15th, 2020, 7:51 pmNo possibility of it moving smoothly up and down I guess? ;-)
Just change the value of the Update variable in the [Variables] section from my version of the code (say, from 1000 to 25), and you'll see how smooth the bar fills and empties. :sly:

Oh, and by the way, the processes will continue to last 6, 2 and 4 seconds, even if you modify the update rate. ;-)

EDIT: If you want to fill and empty the bar "up and down" as opposed to "right and left", just change the corresponding lines in the meter [Bar] to:

Code: Select all

W=#Height#
H=#PxFull#
BarOrientation=Vertical
as previously suggested by balala.
EDIT 2: Similarly switching the width and height values might be needed in meter [Background] as well, like:

Code: Select all

W=(#Height#+#Padding#*2)
H=(#PXFull#+#Padding#*2)
Last edited by Yincognito on October 15th, 2020, 8:09 pm, edited 3 times in total.
rainmad
Posts: 4
Joined: October 15th, 2020, 5:18 pm

Re: Growing and shrinking bar based on time

Post by rainmad »

trying now thanks!
User avatar
Yincognito
Posts: 2759
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Growing and shrinking bar based on time

Post by Yincognito »

balala wrote: October 15th, 2020, 7:48 pm It's not shamelessly at all. The manual is the easiest and much quick way to get simple codes, which can be used in our examples, so why not?
You're right, of course, but it was still funny. :D