It is currently March 28th, 2024, 8:32 pm

[Suggestion] Increase/decrease size of skins through Rainmeter

Report bugs with the Rainmeter application and suggest features.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by fonpaolo »

My only (last) concern about all this scaling (and not only, trying to avoid the use of Refresh as much as I can), is DynamicVariables.
I'm experiencing a little increase in the use of system resources (mostly on CPU).
Ok, this increase is from below 1% to 1-2%, but the only change is the adding of DynamicVariables to some meters, in some cases, a lot of them.
I can also think that all this scaling could use more memory than the same skin, but with the "exact" dimensions.
User avatar
jsmorley
Developer
Posts: 22628
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by jsmorley »

A couple of things to keep in mind with Image meters.

1) When an image is loaded, it is "cached" by Rainmeter and is not reloaded from disk on each update of the meter. However, if you have DynamicVariables=1 on the meter, then the image is reloaded on each update. While Windows itself does a pretty good job of caching files that have not changed, this does use a bit more CPU in Rainmeter.

2) If you have W and / or H on an Image meter, then the image is sized to the specified size on each skin "redraw". This is not during the meter "update", which can be managed with UpdateDivider, but on the skin redraw, which will happen on each skin update, period. This resizing can really use a lot of CPU, more so the more the "difference" is between the real size and the resized size. This has nothing to do with DynamicVariables, and will happen with or without that. This also always happens even if the W and H defined on the meter ARE the actual image size.

So the upshot of it is that the best performance can be had by using images that are already the size you want, and not using any W or H at all on the meter, and only using DynamicVariables=1 on Image meters when the functionality requires it.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by eclectic-tech »

Interesting discussion! TransformationMatrix is the best alternative we have to scale skins.

I have done a lot of scaling to my skins due to the increased resolution of new systems and would like to add the TransformationMatrix formula I have been using that works well for most Rainmeter meters (Shape is a sepaerate beast!).

I would point out that the formula SilverAzide posted does not take into consideration the relative position of individual meters in relation to other meters in the skin.

SilverAzide: TransformationMatrix=#Scaler#;0;0;#Scaler#;#Scaler#;#Scaler# :confused:

The formula I use, was presented by member Xanci, and will keep meters relatively positioned correctly.

Xanci: TransformationMatrix=#Scaler#;0;0;#Scaler#;((1-#Scaler#)*[#CURRENTSECTION#:X]);((1-#Scaler#)*[#CURRENTSECTION#:Y]) :thumbup:

This formula will correct for relative positions as it scales. Thanks Xanci! :welcome:

Aside from the limitations already mentioned, image distortion & especially erratic mouse detection, the use of TransformationMatrix for W, H, and position along with scaling factors of X & Y values, make the process of scaling skins fairly straightforward, but not a 1-button solution...

I leave that up to younger minds! :17flag
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by fonpaolo »

As you've noticed, eclectic-tech, TrasformationMatrix has to be used carefully, I ended up with this:

Code: Select all

TransformationMatrix=#TimeSize#; 0; 0; #TimeSize#; (Round(255*#TimeSize#)); (Round(157*#TimeSize#))
Where Timesize is the scaling factor (obviously), 255 and 157 are, respectively, X and Y position of the original image.
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by eclectic-tech »

fonpaolo wrote:As you've noticed, eclectic-tech, TrasformationMatrix has to be used carefully, I ended up with this:

Code: Select all

TransformationMatrix=#TimeSize#; 0; 0; #TimeSize#; (Round(255*#TimeSize#)); (Round(157*#TimeSize#))
Where Timesize is the scaling factor (obviously), 255 and 157 are, respectively, X and Y position of the original image.
Why are you changing the formula? :17denial

Simply create the original meter at scaler=1 (TimeSize), then add the transformationmatrix formula as it is written.

Code: Select all

