Guest User

Let's Get Blown

a guest
Sep 29th, 2013
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
  3.  
  4. var font = gdi.Font("ProggyTinyTTSZ", 16, 0);
  5. var g_drag = 0;
  6.  
  7. var color =
  8. {
  9.     background: RGB(39, 39, 39),
  10.     frame:      RGB(45, 45, 45),
  11.     //progress:   RGB(143, 99, 153), // DARK.COLOR.1
  12.     progress:   RGB(236, 191, 13),
  13.     //proghead:   RGB(9, 226, 229)   // LIGHT.COLOR.2
  14.     proghead:   RGB(220, 220, 220)
  15. };
  16.  
  17. var barChar =
  18. {
  19.     back:      "▓",
  20.     body:      "█",
  21.     head:      "▌"
  22. };
  23.  
  24. function on_paint(e)
  25. {
  26.     e.SetTextRenderingHint(1);
  27.    
  28.     var ww         = window.Width,
  29.         wh         = window.Height,
  30.         pos        = ww * fb.PlaybackTime / (fb.PlaybackLength == 0 ? 1 : fb.PlaybackLength),
  31.         background = barChar.back,
  32.         progress   = barChar.body,
  33.         bgWidth    = e.MeasureString(barChar.back, font, 0, 0, ww, wh).Width,
  34.         bodyWidth  = e.MeasureString(barChar.body, font, 0, 0, ww, wh).Width;
  35.         headWidth  = e.MeasureString(barChar.head, font, 0, 0, ww, wh).Width;
  36.    
  37.     // generate background string
  38.     for (var i = 0, MAX = Math.ceil(ww / bgWidth); i < MAX; i++)
  39.         background += barChar.back;
  40.    
  41.     // generate progress string
  42.     if (pos > 10)
  43.         for (var i = 0, MAX = Math.floor((pos - headWidth) / bodyWidth); i < MAX; i++)
  44.             progress += barChar.body;
  45.     else
  46.         progress = "";
  47.        
  48.     // Draw frame background
  49.     e.FillSolidRect(0, 0, ww, wh, color.frame);
  50.    
  51.     // Draw the background
  52.     e.DrawString(background, font, color.background, 0, 2, ww+10, wh);
  53.    
  54.     // Draw the progress head
  55.     if (pos > 0)
  56.         e.DrawString(barChar.head, font, color.proghead,Math.floor((pos - headWidth) / bodyWidth) * bodyWidth + (headWidth - 1), 2, ww, wh);
  57.            
  58.     // Draw the progress
  59.     e.DrawString(progress, font, color.progress, 0, 2, ww, wh);    
  60. }
  61.  
  62. function on_mouse_lbtn_down(x, y)
  63. {
  64.     g_drag = 1;
  65. }
  66.  
  67. function on_mouse_lbtn_up(x, y)
  68. {
  69.     on_mouse_move(x,y);
  70.     g_drag = 0;
  71. }
  72.  
  73. function on_mouse_move(x, y)
  74. {
  75.     if (g_drag)
  76.         fb.PlaybackTime = x / window.Width * fb.PlaybackLength;
  77. }
  78.  
  79. function on_mouse_wheel(delta)
  80. {
  81.     fb.PlaybackTime += delta;
  82. }
  83.  
  84. function on_mouse_mbtn_down(x, y) {
  85.     fb.PlayOrPause();
  86. }
  87.  
  88. function on_playback_seek()
  89. {
  90.     window.Repaint();
  91. }
  92.  
  93. function on_playback_time()
  94. {
  95.     window.Repaint();
  96. }
  97.  
  98. function on_playback_stop()
  99. {
  100.     window.Repaint();
  101. }
Advertisement
Add Comment
Please, Sign In to add comment