It is currently April 19th, 2024, 8:09 pm

Using [MeterName:W] inside a forumla for another meters X value?

Get help with creating, editing & fixing problems with skins
User avatar
MultiPotent
Posts: 6
Joined: August 30th, 2021, 10:13 pm

Using [MeterName:W] inside a forumla for another meters X value?

Post by MultiPotent »

Hello, here i am putting two shapes meters side by side with 10 pixel "margin" between both meters

Code: Select all

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

[Variables]
red= 187,32,32
BorderColorA= 36,38,48
BorderColorB= 58,63,75
PrimaryBGColor= 43,46,58

[MeterShapes]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
W=215
SolidColor=#red#
X=0
Y=0

[MeterShape2]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
SolidColor=#red#
X= 225
Y=0
However i was hoping i could use formulas instead. How can i do something like this to achieve a more robust result?

Code: Select all

X= ([MeterShapes:W] + 10)
I found the documentaiton on formulas but was unsure if they can be used in conjuction with the other thing "[MeterShapes:W]" i forget what those are called.

Thanks!
Last edited by MultiPotent on September 18th, 2021, 2:01 am, edited 3 times in total.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using [MeterName:W] inside a forumla for another meters X value?

Post by jsmorley »

It might be simpler to use "relative positioning"...

https://docs.rainmeter.net/manual/meters/general-options/#XY

Code: Select all

[MeterShape2]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
SolidColor=#red#
X=10R
Y=0
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Using [MeterName:W] inside a forumla for another meters X value?

Post by jsmorley »

If you really want to use [SectionVariables], it's like this:

Code: Select all

[MeterShapes]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
W=215
SolidColor=#red#
X=0
Y=0

[MeterShape2]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
SolidColor=#red#
X=([MeterShapes:X]+[MeterShapes:W]+10)
DynamicVariables=1
Y=0
https://docs.rainmeter.net/manual/variables/section-variables/#MeterParameters

Don't forget the DynamicVariables=1.
User avatar
MultiPotent
Posts: 6
Joined: August 30th, 2021, 10:13 pm

Re: Using [MeterName:W] inside a forumla for another meters X value?

Post by MultiPotent »

jsmorley wrote: September 17th, 2021, 10:26 pm It might be simpler to use "relative positioning"...

https://docs.rainmeter.net/manual/meters/general-options/#XY

Code: Select all

[MeterShape2]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
SolidColor=#red#
X=10R
Y=0
Oh right that does make more sense. But its good to know i can use it both ways. My example actually works but wasnt when i posted this so im confused what happened earlier haha but i really appreciate both replies. A perfect response! Thanks!
User avatar
Active Colors
Moderator
Posts: 1251
Joined: February 16th, 2012, 3:32 am
Location: Berlin, Germany

Re: Using [MeterName:W] inside a forumla for another meters X value?

Post by Active Colors »

jsmorley wrote: September 17th, 2021, 10:28 pm If you really want to use [SectionVariables], it's like this:

Code: Select all

[MeterShapes]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
W=215
SolidColor=#red#
X=0
Y=0

[MeterShape2]
Meter=Shape
Shape=Rectangle 0,0,215,206,12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
SolidColor=#red#
X=([MeterShapes:X]+[MeterShapes:W]+10)
DynamicVariables=1
Y=0
https://docs.rainmeter.net/manual/variables/section-variables/#MeterParameters

Don't forget the DynamicVariables=1.

You might also want to adjust it further to this:

Code: Select all

[MeterShapes]
Meter=Shape
Shape=Rectangle 0,0,[#CURRENTSECTION#:W],[#CURRENTSECTION#:H],12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
X=0
Y=0
W=215
H=206
SolidColor=#red#

[MeterShape2]
Meter=Shape
Shape=Rectangle 0,0,[#CURRENTSECTION#:W],[#CURRENTSECTION#:H],12 | Fill Color #BorderColorA# | StrokeWidth 0
Shape2=Rectangle 0,0,209,200,8 | Fill Color #PrimaryBGColor# | StrokeWidth 1 | Stroke Color #BorderColorB# | Offset 3,3
SolidColor=#red#
X=([MeterShapes:X]+[MeterShapes:W]+10)
DynamicVariables=1
Y=0
W=215
H=206
This will prevent you from writing the same value twice while also enable you using the section variables.

You can also substitute my advice with variables.
User avatar
Brian
Developer
Posts: 2679
Joined: November 24th, 2011, 1:42 am
Location: Utah

Re: Using [MeterName:W] inside a forumla for another meters X value?

Post by Brian »

Another option might be to use the XW section variable parameter instead of the :X + :W method.
https://docs.rainmeter.net/manual/variables/section-variables/#XWYH

So, something like this:
X=([MeterShapes:XW]+10)

-Brian