The code should work, but the logic of expression doesn't make what i think.
This is the last example.
I want that the object who i had expression on position, use random position value until it finds position value over a reference calque (by using sample Image and alpha)
The purpose is to have a random dispersion of object (solid or layer) who take the form of the alpha of a layer named Reference.
This is the code :
Code: Select all
if (time<1) {
P = [random(thisComp.width),random(thisComp.height)];
} else {
P1=value;
T1=thisComp.layer("Reference").sampleImage(P1);
if (T1[3]=1) {
P1;
} else {
while (T2=0) {
P2 = [random(thisComp.width),random(thisComp.height)];
T2 = thisComp.layer("Reference").sampleImage(P2);
};
P2;
};
};
The time test is for randomizes the first position of the object, in order to duplicate many times this things whithout keep a same position.
The expression record the actual value and test if the object is over the reference layer, if it's true (the alpha value equals 1) he keep the position.
If he is not over, it test random value until he found one over the reference layer.
The problem is that if i write
Code: Select all
if (T1[3]=1) {
And if i write
Code: Select all
if (T1[3]>0) {
Using script could be a better way, but i want to use expression, in order to create a more interactive tool for my project (GUI panel is too hard for me).
Thanks.