It is currently April 19th, 2024, 12:33 am

Smooth Meter Fade In/Out

Discuss the use of Lua in Script measures.
User avatar
Dany Gee
Posts: 33
Joined: July 11th, 2012, 8:32 am

Re: Smooth Meter Fade In/Out

Post by Dany Gee »

Outstanding job both of you! :thumbup:
With this iteration of the config the slideshow is already complete :givelove:
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Smooth Meter Fade In/Out

Post by balala »

eclectic-tech wrote: July 19th, 2022, 2:19 pm Give this variant of balala's code a try.
Good catch. :thumbup:
Dany Gee wrote: July 19th, 2022, 6:18 pm With this iteration of the config the slideshow is already complete :givelove:
Glad you got it working as expected. As usually, ecelctic-tech's solution is a very good one. However in meantime I wrote my own. didn1t want to post it, but finally I added one more feature and decided to post it.
I practically used the same technique as eclectic-tech, but more authors, more, not entirely the same variations. So in my solution I also adapted a little bit the [MeasureTime] measure and added a LeftMouseUpAction option to both Image meters ([MeterImage0] and [MeterImage1]). But in this case the image transition takes place when [MeasureTime] reaches 1. This lead me immediately to the idea not to have the first image visible when the skin is refreshed / activated, but to fade it in immediately after the refresh. If you are interested, there is an extremely simple solution: you have to hide the meter which is shown on refresh (in this case [MeterImage0] and the hiding is done by modifying the Hidden option of the meter to Hidden=1), then since this meter gets transparent (through its ImageAlpha option, controlled by the #Alpha# variable - ImageAlpha=(255-#Alpha#)) immediately after the refresh (practically when [MeasureTime] gets to be 1, so one second after refresh), you can show it. No change will take place, because even if the meter becomes shown, it is transparent at this point. All others are working same way as previously.
So if you are interested, give a try to the following code. See what's happening when you refresh the skin:

Code: Select all

[Rainmeter]
Update=1000

[Variables]
Alpha=0
Cycle=0
Step=25.5
Scale=1
Upd=[!UpdateMeasure "MeasureAlpha"][!UpdateMeterGroup "Images"][!Redraw]
ImagesPath=D:\MEGA\Pictures\Franczeska_Piorko\Slideshow\Temp
ChangeInterval=10

[MeasureTime]
Measure=Calc
Formula=(( MeasureTime + 1 ) % #ChangeInterval# )
IfCondition=((#CURRENTSECTION#=2)&&(#Cycle#=0))
IfTrueAction=[!UpdateMeasure "MeasureImage1"][!CommandMeasure "MeasureAlpha" "Stop 1"][!CommandMeasure "MeasureAlpha" "Stop 2"]
IfCondition2=((#CURRENTSECTION#=2)&&(#Cycle#=1))
IfTrueAction2=[!UpdateMeasure "MeasureImage0"][!CommandMeasure "MeasureAlpha" "Stop 1"][!CommandMeasure "MeasureAlpha" "Stop 2"][!ShowMeter "MeterImage0]
IfCondition3=((#CURRENTSECTION#=1)&&(#Cycle#=0))
IfTrueAction3=[!SetVariable Cycle "1"][!CommandMeasure "MeasureAlpha" "Execute 1"][!CommandMeasure "MeasureAlpha" "Stop 2"]
IfCondition4=((#CURRENTSECTION#=1)&&(#Cycle#=1))
IfTrueAction4=[!SetVariable Cycle "0"][!CommandMeasure "MeasureAlpha" "Stop 1"][!CommandMeasure "MeasureAlpha" "Execute 2"]
DynamicVariables=1

[MeasureAlpha]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat FadeIn,40,10
FadeIn=[!SetVariable Alpha "(Clamp((#Alpha#+#Step#),0,255))"]#Upd#
ActionList2=Repeat FadeOut,40,10
FadeOut=[!SetVariable Alpha "(Clamp((#Alpha#-#Step#),0,255))"]#Upd#
DynamicVariables=1

[MeasureImage0]
Measure=Plugin
Plugin=QuotePlugin
PathName=#ImagesPath#
FileFilter=*.jpg;*.jpeg;*.gif;*.bmp;*.png
Subfolders=0
UpdateDivider=-1

[MeasureImage1]
Measure=Plugin
Plugin=QuotePlugin
PathName=#ImagesPath#
FileFilter=*.jpg;*.jpeg;*.gif;*.bmp;*.png
Subfolders=0
UpdateDivider=-1

[MeterImage0]
MeasureName=MeasureImage0
Meter=IMAGE
DynamicVariables=1
;ImageRotate=5
X=(72*#Scale#)
Y=(30*#Scale#)
W=(385*#Scale#)
H=(385*#Scale#)
Hidden=1
PreserveAspectRatio=1
ImageAlpha=(255-#Alpha#)
DynamicVariables=1
Group=Images
LeftMouseUpAction=[!DisableMeasure "MeasureTime"][!UpdateMeasure "MeasureTime"][!EnableMeasure "MeasureTime"]

[MeterImage1]
MeasureName=MeasureImage1
Meter=IMAGE
DynamicVariables=1
;ImageRotate=5
X=0r
Y=0r
W=(385*#Scale#)
H=(385*#Scale#)
Hidden=0
PreserveAspectRatio=1
ImageAlpha=#Alpha#
DynamicVariables=1
Group=Images
LeftMouseUpAction=[!DisableMeasure "MeasureTime"][!UpdateMeasure "MeasureTime"][!EnableMeasure "MeasureTime"]
User avatar
Dany Gee
Posts: 33
Joined: July 11th, 2012, 8:32 am

Re: Smooth Meter Fade In/Out

Post by Dany Gee »

Tested both and for now Eclectic's solution seems to be more stable and accurate - all working as expected, no surprises.
Balala's last iteration switches only between two pictures on manual click. Rest seems OK.
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Smooth Meter Fade In/Out

Post by balala »

Dany Gee wrote: July 19th, 2022, 7:27 pm Balala's last iteration switches only between two pictures on manual click. Rest seems OK.
No, not just. It switches on click and after a number of seconds equal with #ChangeInterval#.
User avatar
Dany Gee
Posts: 33
Joined: July 11th, 2012, 8:32 am

Re: Smooth Meter Fade In/Out

Post by Dany Gee »

Yeah, but when you click faster then 1s it changes only between last two photos.
In order for manual change to work properly I need to click, wait at least 1s and then click again.
This was not observed in Eclectics iteration.
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Smooth Meter Fade In/Out

Post by balala »

Dany Gee wrote: July 19th, 2022, 7:35 pm Yeah, but when you click faster then 1s it changes only between last two photos.
In order for manual change to work properly I need to click, wait at least 1s and then click again.
This was not observed in Eclectics iteration.
As you wish. Use the code you like more.
User avatar
Dany Gee
Posts: 33
Joined: July 11th, 2012, 8:32 am

Re: Smooth Meter Fade In/Out

Post by Dany Gee »

I will use the code that simply works better and causes least problems.
Still, thank you both once again for involvement! :great:
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 16144
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Smooth Meter Fade In/Out

Post by balala »

Dany Gee wrote: July 19th, 2022, 7:46 pm I will use the code that simply works better and causes least problems.
Still, thank you both once again for involvement! :great:
You're welcome from my part.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5391
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: Smooth Meter Fade In/Out

Post by eclectic-tech »

Happy to help! :welcome:

There is always more than one way to achieve similar results.
I enjoy seeing how others solve issues and usually learn something new from their solution. :thumbup:
Creepi
Posts: 1
Joined: January 17th, 2023, 7:56 pm

Re: Smooth Meter Fade In/Out

Post by Creepi »

Hey, I was trying to let some text (Icon Names for my Dektop Icons) fade in and out if you hover over a desktop icon. Everything worked until I added the fade. Does anyone know what's wrong and how to fix it?

Code: Select all

[Rainmeter]
Update=20

[Metadata]
Name=BetterIconNames
Author=Creepi
Information=This gives me better Icon Names on my Desktop
Version=0.1

[Variables]
FontSize=20
FontFace=Aquatico
FontColor=255,255,255
FontWeight=950
HeightAbove=520
HeightBelow=680
IconY=572
IconWidth=120
IconWidthBig=120
IconHeight=110
IconStrokeColor=0,0,0,0
IconFillColor=0,0,0,1

[MeasureFade1]
Measure=Script
ScriptFile=Fade.lua
; OPTIONAL SETTINGS:
Step=10
Start=0
MeterName=MeterDesktopFiles1

[MeterDesktopFiles1]
Meter=String
MeasureName=MeasureFade1
StringIndex=1
Text=G A M E S
X=540
Y=#HeightAbove#
FontColor=255,255,255,[MeasureFade1]
FontSize=#FontSize#
FontFace=#FontFace#
FontWeight=#FontWeight#
StringAlign=Center
AntiAlias=1
Hidden=1

[MeterIcon1]
Meter=Shape
Shape=Rectangle 483,#IconY#,#IconWidthBig#,#IconHeight# | Stroke Color #IconStrokeColor# | Fill Color #IconFillColor#
ShapeAlign=Center
MouseOverAction=[!CommandMeasure "MeasureFade1" "Activate('In')"][!ShowMeter MeterDesktopFiles1]
MouseLeaveAction=[!CommandMeasure "MeasureFade1" "Activate('Out')"][!HideMeter MeterDesktopFiles1]