It is currently April 25th, 2024, 4:22 pm

Center aligning an image

Get help with creating, editing & fixing problems with skins
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Center aligning an image

Post by bravo-lemur »

Hi

Is it possible to center align an image around an x,y coordinate? Or can you only set the coordinate of the top-left corner of the image?

Thanks in advance!
User avatar
Yincognito
Rainmeter Sage
Posts: 7164
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: Center aligning an image

Post by Yincognito »

bravo-lemur wrote: August 23rd, 2020, 3:25 pm Hi

Is it possible to center align an image around an x,y coordinate? Or can you only set the coordinate of the top-left corner of the image?

Thanks in advance!
Yes, it's possible, you just have to use formulas for X and Y:

Code: Select all

X=(#X#-([Image:W]/2))
Y=(#Y#-([Image:H]/2))
#X# and #Y# are the values around which you want to center the image (in this case, simulated using variables), [Image:W] and [Image:H] are the width and the height of the image, assuming your image meter is called [Image]. DynamicVariables=1 must be added to the meter where you set the above.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
bravo-lemur
Posts: 24
Joined: August 20th, 2020, 8:49 pm

Re: Center aligning an image

Post by bravo-lemur »

Ah that's great, thanks!
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Center aligning an image

Post by jsmorley »

Do ensure that the values you set for #X# and #Y# are large enough that when 1/2 of the image is moved up and to the left of those values, the image will still fit in the context of the entire skin. Rainmeter cannot expand a skin window up or to the left, and you don't want to truncate the image.