Список разделов › foobar2000 › Секреты foobar2000




















kutuzof:я заставил их двигаться


function RGB(r,g,b) {
    return (0xff000000|(r<<16)|(g<<8)|(b));
} 
var font = gdi.Font("Arial", 12, 0);
DT_LEFT = 0x00000000;
DT_CENTER = 0x00000001;
DT_VCENTER = 0x00000004;
DT_SINGLELINE = 0x00000020; 
DT_NOPREFIX = 0x00000800;
var ww, wh;
var on_mouse = false;
var pos_x = 0, pos_y = 0;;
var VUMOffset_t, t_height, t_width;
var wheel = false;
var tooltip_timer;
var color = [];
ColorTypeCUI = {
    text: 0,
    selection_text: 1,
    inactive_selection_text: 2,   
    background: 3,   
    selection_background: 4,   
    inactive_selection_background: 5,   
    active_item_frame: 6   
}   
                     
ColorTypeDUI = {                     
   text: 0,                  
   background: 1,                  
   highlight: 2,                  
   selection: 3                  
}
function get_color(){ 
    try {    
        if (window.InstanceType == 0){   
            bgcolor = window.GetColorCUI(ColorTypeCUI.background);   
            c1 = window.GetColorCUI(ColorTypeCUI.inactive_selection_text);   
            c2 = window.GetColorCUI(ColorTypeCUI.text);
        } else if (window.InstanceType == 1) {                      
            bgcolor = window.GetColorDUI(ColorTypeDUI.background);
            c1 = window.GetColorDUI(ColorTypeDUI.highlight);   
            c2 = window.GetColorDUI(ColorTypeDUI.text);
        }   
    } catch(e){};
    try {    
        if (window.InstanceType == 0){                     
            bgcolor = window.GetColourCUI(ColorTypeCUI.background);
            c1 = window.GetColourCUI(ColorTypeCUI.inactive_selection_text);   
            c2 = window.GetColourCUI(ColorTypeCUI.text);
        } else if (window.InstanceType == 1) {                      
            bgcolor = window.GetColourDUI(ColorTypeDUI.background);
            c1 = window.GetColourDUI(ColorTypeDUI.highlight);   
            c2 = window.GetColourDUI(ColorTypeDUI.text);
        }   
    } catch(e){};
    window.Repaint();   
}
get_color();
function on_colors_changed(){
    get_color();
}
var dll;
var is_dll = utils.CheckComponent("\\user-components\\foo_vis_vumeter\\foo_vis_vumeter");
if (is_dll) {dll = false} else {dll = true};
if (dll) {VUMeter = new ActiveXObject("VUMeter")};   
if (dll) {VUMeter.RegisterWindow(window.ID)};
   
