Page 1 of 1

How can I find the center of a meter?

Posted: April 3rd, 2017, 12:48 pm
by kyriakos876
Say I have a .png (150x100 pixels) and I want to find its center. Obviously the center here would be the pixel coordinated at X=75 and Y=50 but what if I don't know the size of the picture, or if it's hard to calculate the size of the picture (because the image is being cropped resized etc. on the skin) ?

To understand what I say take as an example the Ellipse Shape meter. X and Y are the coordinates for the center of the meter, as on a random .png X and Y are the coordinates of where is the Top Left Corner of the image.

I want something like X/2 and Y/2 where X,Y are the width and height of the .png in pixels.

Any ideas? Thanks!

Re: How can I find the center of a meter?

Posted: April 3rd, 2017, 12:59 pm
by jsmorley

Code: Select all

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

[MeterRect]
Meter=Image
W=300
H=150
SolidColor=47,47,47,255

[MeterMiddle]
Meter=Image
W=5
H=5
X=(([MeterRect:W]/2) - [MeterMiddle:W]/2)
Y=(([MeterRect:H]/2) - [MeterMiddle:H]/2)
SolidColor=255,255,255,255
DynamicVariables=1
1.jpg
https://docs.rainmeter.net/manual/variables/section-variables/#MeterParameters

To be clear, this is the width and height of the meter, not the contents, like a .png. While it might mostly be the same thing, not always, particularly with Shape meters.

Re: How can I find the center of a meter?

Posted: April 3rd, 2017, 1:11 pm
by kyriakos876
jsmorley wrote:

Code: Select all

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

[MeterRect]
Meter=Image
W=300
H=150
SolidColor=47,47,47,255

[MeterMiddle]
Meter=Image
W=5
H=5
X=(([MeterRect:W]/2) - [MeterMiddle:W]/2)
Y=(([MeterRect:H]/2) - [MeterMiddle:H]/2)
SolidColor=255,255,255,255
DynamicVariables=1
1.jpg

https://docs.rainmeter.net/manual/variables/section-variables/#MeterParameters

To be clear, this is the width and height of the meter, not the contents, like a .png. While it might mostly be the same thing, not always, particularly with Shape meters.
I see. That is what I wanted thanks :)

Re: How can I find the center of a meter?

Posted: April 3rd, 2017, 1:13 pm
by jsmorley
Glad to help.

There could be some additional elements to the calculation if [MeterRect] also had values for X and Y, but those are just more section variables...