It is currently June 27th, 2019, 11:05 am

Universal Transitions

Discuss the use of Lua in Script measures.
User avatar
Kaelri
Developer
Posts: 1739
Joined: July 25th, 2009, 4:47 am

Universal Transitions

Kaelri » August 1st, 2012, 8:52 pm

This is an expanded remake of my earlier smooth fade script. I'm a little proud of it. :)

To Get
UniversalTransitionScript.zip
To Add

Code: Select all

[Transition]
Measure=Script
ScriptFile=Transition.lua
That's it. You do not need to include "Disabled=1" or "UpdateDivider=1". The script handles its own update rate automatically.

To Use

Once the script is loaded, you can use these bangs anywhere you want:
  • MoveToX/Y
    !CommandMeasure Transition "MoveToX('MeterName', 100)"
    !CommandMeasure Transition "MoveToY('MeterName', 5)"
    Move the meter(s) to a coordinate.
  • MoveByX/Y
    !CommandMeasure Transition "MoveByX('MeterName', 120)"
    !CommandMeasure Transition "MoveByY('MeterName', -50)"
    Move the meter(s) by a number of pixels.
  • MoveToggleX/Y
    !CommandMeasure Transition "MoveToggleX('MeterName', 0, 200)"
    !CommandMeasure Transition "MoveToggleY('MeterName', 50, 150)"
    Toggle the meter(s) between two coordinates.
  • Fade
    !CommandMeasure Transition "Fade('MeterName', 128)"
    Fade the meter(s) to a certain alpha value. Since not all meters use the same option for transparency, the script looks for one of the following: ImageAlpha, ImageTint, FontColor, PrimaryColor, BarColor, LineColor, SolidColor. It uses whichever one it finds first.
  • FadeIn/Out
    !CommandMeasure Transition "FadeIn('MeterName')"
    !CommandMeasure Transition "FadeOut('MeterName')"
    Fade the meter(s) in (to 255) or out (to 0).
  • FadeToggle
    !CommandMeasure Transition "FadeToggle('MeterName', [0], [255])"
    Toggle the meter(s) between two alpha values. Defaults to "0" and "255" if no numbers are given.
You do not need to set a lower UpdateDivider on your meters. They can even have UpdateDivider=-1. They will automatically update during the transition, then return to normal after it's done.

Advanced Options
MeterName

The meter name parameter can be multiple meter names, separated by commas.

!CommandMeasure Transition "MoveByX('MeterName', 120)"
!CommandMeasure Transition "MoveByX('MeterName1, MeterName2, MeterName3', 120)"

Variables

All of the bangs above have an optional variable name parameter. If supplied, the transition changes this variable's value, instead of meter options. (You must still provide the name of at least one meter to be updated during the transition.) The variable name 'Auto' will use the default ("automatic") behavior.

!CommandMeasure Transition "MoveByX('MeterName', 120, 'VariableName')"

You may also use meter groups if you target a variable. You can mix meters and groups however you want. This can be useful if you want one transition to affect a large number of meters, or if the automatic behavior is not what you want.

!CommandMeasure Transition "MoveByX('MeterName', 120, 'VariableName')"
!CommandMeasure Transition "MoveByX('GroupName', 120, 'VariableName')"
!CommandMeasure Transition "MoveByX('MeterName1, GroupName2, MeterName3, GroupName4', 120, 'VariableName')"

Steps

By default, transitions take place over 25 skin updates. This determines the duration of the transition. You will probably want a different number of steps depending on your skin's Update rate, so you can override the default in two ways:
  1. Add a "Steps" option to the measure:

    Code: Select all

    [Transition]
    Measure=Script
    ScriptFile=Transition.lua
    Steps=10
  2. Add another parameter to the bang. This must be after the 'variable name' parameter, so if you want to change the number of steps, but you still want the automatic setting, just use 'Auto' as the variable name.
    !CommandMeasure Transition "MoveByX('MeterName', 120, 'VariableName', 10)"
    !CommandMeasure Transition "MoveByX('MeterName', 120, 'Auto', 10)"
Profiles

If you need to use one transition command many times, you can create a profile for it by adding an option to the script measure.

Code: Select all

[Transition]
Measure=Script
ScriptFile=Transition.lua
Profile1=MyProfileName;MoveByX;MeterName;120
The parameters are separated by semicolons (no spaces). The first is the name of the profile, whatever you want it to be. The second is the command name, from the list above. Everything else is added as a parameter to that command. You can run the profile with:

!CommandMeasure Transition Profile('MyProfileName')


Demo Skin


FluidReader_0.2.rmskin
You do not have the required permissions to view the files attached to this post.
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Universal Transitions

KreAch3R » August 2nd, 2012, 1:10 pm

"...little" ???!

O.O

This should become native Rainmeter.
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
poiru
Developer
Posts: 2877
Joined: April 17th, 2009, 12:18 pm

Re: Universal Transitions

poiru » August 2nd, 2012, 1:56 pm

KreAch3R wrote:This should become native Rainmeter.
We're working on it :) That's all I can say at this point.
User avatar
KreAch3R
Posts: 629
Joined: February 7th, 2011, 7:27 pm
Location: Thessaloniki, GR

Re: Universal Transitions

KreAch3R » August 2nd, 2012, 2:12 pm

poiru wrote:We're working on it :) That's all I can say at this point.
Image
Inactive, due to life changes. Send me a PM for any question.

Desktop DeviartArt
Image
User avatar
Seahorse
Posts: 1220
Joined: June 9th, 2010, 5:56 pm
Location: Locks heath, UK

Re: Universal Transitions

Seahorse » August 2nd, 2012, 5:18 pm

Impressive, although quite tall on my monitor (2560x1600). Well done... :thumbup:
"Regrettably your planet is one of those scheduled for demolition"
Mike

My Skins at DeviantArt

User avatar
wiedzmawiedzma
Posts: 112
Joined: August 18th, 2012, 5:19 pm

Re: Universal Transitions

wiedzmawiedzma » September 16th, 2012, 7:40 pm

Kaelri wrote: Once the script is loaded, you can use these bangs anywhere you want:
  • MoveToX/Y
    !CommandMeasure Transition "MoveToX('MeterName', 100)"
    !CommandMeasure Transition "MoveToY('MeterName', 5)"
    Move the meter(s) to a coordinate.
  • MoveByX/Y
    !CommandMeasure Transition "MoveByX('MeterName', 120)"
    !CommandMeasure Transition "MoveByY('MeterName', -50)"
    Move the meter(s) by a number of pixels.
  • MoveToggleX/Y
    !CommandMeasure Transition "MoveToggleX('MeterName', 0, 200)"
    !CommandMeasure Transition "MoveToggleY('MeterName', 50, 150)"
    Toggle the meter(s) between two coordinates.
  • Fade
    !CommandMeasure Transition "Fade('MeterName', 128)"
    Fade the meter(s) to a certain alpha value. Since not all meters use the same option for transparency, the script looks for one of the following: ImageAlpha, ImageTint, FontColor, PrimaryColor, BarColor, LineColor, SolidColor. It uses whichever one it finds first.
  • FadeIn/Out
    !CommandMeasure Transition "FadeIn('MeterName')"
    !CommandMeasure Transition "FadeOut('MeterName')"
    Fade the meter(s) in (to 255) or out (to 0).
  • FadeToggle
    !CommandMeasure Transition "FadeToggle('MeterName', [0], [255])"
    Toggle the meter(s) between two alpha values. Defaults to "0" and "255" if no numbers are given.
"Eclectic-tech" steered me on this subject because I have problems with synchronizing the images change "QuotePlugin" with animation slide "BitmapTransitionFrames" http://rainmeter.net/forum/viewtopic.php?f=5&t=13453
I saw how it works your script in the skin Fluid Reader_0.1.rmskin
And I know how to achieve such an effect on the set of my photo is possible, and here asking you steered me in the right direction in building skins. I have a lot of questions and do without modification LUA, where to apply! CommandMeasure ...... I do not mean ready-made solution, fun is on understanding and building skins! The biggest problem is that I know little English and ask for advice in the form of code so much easier for me to understand :bow:

Code: Select all

[Rainmeter]
Author=WiedzmaWiedzma
Update=1000


[Variables]
ImagePath=#CURRENTPATH#DownloadFile\


[Transition]
Measure=Script
ScriptFile=Transition.lua

[BG]
Meter=IMAGE
ImageName=bg.png
X=0
Y=0
UpdateDivider=-1


[Wall1]
Meter=IMAGE
ImageName=#ImagePath#1.jpg
X=6
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=one

[Wall2]
Meter=IMAGE
ImageName=#ImagePath#2.jpg
X=-460
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=two

[Wall3]
Meter=IMAGE
ImageName=#ImagePath#3.jpg
X=-460
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=three

[Wall4]
Meter=IMAGE
ImageName=#ImagePath#4.jpg
X=-460
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=four

[Wall5]
Meter=IMAGE
ImageName=#ImagePath#5.jpg
X=-460
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=five

[Wall6]
Meter=IMAGE
ImageName=#ImagePath#6.jpg
X=-460
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=six

[WallSlide]
Meter=IMAGE
ImageName=#ImagePath#8.jpg
X=-460
Y=4
W=460
H=224
PreserveAspectRatio=2
UpdateDivider=30
Group=slide
You do not have the required permissions to view the files attached to this post.
User avatar
Kaelri
Developer
Posts: 1739
Joined: July 25th, 2009, 4:47 am

Re: Universal Transitions

Kaelri » September 17th, 2012, 6:50 pm

What you're trying to do isn't possible right now. The reason is because the size of the skin window is "dynamic." So when the image slides to the right, the skin's width will increase, and the image will continue to be visible. This is the same reason why the "Fluid Reader" demo skin is full-screen; it was supposed to be just one item at a time, but I couldn't make it work with items that slide in from the right.

If you want to do a full-screen version of your slideshow skin instead, you can use roughly the same approach. You just need something to trigger the !CommandMeasure bangs - either a button or a "timer" measure of some kind.
User avatar
wiedzmawiedzma
Posts: 112
Joined: August 18th, 2012, 5:19 pm

Re: Universal Transitions

wiedzmawiedzma » September 17th, 2012, 7:13 pm

Kaelri wrote: You just need something to trigger the !CommandMeasure bangs - either a button or a "timer" measure of some kind.
Here I have a "timer" who made jsmorley is set to 5 seconds
but explain to me how it is supposed to look at 30 seconds and 1 minute.
I do not understand this: Formula=Counter % 7 :headbang:

[CalcAutoRefresh]
Measure=CALC
Formula=Counter % 7
IfAboveAction=!RainmeterRefresh
IfAboveValue=5
User avatar
jsmorley
Developer
Posts: 19272
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Universal Transitions

jsmorley » September 17th, 2012, 11:51 pm

wiedzmawiedzma wrote: Here I have a "timer" who made jsmorley is set to 5 seconds
but explain to me how it is supposed to look at 30 seconds and 1 minute.
I do not understand this: Formula=Counter % 7 :headbang:

[CalcAutoRefresh]
Measure=CALC
Formula=Counter % 7
IfAboveAction=!RainmeterRefresh
IfAboveValue=5
I will leave the explanation of Modulus math to http://rainmeter.net/forum/viewtopic.php?f=15&t=8759, but the long and the short of it is that you just need to set the "7" to "31" or "61" and the IfAboveValue to "30" or "60" to get what you want.

What the counter measure is doing is just counting from 0 to the number after the "%". When it hits it, it resets to 0 and starts over. This is not REALLY "seconds" as such, but as long as you have Update=1000 in the [Rainmeter] section of the skin, so the skin updates every 1000 milliseconds, the practical effect is that you are counting seconds.

So then you watch for that number in the IfAboveValue / IfAboveAction and fire away when the desired number is reached.

P.S. Another approach, and one that I think is really better is:

[CalcAutoRefresh]
Measure=CALC
Formula=(CalcAutoRefresh % 30) + 1
IfAboveAction=!Refresh
IfAboveValue=30
DynamicVariables=1

This is using a similar approach, but instead of the internal "counter" variable, which is not reset on the refresh of a skin, this uses the value of the measure itself, adding 1 on each update until it reaches that "30" after the "%", then resets to 1 and starts again. I prefer this as it allow the refresh of the skin to control it, and counts from 1 to xxx instead of 0 to xxx.
lysy1993lbn
Posts: 286
Joined: July 25th, 2011, 9:53 am
Location: Manchester, UK

Re: Universal Transitions

lysy1993lbn » September 18th, 2012, 1:36 am

It's just awesome! I totally love it :D

But.. what about groups? I'd like to make my dock slide on hover, do I have to apply 14 bangs to do it?

Or is possible to move whole skin from another one?
Now I have separate skin to show with fade effect my dock which basically trigger MouseOverAction=[!ShowFade "woodock"][!Hide "woodock\$widgets\position"] at hover on it.
"Never argue with an idiot, he will drag you down to his level and beat you with experience."
my deviantART | Alternative Rainmeter tray icons