{"size": 2225, "ext": "js", "max_stars_repo_path": "src/utils.js", "max_stars_repo_name": "fade-m/sketch", "max_stars_repo_stars_event_min_datetime": "2019-04-15T15:37:29.000Z", "max_stars_repo_stars_event_max_datetime": "2019-04-15T15:37:29.000Z", "max_issues_repo_path": "src/utils.js", "max_issues_repo_name": "fade-m/sketch", "max_issues_repo_issues_event_min_datetime": "2019-06-17T19:23:11.000Z", "max_issues_repo_issues_event_max_datetime": "2021-07-26T12:25:22.000Z", "max_forks_repo_path": "src/utils.js", "max_forks_repo_name": "fade-m/sketch", "max_forks_repo_forks_event_min_datetime": "2019-10-02T00:39:53.000Z", "max_forks_repo_forks_event_max_datetime": "2019-10-02T00:39:53.000Z"}
{"max_stars_count": 1, "max_issues_count": 69, "max_forks_count": 1, "avg_line_length": 31.7857142857, "max_line_length": 110, "alphanum_fraction": 0.5617977528}
/**
 * Determine the mouse position
 *
 * @param event the canvas event
 * @returns *[] tuple of position x,y
 * @private
 */
export const pointerPosition = (event) => {
    event = event || window.event;
    var target = event.target || event.srcElement,
        style = target.currentStyle || window.getComputedStyle(target, null),
        borderLeftWidth = parseInt(style['borderLeftWidth'], 10),
        borderTopWidth = parseInt(style['borderTopWidth'], 10),
        rect = target.getBoundingClientRect(),
        _x = event.clientX - borderLeftWidth - rect.left,
        _y = event.clientY - borderTopWidth - rect.top,
        _touchX = event.changedTouches ? event.changedTouches[0].clientX - borderLeftWidth - rect.left : null,
        _touchY = event.changedTouches ? event.changedTouches[0].clientY - borderTopWidth - rect.top : null;
    return [(_x || _touchX), (_y || _touchY)];
};

//function getMouseCoords(canvas, event)
//{
//    var pointer = canvas.getPointer(event.e);
//    var posX = pointer.x;
//    var posY = pointer.y;
//    console.log(posX+", "+posY);    // Log to console
//}

/**
 * Calculate the distance of two x,y points
 *
 * @param point1 an object with x,y attributes representing the start point
 * @param point2 an object with x,y attributes representing the end point
 *
 * @returns {number}
 */
export const linearDistance = (point1, point2) => {
    let xs = point2.x - point1.x;
    let ys = point2.y - point1.y;
    return Math.sqrt(xs * xs + ys * ys);
};

/**
 * Return a random uuid of the form xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx
 * @returns {string}
 */
export const uuid4 = () => {
    let uuid = '', ii;
    for (ii = 0; ii < 32; ii += 1) {
        switch (ii) {
            case 8:
            case 20:
                uuid += '-';
                uuid += (Math.random() * 16 | 0).toString(16);
                break;
            case 12:
                uuid += '-';
                uuid += '4';
                break;
            case 16:
                uuid += '-';
                uuid += (Math.random() * 4 | 8).toString(16);
                break;
            default:
                uuid += (Math.random() * 16 | 0).toString(16);
        }
    }
    return uuid;
};