<commit_before>var paused = true,
    spiro,
    canvas,
    context,
    line_canvas,
    line_context,
    circle_canvas,
    circle_context,
    center,
    point;

function Gear(x, y, radius) {
    'use strict';
    this.x = x;
    this.y = y;
    this.radius = radius;
}

function Line(length, speed) {
    'use strict';
    this.length = length;
    this.speed = speed;
    this.rotation = 0;
}

Line.prototype.step = function() {
    'use strict';
    var x, y, rads;
    this.rotation += this.speed;
    rads = Math.PI * this.rotation / 360;
    x = this.length * Math.cos(rads);
    y = this.length * Math.sin(rads);
    return [x, y];
};

function Spirograph() {
    'use strict';
    this.lines = [];
    this.lines.push(new Line(400, 2));
    this.gears = [];
    this.gears.push(new Gear(center[0], center[1], 400));
    this.size = 0;
}

Spirograph.prototype.add_gear = function(percent, direction) {
    'use strict';
    var line_len, last_line, new_line, new_speed, real_perc;
    last_line = this.lines[this.lines.length - 1];
    line_len = last_line.length * percent / 100;
    real_perc = percent / 100;
    new_speed = Math.abs(last_line.speed / real_perc) * (1 - real_perc);
    if (direction) {
        new_speed *= -1;
    }
    last_line.length *= ((100 - percent) / 100);
    new_line = new Line(line_len, new_speed);
    new_line.rotation = last_line.rotation;
    this.lines.push(new_line);
    this.gears.push(new Gear(center[0] * 2 - line_len, center[1], line_len));
    update_gearlist();
};

Spirograph.prototype.step = function() {
    'use strict';
    var len, i, line, gear, vector, delta;
    delta = [0, 0];
    delta[0] += center[0];
    delta[1] += center[1];
    for (i = 0; i < this.lines.length; i++) {
        this.gears[i].x = delta[0];
        this.gears[i].y = delta[1];
        line = this.lines[i];
        vector = line.step();
        delta[0] += vector[0];
        delta[1] += vector[1];
    }
    return delta;
};

function mainloop() {
    'use strict';
    if (paused === false) {
        draw_lines();
        draw_circles();

        // draw everything on the visible canvas
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.drawImage(circle_canvas, 0, 0);
        context.drawImage(line_canvas, 0, 0);

        setTimeout(mainloop, 10);
    }
}

function draw_lines() {
        // update the line on off-screen canvas
        line_context.beginPath();
        line_context.moveTo(point[0], point[1]);
        point = spiro.step();
        line_context.lineTo(point[0], point[1]);
        line_context.stroke();
}

function draw_circles() {
        // predraw the circles on off-screen canvas
        var i, lines, gear;
        lines = spiro.lines;
        circle_context.clearRect(0, 0, canvas.width, canvas.height);
        circle_context.beginPath();
        circle_context.arc(point[0], point[1], 3, 0, Math.PI * 2, false);
        for (i = 0; i < spiro.gears.length; i++) {
            gear = spiro.gears[i];
            circle_context.moveTo(gear.x + gear.radius, gear.y);
            circle_context.arc(gear.x, gear.y, gear.radius, 0,
                    Math.PI * 2, false);
        }
        circle_context.stroke();
}

function toggle_pause() {
    'use strict';
    if (paused === true) {
        paused = false;
        mainloop();
    } else {
        paused = true;
    }
    return false;
}
<commit_msg>fixed weird indet<commit_after>var paused = true,
    spiro,
    canvas,
    context,
    line_canvas,
    line_context,
    circle_canvas,
    circle_context,
    center,
    point,
    rounds;

function Gear(x, y, radius) {
    'use strict';
    this.x = x;
    this.y = y;
    this.radius = radius;
}

function Line(length, speed) {
    'use strict';
    this.length = length;
    this.speed = speed;
    this.rotation = 0;
}

Line.prototype.step = function() {
    'use strict';
    var x, y, rads;
    this.rotation += this.speed;
    rads = Math.PI * this.rotation / 360;
    x = this.length * Math.cos(rads);
    y = this.length * Math.sin(rads);
    return [x, y];
};

function Spirograph() {
    'use strict';
    this.lines = [];
    this.lines.push(new Line(400, 2));
    this.gears = [];
    this.gears.push(new Gear(center[0], center[1], 400));
    this.size = 0;
}

Spirograph.prototype.add_gear = function(percent, direction) {
    'use strict';
    var line_len, last_line, new_line, new_speed, real_perc;
    last_line = this.lines[this.lines.length - 1];
    line_len = last_line.length * percent / 100;
    real_perc = percent / 100;
    new_speed = Math.abs(last_line.speed / real_perc) * (1 - real_perc);
    if (direction) {
        new_speed *= -1;
    }
    last_line.length *= ((100 - percent) / 100);
    new_line = new Line(line_len, new_speed);
    new_line.rotation = last_line.rotation;
    this.lines.push(new_line);
    this.gears.push(new Gear(center[0] * 2 - line_len, center[1], line_len));
    update_gearlist();
};

Spirograph.prototype.step = function() {
    'use strict';
    var len, i, line, gear, vector, delta;
    delta = [0, 0];
    delta[0] += center[0];
    delta[1] += center[1];
    for (i = 0; i < this.lines.length; i++) {
        this.gears[i].x = delta[0];
        this.gears[i].y = delta[1];
        line = this.lines[i];
        vector = line.step();
        delta[0] += vector[0];
        delta[1] += vector[1];
    }
    return delta;
};

function mainloop() {
    'use strict';
    if (paused === false) {
        draw_lines();
        draw_circles();

        // draw everything on the visible canvas
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.drawImage(circle_canvas, 0, 0);
        context.drawImage(line_canvas, 0, 0);

        setTimeout(mainloop, 10);
    }
}

function draw_lines() {
    // predraw the lin on off-screen canvas
    line_context.beginPath();
    line_context.moveTo(point[0], point[1]);
    point = spiro.step();
    line_context.lineTo(point[0], point[1]);
    line_context.stroke();
}

function draw_circles() {
    // predraw the circles on off-screen canvas
    var i, lines, gear;
    lines = spiro.lines;
    circle_context.clearRect(0, 0, canvas.width, canvas.height);
    circle_context.beginPath();
    circle_context.arc(point[0], point[1], 3, 0, Math.PI * 2, false);
    for (i = 0; i < spiro.gears.length; i++) {
        gear = spiro.gears[i];
        circle_context.moveTo(gear.x + gear.radius, gear.y);
        circle_context.arc(gear.x, gear.y, gear.radius, 0,
                Math.PI * 2, false);
    }
    circle_context.stroke();
}

function toggle_pause() {
    'use strict';
    if (paused === true) {
        paused = false;
        mainloop();
    } else {
        paused = true;
    }
    return false;
}

{'fraction_non_alphanumeric': 0.15125925925925926, 'fraction_numerical': 0.019851851851851853, 'mean_word_length': 2.416497975708502, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1575925', 'n_tokens_mistral': 2437, 'n_tokens_neox': 2350, 'n_words': 527}