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.
It is currently March 28th, 2024, 10:34 pm
Growing and shrinking bar based on time
-
- Posts: 4
- Joined: October 15th, 2020, 5:18 pm
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Growing and shrinking bar based on time
Possible, yes. Difficult, probably not. By the way, what orientation would you like the bar to have?
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Growing and shrinking bar based on time
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
-
- Posts: 4
- Joined: October 15th, 2020, 5:18 pm
Re: Growing and shrinking bar based on time
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!
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!
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Growing and shrinking bar based on time
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
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?
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.
-
- Rainmeter Sage
- Posts: 16110
- Joined: October 11th, 2010, 6:27 pm
- Location: Gheorgheni, Romania
Re: Growing and shrinking bar based on time
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?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?
-
- Posts: 4
- Joined: October 15th, 2020, 5:18 pm
Re: Growing and shrinking bar based on time
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?
No possibility of it moving smoothly up and down I guess?
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: Growing and shrinking bar based on time
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.
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
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.
-
- Posts: 4
- Joined: October 15th, 2020, 5:18 pm
Re: Growing and shrinking bar based on time
trying now thanks!
-
- Rainmeter Sage
- Posts: 7029
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita