View Single Post
Old 03-08-2023, 12:17 PM   #4
papagirafe
Human being with feelings
 
papagirafe's Avatar
 
Join Date: Aug 2020
Location: Brasil
Posts: 690
Default

Quote:
Originally Posted by vsthem View Post
Basic Helpers: Track opacity/zoom/pan

Are there better ones to use for this function?
Yes and no, it depends heavily on the context of use. Assuming that your are not rotating the image, here is a patched version of the preset. Let me know if this works for you. Just copy and paste this code over the existing one (and save! ctrl-s).
Code:
// Track opacity/zoom/pan
//  **** patched for "smoothness"
//@param1:opacity 'opacity' 1
//@param2:zoom 'zoom' 0 -10 10 0
//@param3:xoffs 'X offset' 0 -1 1 0
//@param4:yoffs 'Y offset' 0 -1 1 0
//@param5:rotate 'rotate' 0 -360 360 0 1
//@param7:filter 'filter' 0 0 1 0.5 1
//@param8:clear 'clear bg' 1 0 1 0.5 1
//@param9:force_w 'force width' 0 0 2600 1024 2
//@param10:force_h 'force height' 0 0 2600 1024 2
//@param11:paspect 'preserve aspect' 1 0 1 0.5 1

function round(v)((v+0.5)|0);
function round2(v)(((v+1)>>1)<<1);

(bg_img=input_ismaster() ? -2 : input_track(0)) ? (
  force_w &= -2; force_h &= -2;
  force_w && !force_h ? force_h = (force_w * project_h / project_w)&-2;
  force_h && !force_w ? force_w = (force_h * project_w / project_h)&-2;
  force_w>0 && force_h>0 ? ( project_w=force_w; project_h=force_h );

  w = opacity < 0.01 ? 0 : opacity > 0.99 ? 1 : opacity;
  gfx_a2=0;
  gfx_blit((w < 1 || clear < 0.5) ? bg_img : -2,1);

  w > 0 ? (
    gfx_mode = filter>0.5 ? 256 : 0;
    gfx_a=w;
    z = 10^(zoom/10);
    dw = (project_w*z)&-2;
    dh = (project_h*z)&-2;
    x = (project_w - dw + xoffs*(project_w+dw))*.5;
    y = (project_h - dh + yoffs*(project_h+dh))*.5;
                                                   // *** patch is here ***
    rotate == 0 ? gfx_blit(0,paspect, round(x),round(y),round2(dw),round2(dh)) : (
      input_info(0,srcw,srch);
      sc=2.0; sc2=sc*.5 - 0.5;
      gfx_rotoblit(0,rotate*$pi/180,(x-dw*sc2)|0,(y-dh*sc2)|0,dw*sc,dh*sc, -srcw*sc2, -srch*sc2, srcw*sc, srch*sc);
    );
  );
);
papagirafe is offline   Reply With Quote