Copy link to clipboard
Copied
I want to set up an expression where I can control the font size, but I want to limit how small/big that font size can go to using the slider. Is this possible?
For example.... If I want to limit the user to a range between 20 and 50 using the slider.
Appreciate any insight that could be provided!
In that case, it would be like this:
sl = thisComp.layer("Slider").effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))
Copy link to clipboard
Copied
A simple linear(slider value, min, max) will do or alternatively a JS math clamp().
Mylenium
Copy link to clipboard
Copied
So something like this would work?
clamp(value, min=20, max=20)
Copy link to clipboard
Copied
I'm also reading that connecting the font size to a slider expression isn't possible.... just the font scale is possible.
My attempts so far have given errors. If it is possible, how should the coding look?
Copy link to clipboard
Copied
Something like this for source text should do it:
sl = effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))
Copy link to clipboard
Copied
Sorry.... still new to the coding aspect of expressions...
If I pickwhip the source text to the slide expression on a Null layer, I get this as a result -
thisComp.layer("Slider").effect("Slider Control")("Slider")
I'm assuming that I have to do something like this to connect it all together -
thisComp.layer("Slider");
sl = effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))
Unfortunately, I'm getting an error and I'm unsure what is throwing it. Thank you again for this help. I want to learn this better and understand it better.
Copy link to clipboard
Copied
In that case, it would be like this:
sl = thisComp.layer("Slider").effect("Slider Control")("Slider");
style.setFontSize(clamp(sl,20,50))
Copy link to clipboard
Copied
Now it's working. I thought I tried a version like that, but I kept getting an error. Thank you very much!