0
Community Expert
,
/t5/after-effects-discussions/expressions-mix-slider-for-blending-between-rgb-white-and-input-color/td-p/15211638
Mar 14, 2025
Mar 14, 2025
Copy link to clipboard
Copied
I ain't the smartest when it comes to math and code. I have a setup that controls a color with two operators. A color picker and a slider that multiplies. Current code:
// Get params
baseColor = effect("Linear Gain")("Color");
gain = effect("Linear Gain")("Gain");
// Multiply the color by the gain value
[baseColor[0] * gain, baseColor[1] * gain, baseColor[2] * gain, baseColor[3]];
I'd like to add an additional slider that can go from 0-100(%) that can control the amount of change from 0% which should result in [1,1,1,1float] ie. 'white' to the specified color*gain result being 100%.
Would love to have some assistance with this.
TOPICS
Expressions
,
Scripting
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
1 Correct answer
Community Expert
,
Mar 16, 2025
Mar 16, 2025
Found a solution through gpt. This is the new code should it help anyone.
// Get params
baseColor = effect("Linear Gain")("Color");
gain = effect("Linear Gain")("Gain");
mixPercent = effect("Linear Gain")("Mix");
// Normalize the mix percentage (from slider) to a 0-1 range
mix = mixPercent / 100;
// Calculate the interpolated color
interpolatedColor = [
baseColor[0] * gain * mix + (1 - mix),
baseColor[1] * gain * mix + (1 - mix),
baseColor[2] * gain * mix + (1 - mix),
baseColor
...
Community Expert
,
LATEST
/t5/after-effects-discussions/expressions-mix-slider-for-blending-between-rgb-white-and-input-color/m-p/15214190#M262922
Mar 16, 2025
Mar 16, 2025
Copy link to clipboard
Copied
Found a solution through gpt. This is the new code should it help anyone.
// Get params
baseColor = effect("Linear Gain")("Color");
gain = effect("Linear Gain")("Gain");
mixPercent = effect("Linear Gain")("Mix");
// Normalize the mix percentage (from slider) to a 0-1 range
mix = mixPercent / 100;
// Calculate the interpolated color
interpolatedColor = [
baseColor[0] * gain * mix + (1 - mix),
baseColor[1] * gain * mix + (1 - mix),
baseColor[2] * gain * mix + (1 - mix),
baseColor[3] // Assuming we want the original alpha value
];
// Return the interpolated color
interpolatedColor;
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

