View all expressions
Conditional

Color Animation Based on Layer Position

Dynamically changes a layer’s color based on its position within the composition, using X and Y coordinates to calculate RGB values.

Contributed by:


xNorm = linear(position[0], 0, thisComp.width, 0, 1); // Normalize X position
yNorm = linear(position[1], 0, thisComp.height, 0, 1); // Normalize Y position
r = linear(xNorm, 0, 1, 0, 255); // Map X to Red
g = linear(yNorm, 0, 1, 0, 255); // Map Y to Green
b = 255 - (r + g) / 2; // Complementary Blue
[r, g, b, 255] / 255; // Normalize to RGB

Color Animation Based on Layer Position

Practical use case

Great for interactive animations where objects change color as they move, such as sliders, maps, or responsive graphics.

Check out similar expressions

Data-driven video workflows for After Effects are easier with Plainly.

a mesh of elegant lines transparent image