It is currently April 26th, 2024, 4:13 am

problem, change image size

Get help with creating, editing & fixing problems with skins
User avatar
xenium
Posts: 867
Joined: January 4th, 2018, 9:52 pm

problem, change image size

Post by xenium »

Hi,
How to apply the # size # variable for offset, to change the size of the A.png image?

I tried
OffsetX=(#size#*125)
OffsetY=(#size#*125)
but it does not work

Code: Select all

[Variables]

size=0.5


[Bg]
Meter=Image
X=0
Y=0
ImageName=#@#bg.png
W=(#size#*250)
H=(#size#*250)

[MeterA]
Meter=Rotator
MeasureName=MeasureA
ImageName=#@#A.png
X=(#size#*2)
Y=(#size#*2)
OffsetX=125
OffsetY=125
W=(#size#*250)
H=(#size#*250)
StartAngle=2.6500
RotationAngle=6.2832
ValueRemainder=360
User avatar
ikarus1969
Posts: 571
Joined: February 28th, 2011, 3:20 pm
Location: Vienna, Austria

Re: problem, change image size

Post by ikarus1969 »

Don't forget to code the DynamicVariables=1 in your meters that use variables ;-)

and, what i've forgotten: OffsetX and OffsetY does not change the size but just define the offset of the center of rotation (docs: https://docs.rainmeter.net/manual-beta/meters/rotator/#OffsetX)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: problem, change image size

Post by eclectic-tech »

Rotator meters do NOT resize the original image; W and H (if defined) are used to determine the center of rotation. In order to change the size of the image you have only 2 options.

One is to resize the image in a graphic editor and make it the size you need prior to using it. That of course is not realistic if you want variable sizes of rotator meters.

The best solution is to use TransformationMatrix to resize the image. It looks complicated, but you only need to control 2 of the 6 values to resize any image.

Read the documentation ikarus mentioned and ask any questions about the code.

I have 2 sample Rotator meters in your modified code, with some comments about how each work. I added a loop measure since you did not define [MeasureA].

Code: Select all

[Variables]
; set the imagewidth and imageheight variables to the actual size of your image
imagewidth=250
imageheight=250
size=0.50


[MeasureA]
Measure=Loop
StartValue=0
EndValue=720
Increment=10
LoopCount=0
InvertMeasure=0

[Bg]
Meter=Image
X=0
Y=0
ImageName=#@#bg.png
W=(#size#*#imagewidth#)
H=(#size#*#imageheight#)

; In Rotator meters X and Y values are used as center of rotation, if W and H are not defined
; Rotator meters W and H do NOT resize the original image, they are used to determine the center of rotation (if defined)

; This meter uses the X and Y values to determine center of rotation
; TransformationMatrix controls the image size
[MeterA]
Meter=Rotator
MeasureName=MeasureA
ImageName=#@#A.png
X=(#imagewidth#/2)
Y=(#imageheight#/2)
OffsetX=(#imagewidth#/2)
OffsetY=(#imageheight#/2)
; W=#imagewidth#
; H=#imageheight#
StartAngle=2.6500
RotationAngle=6.2832
ValueRemainder=360
DynamicVariables=1
; Manual Doc: https://docs.rainmeter.net/manual/meters/general-options/#TransformationMatrix
; TransformationMatrix={scale x};{skew y};{skew x};{scale y};{move x};{move y}
TransformationMatrix=#size#;0;0;#size#;0;0

; This meter uses the X and Y values to determine the position of the meter
; The center of the W and H are used to determine the center of rotation
; TransformationMatrix controls the image size
[MeterB]
Meter=Rotator
MeasureName=MeasureA
ImageName=#@#A.png
X=300
Y=0
OffsetX=(#imagewidth#/2)
OffsetY=(#imageheight#/2)
W=#imagewidth#
H=#imageheight#
StartAngle=2.6500
RotationAngle=6.2832
ValueRemainder=360
DynamicVariables=1
; Manual Doc: https://docs.rainmeter.net/manual/meters/general-options/#TransformationMatrix
; TransformationMatrix={scale x};{skew y};{skew x};{scale y};{move x};{move y}
TransformationMatrix=#size#;0;0;#size#;0;0

User avatar
xenium
Posts: 867
Joined: January 4th, 2018, 9:52 pm

Re: problem, change image size

Post by xenium »

:thumbup: Thank you so much for your help !

P.S
I read the documentation about Transformation Matrix , but.... he gave me a headache :D
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: problem, change image size

Post by balala »

xenium wrote: October 18th, 2018, 6:35 pm P.S
I read the documentation about Transformation Matrix , but.... he gave me a headache :D
Read the Transformation Matrix Guide. It's an excellent document, congratulations to the author, whoever Alex2539 is.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: problem, change image size

Post by eclectic-tech »

xenium wrote: October 18th, 2018, 6:35 pm :thumbup: Thank you so much for your help !

P.S
I read the documentation about Transformation Matrix , but.... he gave me a headache :D
I agree there is a lot to read and comprehend about TransformationMatrix...
Balala has a very good knowledge of how to use it's power in many ways...
He practices the "Black Arts", as far as I can tell, he works magic! ;-)

But to scale images, you only need to set a #Scale# variable as the first and fourth values to be able to change any image size quickly and easily by setting the value of the #Scale# variable.

This is the simplest way to resize meters that use W and H for other purposes (such as Bar, Rotator, and RoundLine meters).

By adding TransformationMatrix=#Scale#;0;0;#Scale#;0;0 to any meter you can resize it simply be modifying the #Scale#.

Glad to help! :welcome:
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: problem, change image size

Post by balala »

eclectic-tech wrote: October 18th, 2018, 7:11 pm I agree there is a lot to read and comprehend about TransformationMatrix...
Balala has a very good knowledge of how to use it's power in many ways...
He practices the "Black Arts", as far as I can tell, he works magic! ;-)
Thanks eclectic-tech for the appreciations, mean a lot...
TransformationMatrix on the other hand is nothing more than pure math (not to boast, but math is a good friend of mine).
eclectic-tech wrote: October 18th, 2018, 7:11 pm But to scale images, you only need to set a #Scale# variable as the first and fourth values to be able to change any image size quickly and easily by setting the value of the #Scale# variable.
Just as a side note eclectic-tech, here is a small issue of the TransformationMatrix applied to those Rotator meters. A such TransformationMatrix is ok, while the meter is positioned to X=0 and Y=0. In such cases, when TransformationMatrix is applied it simply resizes the Rotator meter. But if this meter is positioned to any other X and Y, your TransformationMatrix beside resizing the meter, also moves it. The last two parameters of TransformationMatrix are there exactly to move the meter which has applied the TranformationMatrix option in the any new position. In the "What the heck is Rainmeter doing?!" section of the above guide, is explained detaliately how can you calculate these parameters. The essence is that you have to choose a point which doesn't move when TransformationMatrix is applied and calculate those parameters in a way to keep the chosen point unmoved.
Wat is important is that to keep the Roatator meters unmoved, you should have to use the following TransformationMatrix on both meters: TransformationMatrix=#size#;0;0;#size#;((1-#size#)*[#CURRENTSECTION#:X]);((1-#size#)*[#CURRENTSECTION#:Y]).
Just to demonstrate what am I talking about, I added the following LeftMouseUpAction option to [MeterB] meter:
LeftMouseUpAction=[!SetVariable size "((#size#=0.5)?1:0.5)"][!UpdateMeter "MeterA"][!UpdateMeter "MeterB"][!Redraw]. The above !SetVariable bang toggles the size variable between 0.5 and 1. This way if you click the meter, both of them are resized.
If you try this out, keep in mind that if TransformationMatrix is not applied, the meters have different positions and also different offsets are applied.
User avatar
Mor3bane
Posts: 943
Joined: May 7th, 2016, 7:32 am

Re: problem, change image size

Post by Mor3bane »

Snape-obviously.jpg
balala wrote: October 18th, 2018, 7:55 pm Thanks eclectic-tech for the appreciations, mean a lot...
TransformationMatrix on the other hand is nothing more than pure math (not to boast, but math is a good friend of mine).

Just as a side note eclectic-tech, here is a small issue of the TransformationMatrix applied to those Rotator meters. A such TransformationMatrix is ok, while the meter is positioned to X=0 and Y=0. In such cases, when TransformationMatrix is applied it simply resizes the Rotator meter. But if this meter is positioned to any other X and Y, your TransformationMatrix beside resizing the meter, also moves it. The last two parameters of TransformationMatrix are there exactly to move the meter which has applied the TranformationMatrix option in the any new position. In the "What the heck is Rainmeter doing?!" section of the above guide, is explained detaliately how can you calculate these parameters. The essence is that you have to choose a point which doesn't move when TransformationMatrix is applied and calculate those parameters in a way to keep the chosen point unmoved.
Wat is important is that to keep the Roatator meters unmoved, you should have to use the following TransformationMatrix on both meters: TransformationMatrix=#size#;0;0;#size#;((1-#size#)*[#CURRENTSECTION#:X]);((1-#size#)*[#CURRENTSECTION#:Y]).
Just to demonstrate what am I talking about, I added the following LeftMouseUpAction option to [MeterB] meter:
LeftMouseUpAction=[!SetVariable size "((#size#=0.5)?1:0.5)"][!UpdateMeter "MeterA"][!UpdateMeter "MeterB"][!Redraw]. The above !SetVariable bang toggles the size variable between 0.5 and 1. This way if you click the meter, both of them are resized.
If you try this out, keep in mind that if TransformationMatrix is not applied, the meters have different positions and also different offsets are applied.
You do not have the required permissions to view the files attached to this post.
My DevArt Gallery

There are many ways to be different - there is only one way to be yourself - be amazing at it

The law of averages says what it means; even if you get everything right, you will get something wrong. Therefore; self managing error trapping initiates another set of averages - amongst the errors, some of them will not be errors, instead those instances will appear to be "luck". One cannot complain of the 'appearance' of 'infinite regress of causation', even if it does not have a predictable pattern, only that it requires luck to achieve.
User avatar
balala
Rainmeter Sage
Posts: 16172
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: problem, change image size

Post by balala »

It's not obvious at all. Definitely isn't. But nor impossible is to understand it. It requires an effort once, but it worth. TransformationMatrix is powerfull enough to worth to make an effort to understand it. Plus it can be applied to any type of meter. You can resize even bitmaps, rotators and so on, which otherwise would be close to impossible to be resized. :thumbup:
Probably the single thing you can't do with this option is to convert a rectangular meter, to trapezoidal. This is the only limitation.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5406
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: problem, change image size

Post by eclectic-tech »

@ balala

I DO use the TransformationMatrix code you posted when I want to scale meters
I didn't include the move segment in my example because I got lazy :Whistle
Thank you for the reminder :thumbup:

Code to add to scale a meter using a #size# variable:
TransformationMatrix=#size#;0;0;#size#;((1-#size#)*[#CURRENTSECTION#:X]);((1-#size#)*[#CURRENTSECTION#:Y])