It is currently August 19th, 2022, 8:33 pm

[Solved] Help scale rotator image

Get help with creating, editing & fixing problems with skins
User avatar
Dany Gee
Posts: 34
Joined: July 11th, 2012, 8:32 am

[Solved] Help scale rotator image

Post by Dany Gee »

Hi Rainmeter Savages!
Need your brain power once more.
Have a nice VU meter.
Whole skin is scaling nicely on mouse scroll, but there are some problems with the needle and LED - they don't scale properly.
Please take a look at the skin code and help me solve the issue.
Any other/alternative refinements are as always welcome!
Many thx in advance!

Code: Select all

[Rainmeter]
Update=1
MiddleMouseUpAction=!Refresh
; Resize with mouse scroll
MouseScrollUpAction=[!SetVariable Scale "(#Scale#+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#+#ScrollMouseIncrement#)"][!Refresh] 
MouseScrollDownAction=[!SetVariable Scale "(#Scale#-#ScrollMouseIncrement# < 0.1 ? 0.1 : #Scale#-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "(#Scale#-#ScrollMouseIncrement# < 0.1 ? 0.1 : #Scale#-#ScrollMouseIncrement#)"][!Refresh]

[Metadata]
Skin name=MODERN VU METER
Version=1.0
Author=Dany Gee
Information=Simple, modern looking VU meter for your sound sources
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
; Change colors to your liking
color1=575F6E
color2=8C98A8
Step=(256/#TotalSteps#)
ScrollMouseIncrement=0.2
Scale=1

[MeasureAudioOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=100
RMSGain=2.0
PeakAttack=15
PeakDecay=2500
PeakGain=1.0

[MeasureAudioRMSL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=L
Type=RMS

[MeasureAudioPeakL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=L
Type=Peak

[MeasureLEDPeakL]
Measure=Calc
Formula=MeasureAudioPeakL
; Set the level of LED peak activation (lower value activates it sooner)
IfBelowValue=0.8
IfBelowAction=[!HideMeter MeterLEDPeak][!CommandMeasure MeasureFade Activate()]
IfAboveValue=0.8
IfAboveAction=[!ShowMeter MeterLEDPeak][!CommandMeasure MeasureFade Activate()]

[MeasureFade]
Measure=Script
ScriptFile=Fade.lua
; Optional script settings
Min=0
Max=255
Start=0
Step=20
MeterName=MeterLEDPeak

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin
OnChangeAction=[!Delay 500][!Refresh]

[MeterBackground]
Meter=Image
ImageName=#@#Images\Modern VU Meter BG.png
ImageTint=#color1#
X=(0*#Scale#)
Y=(0*#Scale#)
W=(170*#Scale#)
H=(170*#Scale#)

[MeterAudioRMSL]
Meter=Rotator
MeasureName=MeasureAudioRMSL
X=(85*#Scale#)
Y=(120*#Scale#)
;W=(12*#Scale#)
;H=(280*#Scale#)
ImageName=#@#Images\Needle.png
ImageTint=#color2#
Antialias=1
OffsetX=6
OffsetY=74
StartAngle=5.51
RotationAngle=1.55

[MeterLEDPeak]
Meter=SHAPE
Shape=Rectangle 0,0,25,12,4 | Fill Color 254,99,117,[MeasureFade] | StrokeWidth 0
X=(73*#Scale#)
Y=(135*#Scale#)
DynamicVariables=1
Hidden=1
You do not have the required permissions to view the files attached to this post.
Last edited by Dany Gee on August 1st, 2022, 4:08 pm, edited 1 time in total.
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 14469
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help scale rotator image

Post by balala »

Dany Gee wrote: July 29th, 2022, 8:13 pm Whole skin is scaling nicely on mouse scroll, but there are some problems with the needle and LED - they don't scale properly.
Please take a look at the skin code and help me solve the issue.
Any other/alternative refinements are as always welcome!
In fact the needle doesn't scale at all, because it's a little bit more complicated to scale a Rotator meters. But not impossible. You have to apply a proper TransformationMatrix. For instance the following one: TransformationMatrix=#Scale#;0;0;#Scale#;([#CURRENTSECTION#:X]*(1-#Scale#));([#CURRENTSECTION#:Y]*(1-#Scale#)).

Additional recommendation: it's extremely unfortunate to refresh the skin so frequently when you're scrolling as you do. The refresh is always a not desirable action, which in most cases can and has to be avoided. In this case it is not needed at all. Better is to dynamically set the size of the skin. For this you have to add some features:
  • Since the [Rainmeter] section doesn't support dynamic variables, but to dynamically can resize the skin you should have to use them, you have to convert the !SetVariable and !WriteKeyValue bangs of the [Rainmeter] section to use the changing #Scale# variable as a nesting variable ([#Scale]). In this form the [Rainmeter] section is supporting the dynamically changing variables.
  • You have to add a DynamicVariables=1 option to all meters which are using the #Scale# variable (to can get them following the dynamically changing variable). So add this option to all meters ([MeterBackground], [MeterAudioRMSL] and [MeterLEDPeak]).
    Finally remove the [!Refresh] bang from the MouseScrollUpAction and MouseScrollDownAction options and add bangs to update all abave mentioned meters and another to redraw the skin.
  • There is extremely hard to scroll, because Rainmeter ignores when you1re scrolling over transparent parts of the skin. To avoid this you should have to create a not visible background, which would react to mouse scrolling. This can easily ba done by adding the BackgroundMode=2 and the SolidColor=0,0,0,1 options to the [Rainmeter] section.
With all these modifications your code should look this way:

Code: Select all

[Rainmeter]
Update=1
MiddleMouseUpAction=!Refresh
; Resize with mouse scroll
MouseScrollUpAction=[!SetVariable Scale "([#Scale]+#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "([#Scale]+#ScrollMouseIncrement#)"][!UpdateMeter "MeterBackground"][!UpdateMeter "MeterAudioRMSL"][!UpdateMeter "MeterLEDPeak"][!Redraw]
MouseScrollDownAction=[!SetVariable Scale "([#Scale]-#ScrollMouseIncrement# < 0.1 ? 0.1 : [#Scale]-#ScrollMouseIncrement#)"][!WriteKeyValue Variables Scale "([#Scale]-#ScrollMouseIncrement# < 0.1 ? 0.1 : [#Scale]-#ScrollMouseIncrement#)"][!UpdateMeter "MeterBackground"][!UpdateMeter "MeterAudioRMSL"][!UpdateMeter "MeterLEDPeak"][!Redraw]
BackgroundMode=2
SolidColor=0,0,0,1

[Metadata]
Skin name=MODERN VU METER
Version=1.0
Author=Dany Gee
Information=Simple, modern looking VU meter for your sound sources
License=Creative Commons Attribution-Non-Commercial-Share Alike 3.0

[Variables]
; Change colors to your liking
color1=575F6E
color2=8C98A8
Step=(256/#TotalSteps#)
ScrollMouseIncrement=0.2
Scale=1

[MeasureAudioOutput]
Measure=Plugin
Plugin=AudioLevel
Port=Output
RMSAttack=100
RMSDecay=100
RMSGain=2.0
PeakAttack=15
PeakDecay=2500
PeakGain=1.0

[MeasureAudioRMSL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=L
Type=RMS

[MeasureAudioPeakL]
Measure=Plugin
Plugin=AudioLevel
Parent=MeasureAudioOutput
Channel=L
Type=Peak

[MeasureLEDPeakL]
Measure=Calc
Formula=MeasureAudioPeakL
; Set the level of LED peak activation (lower value activates it sooner)
IfBelowValue=0.8
IfBelowAction=[!HideMeter MeterLEDPeak][!CommandMeasure MeasureFade Activate()]
IfAboveValue=0.8
IfAboveAction=[!ShowMeter MeterLEDPeak][!CommandMeasure MeasureFade Activate()]

[MeasureFade]
Measure=Script
ScriptFile=Fade.lua
; Optional script settings
Min=0
Max=255
Start=0
Step=20
MeterName=MeterLEDPeak

[MeasureWin7Audio]
Measure=Plugin
Plugin=Win7AudioPlugin
;OnChangeAction=[!Delay 500][!Refresh]

[MeterBackground]
Meter=Image
ImageName=#@#Images\Modern VU Meter BG.png
ImageTint=#color1#
X=(0*#Scale#)
Y=(0*#Scale#)
W=(170*#Scale#)
H=(170*#Scale#)
DynamicVariables=1

[MeterAudioRMSL]
Meter=Rotator
MeasureName=MeasureAudioRMSL
X=(85*#Scale#)
Y=(120*#Scale#)
;W=(12*#Scale#)
;H=(280*#Scale#)
ImageName=#@#Images\Needle.png
ImageTint=#color2#
Antialias=1
OffsetX=6
OffsetY=74
StartAngle=5.51
RotationAngle=1.55
TransformationMatrix=#Scale#;0;0;#Scale#;([#CURRENTSECTION#:X]*(1-#Scale#));([#CURRENTSECTION#:Y]*(1-#Scale#))
DynamicVariables=1

[MeterLEDPeak]
Meter=SHAPE
Shape=Rectangle 0,0,25,12,4 | Fill Color 254,99,117,[MeasureFade] | StrokeWidth 0
X=(73*#Scale#)
Y=(135*#Scale#)
DynamicVariables=1
Hidden=1
User avatar
Dany Gee
Posts: 34
Joined: July 11th, 2012, 8:32 am

Re: Help scale rotator image

Post by Dany Gee »

Perfect!
Works like a charm.
The amount of beers I already owe you... :thumbup: ;-)
SYSTEM: Windows 11 Pro 64bit|MOBO: ASUS Z170 Deluxe|CPU: i7-6700K @ 4.3Ghz|GPU: Asus GTX1080 Strix|RAM: 64GB Gskill Trident Z RGB (2400Mhz CL15)
User avatar
balala
Rainmeter Sage
Posts: 14469
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: Help scale rotator image

Post by balala »

Dany Gee wrote: August 1st, 2022, 4:08 pm Perfect!
Works like a charm.
The amount of beers I already owe you... :thumbup: ;-)
:thumbup: And no, you don't owe not a single one. But I'm glad if you got it resized as expected.