seawolf2357 commited on
Commit
d08f8a4
·
verified ·
1 Parent(s): 64ab3bd

Update app-backup-last.py

Browse files
Files changed (1) hide show
  1. app-backup-last.py +60 -20
app-backup-last.py CHANGED
@@ -654,22 +654,35 @@ var nw=sw*scale,nh=sh*scale;
654
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
655
  ctx.drawImage(el,ox,oy,nw,nh);
656
  }}else if(mode==='blur'){{
657
- // 블러 배경: 배경에 확대+블러, 그 위에 원본
658
- // 먼저 배경 (확대해서 꽉 채우기)
659
- ctx.filter='blur(20px)';
 
 
 
 
 
 
 
 
 
 
 
 
660
  var scale=Math.max(dw/sw,dh/sh)*1.1;
661
  var nw=sw*scale,nh=sh*scale;
662
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
663
- ctx.drawImage(el,ox,oy,nw,nh);
664
- ctx.filter='none';
665
  // 어둡게
666
- ctx.fillStyle='rgba(0,0,0,0.3)';
667
  ctx.fillRect(0,0,dw,dh);
668
- // 원본 (fit)
 
669
  var fitScale=Math.min(dw/sw,dh/sh);
670
  var fw=sw*fitScale,fh=sh*fitScale;
671
  var fx=(dw-fw)/2,fy=(dh-fh)/2;
672
- ctx.drawImage(el,fx,fy,fw,fh);
673
  }}else{{
674
  // 맞춤 (fit): 원본 비율 유지, 여백
675
  var scale=Math.min(dw/sw,dh/sh);
@@ -747,6 +760,11 @@ var startTime=performance.now();
747
  var fillMode=S.fillMode;
748
 
749
  // 실시간 기반 렌더링
 
 
 
 
 
750
  await new Promise(function(resolve){{
751
  var frameCount=0;
752
  var lastVideoEl=null;
@@ -791,7 +809,15 @@ lastVideoEl=el;
791
  try{{
792
  var sw=el.videoWidth||el.naturalWidth||el.width||exportW;
793
  var sh=el.videoHeight||el.naturalHeight||el.height||exportH;
 
 
 
 
 
 
 
794
  drawWithModeExport(offCtx,el,sw,sh,exportW,exportH,fillMode);
 
795
  }}catch(e){{}}
796
  }}
797
  }}else{{
@@ -859,25 +885,39 @@ var scale=Math.max(dw/sw,dh/sh);
859
  var nw=sw*scale,nh=sh*scale;
860
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
861
  ctx.drawImage(el,ox,oy,nw,nh);
862
- }}else if(mode==='blur'){{
863
- ctx.filter='blur(20px)';
864
- var scale=Math.max(dw/sw,dh/sh)*1.1;
865
  var nw=sw*scale,nh=sh*scale;
866
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
867
  ctx.drawImage(el,ox,oy,nw,nh);
868
- ctx.filter='none';
869
- ctx.fillStyle='rgba(0,0,0,0.3)';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
870
  ctx.fillRect(0,0,dw,dh);
 
 
871
  var fitScale=Math.min(dw/sw,dh/sh);
872
  var fw=sw*fitScale,fh=sh*fitScale;
873
  var fx=(dw-fw)/2,fy=(dh-fh)/2;
874
- ctx.drawImage(el,fx,fy,fw,fh);
875
- }}else{{
876
- var scale=Math.min(dw/sw,dh/sh);
877
- var nw=sw*scale,nh=sh*scale;
878
- var ox=(dw-nw)/2,oy=(dh-nh)/2;
879
- ctx.drawImage(el,ox,oy,nw,nh);
880
- }}
881
  }}
882
 
883
  function cancelExport(){{S.cancelled=true;document.getElementById('exportModal').style.display='none'}}
 
654
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
655
  ctx.drawImage(el,ox,oy,nw,nh);
