Page 1 of 1

negative to positive value

Posted: May 27th, 2013, 11:20 am
by Ryberg
This one should be very easy but my knowledge on expression scripts is very limited so I call for help.

A camera lens blur effects' blur radius is linked to a slider control and I would like it to turn the value up according to the sliders negative AND positive values, so:
Slider 50 = Blur radius 50
Slider 0 = Blur radius 0
Slider -50 = Blur radius 50

I wrote following nonsense in the blur radius attribute which obviously doesn't work

Code: Select all

x= (thisComp.layer("Adjustment Layer 3").effect("Slider Control")("Slider"))
if (x < 0) {*-1;
}

Re: negative to positive value

Posted: May 27th, 2013, 12:33 pm
by Ryberg
I managed to solve it, I'm happy again.

Code: Select all

x=(thisComp.layer("Adjustment Layer 3").effect("Slider Control")("Slider") *.35);
if (x < 0) x*-1;

Re: negative to positive value

Posted: May 28th, 2013, 4:36 pm
by Paul Tuersley
Or just:

Code: Select all

x = thisComp.layer("Adjustment Layer 3").effect("Slider Control")("Slider");
Math.abs(x);