It is currently March 28th, 2024, 8:31 pm

Playing an animation every time i click on the meter

Get help with creating, editing & fixing problems with skins
Arless
Posts: 4
Joined: November 19th, 2017, 8:29 pm

Playing an animation every time i click on the meter

Post by Arless »

Hi everyone! I'm trying to create a little skin, and I'm trying to implement a little animation everytime i click on the meter. I've been working on it for a while and i still cant figure it out, this is the code i wrote

Code: Select all

[Rainmeter]
Update=16

[MeterAct]
Meter=Button
Padding=120,120
MeasureName=MeasureAct
LeftMouseUpAction=[!SetOption MeasureTrasp InvertMeasure 1][!UpdateMeasure MeasureTrasp][!SetOption MeterRipple Shape "Ellipse $MouseX$,$MouseY$,[*MeasureDiam*] | Fill Color 255,255,255,[*MeasureTrasp*] | StrokeWidth 0 "][!Redraw]

[MeterBG]
Meter=Shape
Shape=Ellipse 60,60,60 | Fill Color 100,50,80,255 | StrokeWidth 0 

[MeterRipple]
Meter=Shape
Shape=Ellipse 0,0,0 | Fill Color 255,255,255,0 | StrokeWidth 0 
Shape2=Rectangle 0,0,120,120 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape3=Ellipse 60,60,60 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape4=Combine Shape2 | XOR Shape3
Shape5=Combine Shape | XOR Shape4 | Exclude Shape4

[MeasureDiam]
Measure=Loop
StartValue=10
EndValue=60
Increment=1
LoopCount=0

[MeasureTrasp]
Measure=Loop
StartValue=0
EndValue=60
Increment=1
LoopCount=0
What happens is that the ripple animation act as i wanted, but in order to make it work, i have to spam click it. The thing that i'm trying to achieve is:
- Click on the ball
- Play the ripple animation once
- Stop
This has to occour every time i click on it. Help?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing an animation every time i click on the meter

Post by balala »

First add a DynamicVariables=1 option to the [MeterRipple] meter.
Then disable the [MeasureDiam] and the [MeasureTrasp] measures, by adding both a Disabled=1 option. You have to do this to not let the measures to start counting when the skin is loaded.
But in this case you also need a way to enable those measures on click. For this add near the existing bangs of the LeftMouseUpAction option of the [MeterAct] the following bangs, without removing any of the existing ones: [!EnableMeasure "MeasureDiam"][!EnableMeasure "MeasureTrasp"].
This solution doesn't completely solves the problem but can be a start.
Arless
Posts: 4
Joined: November 19th, 2017, 8:29 pm

Re: Playing an animation every time i click on the meter

Post by Arless »

Thanks a lot, now is starting to look like what I got in my mind, I just need to figure out how to stop the animation and let it go a bit faster. I will share with you guys the results as soon as I finish it :welcome:
EDIT: Here's the solution that i came up with:

Code: Select all

[Rainmeter]
Update=10

[MeterAct]
Meter=Button
Padding=120,120
MeasureName=MeasureAct
LeftMouseDownAction=[!DisableMeasure "MeasureDiam"][!SetOption MeasureDiam 30][!DisableMeasure "MeasureTrasp"][!SetOption MeasureTrasp 60][!Redraw]
LeftMouseUpAction=[!EnableMeasure "MeasureDiam"][!EnableMeasure "MeasureTrasp"][!UpdateMeasure MeasureTrasp][!SetOption MeterRipple Shape "Ellipse $MouseX$,$MouseY$,[*MeasureDiam*] | Fill Color 255,255,255,[*MeasureTrasp*] | StrokeWidth 0 "][!Redraw]

[MeterBG]
Meter=Shape
Shape=Ellipse 60,60,60 | Fill Color 100,50,80,255 | StrokeWidth 0 

[MeterRipple]
Meter=Shape
DynamicVariables=1
Shape=Ellipse 0,0,30 | Fill Color 255,255,255,0 | StrokeWidth 0 
Shape2=Rectangle 0,0,120,120 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape3=Ellipse 60,60,60 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape4=Combine Shape2 | XOR Shape3
Shape5=Combine Shape | XOR Shape4 | Exclude Shape4

[MeasureDiam]
Measure=Loop
StartValue=30
EndValue=90
Increment=3
LoopCount=0
IfEqualValue=60
IfEqualAction=[!DisableMeasure "MeasureDiam"][!Redraw]

[MeasureTrasp]
Measure=Loop
StartValue=60
EndValue=0
Increment=-3
LoopCount=0
IfEqualValue=0
IfEqualAction=[!DisableMeasure "MeasureTrasp"][!Redraw]
Works like a charm, thanks again!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing an animation every time i click on the meter

Post by balala »

Arless wrote:Works like a charm, thanks again!
But I have two remarks about this code:
  • Update=10 is a too small value. The smallest possible is 16 (second paragraph here).
  • Using small Update values usually is not a preferable option (at least I prefere to avoid it). I think in your case the skin could work even with no update (Update=-1), using the ActionTimer plugin (an extremely good plugin). Right now I have no enough time to rewrite your code, but a bit later I will and will post the code.
Arless
Posts: 4
Joined: November 19th, 2017, 8:29 pm

Re: Playing an animation every time i click on the meter

Post by Arless »

balala wrote:But I have two remarks about this code:
  • Update=10 is a too small value. The smallest possible is 16 (second paragraph here).
  • Using small Update values usually is not a preferable option (at least I prefere to avoid it). I think in your case the skin could work even with no update (Update=-1), using the ActionTimer plugin (an extremely good plugin). Right now I have no enough time to rewrite your code, but a bit later I will and will post the code.
Yeah sure, I'm aware about the Update value, I forgot to change it to 16 :thumbup: And about the plugin i have no idea of how they work, so i tried to avoid them as much as i could, but if you are willing to give me a quick lesson, I can only accept and thank you again :D
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing an animation every time i click on the meter

Post by balala »

Arless wrote:about the plugin i have no idea of how they work, so i tried to avoid them as much as i could, but if you are willing to give me a quick lesson, I can only accept and thank you again :D
ActionTimer is a very good plugin, which can help when you want to create animations for example. With this plugin you can avoid to have to set a small Update value.
Eg in the following code the Update is set to -1 (which means the skin is never updated). But to create the animation, we have to have some increasing / decreasing numeric values. In this case these values are represented by two variables (Diam, corresponding to the old [MeasureDiam] measure and Trasp, corresponding to [MeasureTrasp] - both defined in the [Variables] section). These variables are set by the new [MeasureDiam] and [MeasureTrasp] ActionTimer plugin measures.
I rewrote a lot of things and finally got the following code:

Code: Select all

[Rainmeter]
Update=-1

[Variables]
Diam=30
Trasp=60
Update=20
U=[!UpdateMeasure "MeasureDiam"][!UpdateMeasure "MeasureDiam2"][!UpdateMeasure "MeasureTrasp"][!UpdateMeasure "MeasureTrasp2"][!UpdateMeter "MeterRipple"][!UpdateMeter "Uptime"][!Redraw]

[MeterAct]
Meter=Button
Padding=120,120
MeasureName=MeasureAct
LeftMouseUpAction=[!ShowMeter "MeterRipple"][!CommandMeasure "MeasureDiam" "Execute 1"][!CommandMeasure "MeasureTrasp" "Execute 1"][!SetOption MeterRipple Shape "Ellipse $MouseX$,$MouseY$,#*Diam*# | Fill Color 255,255,255,#*Trasp*# | StrokeWidth 0 "][!Redraw]

[MeterBG]
Meter=Shape
Shape=Ellipse 60,60,60 | Fill Color 100,50,80,255 | StrokeWidth 0 

[MeterRipple]
Meter=Shape
DynamicVariables=1
Shape=Ellipse 0,0,30 | Fill Color 255,255,255,0 | StrokeWidth 0 
Shape2=Rectangle 0,0,120,120 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape3=Ellipse 60,60,60 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape4=Combine Shape2 | XOR Shape3
Shape5=Combine Shape | XOR Shape4 | Exclude Shape4
Hidden=1

[MeasureDiam]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up,#Update#,20
Up=[!SetVariable Diam "(Clamp((#Diam#+3),30,90))"]#U#
DynamicVariables=1

