Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function RGB(r,g,b){ return (0xff000000|(r<<16)|(g<<8)|(b)); }
- var font = gdi.Font("ProFontWindows", 9, 0);
- var g_drag = 0;
- var color =
- {
- background: RGB(27, 27, 27),
- frame: RGB(27, 27, 27),
- //progress: RGB(143, 99, 153), // DARK.COLOR.1
- progress: RGB(111, 153, 180),
- //proghead: RGB(9, 226, 229) // LIGHT.COLOR.2
- proghead: RGB(219, 219, 219)
- };
- var barChar =
- {
- back: "▬",
- body: "▬",
- head: "▪"
- };
- function on_paint(e)
- {
- e.SetTextRenderingHint(1);
- var ww = window.Width,
- wh = window.Height,
- pos = ww * fb.PlaybackTime / (fb.PlaybackLength == 0 ? 1 : fb.PlaybackLength),
- background = barChar.back,
- progress = barChar.body,
- bgWidth = e.MeasureString(barChar.back, font, 0, 0, ww, wh).Width,
- bodyWidth = e.MeasureString(barChar.body, font, 0, 0, ww, wh).Width;
- headWidth = e.MeasureString(barChar.head, font, 0, 0, ww, wh).Width;
- // generate background string
- for (var i = 0, MAX = Math.ceil(ww / bgWidth); i < MAX; i++)
- background += barChar.back;
- // generate progress string
- if (pos > 4)
- for (var i = 0, MAX = Math.floor((pos - headWidth) / bodyWidth); i < MAX; i++)
- progress += barChar.body;
- else
- progress = "";
- // Draw frame background
- e.FillSolidRect(0, 0, ww, wh, color.frame);
- // Draw the background
- e.DrawString(background, font, color.background, 0, 0, ww, wh);
- // Draw the progress
- e.DrawString(progress, font, color.progress, 0, 0, ww, wh);
- // Draw the progress head
- if (pos > 0)
- e.DrawString(barChar.head, font, color.proghead,
- Math.floor((pos - headWidth) / bodyWidth) * bodyWidth + headWidth + 1, 0, ww, wh);
- }
- function on_mouse_lbtn_down(x, y)
- {
- g_drag = 1;
- }
- function on_mouse_lbtn_up(x, y)
- {
- on_mouse_move(x,y);
- g_drag = 0;
- }
- function on_mouse_move(x, y)
- {
- if (g_drag)
- fb.PlaybackTime = x / window.Width * fb.PlaybackLength;
- }
- function on_mouse_wheel(delta)
- {
- fb.PlaybackTime += delta;
- }
- function on_mouse_mbtn_down(x, y) {
- fb.PlayOrPause();
- }
- function on_playback_seek()
- {
- window.Repaint();
- }
- function on_playback_time()
- {
- window.Repaint();
- }
- function on_playback_stop()
- {
- window.Repaint();
- }
Advertisement
Add Comment
Please, Sign In to add comment