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!
It is currently April 27th, 2024, 4:46 pm
How can I find the center of a meter?
-
- Posts: 919
- Joined: January 30th, 2017, 2:01 am
- Location: Greece
-
- 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?
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
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.
-
- Posts: 919
- Joined: January 30th, 2017, 2:01 am
- Location: Greece
Re: How can I find the center of a meter?
I see. That is what I wanted thanksjsmorley wrote:1.jpgCode: 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
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.
-
- 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?
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...
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...