Can we change it to the following:

~~~
if (implicitPrefs) math.max(math.min(r, 1.0), 0.0) else r
~~~