656
  }}else if(mode==='blur'){{
657
+ // 프레임 먼저 캡처
658
+ var frameCanvas=document.createElement('canvas');
659
+ frameCanvas.width=sw;frameCanvas.height=sh;
660
+ var frameCtx=frameCanvas.getContext('2d');
661
+ frameCtx.drawImage(el,0,0,sw,sh);
662
+
663
+ // 블러용 작은 캔버스
664
+ var blurCanvas=document.createElement('canvas');
665
+ blurCanvas.width=16;blurCanvas.height=16;
666
+ var blurCtx=blurCanvas.getContext('2d');
667
+ blurCtx.drawImage(frameCanvas,0,0,16,16);
668
+
669
+ // 배경
670
+ ctx.imageSmoothingEnabled=true;
671
+ ctx.imageSmoothingQuality='high';
672
  var scale=Math.max(dw/sw,dh/sh)*1.1;
673
  var nw=sw*scale,nh=sh*scale;
674
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
675
+ ctx.drawImage(blurCanvas,ox,oy,nw,nh);
676
+
677
  // 어둡게
678
+ ctx.fillStyle='rgba(0,0,0,0.4)';
679
  ctx.fillRect(0,0,dw,dh);
680
+
681
+ // 원본 (캡처된 프레임)
682
  var fitScale=Math.min(dw/sw,dh/sh);
683
  var fw=sw*fitScale,fh=sh*fitScale;
684
  var fx=(dw-fw)/2,fy=(dh-fh)/2;
685
+ ctx.drawImage(frameCanvas,fx,fy,fw,fh);
686
  }}else{{
687
  // 맞춤 (fit): 원본 비율 유지, 여백
688
  var scale=Math.min(dw/sw,dh/sh);
 
760
  var fillMode=S.fillMode;
761
 
762
  // 실시간 기반 렌더링
763
+ // 블러 모드용 프레임 캡처 캔버스 (재사용)
764
+ var frameCanvas=document.createElement('canvas');
765
+ frameCanvas.width=1920;frameCanvas.height=1080;
766
+ var frameCtx=frameCanvas.getContext('2d');
767
+
768
  await new Promise(function(resolve){{
769
  var frameCount=0;
770
  var lastVideoEl=null;
 
809
  try{{
810
  var sw=el.videoWidth||el.naturalWidth||el.width||exportW;
811
  var sh=el.videoHeight||el.naturalHeight||el.height||exportH;
812
+
813
+ // 블러 모드: 프레임을 먼저 캡처
814
+ if(fillMode==='blur'){{
815
+ frameCanvas.width=sw;frameCanvas.height=sh;
816
+ frameCtx.drawImage(el,0,0,sw,sh);
817
+ drawBlurFromFrame(offCtx,frameCanvas,sw,sh,exportW,exportH);
818
+ }}else{{
819
  drawWithModeExport(offCtx,el,sw,sh,exportW,exportH,fillMode);
820
+ }}
821
  }}catch(e){{}}
822
  }}
823
  }}else{{
 
885
  var nw=sw*scale,nh=sh*scale;
886
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
887
  ctx.drawImage(el,ox,oy,nw,nh);
888
+ }}else{{
889
+ var scale=Math.min(dw/sw,dh/sh);
 
890
  var nw=sw*scale,nh=sh*scale;
891
  var ox=(dw-nw)/2,oy=(dh-nh)/2;
892
  ctx.drawImage(el,ox,oy,nw,nh);
893
+ }}
894
+ }}
895
+
896
+ // 블러 전용 - 캡처된 프레임으로 처리
897
+ function drawBlurFromFrame(ctx,frameCanvas,sw,sh,dw,dh){{
898
+ // 1. 작은 캔버스로 축소 (블러 효과)
899
+ var blurCanvas=document.createElement('canvas');
900
+ blurCanvas.width=16;blurCanvas.height=16;
901
+ var blurCtx=blurCanvas.getContext('2d');
902
+ blurCtx.drawImage(frameCanvas,0,0,16,16);
903
+
904
+ // 2. 배경에 확대해서 그림
905
+ ctx.imageSmoothingEnabled=true;
906
+ ctx.imageSmoothingQuality='high';
907
+ var scale=Math.max(dw/sw,dh/sh)*1.1;
908
+ var nw=sw*scale,nh=sh*scale;
909
+ var ox=(dw-nw)/2,oy=(dh-nh)/2;
910
+ ctx.drawImage(blurCanvas,ox,oy,nw,nh);
911
+
912
+ // 3. 어둡게
913
+ ctx.fillStyle='rgba(0,0,0,0.4)';
914
  ctx.fillRect(0,0,dw,dh);
915
+
916
+ // 4. 원본 (캡처된 프레임 사용)
917
  var fitScale=Math.min(dw/sw,dh/sh);
918
  var fw=sw*fitScale,fh=sh*fitScale;
919
  var fx=(dw-fw)/2,fy=(dh-fh)/2;
920
+ ctx.drawImage(frameCanvas,fx,fy,fw,fh);
 
 
 
 
 
 
921
  }}
922
 
923
  function cancelExport(){{S.cancelled=true;document.getElementById('exportModal').style.display='none'}}