function ToDB(Level){   
    return Math.round(2000*Math.log(Level)/Math.LN10)/100;   
} 
var db = [-20, -10, -9, -8, -7, -6, -5, -4, -3, -2, -1, 0, 1, 2, 3];
var points = db.length;
var lp_s = [];
var rp_s = [];
for (var i = 0; i <= points; i++) {   
    lp_s[i] = 0;
    rp_s[i] = 0;
}
var d_w = window.GetProperty("d width", 10);
var d_h = window.GetProperty("d height", 4);
var d_offset = window.GetProperty("d offset", 15);
var panel_xl = Math.round(window.Width / 2 - d_offset * points - d_w / 2);
var panel_xr = Math.round(window.Width / 2 + (d_offset - d_w) + d_w / 2);
var panel_h = window.GetProperty("panel height", 60);   
var panel_y = Math.round(window.Height / 2 - panel_h / 2);
var scale_on = window.GetProperty("scale on", true);
var color_p1 = Math.round(panel_h * 0.1);
var color_p2 = panel_h - color_p1;
for(var j = 0; j < color_p2; j++) {
    color.push(combineColors(c1, bgcolor, j / color_p2)); /// bgcolor
}
var panel_on = true;
function on_paint(gr) {   
    gr.FillSolidRect(0, 0, ww, wh, bgcolor);
    
    if (panel_on && dll) {        
        //L = VUMeter.LeftLevel;   
        //R = VUMeter.RightLevel;   
        LM = VUMeter.LeftPeak;   
        RM = VUMeter.RightPeak;   
        if (fb.IsPlaying) {
            for (var i = 0; i < points; i++) {
                if (Math.round(ToDB(LM)) == db[i]) lp_s[i] = 0;
                lp_color = lp_s[i] <= color_p1 ? c1 : color[lp_s[i] - color_p1];
                if (lp_s[i] >= 0) gr.FillSolidRect(panel_xl + d_offset * i, panel_y + lp_s[i], d_w, d_h, lp_color);
                if (lp_s[i] == panel_h) gr.FillSolidRect(panel_xl + d_offset * i, panel_y + panel_h, d_w, 1, color[Math.round(color.length * 0.5)]);
        
                if (Math.round(ToDB(RM)) == db[points - 1 - i]) rp_s[i] = 0;
                
                rp_color = rp_s[i] <= color_p1 ? c1 : color[rp_s[i] - color_p1];
                if (rp_s[i] >= 0) gr.FillSolidRect(panel_xr + d_offset * i, panel_y + rp_s[i], d_w, d_h, rp_color);
                if (rp_s[i] == panel_h) gr.FillSolidRect(panel_xr + d_offset * i, panel_y + panel_h, d_w, 1, color[Math.round(color.length * 0.5)]);
            } 
           
            for (var j = 0; j < lp_s.length; j++) {
                if (lp_s[j] < panel_h){
                    lp_s[j] = lp_s[j] + 1;
                } else {
                    lp_s[j] = panel_h;
                }
            }
            for (var j = 0; j < rp_s.length; j++) {
                if (rp_s[j] < panel_h){
                    rp_s[j] = rp_s[j] + 1;
                } else {
                    rp_s[j] = panel_h;
                }
            }
        
            if (wheel) {
                VUMOffset_t = Math.round(VUMeter.Offset) + " db";
                th = gr.CalcTextHeight(VUMOffset_t, font) + 2;
                tw = gr.CalcTextWidth(VUMOffset_t, font) + 10;
                gr.FillSolidRect(pos_x - tw, pos_y - th + 0, tw, th, bgcolor);
                gr.GdiDrawText(VUMOffset_t, font, c2, pos_x - tw, pos_y - th, tw, th, DT_SINGLELINE | DT_CENTER | DT_VCENTER); 
            }
        }
    }
    
    for (var i = 0; i <= points; i++) {
        twl = gr.CalcTextWidth(db[i], font);
        twr = gr.CalcTextWidth(db[points - 1 - i], font);
        th = gr.CalcTextHeight(db[i], font);
        if (scale_on && i > 0)gr.GdiDrawText( db[i]% 2 == 0 ? db[i] : "" , font, c2, panel_xl + d_offset * i - twl / 2 + (d_offset - d_w), panel_y + panel_h + th / 2, ww, wh);
        if (scale_on && i < points - 1) gr.GdiDrawText( db[points - 1 - i]% 2 == 0 ? db[points - 1 - i] : "" , font, c2, panel_xr + d_offset * i - twr / 2 + (d_offset - d_w), panel_y + panel_h + th / 2, ww, wh);
    }
}
function on_size() {   
    ww = window.Width;   
    wh = window.Height; 
    panel_xl = Math.round(ww / 2 - d_offset * points - d_w / 2);
    panel_xr = Math.round(ww / 2 + (d_offset - d_w) + d_w / 2);
    panel_y = Math.round(wh / 2 - panel_h / 2);
}   
function on_mouse_move(x,y) {
    on_mouse = true;
    pos_x = x <= t_width ? t_width : x;
    pos_y = y <= t_height ? t_height : y;
    window.SetCursor(32649);
}
function on_mouse_leave() {
    on_mouse = false;
    window.SetCursor(32512);
    //window.Repaint();
}
function on_mouse_wheel(step) {
    wheel = true;
    VUMeter.Offset = VUMeter.Offset + step;
    tooltip_timer && window.ClearTimeout(tooltip_timer);
    tooltip_timer = window.SetTimeout(function() {
        wheel = false;
        tooltip_timer && window.ClearTimeout(tooltip_timer);
    }, 2000);
}
function combineColors(c1, c2, f){ // When fraction is 0, result is 100% color1, when f is 1, result is 100% color2.
    var c1 = toRGB(c1);
    var c2 = toRGB(c2);
    var r = Math.round(c1[0] + f * (c2[0] - c1[0]));
    var g = Math.round(c1[1] + f * (c2[1] - c1[1]));
    var b = Math.round(c1[2] + f * (c2[2] - c1[2]));
    
    return (0xff000000 | (r << 16) | (g << 8) | (b));
}
function toRGB(d){ // convert back to RGB values
    var d = d-0xff000000;
    var r = d >> 16;
    var g = d >> 8 & 0xFF;
    var b = d & 0xFF;
    return [r,g,b];
}
function print(msg) {
    try {    
        fb.trace(msg);   
    } catch(e){console.log(msg);};         
}





Вернуться в Секреты foobar2000