<commit_before>window.onload = function() {

    var canvas = document.getElementById("graph"),

        graphDim = canvas.height,
        pixSize = 5,
        pi = Math.PI;

    if (canvas.getContext) {
        var ctx = canvas.getContext('2d');

        // updateGraph(ctx, 150);
        for (phase = 0; phase < 150; phase += 2) {
            timeoutUpdateGraph(ctx, phase);
        }
    }

    function timeoutUpdateGraph(ctx, phase) {
        setTimeout(function() {
            updateGraph(ctx, phase);
        }, 10);
    }

    function returnSinRGB(x, phase) {
        return 'rgb(' + (127.5*Math.sin(8*pi*(x - phase)/graphDim) + 127.5) + ', 0, 0)';
    }

    function updateGraph(ctx, phase) {
        for (var x = 0; x < graphDim; x += pixSize) {
            for (var y = 0; y < graphDim; y += pixSize) {
                // ctx.clearRect(0, 0, canvas.width, canvas.height);
                ctx.fillStyle = returnSinRGB(x, phase);
                ctx.fillRect(x, y, pixSize, pixSize);
            }
            console.log(x, y, returnSinRGB(x, phase));
        }
    }

};<commit_msg>Faster, high-res sine animation, but probably too slow still<commit_after>window.onload = function() {

    var canvas = document.getElementById("graph"),

        graphDim = canvas.height,
        // pixSize = 5,
        pi = Math.PI,
        phase = 0;

    if (canvas.getContext) {
        var ctx = canvas.getContext('2d'),
            imageData = ctx.getImageData(0, 0, graphDim, graphDim),
            sinData = createSinData();

        // updateGraph(ctx, imageData, 150);
        // for (phase = 0; phase < 150; phase += 2) {
        //     timeoutUpdateGraph(ctx, imageData, phase);
        // }

        var animIntervalID = window.setInterval(updateGraph, 50);
        setTimeout(function() {
            clearInterval(animIntervalID);
        }, 15000);
    }

    // function timeoutUpdateGraph(ctx, imageData, phase) {
    //     setTimeout(function() {
    //         updateGraph(ctx, imageData, phase);
    //     }, 10000);
    // }

    function returnSinR(x, phase) {
        return 127.5*Math.sin(8*pi*(x - phase)/graphDim) + 127.5;
    }

    function createSinData() {
        var imageDataR = [],
            imageDataLength = imageData.data.length;

        for (var phase = 0; phase < 126; phase += 2) {
            imageDataR[phase] = [];
            for (var pixel = 0; pixel < imageDataLength/4; pixel++) {
                imageDataR[phase][pixel] = returnSinR(pixel, phase);
            }
        }
        return imageDataR;
    }

    function updateGraph() {
        var imageDataLength = imageData.data.length;
        console.log(phase);
        for (var pixel = 0; pixel < imageDataLength/4; pixel++) {
            imageData.data[4*pixel] = sinData[phase][pixel];
            imageData.data[4*pixel + 1] = 0;
            imageData.data[4*pixel + 2] = 0;
            imageData.data[4*pixel + 3] = 255;
            // console.log(x, y, returnSinRGB(x, phase));
        }
        ctx.putImageData(imageData, 0, 0);
        if (phase === 124) {
            phase = 0;
        } else {
            phase += 2;
        }
    }

};
{'fraction_non_alphanumeric': 0.14131812420785805, 'fraction_numerical': 0.028200253485424587, 'mean_word_length': 1.81875, 'pattern_counts': {'":': 0, '<': 10, '<?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': '3282551', 'n_tokens_mistral': 1052, 'n_tokens_neox': 951, 'n_words': 213}