User Values

Sometimes you need to put some values into your expression which are more or less arbitrary. Often you want to try out several different values, and it's tedious to change the expression every time by hand. That's where user values come in. Let's reiterate our wave example:

origValXY(x,y+10*sin(x*(2*pi)/60))

There are two parameters here which we have chosen more or less arbitrarily, namely the amplitude of the wave (in this case 10) and the wave length (in this cas 60). Wouldn't it be nice if we could change these values with sliders instead of having to edit the expression?

That's exactly what user_slider provides. It generates a user interface element (a slider) and hands the chosen value to the expression:

amp=user_slider("Amplitude",0,100);
len=user_slider("Wavelength",1,200);
origValXY(x,y+amp*sin(x*(2*pi)/len))

user_slider takes three arguments: the name of the slider (for identification purposes in the user interface), the minimum and the maximum values. Try it out!

There are not only user value functions for numbers, but also for colors, color gradients, curves and even images. Image user values make it possible to have more than one input image in an expression. Check out the Reference Manual for details.

Next topic: Tuples and Tags