It is currently September 25th, 2020, 3:44 am

Help with variables and text

Help with creating, editing & fixing problems with skins
Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Re: Help with variables and text

Post by Gouloudrouioul »

YES ! thanks so much, that's what I was missing exactly !

It works now, as I intended !

You've been a big help :D
User avatar
jsmorley
Developer
Posts: 21387
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

Great! Glad to help...
User avatar
jsmorley
Developer
Posts: 21387
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

If I was going to size an image, I would probably look at something like this:

Code: Select all

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

[Variables]
U=[!UpdateMeasure *][!UpdateMeter *][!Redraw]
Size1W=40
Size1H=40
X1=20
Y1=20

[MeterImage1]
Meter=Image
ImagePath=#@#Images\
ImageName=Chrome.png
W=#Size1W#
H=#Size1H#
X=#X1#
Y=#Y1#
DynamicVariables=1
MouseOverAction=[!CommandMeasure MeasureSizer1 "Stop 2"][!CommandMeasure MeasureSizer1 "Execute 1"]
MouseLeaveAction=[!CommandMeasure MeasureSizer1 "Stop 1"][!CommandMeasure MeasureSizer1 "Execute 2"]

[MeasureSizer1]
Measure=Plugin
Plugin=ActionTimer
ActionList1=Repeat SizeUp, 10, 20
ActionList2=Repeat SizeDown, 10, 20
SizeUp=[!SetVariable Size1W "(Clamp(#Size1W# + 1, 40, 60))"][!SetVariable Size1H "(Clamp(#Size1H# + 1, 40, 60))"][!SetVariable X1 "(Clamp(#X1# - 0.5, 10, 20))"][!SetVariable Y1 "(Clamp(#Y1# - 0.5, 10, 20))"]#U#
SizeDown=[!SetVariable Size1W "(Clamp(#Size1W# - 1, 40, 60))"][!SetVariable Size1H "(Clamp(#Size1H# - 1, 40, 60))"][!SetVariable X1 "(Clamp(#X1# + 0.5, 10, 20))"][!SetVariable Y1 "(Clamp(#Y1# + 0.5, 10, 20))"]#U#
DynamicVariables=1

test1.gif


Since presumably you not only want it to size, but move, in order to keep the same relative position. That's what gives you the "zoom" effect.

Note that I kinda cheated here, since you don't want the "move" to be twice as fast as the "size", or it looks weird. You are only "moving" 1/2 as much as you are "zooming", to keep the center the same. So I used 1/2 (0.5) a pixel in each "move" increment, but really Rainmeter doesn't support 1/2 a pixel. So it is "rounding", and the movement isn't a perfectly smooth transition. If I wasn't lazy and getting tired, I'd do 4 ActionList(N) options, two for the "size" and two for the "move", and have different "Repeat" values for the size vs. the move. Then just update the meter(s) and redraw at the end of each "set" of size and move. In a perfect world, you want exactly 1 "move" for every 2 "zooms". The difference is visibly negligible though, so what I have is probably ok.
You do not have the required permissions to view the files attached to this post.
User avatar
balala
Rainmeter Sage
Posts: 11402
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables and text

Post by balala »

jsmorley wrote: May 17th, 2020, 2:44 am 1) The parameter in the !SetVariable option has spaces in it, so it must be enclosed in "quotes".
Even if this might look as an off topic, but I'd like to tell (not you obviously, but to many users around here), that using quotes is always welcomed, both in !SetVariable and in the !SetOption bangs. But I'd say that those quotes are good to be used in most or almost every bang.
For instance, instead of [!SetVariable MyVariable 1], I recommend [!SetVariable MyVariable "1"], or instead of [!SetOption MyMeter Text 1], recommend [!SetOption MyMeter Text "1"]. Or again, instead of [!UpdateMeter MeterText1], I'd use [!UpdateMeter "MeterText1"]. Practically the quotes are ONLY required if the value contains or might contain spaces, but it is a good habit to get used to use them, not to forget them in any circumstance.
Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137607#p137628
User avatar
jsmorley
Developer
Posts: 21387
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Help with variables and text

Post by jsmorley »

balala wrote: May 17th, 2020, 10:21 am Even if this might look as an off topic, but I'd like to tell (not you obviously, but to many users around here), that using quotes is always welcomed, both in !SetVariable and in the !SetOption bangs. But I'd say that those quotes are good to be used in most or almost every bang.
For instance, instead of [!SetVariable MyVariable 1], I recommend [!SetVariable MyVariable "1"], or instead of [!SetOption MyMeter Text 1], recommend [!SetOption MyMeter Text "1"]. Or again, instead of [!UpdateMeter MeterText1], I'd use [!UpdateMeter "MeterText1"]. Practically the quotes are ONLY required if the value contains or might contain spaces, but it is a good habit to get used to use them, not to forget them in any circumstance.
Details: https://forum.rainmeter.net/viewtopic.php?f=5&t=26350&p=137607#p137628
This is correct, although I have to say that I tend to only quote what might be called "value parameters" in bangs. In other words, I don't quote the "target parameters" like a section name, option name, or variable name, as I already have a self-imposed rule that those can never have spaces in them. I try to always quote the "value parameters".

[!SetVariable SomeVariable "1"]
[!SetOption SomeMeasure UpdateDivider "1"]
[!UpdateMeter SomeMeter]

This has the added advantage(s) of making it a bit more obvious what is a "target" and what is a "value" and also perhaps a bit easier to read in long, complicated bangs or series of bangs.
User avatar
balala
Rainmeter Sage
Posts: 11402
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables and text

Post by balala »

jsmorley wrote: May 17th, 2020, 11:49 am This is correct, although I have to say that I tend to only quote what might be called "value parameters" in bangs.
I use exactly the same rule, with one single difference: in bangs like !UpdateMeasure or !UpdateMeter, I quote the name of the measure or meter, because in this bangs, I consider them to be the "value parameters".
But obviously each can have its own rule. Important looks to be to apply always the same rule, in same way.
jsmorley wrote: May 17th, 2020, 11:49 am I already have a self-imposed rule that those can never have spaces in them.
I always apply the same rule: never using spaces into section names and same way, never using spaces neither in variable's name.

Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Re: Help with variables and text

Post by Gouloudrouioul »

Oh thanks for clarifying balala ! It'll help for the future

So... I'm coming back with an other question.

I'll train to explain my problem.

When I hover my mouse over an image (metallic bar), I want it to unfold an other image (ropes) below the first image.
I want to do this effect to make it as if the ropes goes down from the metallic bar.

To do this, I used TransformationMatrix, and I animated it using all the little tricks you gave me yesterday.
(changing matrix as follow : 1;0;0;0.2;0;0 --> 1;0;0;0.3;0;0 --> 1;0;0;0.4;0;0 --> 1;0;0;0.5;0;0 --> 1;0;0;0.6;0;0, etc...)

The animation works fine : the ropes unfold under the bar.... BUT. It starts a bit too much over the bar, so the illusion is broken :o

What I get from this is : TransformationMatrix uses 0 X and Y coordinates of the skin. When it starts, it starts at the very top of the skin. However my metallic bar image displays the bar with a little space on the top and on the bottom. So this space make the bar appear below the very top of the skin...

So my question is this : is there a way to add margin to a TransformationMatrix ? Or to make it start a bit below ? :D

I hope I was clear enough...
User avatar
balala
Rainmeter Sage
Posts: 11402
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables and text

Post by balala »

Gouloudrouioul wrote: May 17th, 2020, 4:55 pm I hope I was clear enough...
Unfortunately not exactly. Post the code please.
Gouloudrouioul
Posts: 17
Joined: May 17th, 2020, 2:07 am

Re: Help with variables and text

Post by Gouloudrouioul »

A video is worth a thousand words :

https://www.youtube.com/watch?v=sCjNiigQreI&feature=youtu.be

As you can see, when the ropes begin to transform, they begin at the very top of the skin, and not on the bar. Which is ugly.
And I would like to know if they could start to transform below the top of the skin, and more precisely, on the bar coordinates.

Code: Select all

[MeasureTransformMBG]
Measure=Plugin
Plugin=ActionTimer

ActionList1=ShowImage | Repeat UnveilDock, 25, #RepeatTransf#
UnveilDock=[!SetVariable BgTransf (#BgTransf#+#AddTransf#)][!SetOption MeterBackground TransformationMatrix "1;0;0;#BgTransf#;0;0"][!UpdateMeasure MeasureTransformMBG][!UpdateMeter MeterText1][!Update MeterBackground][!Redraw]
ShowImage=[!SetOption MeterBackground ImageName "ropes.png"][!UpdateMeasure MeasureTransformMBG][!Update MeterBackground][!Redraw]

ActionList2=Repeat HideDock, 25, #RepeatTransf# | HideImage
HideDock=[!SetVariable BgTransf (#BgTransf#-#AddTransf#)][!SetOption MeterText1 Text #BgTransf#][!SetOption MeterBackground TransformationMatrix "1;0;0;#BgTransf#;0;0"][!UpdateMeter MeterText1][!UpdateMeasure MeasureTransformMBG][!Update MeterBackground][!Redraw]
HideImage=[!SetOption MeterBackground ImageName ""][!UpdateMeter MeterText1][!UpdateMeasure MeasureTransformMBG][!Update MeterBackground][!Redraw]

IfCondition= ((#BgTransf#>1) || (#BgTransf#<#BaseTransf#)) && (#MouseOverBackground# = 0)
IfTrueAction=[!SetOption MeasureTransformMBG ImageAlpha 0][!SetVariable BgTransf #BaseTransf#][!UpdateMeter MeterText1][!UpdateMeasure MeasureTransformMBG][!Update MeterBackground][!Redraw]
IfCondition2= ((#BgTransf#>1) || (#BgTransf#<#BaseTransf#)) && (#MouseOverBackground# = 1)
IfTrueAction2=[!SetVariable BgTransf 1][!UpdateMeter MeterText1][!UpdateMeasure MeasureTransformMBG][!Update MeterBackground][!Redraw]

DynamicVariables =1

[MeterBackground]
Meter=Image
ImageName="ropes.png"
;ImageAlpha=(#Alpha#+0.3)
X=0
Y=(#LineThickness#/2)
W=((#TotalIcons# * (#SpaceIcons# + #IconSize#)) - #SpaceIcons# + 20)
H=(#IconSize# + #SpaceLineIcons#)
SolidColor=#BackgroundColor#
TransformationMatrix=1;0;0;0.2;0;0
DynamicVariables=1
Here's the part of the code that does it.
As you can see, I am changing the TransformationMatrix Option of MeterBackground with an ActionPlugin, adding 0.1 at every step to make the ropes move.

Any idea on how to fix it?
User avatar
balala
Rainmeter Sage
Posts: 11402
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help with variables and text

Post by balala »

Gouloudrouioul wrote: May 17th, 2020, 7:41 pm Any idea on how to fix it?
First, since the TransformationMatrix options are dynamically set through !SetOption bangs, try to modify the UnveilDock and HideDock options of the [MeasureTransformMBG] measure, this way:

Code: Select all


[MeasureTransformMBG]
...
UnveilDock=[!SetVariable BgTransf (#BgTransf#+#AddTransf#)][!SetOption MeterBackground TransformationMatrix "1;0;0;#*BgTransf*#;0;0"][!UpdateMeasure MeasureTransformMBG][!UpdateMeter MeterText1][!Update MeterBackground][!Redraw]
...
HideDock=[!SetVariable BgTransf (#BgTransf#-#AddTransf#)][!SetOption MeterText1 Text #BgTransf#][!SetOption MeterBackground TransformationMatrix "1;0;0;#*BgTransf*#;0;0"][!UpdateMeter MeterText1][!UpdateMeasure MeasureTransformMBG][!Update MeterBackground][!Redraw]
...
See the difference I added: replaced the #BgTransf# variable in the expressions with #*BgTransf*#, escaping them this way.
If this doesn't help (and I suppose it doesn't), please pack the whole config and upload the package. Would be much easier to help, if I'd have all needed resources (images).