It is currently March 28th, 2024, 11:48 am

[String meter] How to change shadow effect dynamically ?

Get help with creating, editing & fixing problems with skins
Post Reply
User avatar
nek
Posts: 105
Joined: November 3rd, 2019, 12:00 am
Contact:

[String meter] How to change shadow effect dynamically ?

Post by nek »

I expected that the red drop shadow move to right, but nothing happened.
320x180.isShadowDynamic.gif

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
DynamicWindowSize=1
MouseScrollDownAction=[!SetVariable VAR "(Clamp([#VAR]-2,0,40))"][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable VAR "(Clamp([#VAR]+2,0,40))"][!UpdateMeter *][!Redraw]

[Variables]
VAR=0

[MetertString1]
Meter=String
Text=Onett
X=0
Y=0
Antialias=1
DynamicVariables=1
Padding=10,0,10,0
SolidColor=95B9C7FF
FontSize=32
;Shadow | X Offset | Y Offset | Blur Amount | Color
InlineSetting=Shadow | (2+#VAR#) | 0 | 0 | FF0000FF

[MeterString2]
Meter=String
Text=Onett
X=0r
Y=0R
Antialias=1
DynamicVariables=1
Padding=10,0,10,0
SolidColor=87AFC7FF
FontSize=32
;Size | numeric point size
InlineSetting=Size | (32+#VAR#)
InlineSetting=Size | (32+#VAR#) worked, but InlineSetting=Shadow | (2+#VAR#) | 0 | 0 | FF0000FF did't work.
I need help or any suggestions.

InlineSetting=Shadow | https://docs.rainmeter.net/manual/meters/string/inline/#InlineShadow
// Windows 10 Pro 1909 64-bit, Rainmeter 4.4.0.3398 beta (64-bit)
Last edited by nek on August 21st, 2020, 10:46 am, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

nek wrote: August 19th, 2020, 10:27 pm I expected that the red drop shadow move to right, but nothing happened.
InlineSetting=Size | (32+#VAR#) worked, but InlineSetting=Shadow | (2+#VAR#) | 0 | 0 | FF0000FF did't work.
Your expectation was correct, but you missed something in the implementation: adding the appropriate InlineSetting to the resized meter (i.e. [MeterString2]). In other words, the code you have now pointlessly sets the shadow based on #VAR# in the 1st meter, but the 2nd meter is only getting its size changed and no shadow modification. This is the correct way to do it:

Code: Select all

[Rainmeter]
Update=-1
AccurateText=1
DynamicWindowSize=1
MouseScrollDownAction=[!SetVariable VAR "(Clamp([#VAR]-2,0,40))"][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable VAR "(Clamp([#VAR]+2,0,40))"][!UpdateMeter *][!Redraw]

[Variables]
VAR=0

[MetertString1]
Meter=String
Text=Onett
X=0
Y=0
Antialias=1
DynamicVariables=1
Padding=10,0,10,0
SolidColor=95B9C7FF
FontSize=32
;Shadow | X Offset | Y Offset | Blur Amount | Color
InlineSetting=Shadow | 2 | 0 | 0 | FF0000FF

[MeterString2]
Meter=String
Text=Onett
X=0r
Y=0R
Antialias=1
DynamicVariables=1
Padding=10,0,10,0
SolidColor=87AFC7FF
FontSize=32
;Size | numeric point size
InlineSetting=Size | (32+#VAR#)
;Shadow | X Offset | Y Offset | Blur Amount | Color
InlineSetting2=Shadow | (2+#VAR#) | 0 | 0 | FF0000FF
Preview:
InlineSetting Dynamic Shadow.jpg
Notice the InlineSetting2 option. I removed #VAR# from the 1st meter InlineSetting, since as I mentioned, it made no sense as that meter was static (i.e. didn't suffered size modifications like the 2nd).

EDIT: Actually, simply InlineSetting2=Shadow | 2 | 0 | 0 | FF0000FF also works, after all you probably don't need to modify the extent of the shadow anyway. Other than that, generally, inline settings should be used when you need the desired effects on just a part of the string - if you need them on the whole string and you're fine with a 1 pixel shadow, you might as well get rid of the inline settings altogether and just use instead:

Code: Select all

FontSize=(32+#VAR#)
StringEffect=Shadow
FontEffectColor=FF0000FF
Basically, unless some tweaking of the desired effects are needed on the whole string, InlineSettings make the most sense when used in combo with InlinePattern, to designate the part of the string you want to be "different" from the rest.

EDIT2: It would be better to move the mouse actions under the [MeterString2] meter, because: a) the action is, after all, performed on that meter and b) the [Rainmeter] section (where you now have those mouse actions) doesn't support dynamic variables (which you do use). Also, Update=-1, while useful when the idea is to save CPU usage on heavyweight skins, causes variables to not be updated properly in the Rainmeter Log; while this isn't a deal breaker, it may be useful when debugging your skin.
Last edited by Yincognito on August 20th, 2020, 3:15 am, edited 1 time in total.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

A basic example on how to use the InlineSetting/InlinePattern combo dynamically on this 5 char string:

Code: Select all

[Variables]
VAR=0
CHARINDEX=0

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[MetertString1]
Meter=String
Text=Onett
X=0
Y=0
Antialias=1
DynamicVariables=1
Padding=10,0,10,0
SolidColor=95B9C7FF
FontSize=32
;Shadow | X Offset | Y Offset | Blur Amount | Color
InlineSetting=Shadow | 2 | 0 | 0 | FF0000FF

[MeterString2]
Meter=String
Text=Onett
X=0r
Y=0R
Antialias=1
DynamicVariables=1
Padding=10,0,10,0
SolidColor=87AFC7FF
FontSize=32
;Size | numeric point size
InlineSetting=Size | (32+#VAR#)
InlinePattern=^.{#CHARINDEX#}(.)
;Shadow | X Offset | Y Offset | Blur Amount | Color
InlineSetting2=Shadow | 2 | 0 | 0 | FF0000FF
InlinePattern2=^.{#CHARINDEX#}(.)
MouseScrollDownAction=[!SetVariable CHARINDEX ((5+#CHARINDEX#-1)%5)][!SetVariable VAR (Clamp([#VAR]-2,0,40))][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable CHARINDEX ((5+#CHARINDEX#+1)%5)][!SetVariable VAR (Clamp([#VAR]+2,0,40))][!UpdateMeter *][!Redraw]
User avatar
nek
Posts: 105
Joined: November 3rd, 2019, 12:00 am
Contact:

Re: [String meter] How to change shadow effect dynamically ?

Post by nek »

Yincognito wrote: August 20th, 2020, 3:11 am
Thank you for the reply and having your time.

The font size of string meter will be dynamically changed by scrolling the mouse wheel button,
and I would like to adapt the shadow effect to the font size.
320x180goal.png
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

nek wrote: August 20th, 2020, 1:34 pm Thank you for the reply and having your time.

The font size of string meter will be dynamically changed by scrolling the mouse wheel button,
and I would like to adapt the shadow effect to the font size.
320x180goal.png
I see. Well, it seems that the Shadow inline setting doesn't support dynamic variables, and from what I know, it should. For example, in the below code:

Code: Select all

[Variables]
Offset=1

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[MeterString]
Meter=String
Text=Onett
X=0
Y=0
AntiAlias=1
Padding=10,0,10,0
SolidColor=128,128,255,255
FontSize=32
InlineSetting=Shadow | #Offset# | #Offset# | 0 | 255,0,0,255
MouseScrollDownAction=[!SetVariable Offset (#Offset#-1)][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable Offset (#Offset#+1)][!UpdateMeter *][!Redraw]
;MouseScrollDownAction=[!WriteKeyValue Variables Offset (#Offset#-1)][!Refresh]
;MouseScrollUpAction=[!WriteKeyValue Variables Offset (#Offset#+1)][!Refresh]
DynamicVariables=1
the uncommented mouse actions don't produce the desired dynamic change of the text shadow, but the commented mouse actions do, since they write the variable in the file and refresh the skin therefore avoiding dynamic variables altogether.

You should take this and post it in the Bugs & Feature Suggestions section of the forum, or if you don't just let me know and I will. Good catch, by the way. EDIT: I already did that.

EDIT: In the meantime, based on what it has been found about the Shadow inline setting and dynamic variables, you might want to use this workaround, which accomplishes what you want, albeit by refreshing the skin...

Code:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Variables]
Var=0

[MeterString1]
Meter=String
Text=Onett
X=0
Y=0
Antialias=1
Padding=10,0,10,0
SolidColor=95B9C7FF
FontSize=32
InlineSetting=Shadow | 2 | 0 | 0 | FF0000FF
DynamicVariables=1

[MeterString2]
Meter=String
Text=Onett
X=0r
Y=0R
Antialias=1
Padding=10,0,10,0
SolidColor=87AFC7FF
FontSize=32
InlineSetting=Size | (32+#Var#)
InlineSetting2=Shadow | (2+#Var#/10) | (2+#Var#/10) | ((2+#Var#/10)/2) | FF0000FF
MouseScrollDownAction=[!WriteKeyValue Variables Var (Clamp(#Var#-2,0,40))][!Refresh]
MouseScrollUpAction=[!WriteKeyValue Variables Var (Clamp(#Var#+2,0,40))][!Refresh]
DynamicVariables=1
Preview:
ezgif.com-optimize.gif
User avatar
nek
Posts: 105
Joined: November 3rd, 2019, 12:00 am
Contact:

Re: [String meter] How to change shadow effect dynamically ?

Post by nek »

Yincognito wrote: August 20th, 2020, 2:06 am b) the [Rainmeter] section (where you now have those mouse actions) doesn't support dynamic variables (which you do use).
I don't know about the detail of the Varables, but I often use the [#VAR] instead of the #VAR# in my lazy (Update=60000) skins.
And the [#VAR] works fine in the Rainmeter section as well.

Code: Select all

[Rainmeter]
MouseScrollDownAction=[!SetVariable VAR "(Clamp([#VAR]-2,0,40))"][!UpdateMeter *][!Redraw]
MouseScrollUpAction=[!SetVariable VAR "(Clamp([#VAR]+2,0,40))"][!UpdateMeter *][!Redraw]
Yincognito wrote: August 20th, 2020, 2:59 pm
>> How to change shadow effect dynamically ?
Thank for the suggestion of !WriteKeyValue and [!Refresh].

InlineSetting2=Shadow | (2+#Var#/10) | (2+#Var#/10) | ((2+#Var#/10)/2) | FF0000FF
This looks great, I like it.

I have tested the following InlineSetting with dynamic variable, and those worked. It seems that only Shadow doesn't work.
InlineSetting=Size, Weight, Color, CharacterSpacing, GradientColor
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

nek wrote: August 20th, 2020, 7:20 pm I don't know about the detail of the Varables, but I often use the [#VAR] instead of the #VAR# in my lazy (Update=60000) skins. [...] And the [#VAR] works fine in the Rainmeter section as well.
Yeah, this has nothing to do with the nested form of writing variables, which is fine and just a way of referencing them. When talking about dynamic variables in the [Variables] section I was referring to this note in the manual and also the things mentioned here (the 4th paragraph).
nek wrote: August 20th, 2020, 7:20 pm>> How to change shadow effect dynamically ?
Thank for the suggestion of !WriteKeyValue and [!Refresh].

InlineSetting2=Shadow | (2+#Var#/10) | (2+#Var#/10) | ((2+#Var#/10)/2) | FF0000FF
This looks great, I like it.

I have tested the following InlineSetting with dynamic variable, and those worked. It seems that only Shadow doesn't work.
InlineSetting=Size, Weight, Color, CharacterSpacing, GradientColor
I'm glad it worked for you and you liked it. Good to know that Shadow is the only one that didn't seem to work with dynamic variables - hopefully there aren't more of these. Just in case you're interested or you might find useful someday, here's another example of what you can do with InlineSettings (control it by scrolling and left clicking) in the code below. By the way, notice how the appearance of Shadows changes after scrolling and left clicking afterwards - I believe that's also because of the Shadow issue with dynamic variables, but interestingly changing the colors seem to affect drawing the shadows. The funny thing is that I wrote this quite a while ago but didn't realize Shadow had a problem with dynamic variables, and I should have.

Code: Select all

[Variables]
Color0=0,0,0,255
Color1=255,255,255,255
CharSpace=0.5
ShadowOffset=1
ShadowBlur=1

[Rainmeter]
Update=1000
DynamicWindowSize=1
AccurateText=1

---Measures---

---Meters---

[MeterText]
Meter=String
X=0
Y=0
FontFace=Tahoma
FontColor=#Color1#
SolidColor=#Color0#
SolidColor2=#Color1#
GradientAngle=90
InlineSetting=CharacterSpacing | (#CharSpace#) | (#CharSpace#)
InlineSetting2=Shadow | (-#ShadowOffset#) | (-#ShadowOffset#) | (#ShadowBlur#) | #Color0#
InlineSetting3=Shadow | (-#ShadowOffset#) | (#ShadowOffset#) | (#ShadowBlur#) | #Color0#
InlineSetting4=Shadow | (#ShadowOffset#) | (-#ShadowOffset#) | (#ShadowBlur#) | #Color0#
InlineSetting5=Shadow | (#ShadowOffset#) | (#ShadowOffset#) | (#ShadowBlur#) | #Color0#
; StringEffect=Border
; FontEffectColor=#Color0#
FontSize=14
AntiAlias=1
Padding=5,5,5,5
Text="Call The Police#CRLF##CRLF##CRLF##CRLF#American Dream#CRLF##CRLF##CRLF##CRLF#LCD Soundsystem"
LeftMouseUpAction=[!SetVariable Color0 #Color1#][!SetVariable Color1 #Color0#][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseScrollUpAction=[!SetVariable CharSpace (#CharSpace#+0.5)][!SetVariable ShadowOffset (#ShadowOffset#+0.5)][!SetVariable ShadowBlur (#ShadowBlur#+0.5)][!UpdateMeter #CURRENTSECTION#][!Redraw]
MouseScrollDownAction=[!SetVariable CharSpace (#CharSpace#-0.5)][!SetVariable ShadowOffset (#ShadowOffset#-0.5)][!SetVariable ShadowBlur (#ShadowBlur#-0.5)][!UpdateMeter #CURRENTSECTION#][!Redraw]
DynamicVariables=1
This was meant to be a way of making a text of a certain color become easily visible even if the background color becomes the same as the text color. Char spacing is also used in this one.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

And the next beta which corrects the issue is released, see here. Obviously, it can be downloaded from Rainmeter's home page.
User avatar
Yincognito
Rainmeter Sage
Posts: 7017
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: [String meter] How to change shadow effect dynamically ?

Post by Yincognito »

aatraveling wrote: August 25th, 2020, 1:21 pm thanks a lot for the help and information.
your information and links are all appreciated and very helpful for me as i am still learning... thanks again
You're welcome. ;-)
Post Reply