Skip to main content
Participant
October 7, 2024
Answered

[Expressions] - How to make a gradient change of color using the position?

  • October 7, 2024
  • 1 reply
  • 303 views

I have this expression:

// positions
let pX = transform.xPosition;

let minX = 0;

let maxX = 1920;


// colors
let color1 = hexToRgb("E300FF");
let color2 = hexToRgb("00FFA5");

 

linear(value, minX, maxX, color1, color2);

I know the 0 and the 1920 doesn't make sense, what I'm trying to do is reference the position of X at 0 and at 1920, so the color value changes while the shape is moving in between the points.
I thought of doing a control point at 0 and 1920 and use that as the reference, but it didn't work.
So I would like to know if it's possible to reference a shape layer inside another's shape layer expression. 
Any other solution to this is really welcome!
Thanks 😄


This topic has been closed for replies.
Correct answer Airweb_AE

The last line should be:

linear(pX, minX, maxX, color1, color2);

1 reply

Airweb_AECorrect answer
Legend
October 7, 2024

The last line should be:

linear(pX, minX, maxX, color1, color2);
CrybebuAuthor
Participant
October 7, 2024

Thanks!!