<commit_before>var canvas;
var textCanvas;
var gl;
var textContext;
var mvMatrix;
var quadShader;
var textShader;
var perspectiveMatrix;

var textQuads = [];

var textContextHelper = {
    nextStart: 0,
    nextLineStart: 0,
    currentLineHeight: 0,
    texture: null
};

var cameraOptions = {
    targetElement: null,
    isInsideView: false,
    translateMatrix: [0, 0, 0],
    zoom: 1.0,
    extend: [0, 0, 0],
    originalExtend: [0, 0, 0],
    isDragging: false,
    lastMousePosition: {
        x: 0,
        y: 0
    },
    lastGlobalMousePosition: {
        x: 0,
        y: 0
    },
    cameraViewPosition: {
        x: 0,
        y: 0
    }
};

var nodes = [{
    color: [1.0, 0.0, 0.0, 1],
    state: {
        normal: {
            color: [1.0, 0.0, 0.0, 1]
        },
        highlight: {
            color: [1.0, 0.2, 0.2, 1]
        }
    },
    size: 100,
    position: {
        x: 0.0,
        y: 0.0,
        z: 0.0
    },
    name: 'Bob',
    font: 'Arial',
    fontSize: '20px'
}, {
    color: [1.0, 1.0, 0.0, 1],
    state: {
        normal: {
            color: [1.0, 1.0, 0.0, 1]
        },
        highlight: {
            color: [1.0, 1.0, 0.2, 1]
        }
    },
    size: 200,
    position: {
        x: 500.0,
        y: 0.0,
        z: 0
    },
    name: 'Bobby',
    font: 'Arial',
    fontSize: '20px'
}, {
    color: [1.0, 0.0, 1.0, 1],
    state: {
        normal: {
            color: [1.0, 0.0, 1.0, 1]
        },
        highlight: {
            color: [1.0, 0.2, 1.0, 1]
        }
    },
    size: 150,
    position: {
        x: 500.0,
        y: 150.0,
        z: 1
    },
    name: 'Bobbette',
    font: 'Arial',
    fontSize: '20px'
}];

var megaPositionBuffer = null;
var megaColorBuffer = null;
var megaIndexBuffer = null;

function start () {
    canvas = document.getElementById("glcanvas");
    textCanvas = document.getElementById('textCanvas');

    initNodes();

    initWebGL();      // Initialize the GL context
    initWebGLMouseHandlers(canvas);
    initTextContext();

    // Only continue if WebGL is available and working

    if (gl) {
        gl.clearColor(0.2, 0.2, 0.2, 1.0);  // Clear to gray, fully opaque
        gl.clearDepth(1.0);                 // Clear everything
        gl.enable(gl.DEPTH_TEST);           // Enable depth testing
        gl.depthFunc(gl.LEQUAL);            // Near things obscure far things

        gl.enable(gl.BLEND);
        gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);

        // Initialize the shaders; this is where all the lighting for the
        // vertices and so forth is established.

        initShaders();

        // Here's where we call the routine that builds all the objects
        // we'll be drawing.

        initBuffers();

        generateTextQuadsBuffers();

        // Set up to draw the scene periodically.
        requestAnimationFrame(drawScene);
    }
}

function initNodes () {
    var nbNodes = 5000;
    for (var i = 0; i < nbNodes; i++) {
        var color = [Math.random(), Math.random(), Math.random(), 1];
        var highlightColor = [color[0] * 1.2, color[1] * 1.2, color[2] * 1.2, 1];
        nodes.push({
            color: color,
            state: {
                normal: {
                    color: color
                },
                highlight: {
                    color: highlightColor
                }
            },
            size: 1 + Math.random() * 100,
            position: {
                x: (Math.random() * 2 - 1) * 500,
                y: (Math.random() * 2 - 1) * 500,
                z: Math.random()
            },
            font: 'Arial',
            fontSize: (5 + Math.random() * 10).toFixed(0).toString() + 'px',
            name: (1 + Math.random() * 100).toFixed(0).toString()
        })
    }
}

//
// initWebGL
//
// Initialize WebGL, returning the GL context or null if<commit_msg>Test with less nodes.<commit_after>var canvas;
var textCanvas;
var gl;
var textContext;
var mvMatrix;
var quadShader;
var textShader;
var perspectiveMatrix;

