Random Pan and Scan


You can use these expressions to randomly pan and scan a photo that is larger than your comp.

The expressions will automatically compensate for square pixels in a non-square pixel comp.

Import your image into the comp and add a point control to it.

Add the following expression to the point control:


scale_time=1;
hold_time=.5;
max_scale=200;

min_scale=Math.max(this_comp.width/width,this_comp.height/height)*100;
total_time=scale_time+hold_time
seed=Math.floor(time/total_time)+2;
seed_random(seed,true);
new_scale=random(min_scale,max_scale);
seed_random(seed-1,true);
old_scale=random(min_scale,max_scale);
[old_scale,new_scale];

Add the following expression for position:


scale_time=1;
hold_time=.5;

pix_factor=source.pixel_aspect/this_comp.pixel_aspect;
total_time=scale_time+hold_time;
seg_time=time%total_time;
old_scale=effect("Point Control").param("Point")[0];
new_scale=effect("Point Control").param("Point")[1];
seed=Math.floor(time/total_time)+2;
seed_random(seed,true);
max_x=(width/2)*(new_scale/100)*pix_factor;
min_x=this_comp.width-(width/2)*(new_scale/100)*pix_factor;
max_y=(height/2)*(new_scale/100);
min_y=this_comp.height-(height/2)*(new_scale/100);
new_pos=random([min_x,min_y],[max_x,max_y]);
seed_random(seed-1,true);
max_x=(width/2)*(old_scale/100)*pix_factor;
min_x=this_comp.width-(width/2)*(old_scale/100)*pix_factor;
max_y=(height/2)*(old_scale/100);
min_y=this_comp.height-(height/2)*(old_scale/100);
old_pos=random([min_x,min_y],[max_x,max_y]);
if(seg_time > scale_time){
  new_pos
}else{
  percent=seg_time/scale_time;
  ease(percent,old_pos,new_pos)
}

Add the following expression for scale:


scale_time=1;
hold_time=.5;

total_time=scale_time+hold_time;
seg_time=time%total_time;
old_scale=effect("Point Control").param("Point")[0];
new_scale=effect("Point Control").param("Point")[1];
if(seg_time > scale_time){
  [new_scale,new_scale]
}else{
  percent=seg_time/scale_time;
  ease(percent,[old_scale,old_scale],[new_scale,new_scale])
}

Adjust the scale time, hold time, and maximum scale to suit your needs. If you change the scale time or hold time, remember to do it in all three expressions.