[Clock]
Meter=String
X=(255*#Scaler#)
Y=(157*#Scaler#)
...
TransformationMatrix=#Scaler#;0;0#Scaler#;((1-#Scaler#)*[#CURRENTSECTION#:X]);((1-#Scaler#)*[#CURRENTSECTION#:Y])
THe X & Y values use the Scaler variable for position and the Transformationmatrix re-sizes and corrects that "scaled" position.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by fonpaolo »

jsmorley wrote:...
So the upshot of it is that the best performance can be had by using images that are already the size you want, and not using any W or H at all on the meter, and only using DynamicVariables=1 on Image meters when the functionality requires it.
That's exactly what I was thinking.
Often, if not always, I use UpdateDivider=-1 on everything, however, to add some dynamic changes and avoid to refresh the skin(s), there's only DynamicVariables, as the name itself says, if you want to dynamically change (one or all) the variable(s) in a skin.

Probably, having at least 30 skins loaded, using in various meters with both DynamicVariables, and UpdateDivider=-1 isn't a problem, but when using DynamicVariables on meters which also are regularly updated with some measure(s), seems to increase the system resource usage.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by fonpaolo »

eclectic-tech wrote:Why are you changing the formula? :17denial

Simply create the original meter at scaler=1 (TimeSize), then add the transformationmatrix formula as it is written.

Code: Select all

[Clock]
Meter=String
X=(255*#Scaler#)
Y=(157*#Scaler#)
...
TransformationMatrix=#Scaler#;0;0#Scaler#;((1-#Scaler#)*[#CURRENTSECTION#:X]);((1-#Scaler#)*[#CURRENTSECTION#:Y])
THe X & Y values use the Scaler variable for position and the Transformationmatrix re-sizes and corrects that "scaled" position.
Because I tried, only mine is working... :17what
...oh and it's not text, it's Rotator. ;-)
User avatar
eclectic-tech
Rainmeter Sage
Posts: 5382
Joined: April 12th, 2012, 9:40 pm
Location: Cedar Point, Ohio, USA

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by eclectic-tech »

Hmm? Look at this rotator example...

You will need my image (save it in '@Resources\Images' for the code below)
Rectangle.png
And here is a scaled rotator skin code:

Code: Select all

[Rainmeter]
Update=50
Dynamicwindowsize=1
LeftMouseDoubleClickAction=[!WriteKeyValue Variables Scaler 1][!Refresh]

[Variables]
Scaler=1
ImageW=128
ImageH=64
MaxDiameter=(SQRT(#ImageW# ** 2 + #ImageH# ** 2))
ImageSW=(#ImageW#*#Scaler#)
ImageSH=(#ImageH#*#Scaler#)
; The rectangle image size is 128x64 pixels
; To use with a different image, change the ImageW & ImageH 'numbers' to match your image size

[mScalerUp]
Measure=Calc
Formula=(#Scaler#+0.01>2.0)? 2.0:(#Scaler#+0.01)
DynamicVariables=1
UpdateDivider=-1
; Measures the next largest size; limits it to 2x

[mScalerDn]
Measure=Calc
Formula=(#Scaler#-0.01<0.1)? 0.1:(#Scaler#-0.01)
DynamicVariables=1
UpdateDivider=-1
; Measures the next smallest size; limits it to .1x

[MeasureRotate]
Measure=Calc
Formula=(MeasureRotate % 360) + 1
MaxValue=360
; Controls rotation

[MeterBG]
Meter=Image
SolidColor=0,0,0,128
W=(#MaxDiameter#*#Scaler#)
H=(#MaxDiameter#*#Scaler#)
MouseScrollUpAction=[!WriteKeyValue Variables Scaler ([mScalerUp])][!Refresh #CurrentConfig#]
MouseScrollDownAction=[!WriteKeyValue Variables Scaler ([mScalerDn])][!Refresh #CurrentConfig#]

[MeterRotate]
Meter=Rotator
MeasureName=MeasureRotate
ImageName=#@#images\rectangle.png
X=([MeterBG:W]/2)
Y=([MeterBG:H]/2)
OffsetX=(#ImageW#/2)
OffsetY=(#ImageH#/2)
TransformationMatrix=(#Scaler#);0;0;(#Scaler#);((1-#Scaler#)*[#CURRENTSECTION#:X]);((1-#Scaler#)*[#CURRENTSECTION#:Y])
DynamicVariables=1

[MeterScaleText]
Meter=String
X=([MeterBG:W]/2)
Y=([MeterBG:W]/2)
FontColor=255,255,255
StringAlign=CenterCenter
StringEffect=Shadow
Text=Scale: #Scaler#
This is only 1 meter in this skin, so the relative position is not shown, but to see the difference, you could try my Odometer clock skin and change the transformationmatrix formula between SilverAzide's suggestion and Xanci and see how the relative positions are maintain (or not maintained)...
You do not have the required permissions to view the files attached to this post.
User avatar
fonpaolo
Moderator
Posts: 1387
Joined: April 11th, 2013, 8:08 pm
Location: Italy

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by fonpaolo »

Yes, I see, however in your Rotator W and H are equal to 0...
If I add your formula in my skin, now, both are working, if I remove W and H, none... :17what
Not enough time to try to understand the reasons behind, probably it's a matter of positioning, because if I add W and H to your skin, it's not centered.
User avatar
SilverAzide
Rainmeter Sage
Posts: 2588
Joined: March 23rd, 2015, 5:26 pm

Re: [Suggestion] Increase/decrease size of skins through Rainmeter

Post by SilverAzide »

fonpaolo wrote:Oh, as a side node, TransformationMatrix did the trick!
So, balala, be aware: I'm starting to love TransformationMatrix, I hope you're not too jealous.
...And fonpaolo takes the red pill. Welcome to the TransformationMatrix, fonpaolo! :)
eclectic-tech wrote:I would point out that the formula SilverAzide posted does not take into consideration the relative position of individual meters in relation to other meters in the skin.

SilverAzide: TransformationMatrix=#Scaler#;0;0;#Scaler#;#Scaler#;#Scaler#

The formula I use, was presented by member Xanci, and will keep meters relatively positioned correctly.

Xanci: TransformationMatrix=#Scaler#;0;0;#Scaler#;((1-#Scaler#)*[#CURRENTSECTION#:X]);((1-#Scaler#)*[#CURRENTSECTION#:Y])

This formula will correct for relative positions as it scales.
Sweet! Thanks for the tip eclectic-tech, I'm gonna try this! :thumbup:
Gadgets Wiki GitHub More Gadgets...