<commit_before>import LabelPoint from './label_point';

const default_spacing = 50; // spacing of points along line in pixels

let PLACEMENT = {
    ENDPOINTS: 0,       // place labels at endpoints of line segments
    MIDPOINTS: 1,       // place labels at midpoints of line segments
    SPACED: 2           // place labels equally spaced along line
};

export default function fitToLine (line, size, options) {
    let labels = [];
    let strategy;

    if (options.spacing){
        strategy = PLACEMENT.SPACED;
    }
    else {
        // strategy = PLACEMENT.MIDPOINTS;
        strategy = PLACEMENT.ENDPOINTS;
    }

    switch (strategy){
        case PLACEMENT.SPACED:
            let {positions, angles} = getPositionsAndAngles(line, options);
            for (let i = 0; i < positions.length; i++){
                let position = positions[i];
                let angle = angles[i];

                let label = new LabelPoint(position, size, options);
                label.angle = angle;
                labels.push(label);
            }
            break;
        case PLACEMENT.ENDPOINTS:
        let p, q, label;
            for (let i = 0; i < line.length - 1; i++){
                p = line[i];
                q = line[i + 1];
                label = new LabelPoint(p, size, options);
                label.angle = getAngle(p, q, options.angle);
                labels.push(label);
            }

            // add last endpoint
            label = new LabelPoint(q, size, options);
            label.angle = getAngle(p, q, options.angle);
            labels.push(label);<commit_msg>Fix tab indentation<commit_after>import LabelPoint from './label_point';

const default_spacing = 50; // spacing of points along line in pixels

let PLACEMENT = {
    ENDPOINTS: 0,       // place labels at endpoints of line segments
    MIDPOINTS: 1,       // place labels at midpoints of line segments
    SPACED: 2           // place labels equally spaced along line
};

export default function fitToLine (line, size, options) {
    let labels = [];
    let strategy;

    if (options.spacing){
        strategy = PLACEMENT.SPACED;
    }
    else {
        // strategy = PLACEMENT.MIDPOINTS;
        strategy = PLACEMENT.ENDPOINTS;
    }

    switch (strategy){
        case PLACEMENT.SPACED:
            let {positions, angles} = getPositionsAndAngles(line, options);
            for (let i = 0; i < positions.length; i++){
                let position = positions[i];
                let angle = angles[i];

                let label = new LabelPoint(position, size, options);
                label.angle = angle;
                labels.push(label);
            }
            break;
        case PLACEMENT.ENDPOINTS:
            let p, q, label;
            for (let i = 0; i < line.length - 1; i++){
                p = line[i];
                q = line[i + 1];
                label = new LabelPoint(p, size, options);
                label.angle = getAngle(p, q, options.angle);
                labels.push(label);
            }

            // add last endpoint
            label = new LabelPoint(q, size, options);
            label.angle = getAngle(p, q, options.angle);
            labels.push(label);
{'fraction_non_alphanumeric': 0.10267579340385811, 'fraction_numerical': 0.005600497822028625, 'mean_word_length': 1.6592224979321752, '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': '4098100', 'n_tokens_mistral': 928, 'n_tokens_neox': 883, 'n_words': 273}