It is currently March 28th, 2024, 3:27 pm

[Container] make image change position

Report bugs with the Rainmeter application and suggest features.
Post Reply
User avatar
manhti14
Posts: 4
Joined: May 6th, 2019, 9:12 am

[Container] make image change position

Post by manhti14 »

I have 2 shapes and 1 image, and in order to align them, I make X and Y link to other Variables.
Everything algin well before i apply [Container] to Image,
but when I applied [Container] to Image, it moved the image.
Does anyone know how to fix this?
Ps:Sr for my bad english

Before

Code: Select all

Meter=Image
X = (#XX#-#IMGW#/2)
Y = (#XX#-#IMGW#/2)
W = #IMGW#
After

Code: Select all

Meter=Image
X =0
Y =0
W = #IMGW#
Skin

Code: Select all

[Variables]
;Content
TextC=PLOT
TextCT=先行
TextCB=手配
;show/hide
Shapehide=0
TextChide=1
TextCTBhide=1
IMGhide=0
;other
ShapeColor=128,210,011
TextColor=255,255,244
TextFont=Arial Black
FontW=550
ShapeD=220
ShapeS=1
=========
LMUA=["#@#\Links\Daiwa\plot.lnk"]
ImgName=#@#Images\Daiwa\PDFsam2.png
ShapeD2=(#ShapeD#*1.732)
ShapeS2=(#ShapeS#*0.94)
ShapeColor2=255,255,255,0
StrokeColor=66,241,244,255
StrokeW=(#ShapeD#*0.12)
IMGW=(#ShapeD#*2*#ShapeS#)
TextS=(#ShapeD#*0.4)
TextSize=#TextS#*#ShapeS#
XX=(#ShapeD#*#ShapeS#*2)
YY=(#ShapeD#*#ShapeS#*2)

[MeterShape1]
Meter=Shape
X=(#XX#-(#ShapeD2#/2))
Y=(#YY#-#ShapeD#/2)
Shape=Rectangle 0,0,#ShapeD2#,#ShapeD#,1,1| Extend MySharedModifiers
Shape2=Rectangle 0,0,#ShapeD2#,#ShapeD#,1,1| Extend MySharedModifiers| Rotate 60
Shape3=Rectangle 0,0,#ShapeD2#,#ShapeD#,1,1| Extend MySharedModifiers| Rotate 120
MySharedModifiers=Fill Color #ShapeColor# | StrokeWidth 0 | Stroke Color #ShapeColor#
Shape4=Combine Shape | Union Shape2| Union Shape3| Scale #ShapeS#,#ShapeS#
MouseOverAction=[!SetOption MeterShape0 HIDDEN "0"][!UpdateMeter MeterShape0][!Redraw]
MouseLeaveAction=[!SetOption MeterShape0 HIDDEN "1"][!UpdateMeter MeterShape0][!Redraw]
LeftMouseUpAction=#LMUA#
Hidden=#Shapehide#

[Image]
Meter=Image
X =0
Y =0
W = #IMGW#
ImageAlpha=255
ImageName=#ImgName#
Hidden=#IMGhide#
Container=MeterShape1

[MeterShape0]
Meter=Shape
X=(#XX#-(#ShapeD2#/2))
Y=(#YY#-#ShapeD#/2)
Shape=Rectangle 0,0,#ShapeD2#,#ShapeD#,1,1| Extend MySharedModifiers
Shape2=Rectangle 0,0,#ShapeD2#,#ShapeD#,1,1| Extend MySharedModifiers| Rotate 60
Shape3=Rectangle 0,0,#ShapeD2#,#ShapeD#,1,1| Extend MySharedModifiers| Rotate 120
MySharedModifiers=Fill Color #ShapeColor2# | StrokeWidth #StrokeW# | Stroke Color #StrokeColor#
Shape4=Combine Shape | Union Shape2| Union Shape3| Scale #ShapeS2#,#ShapeS2#
Hidden=1

[Text Center]
Meter=String
X=(#XX#-#TextSize#/10)
Y=#YY#
Text=#TextC#
FontColor=#textcolor#
FontSize=#TextSize#
FontWeight=#FontW#
StringAlign=CenterCenter
AntiAlias=1
Hidden=#TextChide#

[Text Top]
Meter=String
X=(#XX#-#TextSize#/10)
Y=(#YY#+#TextSize#/2.5)
Text=#TextCT#
FontColor=#textcolor#
FontSize=#TextSize#
FontWeight=#FontW#
StringAlign=CenterBottom
AntiAlias=1
Hidden=#TextCTBhide#

[Text Bottom]
Meter=String
X=(#XX#-#TextSize#/10)
Y=(#YY#-#TextSize#/8)
Text=#TextCB#
FontColor=#textcolor#
FontSize=#TextSize#
FontWeight=#FontW#
StringAlign=CenterTop
AntiAlias=1
Hidden=#TextCTBhide#
Attachments
無題.jpg
Last edited by eclectic-tech on May 6th, 2019, 11:52 am, edited 1 time in total.
Reason: Please use code tags. It is the </> symbol.
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Container] make image change position

Post by balala »

manhti14 wrote: May 6th, 2019, 9:19 am Everything algin well before i apply [Container] to Image,
but when I applied [Container] to Image, it moved the image.
Does anyone know how to fix this?
Yep, this is caused by the fact that when not applying Container, a meter is positioned relatively to the upper left corner of the skin. But if you apply a Container, the meter which has that option is positioned relatively to the container (details):
•A meter that has a Container option will in effect be put "inside" the container meter. It will be positioned relative to the container, and will be visibly constrained by it. Only the part of the content that is "inside" the container will be drawn.
For example let's say you have an Image meter, positioned as it follows:

Code: Select all

[MeterImage]
Meter=Image
X=100
Y=50
...
and a Shape meter which will be declared as the container:

Code: Select all

[MeterContainer]
Meter=Shape
X=100
Y=50
Shape=Rectangle 0,0,50,50,10
See that both meters have the same position.
Now if you apply the [MeterContainer] meter to be the container of [MeterImage] (adding a Container=MeterContainer option to the [MeterImage] meter), [MeterImage] will be moved to a new position defined with X=200 and Y=100, both positions being calculated as the sum of positions of the meter itself and the container. To get the [MeterImage] meter in the same position as initially, you have to modify its position to:

Code: Select all

[MeterImage]
Meter=Image
X=0
Y=0
...
Now the two meters are placed into the same position and the container is applied.
Not having the needed images it's very hard to test your code. If you can't get it to properly work, please pack the whole config and upload it.
User avatar
manhti14
Posts: 4
Joined: May 6th, 2019, 9:12 am

Re: [Container] make image change position

Post by manhti14 »

Finally did it, thanks for your help. :thumbup:
User avatar
balala
Rainmeter Sage
Posts: 16109
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: [Container] make image change position

Post by balala »

You're welcome.
Post Reply