ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Colour: numlayers/index

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Conor Flanagan
Colour: numlayers/index
on Mar 25, 2020 at 8:39:54 pm

Hi all,
I really didn't want to have to write this but I'm stuck and the key terms to search with are very vague.

So I've used a version of this expression before on many different projects, but I am now trying to get it to work for colour.
I want to basically have the lightness of the colour divide among the total layers in a comp.

So for example 10 layers, the lightness will increase in increments of .1
And adjust dynamically as more layers are added.

Now I've gotten this work up until I add the *i
For whatever reason multiplying by the index breaks it. No error though, just reverts to default value. I remove the *i I get the result of 1/n

Is index broken? Am I broken?

I created a more hackery way for the job I was doing, but now I just want to know how I was being stupid.

Cheers all.

n = thisComp.numLayers;
i = index;
h = 0
s = 0;
l = (1/n)*i;
a = 0;
HSL = [h,s,l,a];
hslToRgb(HSL);


Return to posts index

Andrei Popa
Re: Colour: numlayers/index
on Mar 25, 2020 at 10:06:12 pm

This works great on my pc. However, since it is the i that gives you trouble, you can try changing it like this:

n = thisComp.numLayers;
h = 0
s = 0;
l = index/n;
a = 0;
HSL = [h,s,l,a];
hslToRgb(HSL);


Andrei
My Envato portfolio.


Return to posts index

Conor Flanagan
Re: Colour: numlayers/index
on Mar 26, 2020 at 9:27:46 am

doh....
I did restart AE but not the computer.
Sorry.

But of course index/n. I was worried about numbers exceeding 1, but you'll never have more than the total.

Thank you for the sanity and math check Andrei.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]