[MeasureDiam2]
Measure=Calc
Formula=#Diam#
IfCondition=(#CURRENTSECTION#>=60)
IfTrueAction=[!CommandMeasure "MeasureDiam" "Stop 1"][!SetVariable Diam "30"]#U#
DynamicVariables=1

[MeasureTrasp]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up,#Update#,20
Up=[!SetVariable Trasp "(Clamp((#Trasp#-6),0,60))"]#U#
DynamicVariables=1

[MeasureTrasp2]
Measure=Calc
Formula=#Trasp#
IfCondition=(#CURRENTSECTION#<=0)
IfTrueAction=[!CommandMeasure "MeasureTrasp" "Stop 1"][!SetVariable Trasp "60"][!HideMeter "MeterRipple"]#U#
DynamicVariables=1
See the Update value set up to -1 in the [Rainmeter] section. Also added a lot of variables. U is used by the ActionTimer plugin measures, which has to update the appropriate measures / meters, because they are never updated, due to the Update set to -1. The two !CommandMeasure bangs in the LeftMouseUpAction option of the [MeterAct] meter, run the two ActionTimer plugins when you click. In this moment, the measures start to modify the values of the variables, increasing the Diam and decreasing the Trasp variable. [MeasureDiam2] and [MeasureTrasp2] are also updated in each cycle and they are used to stop the plugin measures in the appropriate moment. When the plugins are stopped, new values are also set for the Diam and Trasp variables, to restore the initial situation, with the initial values of the variables.
Please try this code and let me know how is it working. Also come back if you have any question about it.
Arless
Posts: 4
Joined: November 19th, 2017, 8:29 pm

Re: Playing an animation every time i click on the meter

Post by Arless »

balala wrote:ActionTimer is a very good plugin, which can help when you want to create animations for example. With this plugin you can avoid to have to set a small Update value.
Eg in the following code the Update is set to -1 (which means the skin is never updated). But to create the animation, we have to have some increasing / decreasing numeric values. In this case these values are represented by two variables (Diam, corresponding to the old [MeasureDiam] measure and Trasp, corresponding to [MeasureTrasp] - both defined in the [Variables] section). These variables are set by the new [MeasureDiam] and [MeasureTrasp] ActionTimer plugin measures.
I rewrote a lot of things and finally got the following code:

Code: Select all

[Rainmeter]
Update=-1

[Variables]
Diam=30
Trasp=60
Update=20
U=[!UpdateMeasure "MeasureDiam"][!UpdateMeasure "MeasureDiam2"][!UpdateMeasure "MeasureTrasp"][!UpdateMeasure "MeasureTrasp2"][!UpdateMeter "MeterRipple"][!UpdateMeter "Uptime"][!Redraw]

[MeterAct]
Meter=Button
Padding=120,120
MeasureName=MeasureAct
LeftMouseUpAction=[!ShowMeter "MeterRipple"][!CommandMeasure "MeasureDiam" "Execute 1"][!CommandMeasure "MeasureTrasp" "Execute 1"][!SetOption MeterRipple Shape "Ellipse $MouseX$,$MouseY$,#*Diam*# | Fill Color 255,255,255,#*Trasp*# | StrokeWidth 0 "][!Redraw]

[MeterBG]
Meter=Shape
Shape=Ellipse 60,60,60 | Fill Color 100,50,80,255 | StrokeWidth 0 

[MeterRipple]
Meter=Shape
DynamicVariables=1
Shape=Ellipse 0,0,30 | Fill Color 255,255,255,0 | StrokeWidth 0 
Shape2=Rectangle 0,0,120,120 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape3=Ellipse 60,60,60 | Fill Color 255,255,255,100 | StrokeWidth 0
Shape4=Combine Shape2 | XOR Shape3
Shape5=Combine Shape | XOR Shape4 | Exclude Shape4
Hidden=1

[MeasureDiam]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up,#Update#,20
Up=[!SetVariable Diam "(Clamp((#Diam#+3),30,90))"]#U#
DynamicVariables=1

[MeasureDiam2]
Measure=Calc
Formula=#Diam#
IfCondition=(#CURRENTSECTION#>=60)
IfTrueAction=[!CommandMeasure "MeasureDiam" "Stop 1"][!SetVariable Diam "30"]#U#
DynamicVariables=1

[MeasureTrasp]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat Up,#Update#,20
Up=[!SetVariable Trasp "(Clamp((#Trasp#-6),0,60))"]#U#
DynamicVariables=1

[MeasureTrasp2]
Measure=Calc
Formula=#Trasp#
IfCondition=(#CURRENTSECTION#<=0)
IfTrueAction=[!CommandMeasure "MeasureTrasp" "Stop 1"][!SetVariable Trasp "60"][!HideMeter "MeterRipple"]#U#
DynamicVariables=1
See the Update value set up to -1 in the [Rainmeter] section. Also added a lot of variables. U is used by the ActionTimer plugin measures, which has to update the appropriate measures / meters, because they are never updated, due to the Update set to -1. The two !CommandMeasure bangs in the LeftMouseUpAction option of the [MeterAct] meter, run the two ActionTimer plugins when you click. In this moment, the measures start to modify the values of the variables, increasing the Diam and decreasing the Trasp variable. [MeasureDiam2] and [MeasureTrasp2] are also updated in each cycle and they are used to stop the plugin measures in the appropriate moment. When the plugins are stopped, new values are also set for the Diam and Trasp variables, to restore the initial situation, with the initial values of the variables.
Please try this code and let me know how is it working. Also come back if you have any question about it.
Wow! I just tried it and it feel just so much better! This is awesome thank you, I'm definitely gonna spend some time studying it to master it. Thanks again!
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Playing an animation every time i click on the meter

Post by balala »

Glad to help.
Skins which has the Update set to -1 are much less resource consumers. When I can, I definitely prefer to use this option, however that1s not always possible.