Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


How to auto calculate a number when a slider is in a certain range?

Community Beginner ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

I'm curious if there's is a solution to the following:

 

var horizontal = comp("Render").layer("Controller").effect("B-films Credits Builder")("Horizontal Position");
var vertical = comp("Render").layer("Controller").effect("B-films Credits Builder")("Vertical Position");
var depth = comp("Render").layer("Controller").effect("B-films Credits Builder")("Depth Position");
[horizontal, 1920 - 420 - vertical, -depth];

 

The bold text has to be automatically calculated when the vertical slider is between 0 and 540.

If the vertical slider is at 540 it should be 420, when the vertical slider is at 0 it should be 0 and between those value it should calculate the value automatically.

 

Is there any way to do this?

TOPICS
Expressions

Views

66

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Adobe Community Professional , Jul 11, 2021 Jul 11, 2021
You just need to declare some variables. Here's the code on a text layer and the resulting values: vertical = effect("Slider 1")("Slider").value.toFixed(1); vertical_Clamp = clamp(vertical, 0, 540).toFixed(1); vertical_Ofst = linear(vertical_Clamp, 0, 540, 0, 420).toFixed(1); // the following code displays the values for the variables "Vertical Slider: " + vertical + "\r" + "Vertical Clamp: " + vertical_Clamp + "\r" + "Vertical Offset: " + vertical_Ofst Plug those variables into your expre...

Likes

Translate

Translate
Adobe Community Professional ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

If you know the values it's as imple as using a linear() interpolator to derive the inbetween values:

 

linear(vertical, 540,0,420,0);

 

Mylenium

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

It sorta works, it sorta doesn't.

I need the slider to keep it's original values.

I only need the offset between 1920 and the slider to be recalculated.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Community Professional ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

You just need to declare some variables. Here's the code on a text layer and the resulting values:

vertical = effect("Slider 1")("Slider").value.toFixed(1);
vertical_Clamp = clamp(vertical, 0, 540).toFixed(1);
vertical_Ofst = linear(vertical_Clamp, 0, 540, 0, 420).toFixed(1);
// the following code displays the values for the variables
"Vertical Slider:  " + vertical  + "\r" + 
"Vertical Clamp: " + vertical_Clamp + "\r" +
"Vertical Offset: " + vertical_Ofst

clamp values.gif

Plug those variables into your expression and it should work. I added clamp(1) to the end of each variable to clean up the text display. You can delete it unless you want pixel-level rounding. 

 

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 11, 2021 Jul 11, 2021

Copy link to clipboard

Copied

LATEST

Thank you very much!

 

This is exactly what I meant!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines