It is currently April 26th, 2024, 8:12 am

Rainmeter 3.2.0 Beta Clamp() Inconsistency

Report bugs with the Rainmeter application and suggest features.
hakshak
Posts: 6
Joined: February 23rd, 2015, 11:35 pm

Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by hakshak »

Was trying to clamp a color crossfade to [0-255] like so:

Code: Select all

;Low value is bright blue, closer to 75% reduce the blue
(Clamp((255-((([GPUTemperature:%]-0)*255)/75)),0,255))
Which works here:

Code: Select all

[GPUTempColorB]
Measure=Calc
Formula=(Clamp((255-((([GPUTemperature:%]-0)*255)/75)),0,255))
DynamicVariables=1
However, when I try to inline this into LineColor, it seems to get confused and report a paren mismatch:

Code: Select all

;This should start to crossfade blue to red at 70% and be completely red at 75%
LineColor=(Clamp(((([GPUTemperature:%]-70)*255)/30),0,255)),0,(Clamp((255-((([GPUTemperature:%]-0)*255)/75)),0,255)),255

;These versions also mismatch
LineColor=(Clamp(((([GPUTemperature:%]-70)*255)/30),0,255)),0,0,255
LineColor=0,0,(Clamp((255-((([GPUTemperature:%]-0)*255)/75)),0,255)),255
Am I doing something wrong? I just worked around this by creating two more measures in the second code example and that worked. Like so:

Code: Select all

LineColor=[GPUTempColorR],0,[GPUTempColorB],255

I would expect math functions to work in LineColor, or is that not the case?

Thanks!
User avatar
iNjUST
Posts: 117
Joined: June 20th, 2012, 12:44 am

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by iNjUST »

Math functions do work otherwise, but Clamp is a new example of a multi parameter function, whereas most others are single parameter. Any Color key looks for commas as delimiters, so the commas between parameters in the Clamp function breaks the parsing of the Color value.

Definitely a bug, but not sure if there exists an easy fix due to parsing the Color value with commas.

For the time being you could work around this by putting the math expression for each the Red, Green, and Blue pieces into separate Calc measures, and use those to return a single value.
hakshak
Posts: 6
Joined: February 23rd, 2015, 11:35 pm

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by hakshak »

Yeah, that's unfortunately what I ended up doing as shown above. :?

Wouldn't be that big of a deal if there were some kind of "MeasureStyle" paradigm or functional paradigm for the measures themselves. I was hoping to achieve this natively without resorting to Lua.
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by dgrace »

I think you're right - I noticed something weird when I added it but thought it was just me. I don't think it's an issue with Clamp() specifically as an issue with how the expression parser does grouping/sorting of operands. i.e. I'll bet the same issues pop up using any of the multi-arg expressions. I think poiru owns that stuff mostly so he may be the best person to ping.

dave
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by jsmorley »

Chances are this is only going to be an issue with multi-argument, comma separated math functions (I think there is only atan2, min, max, clamp, and round) used in any of the "color" options, as well as "padding", "ImageCrop" and a few others, which are also comma separated. Might not be all that easy to fix without having to sorta burn the house down and start over.
User avatar
dgrace
Developer
Posts: 265
Joined: June 28th, 2014, 8:32 am
Location: Tokyo, Japan

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by dgrace »

Yeah the bummer is that Clamp() is really useful for color operations. :(

dave
hakshak
Posts: 6
Joined: February 23rd, 2015, 11:35 pm

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by hakshak »

Is there any reason not to clamp them before they make it into Color:MakeARGB? As described here: https://github.com/rainmeter/rainmeter/issues/38
User avatar
jsmorley
Developer
Posts: 22630
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by jsmorley »

I think we will have a fix for this in the next beta version.
hakshak
Posts: 6
Joined: February 23rd, 2015, 11:35 pm

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

Post by hakshak »

Just in case anyone is curious about this, I posted the Lua version here:

http://rainmeter.net/forum/viewtopic.php?f=99&t=20501