It is currently April 27th, 2024, 4:46 pm

How can I find the center of a meter?

Get help with creating, editing & fixing problems with skins
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

How can I find the center of a meter?

Post 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!
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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.
You do not have the required permissions to view the files attached to this post.
User avatar
kyriakos876
Posts: 919
Joined: January 30th, 2017, 2:01 am
Location: Greece

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

Post 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 :)
User avatar
jsmorley
Developer
Posts: 22631
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

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

Post 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...