Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 1590

Bugs & Feature Suggestions • Re: [BUG/SUGGESTION] Inverted and negative low and high values in Clamp function

$
0
0
the behavior of the function is inconsistent
There is where I am lost. What exactly is inconsistent with the results of the clamp function? As far as I can tell, it is behaving exactly as described.

Clamp is just shorthand for: (x < low) ? low : ((x > high) ? high : x).

Here is your 2nd example with some extra visuals to show the values in clamp:

Code:

[Variables]TxtG=1#CRLF#2#CRLF#3#CRLF#4#CRLF#5#CRLF#6#CRLF#7#CRLF#8#CRLF#9#CRLF#10#CRLF#11#CRLF#12#CRLF#13#CRLF#14#CRLF#15#CRLF#16#CRLF#17#CRLF#18#CRLF#19#CRLF#20#CRLF#21#CRLF#22#CRLF#23#CRLF#24#CRLF#25#CRLF#26#CRLF#27#CRLF#28#CRLF#29#CRLF#30TxtB=1#CRLF#2#CRLF#3#CRLF#4#CRLF#5#CRLF#6#CRLF#7#CRLF#8#CRLF#9#CRLF#10OffsetY=0[Rainmeter]Update=1000AccurateText=1DynamicWindowSize=1---Meters---[ContainerVisible]Meter=ImageW=100H=242SolidColor=0,0,0,255MouseScrollUpAction=[!SetVariable OffsetY (Clamp(#OffsetY#+16.1,[Container:H]-[Text:H],0))][!UpdateMeter *][!Redraw]MouseScrollDownAction=[!SetVariable OffsetY (Clamp(#OffsetY#-16.1,[Container:H]-[Text:H],0))][!UpdateMeter *][!Redraw]DynamicVariables=1[Container]Meter=ImageW=100H=242SolidColor=0,0,0,255[Text]Container=ContainerMeter=StringFontFace=TahomaFontSize=10Y=#OffsetY#FontColor=255,255,255,255Text=#TxtB#DynamicVariables=1[X]Measure=CalcFormula=#OffsetY#+16.1DynamicVariables=1[Low]Measure=CalcFormula=[Container:H]-[Text:H]DynamicVariables=1[High]Measure=CalcFormula=0DynamicVariables=1[ClampInfo]Meter=StringFontFace=TahomaFontSize=9X=30FontColor=255,255,255,255Text=X=[X]#CRLF#Low=[Low]#CRLF#High=[High]#CRLF#OffsetY:#OffsetY#DynamicVariables=1
When I scroll down, the result changes the offset to 81 (seems correct to me). When I keep scrolling down, it stays at 81.

Code:

First time:  X = 0  - 16.1  = -16.1  OffsetY = (-16.1 < 81) ? 81 : (-16.1 > 0) ? 0 : -16.1    =  81Second time:  X = 81 - 16.1  =  64.9  OffsetY = ( 64.9 < 81) ? 81 : ( 64.9 > 0) ? 0 :  64.9    =  81
When I scroll up, the result "toggles" between 0 and 81 because of the formula.

Code:

First time:  X = 0  + 16.1  = 16.1  OffsetY = (16.1 < 81) ? 81 : (16.1 > 0) ? 0 : 16.1    =  81Second time:  X = 81 + 16.1  = 97.1  OffsetY = (97.1 < 81) ? 81 : (97.1 > 0) ? 0 : 97.1    =  0
-Brian

Statistics: Posted by Brian — Yesterday, 7:43 pm



Viewing all articles
Browse latest Browse all 1590

Trending Articles