It is currently March 28th, 2024, 11:55 pm

How to Fade Metergroup

Get help with creating, editing & fixing problems with skins
User avatar
Nilvarno
Posts: 64
Joined: March 24th, 2019, 5:52 pm

How to Fade Metergroup

Post by Nilvarno »

Hello, this is a part of a skin i made, i need to add a fade transition to it when it toggles on, if possible. Thanks for your time.

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1

[Variables]
Menu=0
@Include=#@#Variables.inc

[MeasureToggle]
Measure=Plugin
Plugin=HotKey
HotKey=CTRL NUM0
KeyDownAction=[!SetVariable Menu "(1-#Menu#)"][!UpdateMeasure "#CURRENTSECTION#"][!UpdateMeasure "MeasureMenu"]
DynamicVariables=1

[MeasureMenu]
Measure=Calc
Formula=#Menu#
IfCondition=(#CURRENTSECTION#>=1)
IfTrueAction=[!ShowMeterGroup "Menu"][!HideMeterGroup "Tile"][!Redraw]
IfFalseAction=[!HideMeterGroup "Menu"][!HideMeterGroup "Tile"][!Redraw]
DynamicVariables=1

[Mask1]
meter=image
ImageName=MSK1.png
X=0
Y=0
w=3840
h=2160
Group=Menu

[Mask2]
meter=image
ImageName=MSK2.png
X=0
Y=0
w=3840
h=2160
Group=Menu

[Mask3]
meter=image
ImageName=MSK3.png
X=188
Y=268
w=2560
h=1440
Group=Menu
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to Fade Metergroup

Post by balala »

You have to use the ActionTimer plugin. If you're interested, here is what to do:
First add the following ActionTimer plugin to your code:

Code: Select all

[MeasureFade]
Measure=Plugin
Plugin=ActionTimer
Group=Sliders
ActionList1=Repeat FadeIn,20,20
FadeIn=[!SetVariable Alpha "(Clamp((#Alpha#+12.75),0,255))"]#U#
ActionList2=Repeat FadeOut,20,20
FadeOut=[!SetVariable Alpha "(Clamp((#Alpha#-12.75),0,255))"]#U#
DynamicVariables=1
The newly introduced Alpha variable controls the transparency of the Image meters (see below). Its value varies between 0 (fully transparent) and 255 (completely opac).
To get it to work, you have to define in the [Variables] section both newly added variables, Alpha and U. Add them:

Code: Select all

[Variables]
...
U=[!UpdateMeasure "MeasureFade"][!UpdateMeterGroup "Menu"][!UpdateMeterGroup "Tile"][!Redraw]
Alpha=0
(take care not to remove the already existing variables, just add these ones).
Now add an ImageAlpha=#Alpha# option to all meters belonging to the Menu group, along with a DynamicVariables=1 option as well. With ImageAlpha you set the transparency of those Image meters. This will be controled by the value of the Alpha variable, which changes through the previously added [MeasureFade] measure:

Code: Select all

[Mask1]
...
ImageAlpha=#Alpha#
DynamicVariables=1 

[Mask2]
...
ImageAlpha=#Alpha#
DynamicVariables=1

[Mask3]
...
ImageAlpha=#Alpha#
DynamicVariables=1
The final step is to modify the IfTrueAction and IfFalseAction options of the [MeasureMenu] measure, in order to can control the [MeasureFade] measure:

Code: Select all

[MeasureMenu]
...
IfTrueAction=[!CommandMeasure "MeasureFade" "Execute 1"][!CommandMeasure "MeasureFade" "Stop 2"]
IfFalseAction=[!CommandMeasure "MeasureFade" "Stop 1"][!CommandMeasure "MeasureFade" "Execute 2"]
...
That's it. If you want to modify the speed of fading, you have to modify the first numeric value into the ActionList1 and ActionList2 options of the [MeasureFade] measure. Just take care that increasing the value decreases the speed and vice-versa: decreasing the value, increases the speed of the fade effect.
User avatar
Nilvarno
Posts: 64
Joined: March 24th, 2019, 5:52 pm

Re: How to Fade Metergroup

Post by Nilvarno »

thank you, it worked, as always when you help :)

anyway it's slow even with numbers set at minimum, it's like 1fps... i suppose it can't get as smooth as !fade command, right?
User avatar
balala
Rainmeter Sage
Posts: 16110
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to Fade Metergroup

Post by balala »

Nilvarno wrote: August 10th, 2019, 9:16 am thank you, it worked, as always when you help :)
I'm glad if you think so.
Nilvarno wrote: August 10th, 2019, 9:16 am anyway it's slow even with numbers set at minimum, it's like 1fps... i suppose it can't get as smooth as !fade command, right?
What you mean by "set at minimum"? It shouldn't have to be too slow if you've decreased the appropriate value. Post please the code of the [MeasureFade] measure, as you have it now.