Advertisement
nanogyth

Untitled

Dec 1st, 2012
191
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function ng_bighalo(
  2. \   clip clp,
  3. \ string text,
  4. \  float "x",
  5. \  float "y",
  6. \    int "first_frame",
  7. \    int "last_frame",
  8. \ string "font",
  9. \  float "size",
  10. \    int "text_color",
  11. \    int "halo_color",
  12. \    int "align",
  13. \    int "spc",
  14. \    int "lsp",
  15. \  float "font_width",
  16. \  float "font_angle",
  17. \    int "halo_radius",
  18. \ string "mode",
  19. \ string "halo",
  20. \ string "shadow"
  21. \){
  22.  
  23. #Version 16-17 2012/12/1
  24. # - added circle_12 as default
  25. # - reworked math to avoid bitwise functions that are only
  26. #   availible in experimental builds
  27. #Version 15 2012/12/1
  28. # - drop shadow added
  29. # - halo_radius still works, but calculating the points of
  30. #   a hollow circle for halo is much faster
  31. # - mode is depricated since memo-ing isn't as needed
  32.  
  33.     first_frame = default(first_frame, 0)
  34.     last_frame  = default( last_frame, first_frame + 299)
  35.     font        = default(       font, "Ariel")
  36.     size        = default(       size, 112)
  37.     x           = default(          x, -1)
  38.     y           = default(          y, -1)
  39.     text_color  = default( text_color, $00DDDDDD)
  40.     halo_color  = default( halo_color, $80000000)
  41.     align       = default(      align, 5)
  42.     spc         = default(        spc, 0)
  43.     lsp         = default(        lsp, 0)
  44.     font_width  = default( font_width, 0)
  45.     font_angle  = default( font_angle, 0)
  46.     shadow      = default(     shadow, " -4 -8")
  47.     w           = clp.width
  48.     h           = clp.height
  49. ###
  50.    ###
  51.       ##
  52.         #
  53.          #
  54.           #
  55.           #
  56.            #
  57.            #
  58.            #
  59.             #
  60.             #
  61. #           #
  62. circle_12="0 0 "+\
  63. "12 0 0 12 -12 0 0 -12 "+\
  64. "1 12 2 12 3 11 4 11 5 11 6 10 7 10 8 9 "+\
  65. "12 1 12 2 11 3 11 4 11 5 10 6 10 7 9 8 "+\
  66. "-1 12 -2 12 -3 11 -4 11 -5 11 -6 10 -7 10 -8 9 "+\
  67. "-12 1 -12 2 -11 3 -11 4 -11 5 -10 6 -10 7 -9 8 "+\
  68. "-1 -12 -2 -12 -3 -11 -4 -11 -5 -11 -6 -10 -7 -10 -8 -9 "+\
  69. "-12 -1 -12 -2 -11 -3 -11 -4 -11 -5 -10 -6 -10 -7 -9 -8 "+\
  70. "1 -12  2 -12 3 -11 4 -11 5 -11 6 -10 7 -10 8 -9 "+\
  71. "12 -1  12 -2 11 -3 11 -4 11 -5 10 -6 10 -7 9 -8 "
  72.     halo = (defined(halo_radius)) ? mt_circle(halo_radius) : circle_12
  73.  
  74.     invis = BlankClip(1, w, h, pixel_type="YV12")
  75.     tm = Subtitle(invis, text, x, y, 0, 0, font, size, $00FFFFFF,\
  76.         0, align, spc, lsp, font_width, font_angle)
  77.     text_mask = tm.mt_expand(mode="0 0 "+shadow, chroma="-128")
  78.     halo_mask = text_mask.mt_expand(mode=halo, chroma="-128")
  79.    
  80.     h0      = halo_color%$01000000
  81.     h_color = (h0>=0) ? h0 : $01000000+h0
  82.     t0      = text_color%$01000000
  83.     t_color = (t0>=0) ? t0 : $01000000+t0
  84.     h_alpha = (halo_color>=0) ? 255-(halo_color/$01000000) : (-halo_color-1)/$01000000
  85.     t_alpha = (text_color>=0) ? 255-(text_color/$01000000) : (-text_color-1)/$01000000
  86.     lut_str = string(h_alpha)+ " x * 255 / " +string(t_alpha)+\
  87.               " " +string(h_alpha)+ " - y * 255 / +"
  88.  
  89.     alpha_mask = mt_lutxy(halo_mask, text_mask, lut_str)
  90.  
  91.     hc = BlankClip(1, w, h, color=h_color)
  92.     tc = Subtitle(hc, text, x, y, 0, 0, font, size, t_color,\
  93.         0, align, spc, lsp, font_width, font_angle)
  94.     overlay = tc.Mask(alpha_mask.ConvertToRGB32())
  95.    
  96.     clp.ApplyRange(first_frame, last_frame, "Layer", overlay)
  97. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement