It is currently December 16th, 2018, 2:42 am

Rainmeter 3.2.0 Beta Clamp() Inconsistency

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

Rainmeter 3.2.0 Beta Clamp() Inconsistency

hakshak » February 23rd, 2015, 11:44 pm

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: 118
Joined: June 20th, 2012, 12:44 am

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

iNjUST » February 24th, 2015, 12:55 am

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: 7
Joined: February 23rd, 2015, 11:35 pm

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

hakshak » February 24th, 2015, 8:34 am

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

dgrace » February 24th, 2015, 11:27 pm

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: 18516
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

jsmorley » February 25th, 2015, 2:19 am

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

dgrace » February 25th, 2015, 11:27 pm

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

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

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

hakshak » February 28th, 2015, 2:30 pm

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: 18516
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

jsmorley » February 28th, 2015, 2:33 pm

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

Re: Rainmeter 3.2.0 Beta Clamp() Inconsistency

hakshak » March 1st, 2015, 4:16 pm

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

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