ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Re: restricted area for random layers

COW Forums : Adobe After Effects Expressions

FAQ   •   VIEW ALL   •   ADD A NEW POST   •   PRINT
Respond to this post   •   Return to posts index   •   Read entire thread


cow
Alex English
Re: restricted area for random layers
on Jun 15, 2008 at 9:09:52 am

The following worked for me. Just set the windowpercent variable to whatever percentage of the area of the comp you want to block out in the center. So, say you need a window in the center that is 20% of the comp width wide and 20% of the comp width tall, you would set windowpercent = 20/100

x = 10;
f = thisComp.frameDuration * x;
posterizeTime(1 / f);
minPos = [0,0];
maxPos = [thisComp.width, thisComp.height];
loc = random(minPos, maxPos);
windowpercent = 50 / 100;
widthleft = thisComp.width * (1 - windowpercent);
heightleft = thisComp.height * (1 - windowpercent);
finalpos = []
if(loc[0] < (thisComp.width - widthleft / 2) && loc[0] > (widthleft / 2))
{
side = (thisComp.width / 2) - loc[0];
if(side < 0)
finalpos[0] = thisComp.width - widthleft / 2 - side * (1 - windowpercent);
else
finalpos[0] = widthleft / 2 - side * (1 - windowpercent);
}
else
finalpos[0] = loc[0];

if(loc[1] < (thisComp.height - heightleft / 2) && loc[1] > (heightleft / 2))
{
side = (thisComp.height / 2) - loc[1];
if(side < 0)
finalpos[1] = thisComp.height - heightleft / 2 - side * (1 - windowpercent);
else
finalpos[1] = heightleft / 2 - side * (1 - windowpercent);
}
else
finalpos[1] = loc[1];
finalpos;



It seems like there should be a much simpler answer than this, but it's what I came up with. It worked for me to do what I think you were asking for. Hopefully it can serve as a functional base for you to develop what you need.



Posts IndexRead Thread 


Current Message Thread:





© 2020 CreativeCOW.net All Rights Reserved
[TOP]