var textQuads = [];

var textContextHelper = {
    nextStart: 0,
    nextLineStart: 0,
    currentLineHeight: 0,
    texture: null
};

var cameraOptions = {
    targetElement: null,
    isInsideView: false,
    translateMatrix: [0, 0, 0],
    zoom: 1.0,
    extend: [0, 0, 0],
    originalExtend: [0, 0, 0],
    isDragging: false,
    lastMousePosition: {
        x: 0,
        y: 0
    },
    lastGlobalMousePosition: {
        x: 0,
        y: 0
    },
    cameraViewPosition: {
        x: 0,
        y: 0
    }
};

var nodes = [{
    color: [1.0, 0.0, 0.0, 1],
    state: {
        normal: {
            color: [1.0, 0.0, 0.0, 1]
        },
        highlight: {
            color: [1.0, 0.2, 0.2, 1]
        }
    },
    size: 100,
    position: {
        x: 0.0,
        y: 0.0,
        z: 0.0
    },
    name: 'Bob',
    font: 'Arial',
    fontSize: '20px'
}, {
    color: [1.0, 1.0, 0.0, 1],
    state: {
        normal: {
            color: [1.0, 1.0, 0.0, 1]
        },
        highlight: {
            color: [1.0, 1.0, 0.2, 1]
        }
    },
    size: 200,
    position: {
        x: 500.0,
        y: 0.0,
        z: 0
    },
    name: 'Bobby',
    font: 'Arial',
    fontSize: '20px'
}, {
    color: [1.0, 0.0, 1.0, 1],
    state: {
        normal: {
            color: [1.0, 0.0, 1.0, 1]
        },
        highlight: {
            color: [1.0, 0.2, 1.0, 1]
        }
    },
    size: 150,
    position: {
        x: 500.0,
        y: 150.0,
        z: 1
    },
    name: 'Bobbette',
    font: 'Arial',
    fontSize: '20px'
}];

var megaPositionBuffer = null;
var megaColorBuffer = null;
var megaIndexBuffer = null;

function start () {
    canvas = document.getElementById("glcanvas");
    textCanvas = document.getElementById('textCanvas');

    initNodes();

    initWebGL();      // Initialize the GL context
    initWebGLMouseHandlers(canvas);
    initTextContext();

    // Only continue if WebGL is available and working

    if (gl) {
        gl.clearColor(0.2, 0.2, 0.2, 1.0);  // Clear to gray, fully opaque
        gl.clearDepth(1.0);                 // Clear everything
        gl.enable(gl.DEPTH_TEST);           // Enable depth testing
        gl.depthFunc(gl.LEQUAL);            // Near things obscure far things

        gl.enable(gl.BLEND);
        gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);

        // Initialize the shaders; this is where all the lighting for the
        // vertices and so forth is established.

        initShaders();

        // Here's where we call the routine that builds all the objects
        // we'll be drawing.

        initBuffers();

        generateTextQuadsBuffers();

        // Set up to draw the scene periodically.
        requestAnimationFrame(drawScene);
    }
}

function initNodes () {
    var nbNodes = 2000;
    for (var i = 0; i < nbNodes; i++) {
        var color = [Math.random(), Math.random(), Math.random(), 1];
        var highlightColor = [color[0] * 1.2, color[1] * 1.2, color[2] * 1.2, 1];
        nodes.push({
            color: color,
            state: {
                normal: {
                    color: color
                },
                highlight: {
                    color: highlightColor
                }
            },
            size: 1 + Math.random() * 100,
            position: {
                x: (Math.random() * 2 - 1) * 500,
                y: (Math.random() * 2 - 1) * 500,
                z: Math.random()
            },
            font: 'Arial',
            fontSize: (5 + Math.random() * 10).toFixed(0).toString() + 'px',
            name: (1 + Math.random() * 100).toFixed(0).toString()
        })
    }
}

//
// initWebGL
//
// Initialize WebGL, returning the GL context or null if
{'fraction_non_alphanumeric': 0.14198966408268734, 'fraction_numerical': 0.043669250645994834, 'mean_word_length': 1.5157621059473514, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '206522', 'n_tokens_mistral': 2838, 'n_tokens_neox': 2565, 'n_words': 684}