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.